Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JS: Sharpen up EnumerationRegExp #18892

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

asgerf
Copy link
Contributor

@asgerf asgerf commented Feb 28, 2025

The class EnumerationRegExp is 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 exists that was probably meant to be forall or forex, 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, but EnumerationRegExp gives rise to MembershipCandidate which gives rise to barrier guards, so we have two ways for regexp checks to become barrier guards. The ones from EnumerationRegExp should however be a subset of those from SanitizerRegExpTest and previously they weren't.

@github-actions github-actions bot added the JS label Feb 28, 2025
@asgerf asgerf force-pushed the js/membership-regexp-test branch from 6fbf21a to c8a89c4 Compare February 28, 2025 13:04
@asgerf asgerf marked this pull request as ready for review February 28, 2025 13:16
@Copilot Copilot bot review requested due to automatic review settings February 28, 2025 13:16
@asgerf asgerf requested a review from a team as a code owner February 28, 2025 13:16
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

…st.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant