Skip to content

fix(rules): sql-concat rules ignore prose and identifier interpolation (#662) - #665

Merged
ajianaz merged 1 commit into
developfrom
fix/662-sql-concat-prose-identifiers
Oct 15, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/662-sql-concat-prose-identifiers

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #662.

What

Extends the existing SQL false-positive filter (now also applied to sec-sql-concat):

  • Prose is not SQL. The line must have SQL structure (SELECT..FROM, INSERT INTO, UPDATE x SET, DELETE FROM); format!("Insert failed: {e}") and format!("Deleted tag '{}'") are suppressed.
  • Only a spliced value is injection. A {x} / ${x} in a value position (after =, <, >, LIKE, IN (, a quote, %, or inside a VALUES list) or "..." + value concatenation stays Critical. Identifier and fragment positions (FROM {table}, SET {cols}, {column} IS NOT NULL) and parameter indexes (?{n}) are suppressed: they cannot be bound as parameters.
  • query += ... keeps being flagged whatever else is on the line.

Why

Issue #662: 5 of the 38 Critical/Major false positives found on two real codebases were these rules.

Testing

  • cargo fmt --check, cargo clippy --all-targets --features tree-sitter -- -D warnings, cargo test --features tree-sitter (1220 passed). New: 4 prose lines, 5 identifier/fragment lines suppressed; 8 injection shapes (Rust format!, Python f-string, JS template, + concat, LIKE, IN, VALUES) and query += still flagged.
  • Real build re-scan of uteke and uteke-cloud (Critical+Major): the 5 SQL findings are gone (uteke 20 → 15).
  • Known limit: a table name taken from user input in FROM {table} is no longer reported; static analysis cannot tell, and identifiers cannot be parameterized.

#662)

A SQL keyword in a message is not SQL, and identifiers/SET fragments
cannot be bound as parameters. Only a value spliced into real SQL
(or string concatenation) stays a finding.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: ajianaz <ajianaz@users.noreply.github.com>
@ajianaz
ajianaz force-pushed the fix/662-sql-concat-prose-identifiers branch from 43dd10e to fc32e4e Compare October 15, 2026 08:05
@ajianaz
ajianaz merged commit eda5667 into develop Oct 15, 2026
14 checks passed
@ajianaz
ajianaz deleted the fix/662-sql-concat-prose-identifiers branch October 15, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(rules): sql-concat rules flag prose ("Insert failed") and allowlisted identifier interpolation

1 participant