@@ -10,7 +10,7 @@ private import RegexFlowModels
10
10
private import semmle.code.java.security.SecurityTests
11
11
12
12
private class ExploitableStringLiteral extends StringLiteral {
13
- ExploitableStringLiteral ( ) { this .getValue ( ) .matches ( [ "%+%" , "%*%" ] ) }
13
+ ExploitableStringLiteral ( ) { this .getValue ( ) .matches ( [ "%+%" , "%*%" , "%{%}%" ] ) }
14
14
}
15
15
16
16
private class RegexCompileFlowConf extends DataFlow2:: Configuration {
@@ -32,6 +32,9 @@ private class RegexCompileFlowConf extends DataFlow2::Configuration {
32
32
/**
33
33
* Holds if `s` is used as a regex, with the mode `mode` (if known).
34
34
* If regex mode is not known, `mode` will be `"None"`.
35
+ *
36
+ * As an optimisation, only regexes containing an infinite repitition quatifier (`+`, `*`, or `{x,}`)
37
+ * and therefore may be relevant for ReDoS queries are considered.
35
38
*/
36
39
predicate usedAsRegex ( StringLiteral s , string mode , boolean match_full_string ) {
37
40
exists ( DataFlow:: Node sink |
@@ -224,6 +227,9 @@ private class RegexMatchFlowConf extends DataFlow2::Configuration {
224
227
225
228
/**
226
229
* Holds if the string literal `regex` is a regular expression that is matched against the expression `str`.
230
+ *
231
+ * As an optimisation, only regexes containing an infinite repitition quatifier (`+`, `*`, or `{x,}`)
232
+ * and therefore may be relevant for ReDoS queries are considered.
227
233
*/
228
234
predicate regexMatchedAgainst ( StringLiteral regex , Expr str ) {
229
235
exists (
0 commit comments