Strip credentials from normalized Git remote URLs#36
Open
arseniy-pplx wants to merge 1 commit into
Open
Conversation
Git remote URLs can embed credentials in their userinfo (https://user:token@host/...), most often from CI checkout URLs or a caller-supplied --git-remote-url. Normalization previously rewrote only SSH/SCP forms and stripped the .git suffix, so credentials in an http(s) URL flowed unchanged into published component annotations, CLI output, logs, and browse links. Make credential removal a guarantee of URL normalization. _normalize_git_url now parses the URL and rebuilds the netloc from host and port only, dropping all userinfo, converts ssh:// to https://, drops userinfo from SCP-style remotes, strips the .git suffix, and redacts known sensitive query parameters. The function is idempotent. ComponentPublisher sanitizes a caller-supplied git_remote_url at construction, and component_inspector sanitizes before emitting transparency reasons and building browse links. Scheme, host, port, and path are preserved; only credential material is removed, and clone/fetch authentication is unaffected.
arseniy-pplx
marked this pull request as ready for review
July 20, 2026 18:11
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
Git remote URLs can embed authentication material in their userinfo (
https://user:token@host/...) — most commonly via CI checkout URLs (e.g. GitLab'shttps://gitlab-ci-token:<token>@gitlab.com/...) or a caller-supplied--git-remote-url. Previously_normalize_git_urlonly rewrote SSH/SCP forms and stripped the.gitsuffix, so credentials in anhttp(s)URL flowed unchanged into published component annotations, CLI output, logs, transparency reasons, and generated browse links. This change makes credential removal a hard guarantee of URL normalization._normalize_git_url(utils.py) is now the canonical sanitizer: it parses the URL, rebuilds the netloc from host + port only (dropping alluser[:password]@userinfo), convertsssh://tohttps://, drops userinfo from SCP-style remotes, strips the.gitsuffix, and redacts known sensitive query parameters (access_token,private_token,password,sig, etc.). It is idempotent.ssh://, SCP-styleuser@host:path,file://, bare local paths, and Windows drive paths without corrupting valid input.ComponentPublishersanitizes the resolvedgit_remote_urlat construction, so a caller-supplied--git-remote-url(which bypassesget_git_info's normalization) can never persist credentials into annotations.component_inspectorsanitizesgit_remote_urlbefore emitting it in transparency reasons and before building browse links, as defense-in-depth for annotations that arrive from the server.Context
Scheme, host, port, path, and fragment are preserved; only credential material is removed. Actual clone/fetch authentication is unaffected — sanitization applies to the persisted or displayed value, not to any network operation.
Testing
uv run pytest tests/test_component_inspector.py tests/test_component_publisher.py tests/test_utils.py@assertions, sensitive query-param redaction, and preservation/idempotency for credential-free URLs and local pathsuvx ruff checkon the touched filesuv lock --check;uv build --sdist; CLI import/--helpsmoke checkgit diff --check