fix(detect): spare genuine source from the Stage 1 sensitive-dir drop (#1943)#1955
Closed
alphanury wants to merge 1 commit into
Closed
fix(detect): spare genuine source from the Stage 1 sensitive-dir drop (#1943)#1955alphanury wants to merge 1 commit into
alphanury wants to merge 1 commit into
Conversation
…Graphify-Labs#1943) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
safishamsi
added a commit
that referenced
this pull request
Jul 17, 2026
…rve-out (follow-up to #1955) The #1943 carve-out rescues genuine source under secrets/ / credentials/, but .tfvars sits in CODE_EXTENSIONS while being Terraform's canonical values store (routinely real secrets), so it would now be indexed. Add .tfvars to _SECRET_PRONE_DATA_EXTS so the shared graphable-source predicate drops it in both Stage 1 and Stage 3; .tf/.hcl stay graphable as genuine infra source. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Landed on v8 (ships in 0.9.18), cherry-picked to preserve your authorship. Thanks @alphanury — genuine source under an ambiguous secrets/ or credentials/ dir is spared while dedicated stores still drop everything. Follow-up added on top: .tfvars is now in the secret-prone extension set, so Terraform values files stay out of the graph (they routinely hold real secrets) while .tf/.hcl source stays graphable. |
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.
Fixes #1943.
Stage 1 of
_is_sensitivedropped every file beneath a directory namedsecrets/,.secrets/, orcredentials/— including genuine source packages (Gointernal/secrets, acredentials/service module). Same false-positive class as #1666, which already gave the Stage 3 keyword heuristic a source-code carve-out; this applies that carve-out at the directory level, as proposed in the issue.Change
_SENSITIVE_DIRS:_CREDENTIAL_STORE_DIRS(.ssh,.gnupg,.aws,.gcloud): everything beneath stays dropped, no carve-out — a.pyinside~/.sshis key tooling, not a package._AMBIGUOUS_SENSITIVE_DIRS(secrets,.secrets,credentials): dropped except genuine programming-language source._is_graphable_source()and shared by both stages, so the two carve-outs can't drift.secrets/service_account.py(Stage 2 pattern) andcredentials/id_rsastay dropped.parts[:-1]parent-only semantics unchanged — Sensitive filename detection misses underscore-separated names (\b boundary) #920's root-level-file guarantee still holds.Behavior (issue repro)
internal/secrets/vault.goapp/services/credentials/manager.pysecrets/db.json.secrets/token.yaml.ssh/config,.aws/credentials,.gnupg/helper.py.graphifyincludestill cannot rescue credential stores (untouched here; #1921 tracks the include interplay for Stage 3).Safety notes
classify_filefalls back to a shebang peek, and_shebang_interpreterswallowsOSError— a0600file undersecrets/classifiesNone→ stays dropped, no crash..tf,.tfvars,.hcl) classify as source. If that should tighten, adding them to_SECRET_PRONE_DATA_EXTSnow covers both stages in one place.Tests
tests/test_detect.py: 158 passed.test_security/test_paths/test_extract/test_analyze/test_cache/test_export: 379 passed, 1 skipped.🤖 Generated with Claude Code