Support SCP-style Git URLs without user@ prefix#138
Open
turian wants to merge 2 commits intonephila:masterfrom
Open
Support SCP-style Git URLs without user@ prefix#138turian wants to merge 2 commits intonephila:masterfrom
turian wants to merge 2 commits intonephila:masterfrom
Conversation
…r/repo.git) Previously, all SSH patterns required a user@ prefix (either hardcoded git@ or a regex capture group). URLs like github.com:owner/repo.git — commonly produced by credential sanitization layers — would crash with AttributeError. The fix makes user@ optional in all SSH patterns across all platforms, defaulting to the platform's configured user (typically "git"). A negative lookahead (?!.*://) prevents git:// and https:// URLs from incorrectly matching SSH patterns, and domain character classes now exclude @ to reject malformed inputs like @github.com:Org/Repo.git. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… SCP change Tests added (per ROI-prioritized test plan): - Invalid inputs: foo:bar, a:b, localhost:repo, C:\repo, host:/repo.git, :Org/Repo.git - Platform disambiguation: assembla, github, gitlab, bitbucket userless SCP - Rewrite round-trips: userless SCP → ssh, https, git for all platforms - Non-git users: alice@github.com, alice@host.org, bob@git.assembla.com - GitLab port variants: alice@host.org:9999, ssh://alice@host.org - Unknown host fallback: git.example.com:team/repo.git → gitlab Code fixes: - BasePlatform SSH domain now requires a dot (FQDN) to reject generic host:path - GitLab SSH owner excludes colon to prevent backtracking parse of host:/repo.git - GitLab GIT format uses port_colon for correct git://host:port/path output - result.py adds port_colon format helper Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
|
@turian Hi, thanks for opening this pr! In order to make the CI pass may I ask you to:
|
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.
Summary
parse()crashes withAttributeErroron SCP-style Git URLs without a user prefix (e.g.,github.com:owner/repo.git). These are commonly produced by credential sanitization layers that stripuser@from remote URLs.Root cause
All SSH regex patterns require
user@before the domain — either hardcodedgit@(GitHub, Bitbucket, Assembla) or a mandatory capture group (GitLab, Base).Changes
SSH pattern fix (all 5 platforms):
user@is now optional via(?:(?P<_user>[^@]+)@)?, defaulting to the platform's configured user (typically"git")(?:...://|(?!.*://))alternation to preventgit://andhttps://URLs from incorrectly matching SSH patterns (previouslygit@served as an implicit anchor)[^/:@]+to reject malformed inputs like@github.com:Org/Repo.gitFalse-positive hardening:
host:pathlikefoo:bar,localhost:repo,C:\repo[^/:]+) — prevents regex backtracking from parsinghost:/repo.gitwithowner=":"GitLab port format fix:
%(port_colon)sinstead of%(port)s— fixesgit://host.org:9999/...output (wasgit://host.org9999/...)Files changed
platforms/github.pyplatforms/gitlab.py:, GIT port format fixplatforms/bitbucket.pyplatforms/assembla.pyplatforms/base.py://negative lookaheadresult.pyport_colonformat helpertests/test_parse.pytests/test_rewrite.pyTest plan
github.com:Org/Repo.git,bitbucket.org:Org/Repo.git,host.org:Org/Repo.git,host.org:9999/Org/Repo.git,git.assembla.com:SomeRepoID.gitalice@github.com:Org/Repo.git,alice@host.org:Org/Repo.git,bob@git.assembla.com:SomeRepoID.gitssh://alice@host.org/Org/Repo.gitalice@host.org:9999/Org/Repo.git,ssh://git@host.org:9999/Org/Repo.gitgit.example.com:team/repo.git→ gitlabfoo:bar,a:b,localhost:repo,C:\repo,host:/repo.git,:Org/Repo.git@github.com:Org/Repo.git(@ without username) remains invalidgit://,https://) unaffected🤖 Generated with Claude Code