Skip to content

Fix ghs_ redaction pattern to support new token format#153

Open
hpsin wants to merge 3 commits into
mainfrom
fix/ghs-token-regex-new-format
Open

Fix ghs_ redaction pattern to support new token format#153
hpsin wants to merge 3 commits into
mainfrom
fix/ghs-token-regex-new-format

Conversation

@hpsin
Copy link
Copy Markdown
Member

@hpsin hpsin commented May 25, 2026

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/
Tracking in Slack: #tmp-stateless-app-tokens
Part of: github/authentication#5980

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

Copilot AI left a comment

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
Copy link
Copy Markdown
Member Author

hpsin commented May 26, 2026

@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
Copy link
Copy Markdown

hagould commented May 26, 2026

@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

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.

4 participants