Repository navigation
fix(sanitizer): redact bare SendGrid API keys (TSK-007) - #104
Merged
Merged
Conversation
Add an SG.<22>.<43> pattern to redactProviderTokens so keys whose segments contain _ or - are replaced whole with [REDACTED_SENDGRID_KEY]. Tests build keys at runtime to avoid secret scanning. SPECS.md lists SendGrid among covered providers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
🤖 hustle review: approve — SendGrid pattern is correct, with a lookahead for keys ending in - or _. Fixture lengths check out at 22 and 43, and tests build keys at runtime. SPECS.md and the backlog are updated, so all acceptance criteria are met. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
🤖 hustle review: approve — SendGrid pattern is correct (22/43 segments, lookahead handles trailing -/_), tests cover all required cases with runtime-built keys, docs and backlog updated; all acceptance criteria met. |
Contributor
|
🎉 This PR is included in version 4.1.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
What changed
src/core/sanitizer.ts:redactProviderTokensgets a SendGrid pattern,/\bSG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g→[REDACTED_SENDGRID_KEY]. The pattern ends with a negative lookahead, not\b, because keys can end in-or_(same issue as the Google key fix). Before this change, bareSG.<22>.<43>keys had no provider pattern, and the opaque-id fallback misses base64url segments with_/-, so they leaked whole.src/core/sanitizer.test.ts: newSendGrid API keysblock. It covers a realistic key with_and-, an all-letter key, and a key inside a curl command. Keys are built at runtime (['SG', id, secret].join('.')), so no literal key is committed. One test also checks the 22/43 segment lengths of the fixtures.docs/SPECS.md: SendGrid is now in the provider list.pending/tocomplete/with its progress log, plus learningLRN-006(dev install notes).Acceptance criteria
_or-.pnpm vitest run src/core/sanitizer.test.ts -t SendGrid: 3 of 4 failed before the pattern (the 4th checks fixture lengths only). All 4 pass after it. Output is exactly[REDACTED_SENDGRID_KEY].SendGrid API keysdescribe block.git show HEAD | rg 'SG\.[A-Za-z0-9_-]{20,}\.'finds no matches, and GitHub push protection accepted the push.docs/SPECS.md:165.pnpm check && pnpm testpass.pnpm checkexits 0.pnpm testpasses 26 files and 471 tests.pnpm buildalso succeeds. All three were re-run on the committed tree after lint-staged.How it was verified
Locally on Node 24.22.0, because
engine-strictrejects Node 25. The local shell exportsNODE_ENV=production, which makes pnpm skip devDependencies, so I ran install withNODE_ENV=developmentand tests withNODE_ENV=test. CI is not affected.🤖 Generated with Claude Code