Management will now run the following files: at the indicated step o…#48
Open
Management will now run the following files: at the indicated step o…#48
Conversation
… un/installation.
| 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
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year 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
| @@ -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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…f un/installation.
Files are:
pre-install.shpost-install.shpre-uninstall.shpost-uninstall.shIf 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.