Skip to content

Commit 01900d7

Browse files
committed
remove false positive due to "\n" not being in the relevant relation
1 parent 401e516 commit 01900d7

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ private module SuffixConstruction {
905905
exists(ascii(result))
906906
or
907907
exists(InputSymbol s | belongsTo(s, root) | result = intersect(s, _))
908+
or
909+
// The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
910+
// The three chars must be kept in sync with `hasSimpleRejectEdge`.
911+
result = ["|", "\n", "Z"]
908912
}
909913

910914
/**
@@ -923,7 +927,7 @@ private module SuffixConstruction {
923927
* This predicate is used as a cheap pre-processing to speed up `hasRejectEdge`.
924928
*/
925929
private predicate hasSimpleRejectEdge(State s) {
926-
// The three chars were chosen arbitrarily.
930+
// The three chars were chosen arbitrarily. The three chars must be kept in sync with `relevant`.
927931
exists(string char | char = ["|", "\n", "Z"] | not deltaClosedChar(s, char, _))
928932
}
929933

javascript/ql/test/query-tests/Performance/ReDoS/polynomial-redos.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,6 @@ app.use(function(req, res) {
123123
result += replaced;
124124
result = result.replace(/^\s+|\s+$/g, ''); // NOT OK
125125
})();
126+
127+
tainted.match(/(https?:\/\/[^\s]+)/gm); // OK
126128
});

0 commit comments

Comments
 (0)