Fix ghs_ DLP pattern to support new token format#3783
Closed
hpsin wants to merge 1 commit into
Closed
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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
| @@ -52,7 +52,7 @@ const DLP_PATTERNS: DlpPattern[] = [ | |||
| { | |||
| name: 'GitHub App Installation Token', | |||
| description: 'GitHub App installation access token (ghs_)', | |||
| 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 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,}'); |
Collaborator
Member
Author
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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