Skip to content

fix(secrets): judge test code on a file's path in the project - #255

Merged
SizzleUnrlsd merged 1 commit into
mainfrom
fix/credential-project-path
Oct 14, 2026
Merged

SizzleUnrlsd merged 1 commit into
mainfrom
fix/credential-project-path

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

hardcoded-credential and config-secrets classified the absolute path. A project under a directory named test, tests, testing, fixtures or __tests__ had every credential at low confidence, as test code. Its template files were labelled test instead of example.

As proposed in #253 (first direction), the rule keeps the decision and is given the file's path in the project:

  • findings.context.path_in_project is the single rule for "the path from the root". The engine uses it for the context of findings: test code is recognised only by hardcoded-credential #244, and so do the plugins.
  • PluginContext.path(source_id) gives that path to module plugins; run_plugins takes an optional root. This is an additive API change: callers without a root keep their behaviour.
  • The engine passes the root on every path: one process, worker processes (from their project configuration), and a file checked alone (the same reference as the context: the file's directory).
  • SecretDetector.judge takes the path in the project. hardcoded-credential reads it from ctx.path, and config-secrets computes it from ctx.root. credential_context is unchanged.

Verdicts change only for projects located under such a directory: that is the fix.

Verification

Closes #253

@SizzleUnrlsd SizzleUnrlsd added the bug Something isn't working label Oct 14, 2026
@SizzleUnrlsd SizzleUnrlsd self-assigned this Oct 14, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit 115c11f into main Oct 14, 2026
10 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the fix/credential-project-path branch October 14, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hardcoded-credential: test code is judged on the absolute path, so a project under a tests directory has every credential at low confidence

1 participant