Repository navigation
fix: keep .env-suffixed names and credentialed source out of the defaults (#51) - #54
Closed
zhongerdeajie wants to merge 1 commit into
Closed
zhongerdeajie wants to merge 1 commit into
zhongerdeajie wants to merge 1 commit into
Conversation
…ults (dzhng#51) A key pasted into an ordinary file left with the source previews: the name policy only matched .env and .env.*, and the content scan only caught a private-key block. Two gaps, closed in the place the policy already owns: - isSensitive treats names ending in .env like .env and .env.* (prod.env, keys.env), still under sensitive_name. - readSnapshot's content scan now also refuses a provider token shape - sk-, sk_live_, ghp_, github_pat_, glpat-, xox[abpr]-, AKIA+16, AIza+35, each with a minimum length past its prefix so prose does not trip it - as api_key, the same gate and the same includeSensitive override the private-key check has. The filters remain not a guarantee (README's own words); this narrows the gap the issue measured, where four credential files went out on every search without ever appearing in the printed context. Co-Authored-By: Claude Code <noreply@anthropic.com>
Owner
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.
Closes #51.
Root cause. A key pasted into an ordinary file left with the source previews, for two
independent reasons:
isSensitive) matched only.envand.env.*, soprod.envandkeys.envwere eligible;readSnapshotcaught only a-----BEGIN ... PRIVATE KEY-----block,so a token pasted into
settings.json/config.toml/keys.jsonwent out on everyrequest — API keys in ordinary config files are sent to the provider #51 measured 12 of 29 requests carrying one fake value — while never appearing
in the printed context, so the calling agent had no way to notice.
Fix. Both gaps closed in the place the policy already owns, cheapest first as the issue
proposes:
isSensitivetreats names ending in.envlike.envand.env.*(samesensitive_namereason, sameincludeSensitiveoverride);readSnapshot's content scan also refuses a provider token shape —sk-,sk_live_,ghp_,github_pat_,glpat-,xox[abpr]-,AKIA+ 16,AIza+ 35, each with aminimum length past its prefix so prose and identifiers do not trip it — as a new
api_keyreason, behind the same!policy.includeSensitivegate as the private-keycheck, so the existing override admits it unchanged.
Not a guarantee. README's own words stand: the filters narrow what a search sends, they
do not promise secrets are caught. This only closes the specific gap the issue measured.
Tests (
packages/core/test/filesystem.test.ts, written first, red/green):prod.env/keys.env→ excluded assensitive_name;settings.json,config.toml,keys.json,aws.txt,slack.ts,gitlab.txt,github.txt) → excluded asapi_key;sk-alone,AKIA12345) stays eligible;includeSensitive: trueadmits all of the above, as before for the private-key case.The fixture tokens are assembled by string concatenation inside the test so the literal
credential shapes never appear verbatim in committed source (secret scanners match raw
text); the values the assertions exercise are unchanged.