Skip to content

Commit

Permalink
fix ValidateURI
Browse files Browse the repository at this point in the history
  • Loading branch information
haitham911 committed Jan 21, 2025
1 parent d0490de commit 4b3c662
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions internal/exec/go_getter_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ 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")
}
Expand Down Expand Up @@ -57,7 +61,6 @@ func IsValidScheme(scheme string) bool {
"git": true,
"ssh": true,
"git::https": true,
"file": true,
}
return validSchemes[scheme]
}
Expand Down
10 changes: 6 additions & 4 deletions internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,14 @@ func ExecuteAtmosVendorInternal(
if err != nil {
return err
}
err = ValidateURI(uri)
if err != nil {
return err
}

useOciScheme, useLocalFileSystem, sourceIsLocalFile := determineSourceType(&uri, vendorConfigFilePath)
if !useLocalFileSystem {
err = ValidateURI(uri)
if err != nil {
return err
}
}

// Determine package type
var pType pkgType
Expand Down

0 comments on commit 4b3c662

Please sign in to comment.