-
Notifications
You must be signed in to change notification settings - Fork 1
fix: resolve 11 CodeQL path-injection alerts in Go CLI #411
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,7 +181,12 @@ | |
| } | ||
|
|
||
| func writeInitFiles(state config.State) error { | ||
| if err := config.EnsureDir(state.DataDir); err != nil { | ||
| safeDir, err := config.SecurePath(state.DataDir) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| state.DataDir = safeDir // normalize before persisting | ||
| if err := os.MkdirAll(safeDir, 0o700); err != nil { | ||
Check failureCode scanning / CodeQL Uncontrolled data used in path expression High
This path depends on a
user-provided value Error loading related location Loading This path depends on a user-provided value Error loading related location Loading This path depends on a user-provided value Error loading related location Loading Copilot AutofixAI 3 months ago Copilot could not generate an autofix suggestion Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support. |
||
| return fmt.Errorf("creating data directory: %w", err) | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -191,7 +196,7 @@ | |
| return fmt.Errorf("generating compose file: %w", err) | ||
| } | ||
|
|
||
| composePath := filepath.Join(state.DataDir, "compose.yml") | ||
| composePath := filepath.Join(safeDir, "compose.yml") | ||
| if err := os.WriteFile(composePath, composeYAML, 0o600); err != nil { | ||
| return fmt.Errorf("writing compose file: %w", err) | ||
| } | ||
|
|
@@ -228,7 +233,11 @@ | |
| } | ||
|
|
||
| func fileExists(path string) bool { | ||
| _, err := os.Stat(path) | ||
| safe, err := config.SecurePath(path) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| _, err = os.Stat(safe) | ||
|
|
||
| return err == nil | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.