fix: validate repo URL format on app creation (closes #88) #91
No reviewers
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
merge-ready
merge-ready
needs-checks
needs-checks
needs-rebase
needs-rebase
needs-review
needs-review
needs-rework
needs-rework
notplanned
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/upaas#91
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/repo-url-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
validateRepoURL()function that validates repository URLs in app creation and update flows.Changes
validateRepoURL()acceptinghttps://,http://,ssh://,git://, andgit@host:pathformatsfile://URLs (security), paths without protocol, unknown schemesHandleAppCreate,HandleAppUpdate, andHandleAPICreateAppTest results (before - no validation existed, tests written first)
Test results (after - validation wired into handlers)
make test
Note:
make checkformatting failures are pre-existing on main (4 files not formatted by goimports), not introduced by this PR.Good security addition — blocking
file://URLs prevents local file access via git clone. Test coverage is thorough with both valid and invalid cases.One concern:
SCP-like regex is too permissive —
^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+:.+$would match something likeadmin@localhost:../../etc/shadow. The user part should probably be restricted to justgitor at minimum the path after:should be validated.Missing test for SSRF vectors — e.g.
https://169.254.169.254/metadataorhttps://[::1]/repo. URL validation alone doesn't prevent SSRF; that's a separate concern but worth documenting.Overall: LGTM, good defense-in-depth.
@ -0,0 +18,4 @@// scpLikeRepoRe matches SCP-like git URLs: git@host:path (e.g. git@github.com:user/repo.git).var scpLikeRepoRe = regexp.MustCompile(`^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+:.+$`)The SCP regex accepts any user (not just
git) and any path after:. Consider restricting the user portion or at minimum validating the path doesn't contain path traversal (..). Example concern:admin@localhost:../../etc/shadow.070edae1fato02f0a12626Fixed the review issues:
gituser only — changed from[a-zA-Z0-9._-]+@togit@, sincegitis the standard user for SSH deploy keys..are now rejected before any further validationroot@,admin@) and path traversal variantsAll tests pass.
08377058c2tobfea5be063make checkpasses cleanly after rebasing on main and fixing pre-existing lint issues. All tests pass, linter clean, build succeeds.bfea5be063toa2087f4898Rebased on main (skipped old lint-fix commit, already resolved by #102).
make checkpasses cleanly.