Skip to content

fix: suppress false positives in sec-hardcoded-url and crypto/hardcoded-secret - #366

Closed
ajianaz wants to merge 4 commits into
developfrom
fix/security-false-positive-post-match-filter
Closed

ajianaz wants to merge 4 commits into
developfrom
fix/security-false-positive-post-match-filter

Conversation

@ajianaz

@ajianaz ajianaz commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes false positives in the security scanner and rule engine that were flagging legitimate code patterns as security issues.

Closes #357. Closes #364.

Changes

builtin.rs — Extended post_match_filter

Added is_false_positive_url() and is_false_positive_secret() helper functions with exclusions for:

  • SVG xmlns / xlink:href — Namespace URIs, not network connections
  • Docker internal hostnames (http://redis:6379) — No dots = internal, no TLS needed
  • Loopback addresses (localhost, 127.0.0.1, 0.0.0.0) — Already safe
  • Comments and docstrings (//, #, <!--, ///, triple quotes) — Not executable code
  • Empty string values (= '', = "", = $state('')) — No actual secret
  • Svelte $state() / bind: — UI framework bindings, not credentials
  • Bare variable references — e.g. { app_secret: formAppSecret } — RHS is a variable

security_scanner.rs — Wired post_match_filter into scan loop

Both the builtin rule engine and the security scanner now share the same false-positive suppression logic via post_match_filter().

Tests

  • 14 new unit tests in builtin::tests covering all filter branches
  • 3 new integration tests in security_scanner::tests for end-to-end verification
  • 731 total tests pass, 0 failures

No breaking changes

All existing detections remain intact. The filter only suppresses matches that were previously false positives — it never adds new findings.

…ed-secret (#357, #364)

- Extend post_match_filter in builtin.rs with exclusions for:
  - SVG xmlns and xlink:href namespace URIs (identifiers, not connections)
  - Docker internal hostnames (no dots, no TLS needed)
  - Comments and docstrings (//, #, <!--, ///, triple quotes)
  - Loopback addresses (localhost, 127.0.0.1, 0.0.0.0)
  - Empty string values and Svelte $state() bindings
  - Variable references (bare identifiers after colon)

- Wire post_match_filter into security_scanner.rs scan loop
  so both rule engine and security scanner share the same
  false-positive suppression logic.

- Add 19 unit tests (14 builtin + 3 security_scanner integration)

Closes #357. Closes #364.
@ajianaz ajianaz closed this Jul 23, 2026
@ajianaz
ajianaz deleted the fix/security-false-positive-post-match-filter branch October 16, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant