fix(sanitizer): redact GitHub user-to-server (ghu_) tokens (#1502)

redactGitHubTokens covers ghp_, gho_, ghs_, ghr_, and github_pat_
tokens but misses ghu_ (GitHub App user-to-server tokens), one of the
documented GitHub token prefixes. A ghu_ token appearing in issue or
PR content passed through sanitization unredacted.

Add the ghu_ pattern, mirroring the existing 40-character token
patterns, with unit tests including the git-credential URL form.
This commit is contained in:
NickNojiri
2026-07-14 13:06:18 -07:00
committed by GitHub
parent f1bd27ca5b
commit 4f07c81564
2 changed files with 16 additions and 0 deletions
+6
View File
@@ -83,6 +83,12 @@ export function redactGitHubTokens(content: string): string {
"[REDACTED_GITHUB_TOKEN]",
);
// GitHub user-to-server tokens: ghu_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (40 chars)
content = content.replace(
/\bghu_[A-Za-z0-9]{36}\b/g,
"[REDACTED_GITHUB_TOKEN]",
);
// GitHub installation tokens: ghs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (40 chars)
content = content.replace(
/\bghs_[A-Za-z0-9]{36}\b/g,