Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Management will now run the following files: at the indicated step o… #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdrodjpl
Copy link
Collaborator

@jdrodjpl jdrodjpl commented Jan 9, 2025

…f un/installation.

Files are:

pre-install.sh
post-install.sh
pre-uninstall.sh
post-uninstall.sh

If these files are found in the base dir of the marketplace item they will be executed either before or after the terraform is executed.

The scripts will be executed in the base dir of the marketplace item and should have access to the main terraform environment.

@@ -109,6 +110,27 @@
fetchAllApplications(db)

logfile := filepath.Join(logDir, fmt.Sprintf("%s_%s_install_log", application.Name, application.DeploymentName))

// Open the log file in append mode
fileHandle, err := os.OpenFile(logfile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 18 days ago

To fix the problem, we need to validate the user input before using it to construct the file path. Specifically, we should ensure that the application.Name and application.DeploymentName fields do not contain any path separators or parent directory references. This can be done by checking for the existence of any path separators ("/" or "\") or ".." sequences in the input, and rejecting the input if any are found.

Suggested changeset 1
backend/internal/processes/installer.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/backend/internal/processes/installer.go b/backend/internal/processes/installer.go
--- a/backend/internal/processes/installer.go
+++ b/backend/internal/processes/installer.go
@@ -88,2 +88,10 @@
 func executeTerraformInstall(db database.Datastore, appConfig *config.AppConfig, meta *marketplace.MarketplaceMetadata, application *types.InstalledMarketplaceApplication, location string) error {
+	// Validate application.Name and application.DeploymentName
+	if strings.Contains(application.Name, "/") || strings.Contains(application.Name, "\\") || strings.Contains(application.Name, "..") {
+		return fmt.Errorf("invalid application name: %s", application.Name)
+	}
+	if strings.Contains(application.DeploymentName, "/") || strings.Contains(application.DeploymentName, "\\") || strings.Contains(application.DeploymentName, "..") {
+		return fmt.Errorf("invalid deployment name: %s", application.DeploymentName)
+	}
+
 	// Create install_logs directory if it doesn't exist
EOF
@@ -88,2 +88,10 @@
func executeTerraformInstall(db database.Datastore, appConfig *config.AppConfig, meta *marketplace.MarketplaceMetadata, application *types.InstalledMarketplaceApplication, location string) error {
// Validate application.Name and application.DeploymentName
if strings.Contains(application.Name, "/") || strings.Contains(application.Name, "\\") || strings.Contains(application.Name, "..") {
return fmt.Errorf("invalid application name: %s", application.Name)
}
if strings.Contains(application.DeploymentName, "/") || strings.Contains(application.DeploymentName, "\\") || strings.Contains(application.DeploymentName, "..") {
return fmt.Errorf("invalid deployment name: %s", application.DeploymentName)
}

// Create install_logs directory if it doesn't exist
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant