Repository navigation
Conversation
…ve SCP username parsing - In MakeCommitURL and MakeDirURL, ensure non-HTTP schemes (git, git+ssh, ssh) normalize to https so generated browser links open properly. - In MakeFileCreationURL, strip user credentials (u.User = nil) to prevent credential and token leakage in generated browser links. - In parseScp, support hyphens and dots in SCP usernames (e.g. git-deployer, deploy.bot). - In parseGitURL, trim leading/trailing whitespace around raw URLs. - In parseTransport, treat URL scheme case-insensitively. - Add unit tests covering git, git+ssh, and ssh:// schemes, credential stripping, hyphenated/dotted SCP usernames, whitespace, and uppercase schemes. Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
✅ Deploy Preview for pipecd-site canceled.
|
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.
What this PR does:
This PR improves Git URL parsing and web URL generation in
pkg/git/url.go:https: InMakeCommitURLandMakeDirURL, the scheme previously checkedif u.Scheme != "ssh" { scheme = u.Scheme }. For repositories configured withgit://orgit+ssh://, this producedgit://...orgit+ssh://...links that cannot be opened in a web browser. Now, any non-HTTP protocol (ssh,git,git+ssh) cleanly normalizes tohttps, whilehttpis preserved.MakeFileCreationURL, previouslyu.User = nilwas only applied ifu.Scheme == "ssh". When using HTTP/HTTPS repository URLs containing user credentials or access tokens (e.g.,https://oauth2:token@github.com/...), the sensitive credentials leaked into the generated browser URL.u.Useris now always stripped.([a-zA-Z0-9_]+@)?, which failed to parse valid Git SCP URLs containing hyphens or dots in the username (such asgit-deployer@host:...ordeploy.bot@host:...). Updating the character class to[a-zA-Z0-9_.-]+enables proper parsing.parseGitURL: Strips leading and trailing whitespace from input URLs.parseTransport: Normalizes the scheme to lowercase per RFC 3986 so mixed-case or uppercase schemes (e.g.,HTTPS://...) are handled gracefully.Why we need it:
git://andgit+ssh://repositories failed to open in web browsers.MakeFileCreationURL.no scp URL found.Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?:
cc @mohammedfirdouss @armistcxy