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

Skip to content

Commit 804aaf3

Browse files
committed
support inverted char class and dot
1 parent 64d680e commit 804aaf3

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

javascript/ql/src/Performance/ReDoS.ql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,11 @@ string intersect(InputSymbol c, InputSymbol d) {
454454
)
455455
or
456456
exists(RegExpCharacterClass cc | c = InvertedCharClass(cc) and result = chooseFromInverted(cc) |
457-
// TODO: Not done here - later commits will add more
458-
//d = Dot() and
459-
//not (result = "\n" or result = "\r")
460-
//or
461457
d = InvertedCharClass(cc)
462458
or
459+
d = Dot() and
460+
not (result = "\n" or result = "\r")
461+
or
463462
d = Any()
464463
)
465464
or

javascript/ql/test/query-tests/Performance/ReDoS/ReDoS.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@
5555
| tst.js:89:25:89:32 | (a\|aa?)* | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'a'. |
5656
| tst.js:95:15:95:25 | ([^]\|[^a])* | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'b'. |
5757
| tst.js:98:15:98:20 | [^"']+ | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of '('. |
58+
| tst.js:101:15:101:23 | (.\|[^a])* | This part of the regular expression may cause exponential backtracking on strings containing many repetitions of 'b'. |

javascript/ql/test/query-tests/Performance/ReDoS/tst.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ var bad18 = /(([^]|[^a])*)"/;
9696

9797
// NOT GOOD
9898
var bad19 = /([^"']+)*/g;
99+
100+
// NOT GOOD
101+
var bad20 = /((.|[^a])*)"/;

0 commit comments

Comments
 (0)