Skip to content

Commit

Permalink
fix(vendor): Remove excessive URL validation (#1024)
Browse files Browse the repository at this point in the history
* fix(vendor): Remove excessive URL validation

Fixes #1019

* feat(vendor): Add component to error message

---------

Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
  • Loading branch information
2 people authored and Cerebrovinny committed Feb 9, 2025
1 parent e152a10 commit 5ce76d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 0 additions & 5 deletions internal/exec/go_getter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@ func ValidateURI(uri string) error {
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")
}
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:], "/") {
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,9 @@ func ExecuteAtmosVendorInternal(
err = ValidateURI(uri)
if err != nil {
if strings.Contains(uri, "..") {
return fmt.Errorf("Invalid URI '%s': %w. Please ensure the source is a valid local path or a properly formatted URI.", uri, err)
return fmt.Errorf("invalid URI for component %s: %w: Please ensure the source is a valid local path", s.Component, err)
}
return err
return fmt.Errorf("invalid URI for component %s: %w", s.Component, err)
}
}

Expand Down

0 comments on commit 5ce76d7

Please sign in to comment.