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

Skip to content

Commit 58c31f0

Browse files
committed
prune more regexps initially in the ReDoS query
1 parent c4153a6 commit 58c31f0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

javascript/ql/src/Performance/ReDoS.ql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ class RegExpRoot extends RegExpTerm {
103103
*/
104104
predicate isRelevant() {
105105
// there is at least one repetition
106-
exists(RegExpRepetition rep | getRoot(rep) = this) and
106+
exists(RegExpRepetition rep | getRoot(rep) = this |
107+
// that could possibly match the same thing in multiple ways.
108+
exists(RegExpTerm child |
109+
child instanceof RegExpAlt or
110+
child instanceof RegExpQuantifier
111+
|
112+
child.getParent+() = rep
113+
)
114+
) and
107115
// there are no lookbehinds
108116
not exists(RegExpLookbehind lbh | getRoot(lbh) = this) and
109117
// is actually used as a RegExp

0 commit comments

Comments
 (0)