JS: Fix FP in js/build-artifact-leak when keys come from an array of constants#20397
Merged
asgerf merged 3 commits intogithub:mainfrom Oct 28, 2025
Merged
JS: Fix FP in js/build-artifact-leak when keys come from an array of constants#20397asgerf merged 3 commits intogithub:mainfrom
asgerf merged 3 commits intogithub:mainfrom
Conversation
The tests already have the annotations, it just seems to have been disable by accident
14274c1 to
d75fddf
Compare
d75fddf to
2a4d683
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a false positive in the js/build-artifact-leak security query where environment variable keys are filtered through an array of safe constants. The fix adds logic to recognize when a reduce operation iterates over an array of constant strings, indicating intentional filtering rather than a security vulnerability.
Key Changes
- Added test case demonstrating the false positive scenario with array-based key filtering
- Extended the sanitizer logic to recognize arrays of constant strings as safe sources
- Updated test expectations to use inline expectations format
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
javascript/ql/test/query-tests/Security/CWE-312/build-leaks.js |
Added test case getFilteredEnv4() demonstrating safe filtering via constant array |
javascript/ql/test/query-tests/Security/CWE-312/BuildArtifactLeak.qlref |
Enabled inline expectations test postprocessing |
javascript/ql/test/query-tests/Security/CWE-312/BuildArtifactLeak.expected |
Updated expected results with inline expectations format |
javascript/ql/lib/semmle/javascript/security/dataflow/CleartextLoggingCustomizations.qll |
Implemented isArrayOfConstants predicate to recognize constant array sources |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.