-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
fix bug atmos vendor pull URI cannot contain path traversal sequences and git schema #899
Open
haitham911
wants to merge
9
commits into
main
Choose a base branch
from
issues-888
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2
−20
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5900ef3
allow URI contain path traversal
haitham911 71fff29
allow scheme: git::
haitham911 4e8c172
remove max length check url
haitham911 26fb6f6
remove character url validate
haitham911 dcd0086
fix log error
haitham911 ee879d9
add git schema to source on vendor yaml
haitham911 f10db51
modify source on vendor yaml
haitham911 4ebd799
use git on vendor test
haitham911 521ba3b
Merge branch 'main' into issues-888
osterman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,32 +637,14 @@ func validateURI(uri string) error { | |
if uri == "" { | ||
return fmt.Errorf("URI cannot be empty") | ||
} | ||
// Maximum length check | ||
if len(uri) > 2048 { | ||
return fmt.Errorf("URI exceeds maximum length of 2048 characters") | ||
} | ||
// Add more validation as needed | ||
// Validate URI format | ||
if strings.Contains(uri, "..") { | ||
return fmt.Errorf("URI cannot contain path traversal sequences") | ||
} | ||
Comment on lines
-646
to
-648
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. Please add a test for vendoring from:
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. add it to |
||
if strings.Contains(uri, " ") { | ||
return fmt.Errorf("URI cannot contain spaces") | ||
} | ||
// Validate characters | ||
if strings.ContainsAny(uri, "<>|&;$") { | ||
return fmt.Errorf("URI contains invalid characters") | ||
} | ||
// Validate scheme-specific format | ||
if strings.HasPrefix(uri, "oci://") { | ||
if !strings.Contains(uri[6:], "/") { | ||
return fmt.Errorf("invalid OCI URI format") | ||
} | ||
} else if strings.Contains(uri, "://") { | ||
scheme := strings.Split(uri, "://")[0] | ||
if !isValidScheme(scheme) { | ||
return fmt.Errorf("unsupported URI scheme: %s", scheme) | ||
} | ||
} | ||
return nil | ||
} | ||
|
Oops, something went wrong.
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.
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.
💡 Codebase verification
Git URL format needs to be updated across example files! 🔄
The codebase shows inconsistent URL formats in example and test files. While some files use the secure
git::
prefix, others don't. Based on the code analysis:determineSourceType
function supports multiple source types (OCI, local, remote) but doesn't enforce thegit::
prefixgit::
prefix:examples/quick-start-advanced/vendor.yaml
examples/tests/vendor/*.yaml
examples/demo-vendoring/**/*.yaml
examples/demo-component-versions/vendor.yaml
These files should be updated to use the secure
git::
prefix to maintain consistency with the security improvements and to serve as proper examples for users.🔗 Analysis chain
Strong approval: Proper Git URL format enhances security! 💪
The addition of the
git::
prefix is a robust improvement that explicitly declares the protocol, making the source URL more secure and resistant to path traversal attacks. This change aligns perfectly with the PR's objective.Let's verify other Git URLs in the codebase follow this pattern:
Git URL format needs standardization across example files! 🛡️
Several example and test files are using potentially unsafe Git URLs without the
git::
prefix. This inconsistency could lead to confusion and potential security risks.Locations requiring attention:
examples/quick-start-advanced/vendor.yaml
examples/tests/vendor/*.yaml
filesexamples/demo-vendoring/**/*.yaml
filesexamples/demo-component-versions/vendor.yaml
Let's verify if this is a test requirement or if these files need to be updated to match the secure pattern:
Let's check the code to see if there's any validation logic that treats these URLs differently:
Let's check the vendor-related code specifically:
Let's check the specific validation logic for source URLs:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 1932
Script:
Length of output: 1909
Script:
Length of output: 832
Script:
Length of output: 13623
Script:
Length of output: 20412