Skip to content

Commit

Permalink
JS: Sharpen up EnumerationRegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerf committed Feb 28, 2025
1 parent 93b1114 commit 6fbf21a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions javascript/ql/lib/semmle/javascript/MembershipCandidates.qll
Original file line number Diff line number Diff line change
@@ -140,22 +140,17 @@ module MembershipCandidate {
EnumerationRegExp() {
this.isRootTerm() and
RegExp::isFullyAnchoredTerm(this) and
exists(RegExpTerm child | this.getAChild*() = child |
child instanceof RegExpSequence or
child instanceof RegExpCaret or
child instanceof RegExpDollar or
child instanceof RegExpConstant or
child instanceof RegExpAlt or
child instanceof RegExpGroup
) and
// exclude "length matches" that match every string
not this.getAChild*() instanceof RegExpDot
not exists(RegExpTerm child | child.getRootTerm() = this |
child instanceof RegExpDot or
child instanceof RegExpCharacterClass or
child instanceof RegExpUnicodePropertyEscape
)
}

/**
* Gets a string matched by this regular expression.
*/
string getAMember() { result = this.getAChild*().getAMatchedString() }
string getAMember() { result = any(RegExpTerm t | t.getRootTerm() = this).getAMatchedString() }
}

/**

0 comments on commit 6fbf21a

Please sign in to comment.