fix(rules): narrow sql-concat, debug-enabled, hardcoded-role patterns - #492
Merged
Merged
Conversation
…#485, #486, #490) sql-concat: require SQL keyword inside string literal + post-match filter for comments/docstrings. Regex now needs a quote char before the + to qualify as SQL injection. debug-enabled: remove bare --debug from regex (too many false positives on CLI flags, Dockerfiles, argument parsers). Keep DEBUG = True and debug: true assignments. Add post-match filter for comment lines, argument parser definitions, and env var references. hardcoded-role: add quoted patterns ("admin", 'admin'), strict equality (===), property access (user.role), and superuser to the regex. Now covers JS, TS, Python, Go patterns. Tests: 854 pass (18 new), 0 clippy warnings, fmt clean. Closes #485, closes #486, closes #490.
This was referenced Aug 5, 2026
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
Three security scanner rules produced false positives or false negatives due to overly broad or overly narrow regex patterns. This PR narrows and adds post-match filters for each, following the same 3-layer defense approach established in #484.
Why
#485 —
injection/sql-concatflagged comments, prose, and non-SQL concatenation. The old regex(?i)(?:SELECT|INSERT|UPDATE|DELETE)\s+.*\+matched any SQL keyword followed by+anywhere — including// SELECT a + bandlet total = a + b; // UPDATE: not SQL.#486 —
config/debug-enabledflagged CLI flags, argument parser definitions, and Dockerfile RUN commands. The old regex included--debugwhich is a CLI convention, not a config assignment.#490 —
auth/hardcoded-rolemissed the most common real-world pattern: quoted role comparisons. The old regex only matched barewordrole == admin(rare outside Ruby/PHP), missingrole == "admin"(JS, TS, Python, Go),user.role === "admin"(property access + strict equality), and"superuser".Closes #485, closes #486, closes #490.
How
injection/sql-concat(security_scanner.rs):+format!("SELECT ...")pattern for Rust format macrosis_false_positive_sql_concat()post-match filter: suppresses comment lines (//,#,--,/*,*) and docstringsconfig/debug-enabled(security_scanner.rs):--debugfrom regex — too many false positives in dev toolingDEBUG = True,debug: true, addeddebug = trueis_false_positive_debug()post-match filter: suppresses comment lines, argument parser definitions (add_argument,.option(,parser.), and env var referencesauth/hardcoded-role(security_scanner.rs):["']?), strict equality ([=]{2,3}), property access ((?:\w+\.)*role), andsuperuserrole == "admin",user.role === 'super',if role === "superuser", etc.Testing
cargo test --features tree-sitterpasses — 854 tests, 0 failures (18 new tests added)cargo fmt --all -- --checkpassescargo clippy --all-targets --features tree-sitter -- -D warningspassescargo build --release --features tree-sitterpassesNew test coverage:
Related Issues
Closes #485, closes #486, closes #490
Part of epic #487
Checklist
fix/)develop