feat(EXPOSED_SECRETS): expand secret detection from 4 to 13 patterns + add tests#49
Open
dmchaledev wants to merge 1 commit into
Open
feat(EXPOSED_SECRETS): expand secret detection from 4 to 13 patterns + add tests#49dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The EXPOSED_SECRETS rule (CRITICAL) only matched 4 secret formats — OpenAI keys, classic GitHub PATs, AWS access key IDs, and password assignments — so many common, high-signal credential shapes leaked through undetected, and the rule had no dedicated unit tests. Expand SECRET_PATTERNS to 13 prefix-anchored patterns, adding: - Anthropic API keys (sk-ant-) - GitHub OAuth/server/user/refresh tokens (gho_/ghs_/ghu_/ghr_) and fine-grained PATs (github_pat_) - GitLab PATs (glpat-) - Google API keys (AIza...) - Slack tokens (xox[baprs]-) - Stripe live secret/restricted keys (sk_live_/rk_live_) - npm tokens (npm_) - PEM private-key blocks Patterns stay prefix-anchored to keep false positives low: a JWT-shaped auth token (as used by examples/secure-config.json) is not flagged. Add a dedicated EXPOSED_SECRETS test suite (16 cases) covering each new pattern, the JWT false-positive guard, benign strings, and single-report dedup. Update CHANGELOG. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QJfFuGXGPxiQzpfCP21SCv
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.
Summary
EXPOSED_SECRETSis a CRITICAL rule, but it only matched 4 secret formats — OpenAI keys, classic GitHub PATs (ghp_), AWS access key IDs, and password assignments. Many common, high-signal credential shapes leaked through undetected, and the rule had no dedicated unit tests.This PR widens coverage to 13 prefix-anchored patterns and adds a full test suite for the rule.
What's added
New detections in
SECRET_PATTERNS(src/rules/runtime-rules.ts):sk-ant-…gho_/ghs_/ghu_/ghr_github_pat_…glpat-…AIza…xox[baprs]-…sk_live_…/rk_live_…npm_…-----BEGIN … PRIVATE KEY-----The original 4 patterns (OpenAI,
ghp_, AWSAKIA, password assignment) are retained.False-positive safety
All patterns are prefix-anchored to distinctive, structured markers, so precision stays high. In particular, a JWT-shaped auth token — as used by the bundled
examples/secure-config.json— is not flagged (verified by test and by scanning the example config: 0EXPOSED_SECRETSfindings).Tests
Adds a dedicated
EXPOSED_SECRETSsuite (16 cases) covering:Synthetic test tokens are assembled from split literals so they can't be mistaken for live credentials by push protection.
npm run lintandnpm run buildare clean.Verification
Scoped to
src/rules/runtime-rules.ts+ tests + CHANGELOG; no behavior change to any other rule.🤖 Generated with Claude Code
https://claude.ai/code/session_01QJfFuGXGPxiQzpfCP21SCv
Generated by Claude Code