Skip to content

Fix ghs_ DLP pattern to support new token format#3783

Closed
hpsin wants to merge 1 commit into
github:mainfrom
hpsin:fix/ghs-token-regex-new-format
Closed

Fix ghs_ DLP pattern to support new token format#3783
hpsin wants to merge 1 commit into
github:mainfrom
hpsin: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: https://github-grid.enterprise.slack.com/archives/C0AH8M0MVUK

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

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

Note

Copilot was unable to run its full agentic suite in this review.

Updates the DLP detector to recognize newer GitHub App installation token formats that include dots, and expands test coverage accordingly.

Changes:

  • Broadened the ghs_ token regex to allow . / _ and variable length (36+).
  • Updated the existing ghs_ test expectation to match the new regex.
  • Added a new test case covering dot-separated ghs_ tokens.
Show a summary per file
File Description
src/dlp.ts Expands the ghs_ detection regex to match the new token format.
src/dlp.test.ts Updates and adds tests to validate detection of the new ghs_ token format.

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: 3

Comment thread src/dlp.ts
@@ -52,7 +52,7 @@ const DLP_PATTERNS: DlpPattern[] = [
{
name: 'GitHub App Installation Token',
description: 'GitHub App installation access token (ghs_)',
Comment thread src/dlp.ts
name: 'GitHub App Installation Token',
description: 'GitHub App installation access token (ghs_)',
regex: 'ghs_[a-zA-Z0-9]{36}',
regex: 'ghs_[A-Za-z0-9._]{36,}',
Comment thread src/dlp.test.ts
Comment on lines +58 to +62
it('should detect new-format GitHub App installation token (ghs_) with dots', () => {
const matchingRegexes = findMatchingDlpRegexes(
'https://api.example.com/?key=ghs_ABC.DEF.GHIJKLMNOPQRSTUVWXYZabcdefghij'
);
expect(matchingRegexes).toContain('ghs_[A-Za-z0-9._]{36,}');
@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 25, 2026

@hpsin thanks for the heads up. addressed here #3786

@lpcox lpcox closed this May 25, 2026
@hpsin
Copy link
Copy Markdown
Member Author

hpsin commented May 25, 2026

Thanks! Sorry, this was a Copilot spray and pray so I hadn't gotten to cleaning up this PR. Not loving that it opened them straight instead of as a draft - thanks for tackling it!

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.

3 participants