File tree Expand file tree Collapse file tree
javascript/ql/src/Security/CWE-020 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,16 +15,19 @@ import semmle.javascript.CharacterEscapes
1515import HostnameRegexpShared
1616
1717/**
18- * Holds if `term` occurs inside a quantifier or alternative, and thus
19- * can not be expected to correspond to a unique match.
18+ * Holds if `term` occurs inside a quantifier or alternative (and thus
19+ * can not be expected to correspond to a unique match), or as part of
20+ * a lookaround assertion (which are rarely used for capture groups).
2021 */
21- predicate isInsideChoice ( RegExpTerm term ) {
22+ predicate isInsideChoiceOrSubPattern ( RegExpTerm term ) {
2223 exists ( RegExpParent parent | parent = term .getParent ( ) |
2324 parent instanceof RegExpAlt
2425 or
2526 parent instanceof RegExpQuantifier
2627 or
27- isInsideChoice ( parent )
28+ parent instanceof RegExpSubPattern
29+ or
30+ isInsideChoiceOrSubPattern ( parent )
2831 )
2932}
3033
@@ -33,7 +36,7 @@ predicate isInsideChoice(RegExpTerm term) {
3336 */
3437predicate isLikelyCaptureGroup ( RegExpGroup group ) {
3538 group .isCapture ( ) and
36- not isInsideChoice ( group )
39+ not isInsideChoiceOrSubPattern ( group )
3740}
3841
3942/**
You can’t perform that action at this time.
0 commit comments