Skip to content
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
wants to merge 9 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion internal/exec/vendor_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (m *modelVendor) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
version := grayColor.Render(version)
return m, tea.Sequence(
tea.Printf("%s %s %s", mark, pkg.name, version),
tea.Printf("%s %s %s %s", mark, pkg.name, version, errMsg),
tea.Quit,
)
}
Expand Down
18 changes: 0 additions & 18 deletions internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for vendoring from:

../../demo-library/weather

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add it to example/tests

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
}
Expand Down
Loading