fix(proxy): #1588 accept smart-HTTP paths without .git suffix#1642
Open
re-vlad wants to merge 1 commit into
Open
fix(proxy): #1588 accept smart-HTTP paths without .git suffix#1642re-vlad wants to merge 1 commit into
re-vlad wants to merge 1 commit into
Conversation
✅ Deploy Preview for endearing-brigadeiros-63f9d0 canceled.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1642 +/- ##
==========================================
+ Coverage 85.87% 85.89% +0.01%
==========================================
Files 84 84
Lines 8109 8116 +7
Branches 1376 1379 +3
==========================================
+ Hits 6964 6971 +7
Misses 1117 1117
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Git smart-HTTP clients may send repository paths without a
.gitsuffix (e.g.GET /owner/repo/info/refs?service=git-upload-pack). GitHub accepts this form; Git Proxy previously did not.processUrlPathonly matched paths containing.git((.+\.git)(\/.*)?). For.git-less smart-HTTP URLs it returnednull, so -proxyFilterrejected the request withInvalid request receivedbefore the plugin chain ran.This PR fixes that in two places (both are required for a full clone/fetch):
processUrlPath- after the existing.gitregex, add a smart-HTTP suffix fallback for paths ending in/info/refs,/git-upload-pack, or/git-receive-pack. NormaliserepoPathto end with.gitinternally soparseActionandgetRepoByUrlcontinue to work unchanged.isPackPost- make.gitoptional in the POST pack URL regex soPOST /owner/repo/git-upload-packis recognised andextractRawBodyruns. Without this, discovery could succeed but clone/fetch would still fail on the second HTTP request.Complementary to, not a substitute for: v1->v2 DB URL migration (#1535 / #1543), which normalises stored
repos.url. This PR fixes inbound wire paths clients send at runtime.Related Issue
Resolves #1588
Checklist
General
Documentation
N/A — behaviour fix aligned with GitHub/git client conventions; no new user-facing configuration.
Configuration
config.schema.json) was modified:npm run generate-config-types)npm run gen-schema-doc)N/A —
config.schema.jsonnot modified.Tests
npm test)npm run lintandnpm run format:check)npm run check-types)Local verification:
npm test(1141 passed),npm run lint, Prettier on changed files.Test plan
processUrlPath('/octocat/hello-world/info/refs?service=git-upload-pack')→repoPath: /octocat/hello-world.gitprocessUrlPath('/github.com/octocat/hello-world/info/refs?service=git-upload-pack')→ proxied host path with.gitnormalisedprocessUrlPath('/org/owner/repo/git-upload-pack')→ pack path parsed.gitunchanged (/octocat/hello-world.git/info/refs?...,/octocat/hello-world.git,/octocat/hello-world.git/)isPackPosttrue forPOST /a/b/git-upload-packandPOST /a/b.git/git-upload-packproxyFilterallowsGET /github.com/finos/git-proxy/info/refs?service=git-upload-packwithout mockingprocessUrlPathcurl -H "User-Agent: git/2.43.0" "http://<proxy>/owner/repo/info/refs?service=git-upload-pack"against authorised repo (both with and without.gitin path)