JS: Exclude environment variables from js/regex-injection query by default#20148
Merged
Napalys merged 4 commits intogithub:mainfrom Aug 18, 2025
Merged
Conversation
f980d9a to
b820cb5
Compare
b820cb5 to
3f9061a
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the js/regex-injection query to exclude environment variables as default sources while allowing them to be re-enabled via the "environment" threat model. The change reduces false positives for scenarios where environment variables are considered trusted input.
- Removes environment variables from default sources in the RegExp injection query
- Adds support for re-enabling environment variables through the "environment" threat model
- Updates test cases to verify the new behavior with both enabled and disabled threat models
Reviewed Changes
Copilot reviewed 8 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| RegExpInjectionCustomizations.qll | Refactors source detection to exclude environment variables by default and adds conditional environment variable sources |
| Threat-models-enabled/* | New test files to verify environment variables are detected when threat model is enabled |
| Threat-models-disabled/RegExpInjection.js | Updates test to reflect that environment variables should not be detected by default |
| Threat-models-disabled/RegExpInjection.expected | Updates expected results removing environment variable alerts |
| 2025-07-31-regexp-injection-threat-model.md | Documents the change in behavior |
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.
Removes environment variables as default sources for the
js/regex-injectionquery while allowing them to be re-enabled via the "environment" threat model.