Repository navigation
fix(rules): secret rules ignore name: value entries with non-literal values (#661) - #664
Merged
Merged
Conversation
…values (#661) In source files a bare expression after name: (env reads, member access, type annotations, dict values) is a reference or a type, never a secret, and format placeholders are not values. Quoted literals are unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
Every name: value entry on a line must be a non-literal (a harmless first entry no longer hides a later real secret), an env read with a literal fallback stays flagged, and braced values containing digits are not format placeholders. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
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 #661.
What
In source files (
rhs_style == Code), aname: valueentry whose value is not a quoted literal is no longer reported bycrypto/hardcoded-secret/sec-hardcoded-secret:webhook_secret: env::var("X"),refresh_token: prev?.refresh_token,token: Option<&'static str>,"password": ACCOUNT_PW,"clientSecret": j["clientSecret"]. Format placeholders ("{}","{key}","%s") are references, not values. Quoted literals (token: "ghp_..."),=assignments and config-style files (YAML, TOML, ...) are judged exactly as before.Why
Issue #661: on two real codebases (
uteke,uteke-cloud) all 38 Critical/Major findings were false positives, 26 from these rules; every Critical blocks--ci/hook.mode: block.Testing
cargo fmt --check,cargo clippy --all-targets --features tree-sitter -- -D warnings,cargo test --features tree-sitter(1221 passed). New tests: nine non-literal entries suppressed, five placeholders suppressed, six real secret literals still flagged, path segments /:=/ YAML untouched.api_key: "k".into()) and test URLs need test-code awareness (feat(rules): test-code awareness (#[cfg(test)], fixtures, CLI binaries) for built-in rules #663); SQL rules are fix(rules): sql-concat rules flag prose ("Insert failed") and allowlisted identifier interpolation #662. The one remaining cloud secret finding is a placeholder in a shell-script comment (API_KEY=utk_live_…), left flagged because commented-out real secrets are real leaks.