Repository navigation
fix(security): handle GitLab nested groups in URL parsing - #768
Merged
Merged
Conversation
The GitRemoteUrl parser previously assumed exactly /<owner>/<repo> structure, which silently dropped segments for GitLab nested groups. For gitlab.com/group/subgroup/repo, the parser would return owner="group" and repo="subgroup", dropping the actual repo name. This caused project_identifier() to be non-unique across repos in the same parent group, allowing approval bypass - approvals for one repo would apply to sibling repos. Fix: Treat all path segments except the last as the namespace. Now gitlab.com/group/subgroup/repo correctly returns owner="group/subgroup" and repo="repo", with project_identifier="gitlab.com/group/subgroup/repo". Added comprehensive tests for: - All URL formats (https, http, git://, ssh://, git@) - Deep nesting (7+ levels) - Security uniqueness verification - Edge cases (double slashes, .git suffixes, malformed paths) Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
Restructure adversarial tests to ensure all assertions execute: - Use .unwrap() for URLs that should parse successfully - Use is_none() assertions for URLs that should fail parsing - Add https:// variants where SSH parsing fails but https:// succeeds This fixes the codecov/patch coverage requirement. Co-Authored-By: Claude <[email protected]>
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
gitlab.com/group/subgroup/repo1andgitlab.com/group/subgroup/repo2previously both resolved to identifiergitlab.com/group/subgroup, allowing approval bypassProblem
The
GitRemoteUrl::parse()function assumed exactly/<owner>/<repo>structure. For nested GitLab groups:gitlab.com/group/subgroup/repo→ owner=group, repo=subgroup(repo dropped!)gitlab.com/group/subgroup(same for all repos in that group)This meant approvals for one repo would apply to sibling repos, bypassing command approval security.
Solution
Introduced
split_namespace_repo()helper that treats everything before the last path segment as the namespace:group/subgroup, repo=repogitlab.com/group/subgroup/repo(unique per repo)Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]