Skip to content

Redact credentials from git remote URLs#65

Merged
andrew merged 1 commit intomainfrom
redact-remote-credentials
Apr 30, 2026
Merged

Redact credentials from git remote URLs#65
andrew merged 1 commit intomainfrom
redact-remote-credentials

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented Apr 30, 2026

git remote get-url returns whatever is stored in .git/config, which can include personal access tokens embedded in the userinfo section of HTTPS URLs. brief was printing these verbatim in JSON, text and markdown output, and passing them to the scorecard API during enrichment.

Remote URLs now go through redactURL before reaching the report. Any password component is stripped, and bare usernames that look like tokens (known github_pat_ / ghp_ / glpat- style prefixes, or 24+ character alphanumeric blobs) are replaced with REDACTED. Ordinary git@ SSH remotes and short real usernames are left untouched so the common case isn't mangled.

Also stops echoing the raw clone URL in remote.cloneURL errors, since git's own stderr already prints a credential-safe failure message.

Test fixtures are built with strings.Repeat so they don't trip GitHub secret scanning on this repo.

git remote get-url returns whatever is in .git/config, which can include
personal access tokens embedded as userinfo. These were being printed
verbatim in the JSON, text and markdown reports, and were also being
passed to the scorecard API during enrichment.

Remote URLs now go through redactURL before they reach the report. Any
password component is stripped, and bare usernames that look like tokens
(known github_pat_/ghp_/glpat- prefixes, or 24+ char alphanumeric blobs)
are replaced with REDACTED. Ordinary ssh git@ remotes and short real
usernames are left untouched.

Also stop echoing the raw clone URL in remote.cloneURL errors; git's own
stderr already prints a credential-safe failure message.
@andrew andrew merged commit 679ddef into main Apr 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant