Skip to content

Commit 2201974

Browse files
committed
Jave: Use force local to make parsing local after global regex finding.
1 parent 7670a2b commit 2201974

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

java/ql/lib/semmle/code/java/regex/RegexFlowConfigs.qll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,22 @@ private module RegexFlowConfig implements DataFlow::ConfigSig {
163163

164164
private module RegexFlow = DataFlow::Global<RegexFlowConfig>;
165165

166+
private predicate usedAsRegexImpl(StringLiteral regex, string mode, boolean match_full_string) {
167+
RegexFlow::flow(DataFlow::exprNode(regex), _) and
168+
mode = "None" and // TODO: proper mode detection
169+
(if matchesFullString(regex) then match_full_string = true else match_full_string = false)
170+
}
171+
166172
/**
167173
* Holds if `regex` is used as a regex, with the mode `mode` (if known).
168174
* If regex mode is not known, `mode` will be `"None"`.
169175
*
170176
* As an optimisation, only regexes containing an infinite repitition quatifier (`+`, `*`, or `{x,}`)
171177
* and therefore may be relevant for ReDoS queries are considered.
172178
*/
173-
predicate usedAsRegex(StringLiteral regex, string mode, boolean match_full_string) {
174-
RegexFlow::flow(DataFlow::exprNode(regex), _) and
175-
mode = "None" and // TODO: proper mode detection
176-
(if matchesFullString(regex) then match_full_string = true else match_full_string = false)
177-
}
179+
overlay[local]
180+
predicate usedAsRegex(StringLiteral regex, string mode, boolean match_full_string) =
181+
forceLocal(usedAsRegexImpl/3)(regex, mode, match_full_string)
178182

179183
/**
180184
* Holds if `regex` is used as a regular expression that is matched against a full string,

0 commit comments

Comments
 (0)