fix(rules): widen CORS regex for framework patterns and fix negation filter edge cases - #491
Merged
Merged
Conversation
ajianaz
force-pushed
the
fix/cors-overcorrection-488-489
branch
from
August 4, 2026 15:49
eacea8b to
6460809
Compare
…filter edge cases (#488, #489) Rewrote CORS regex with 10 framework pattern alternatives using (?ix) extended mode: HTTP header, generic assignment, Django, Spring Boot, .NET, tower-http, Express, FastAPI, nginx, actix-web. Also fixes: - Removed unsupported lookahead (?!\w) — Rust regex crate limitation - Negation filter skips suppression when comment has code indicators - cors_config suppression scoped to env::var() reads only - Pre-compiled negation regexes with LazyLock - is_doc_file() checks for dot before extracting extension Tests: 836 pass, 0 fail, 0 clippy warnings, fmt clean. Closes #488, closes #489.
ajianaz
force-pushed
the
fix/cors-overcorrection-488-489
branch
from
August 4, 2026 15:52
6460809 to
0ff0ead
Compare
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
Rewrites the CORS wildcard regex to cover 10 framework-specific patterns that were missed after PR #484, and fixes three edge cases in the negation filter and env-var suppression that caused false negatives.
Why
PR #484 narrowed the CORS regex to fix false positives (#483), but the narrowing was too aggressive: 13 of 14 common framework-specific CORS wildcard patterns were no longer detected. The negation filter also suppressed real findings on mixed comment/code lines, and the
cors_configsuppression caught bare assignments instead of only env-var reads. Additionally,is_doc_file()treated extensionless filenames likeorgortexas documentation.Closes #488, closes #489.
How
security_scanner.rs:(?ix)extended mode with 10 alternatives covering HTTP headers, generic assignments, Django, Spring Boot, .NET, tower-http, Express, FastAPI, nginx, and actix-web(?!\w)(Rust regex crate limitation) — replaced with explicit trailing delimitersis_doc_file()to check for dot before extracting extensionbuiltin.rs:=,fn,let,const)cors_configsuppression scoped toenv::var()/getenv()/os.environread patterns onlyLazyLock<Vec<Regex>>Testing
cargo test --features tree-sitterpasses — 836 tests, 0 failures (15 new tests added)cargo fmt --all -- --checkpassescargo clippy --all-targets --features tree-sitter -- -D warningspassescargo build --release --features tree-sitterpassesNew test coverage:
is_doc_fileextensionless file testRelated Issues
Closes #488, closes #489
Checklist
fix/)develop