JS: Sharpen up EnumerationRegExp#18892
Merged
erik-krogh merged 4 commits intogithub:mainfrom Mar 10, 2025
Merged
Conversation
6fbf21a to
c8a89c4
Compare
Contributor
There was a problem hiding this comment.
PR Overview
This PR addresses an overly permissive regular expression in the EnumerationRegExp class, making it more restrictive to correctly form barrier guards. Key changes include:
- Updating change notes to reflect the bug fix.
- Adding a new test file to verify the improved regexp logic.
Reviewed Changes
| File | Description |
|---|---|
| javascript/ql/src/change-notes/2025-02-28-membership-regexp-test.md | Updates for bug fix documentation and messaging |
| javascript/ql/test/library-tests/TaintTracking/regexp-sanitiser.js | Addition of a test case for regexp-based sanitizer behavior |
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
javascript/ql/src/change-notes/2025-02-28-membership-regexp-test.md
Outdated
Show resolved
Hide resolved
…st.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
erik-krogh
approved these changes
Mar 10, 2025
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.
The class
EnumerationRegExpis intended to capture the idea of a regexp that acts as a hardcoded list of values to check, e.g./^(foo|bar|baz)$/but with some leeway for choice, like/^(found/recogni[sz]ed)$/.However, the implementation used an
existsthat was probably meant to beforallorforex, which means it was way too loose in what it accepted. This gave rise to some invalid barrier guards, which is not caught by any existing test nor by DCA, but I have a simple tests now. This PR makes it more restrictive.Regexp-based barrier guards are primarily the responsibility of
SanitizerRegExpTest, butEnumerationRegExpgives rise toMembershipCandidatewhich gives rise to barrier guards, so we have two ways for regexp checks to become barrier guards. The ones fromEnumerationRegExpshould however be a subset of those fromSanitizerRegExpTestand previously they weren't.