-
Notifications
You must be signed in to change notification settings - Fork 0
Windows support for Maven trust store config #112
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
base: main
Are you sure you want to change the base?
Changes from all commits
34f8f7c
024e99d
812f525
8532832
80948c8
80a9cf6
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||||||||
| package platform | ||||||||||||
|
|
||||||||||||
| import ( | ||||||||||||
| "fmt" | ||||||||||||
| "os" | ||||||||||||
| "path/filepath" | ||||||||||||
| "strings" | ||||||||||||
|
|
||||||||||||
| "github.com/AikidoSec/safechain-internals/internal/utils" | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| func installMavenRcOverride(mavenrcPath, startMarker, endMarker, contentLine string, filePerm os.FileMode) error { | ||||||||||||
| filename := filepath.Base(mavenrcPath) | ||||||||||||
|
|
||||||||||||
| content := "" | ||||||||||||
| if data, err := os.ReadFile(mavenrcPath); err == nil { | ||||||||||||
| content = string(data) | ||||||||||||
| } else if !os.IsNotExist(err) { | ||||||||||||
| return fmt.Errorf("failed to read %s: %w", filename, err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if strings.Contains(content, startMarker) { | ||||||||||||
| if !strings.Contains(content, endMarker) { | ||||||||||||
| return fmt.Errorf("found start marker in %s but not end marker - corrupt configuration", filename) | ||||||||||||
| } | ||||||||||||
| return nil | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| lineEnding := "\n" | ||||||||||||
| if strings.Contains(content, "\r\n") { | ||||||||||||
| lineEnding = "\r\n" | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if content != "" && !strings.HasSuffix(content, "\n") && !strings.HasSuffix(content, "\r\n") { | ||||||||||||
| content += lineEnding | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| block := strings.Join([]string{startMarker, contentLine, endMarker}, lineEnding) + lineEnding | ||||||||||||
| return os.WriteFile(mavenrcPath, []byte(content+block), filePerm) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func uninstallMavenRcOverride(mavenrcPath, startMarker, endMarker string, filePerm os.FileMode) error { | ||||||||||||
| filename := filepath.Base(mavenrcPath) | ||||||||||||
|
|
||||||||||||
| data, err := os.ReadFile(mavenrcPath) | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential file inclusion attack via reading file - high severity Show FixAikido AutoFix Patch Suggestion - medium confidence This will fix the Potential file inclusion attack via reading file issue detected on line: 45.
Suggested change
|
||||||||||||
| if err != nil { | ||||||||||||
| if os.IsNotExist(err) { | ||||||||||||
| return nil | ||||||||||||
| } | ||||||||||||
| return fmt.Errorf("failed to read %s: %w", filename, err) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| newContent, removed, err := utils.RemoveMarkedBlock(string(data), startMarker, endMarker) | ||||||||||||
| if err != nil { | ||||||||||||
| return err | ||||||||||||
| } | ||||||||||||
| if !removed { | ||||||||||||
| return nil | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return os.WriteFile(mavenrcPath, []byte(newContent), filePerm) | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential file inclusion attack via reading file - high severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.
Show Fix
Aikido AutoFix Patch Suggestion - medium confidence
This patch mitigates potential file inclusion attacks by implementing input validation for the ReadFile function.
This will fix the Potential file inclusion attack via reading file issue detected on line: 16.
View details in Aikido Security