diff --git a/java/ql/lib/semmle/code/java/frameworks/Regex.qll b/java/ql/lib/semmle/code/java/frameworks/Regex.qll index e1a89e3239d..28b7dd6a31a 100644 --- a/java/ql/lib/semmle/code/java/frameworks/Regex.qll +++ b/java/ql/lib/semmle/code/java/frameworks/Regex.qll @@ -96,10 +96,20 @@ class PatternMatchesCall extends MethodCall, RegexExecutionExpr::Range { class MatcherMatchesCall extends MethodCall, RegexExecutionExpr::Range { MatcherMatchesCall() { this.getMethod() instanceof MatcherMatchesMethod } + /** + * Get the call to `java.util.regex.Pattern.matcher` which returned the + * qualifier of this call. This is needed to determine the string being + * matched. + */ PatternMatcherCall getPatternMatcherCall() { DataFlow::localExprFlow(result, this.getQualifier()) } + /** + * Get the call to `java.util.regex.Pattern.compile` which returned the + * `Pattern` used by this matcher. This is needed to determine the regular + * expression being used. + */ PatternCompileCall getPatternCompileCall() { DataFlow::localExprFlow(result, this.getPatternMatcherCall()) }