Skip to content

Commit a44c190

Browse files
hpsinHirsch SinghalCopilot
authored
Fix ghs_ token redaction regex to support new token format (#61392)
Co-authored-by: Hirsch Singhal <hpsin@h6cw215236.localdomain> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c851dd1 commit a44c190

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

content/copilot/tutorials/copilot-cli-hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ REDACTED_TOOL_ARGS="$(echo "$TOOL_ARGS_RAW" | \
374374
sed -E 's/ghp_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
375375
sed -E 's/gho_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
376376
sed -E 's/ghu_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
377-
sed -E 's/ghs_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
377+
sed -E 's/ghs_[A-Za-z0-9\._\-]{20,}/[REDACTED_TOKEN]/g' | \
378378
sed -E 's/Bearer [A-Za-z0-9_\-\.]+/Bearer [REDACTED]/g' | \
379379
sed -E 's/--password[= ][^ ]+/--password=[REDACTED]/g' | \
380380
sed -E 's/--token[= ][^ ]+/--token=[REDACTED]/g')"
@@ -416,7 +416,7 @@ deny() {
416416
sed -E 's/ghp_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
417417
sed -E 's/gho_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
418418
sed -E 's/ghu_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
419-
sed -E 's/ghs_[A-Za-z0-9]{20,}/[REDACTED_TOKEN]/g' | \
419+
sed -E 's/ghs_[A-Za-z0-9\.\-_]{20,}/[REDACTED_TOKEN]/g' | \
420420
sed -E 's/Bearer [A-Za-z0-9_\-\.]+/Bearer [REDACTED]/g' | \
421421
sed -E 's/--password[= ][^ ]+/--password=[REDACTED]/g' | \
422422
sed -E 's/--token[= ][^ ]+/--token=[REDACTED]/g')"

src/search/lib/sanitize-search-query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export function sanitizeSearchQuery(query: string): string {
1111

1212
// Redact GitHub tokens (all formats)
1313
// Classic tokens: ghp_, gho_, ghu_, ghs_, ghr_
14-
sanitized = sanitized.replace(/\b(ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}\b/gi, '[TOKEN]')
14+
// See https://github.blog/changelog/2026-05-15-github-app-installation-tokens-per-request-override-header/
15+
sanitized = sanitized.replace(/(ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9._-]{20,}/gi, '[TOKEN]')
1516
// Fine-grained personal access tokens: github_pat_
1617
sanitized = sanitized.replace(/\bgithub_pat_[A-Za-z0-9_]{20,}\b/gi, '[TOKEN]')
1718
// OAuth tokens: gho_

0 commit comments

Comments
 (0)