Skip to content

Commit 1746638

Browse files
authored
Merge pull request #15351 from erik-krogh/zero-to-question
JS/PY/JAVA/RB: mark the range [0-?] as good in the overly-large-range query
2 parents 8610c95 + 1a8a70d commit 1746638

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

javascript/ql/test/query-tests/Security/CWE-020/SuspiciousRegexpRange/tst.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ var overlapsWithClass1 = /[0-9\d]/; // NOT OK
2727
var overlapsWithClass2 = /[\w,.-?:*+]/; // NOT OK
2828

2929
var tst2 = /^([-]|[-])+$/; // OK
30-
var tst3 = /[0-9-]/; // OK
30+
var tst3 = /[0-9-]/; // OK
31+
32+
var question = /[0-?]/; // OK. matches one of: 0123456789:;<=>?

shared/regex/codeql/regex/OverlyLargeRangeQuery.qll

+3
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ module Make<RegexTreeViewSig TreeImpl> {
129129
or
130130
// starting from the zero byte is a good indication that it's purposely matching a large range.
131131
result.isRange(0.toUnicode(), _)
132+
or
133+
// the range 0123456789:;<=>? is intentional
134+
result.isRange("0", "?")
132135
}
133136

134137
/** Gets a char between (and including) `low` and `high`. */

0 commit comments

Comments
 (0)