Skip to content

Fix ghs_ redaction pattern to support new token format#153

Merged
nobe4 merged 4 commits into
mainfrom
fix/ghs-token-regex-new-format
Jun 11, 2026
Merged

Fix ghs_ redaction pattern to support new token format#153
nobe4 merged 4 commits into
mainfrom
fix/ghs-token-regex-new-format

Conversation

@hpsin

@hpsin hpsin commented May 25, 2026

Copy link
Copy Markdown
Member

Updates the ghs_ token regex to support the new token format which allows dots and underscores ([A-Za-z0-9._]) and variable length (no longer fixed at 36 chars).

See the changelog: https://github.blog/changelog/2026-05-15-github-app-installation-tokens-per-request-override-header/

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the default redaction pattern for ghs_ tokens to match GitHub’s new installation token format (allowing . and _ and variable length), and adjusts specs to ensure the new format is properly redacted.

Changes:

  • Expand the ghs_ default regex to allow [A-Za-z0-9._] and variable length.
  • Update the existing ghs_ spec to expect full-token redaction.
  • Add a new spec case covering ghs_ tokens containing dots and underscores.
Show a summary per file
File Description
spec/lib/redacting_logger_spec.rb Updates/extends redaction test cases to validate the new ghs_ token formats are fully redacted.
lib/patterns/default.rb Broadens the default ghs_ redaction regex to match the new allowed character set and variable length.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment thread lib/patterns/default.rb Outdated
/ghp_[A-Za-z0-9]{36,}|[0-9A-Fa-f]{40,}/,
/github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}/, # Fine Grained
/ghs_[a-zA-Z0-9]{36}/, # Temporary Actions Tokens
/ghs_[A-Za-z0-9._]{36,}/, # GitHub App installation tokens
@GrantBirki

Copy link
Copy Markdown
Contributor

@hpsin you will also want to bump the version file and cut a new release:

VERSION = "1.5.1"

@hpsin hpsin marked this pull request as draft May 26, 2026 01:01
@hpsin

hpsin commented May 26, 2026

Copy link
Copy Markdown
Member Author

@github/authentication-reviewers — FYI, this draft PR updates the ghs_ token regex to support the new stateless token format. Please review when ready. Part of github/authentication#6826.

@hpsin hpsin marked this pull request as ready for review May 26, 2026 18:34
@hagould hagould force-pushed the fix/ghs-token-regex-new-format branch from d8e81b7 to ac21280 Compare May 26, 2026 22:37
@hagould

hagould commented May 26, 2026

Copy link
Copy Markdown
Contributor

@GrantBirki Pushed, could you help us with the release process? Also would like to know how many downstream services are dependent on this for log redaction - we're currently in the early stages of rolling out the new token format.

@GrantBirki

Copy link
Copy Markdown
Contributor

@hagould simply merging this PR should kick off the release process and publish to RubyGems since you bumped the version.rb file -> https://github.com/github/redacting-logger/blob/main/.github/workflows/release.yml

I don't work at GitHub any more and I won't comment publicly on the services at GitHub that use this Gem 😉.

@GrantBirki

Copy link
Copy Markdown
Contributor

If this is still early on, I might consider adding some unit tests for this new redaction pattern as well -> https://github.com/github/redacting-logger/blob/main/spec/lib/redacting_logger_spec.rb

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hagould hagould requested a review from GrantBirki May 27, 2026 18:35
@hagould

hagould commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

@GrantBirki Should be ready for another review

@hagould

hagould commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@GrantBirki Do you know the appropriate team to add for a write access review?

@GrantBirki

Copy link
Copy Markdown
Contributor

@nobe4 or @northrup might be able to help here. Might want to also remove me from the CODEOWNERS file ->

@nobe4

nobe4 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Thanks for this @hpsin 🙏

@nobe4 nobe4 merged commit 2da293a into main Jun 11, 2026
11 checks passed
@nobe4 nobe4 deleted the fix/ghs-token-regex-new-format branch June 11, 2026 13:11
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.

5 participants