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

Skip to content

Commit d1706e8

Browse files
committed
reuse InfiniteRepetitionQuantifier from SuperLiniearBacktracking
1 parent 3954037 commit d1706e8

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

javascript/ql/src/Performance/ReDoS.ql

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
import javascript
16+
import semmle.javascript.security.performance.SuperlinearBackTracking
1617

1718
/*
1819
* This query implements the analysis described in the following two papers:
@@ -104,7 +105,7 @@ class RegExpRoot extends RegExpTerm {
104105
*/
105106
predicate isRelevant() {
106107
// there is at least one repetition
107-
exists(RegExpRepetition rep | getRoot(rep) = this |
108+
exists(InfiniteRepetitionQuantifier rep | getRoot(rep) = this |
108109
// that could possibly match the same thing in multiple ways.
109110
exists(RegExpTerm child |
110111
child instanceof RegExpAlt or
@@ -120,17 +121,6 @@ class RegExpRoot extends RegExpTerm {
120121
}
121122
}
122123

123-
/**
124-
* A term that matches repetitions of a given pattern, that is, `E*`, `E+`, or `E{n,m}`.
125-
*/
126-
class RegExpRepetition extends RegExpParent {
127-
RegExpRepetition() {
128-
this instanceof RegExpStar or
129-
this instanceof RegExpPlus or
130-
this instanceof RegExpRange
131-
}
132-
}
133-
134124
/**
135125
* A constant in a regular expression that represents valid Unicode character(s).
136126
*/

javascript/ql/src/semmle/javascript/security/performance/SuperlinearBackTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import javascript
88
/**
99
* A regular expression term that permits unlimited repetitions.
1010
*/
11-
private class InfiniteRepetitionQuantifier extends RegExpQuantifier {
11+
class InfiniteRepetitionQuantifier extends RegExpQuantifier {
1212
InfiniteRepetitionQuantifier() {
1313
this instanceof RegExpPlus
1414
or

0 commit comments

Comments
 (0)