Merge pull request #183 from sauyon/regexp-improvements

OpenUrlRedirect: Use the regexp library for RegexpCheck
This commit is contained in:
Max Schaefer
2019-11-13 09:20:19 +00:00
committed by GitHub Enterprise

View File

@@ -93,20 +93,16 @@ module OpenUrlRedirect {
* This is overapproximate: we do not attempt to reason about the correctness of the regexp.
*/
class RegexpCheck extends BarrierGuard {
RegexpMatchFunction matchfn;
DataFlow::CallNode call;
RegexpCheck() {
exists(string fn | fn.matches("Match%") |
call.getTarget().hasQualifiedName("regexp", fn) and
this = DataFlow::extractTupleElement(call, 0).getASuccessor*()
or
call.getTarget().(Method).hasQualifiedName("regexp", "Regexp", fn) and
this = call.getASuccessor*()
)
matchfn.getACall() = call and
this = matchfn.getResult().getNode(call).getASuccessor*()
}
override predicate checks(Expr e, boolean branch) {
e = call.getAnArgument().asExpr() and
e = matchfn.getValue().getNode(call).asExpr() and
(branch = false or branch = true)
}
}