Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a5268a

Browse files
Sync shared library changes across languages.
1 parent bb56264 commit 0a5268a

6 files changed

Lines changed: 39 additions & 6 deletions

File tree

javascript/ql/lib/semmle/javascript/security/performance/ReDoSUtil.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,15 @@ State after(RegExpTerm t) {
610610
or
611611
exists(RegExpGroup grp | t = grp.getAChild() | result = after(grp))
612612
or
613-
exists(EffectivelyStar star | t = star.getAChild() | result = before(star))
613+
exists(EffectivelyStar star | t = star.getAChild() |
614+
not isPossessive(star) and
615+
result = before(star)
616+
)
614617
or
615618
exists(EffectivelyPlus plus | t = plus.getAChild() |
616-
result = before(plus) or
619+
not isPossessive(plus) and
620+
result = before(plus)
621+
or
617622
result = after(plus)
618623
)
619624
or

javascript/ql/lib/semmle/javascript/security/performance/ReDoSUtilSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ predicate isEscapeClass(RegExpTerm term, string clazz) {
1212
exists(RegExpCharacterClassEscape escape | term = escape | escape.getValue() = clazz)
1313
}
1414

15+
/**
16+
* Holds if `term` is a possessive quantifier.
17+
* As javascript's regexes do not support possessive quantifiers, this never holds, but is used by the shared library.
18+
*/
19+
predicate isPossessive(RegExpQuantifier term) { none() }
20+
1521
/**
1622
* Holds if the regular expression should not be considered.
1723
*

python/ql/lib/semmle/python/security/performance/ReDoSUtil.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,15 @@ State after(RegExpTerm t) {
610610
or
611611
exists(RegExpGroup grp | t = grp.getAChild() | result = after(grp))
612612
or
613-
exists(EffectivelyStar star | t = star.getAChild() | result = before(star))
613+
exists(EffectivelyStar star | t = star.getAChild() |
614+
not isPossessive(star) and
615+
result = before(star)
616+
)
614617
or
615618
exists(EffectivelyPlus plus | t = plus.getAChild() |
616-
result = before(plus) or
619+
not isPossessive(plus) and
620+
result = before(plus)
621+
or
617622
result = after(plus)
618623
)
619624
or

python/ql/lib/semmle/python/security/performance/ReDoSUtilSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ predicate isEscapeClass(RegExpTerm term, string clazz) {
1313
exists(RegExpCharacterClassEscape escape | term = escape | escape.getValue() = clazz)
1414
}
1515

16+
/**
17+
* Holds if `term` is a possessive quantifier.
18+
* As python's regexes do not support possessive quantifiers, this never holds, but is used by the shared library.
19+
*/
20+
predicate isPossessive(RegExpQuantifier term) { none() }
21+
1622
/**
1723
* Holds if the regular expression should not be considered.
1824
*

ruby/ql/lib/codeql/ruby/security/performance/ReDoSUtil.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,15 @@ State after(RegExpTerm t) {
610610
or
611611
exists(RegExpGroup grp | t = grp.getAChild() | result = after(grp))
612612
or
613-
exists(EffectivelyStar star | t = star.getAChild() | result = before(star))
613+
exists(EffectivelyStar star | t = star.getAChild() |
614+
not isPossessive(star) and
615+
result = before(star)
616+
)
614617
or
615618
exists(EffectivelyPlus plus | t = plus.getAChild() |
616-
result = before(plus) or
619+
not isPossessive(plus) and
620+
result = before(plus)
621+
or
617622
result = after(plus)
618623
)
619624
or

ruby/ql/lib/codeql/ruby/security/performance/ReDoSUtilSpecific.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ predicate isExcluded(RegExpParent parent) {
3333
parent.(RegExpTerm).getRegExp().(AST::RegExpLiteral).hasFreeSpacingFlag() // exclude free-spacing mode regexes
3434
}
3535

36+
/**
37+
* Holds if `term` is a possessive quantifier.
38+
* Not currently implemented, but is used by the shared library.
39+
*/
40+
predicate isPossessive(RegExpQuantifier term) { none() }
41+
3642
/**
3743
* A module containing predicates for determining which flags a regular expression have.
3844
*/

0 commit comments

Comments
 (0)