Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit ed95cde

Browse files
Max SchaeferGitHub Enterprise
authored andcommitted
Merge pull request #183 from sauyon/regexp-improvements
OpenUrlRedirect: Use the regexp library for RegexpCheck
2 parents 899ae10 + 3b39f5c commit ed95cde

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ql/src/semmle/go/security/OpenUrlRedirectCustomizations.qll

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,16 @@ module OpenUrlRedirect {
9393
* This is overapproximate: we do not attempt to reason about the correctness of the regexp.
9494
*/
9595
class RegexpCheck extends BarrierGuard {
96+
RegexpMatchFunction matchfn;
9697
DataFlow::CallNode call;
9798

9899
RegexpCheck() {
99-
exists(string fn | fn.matches("Match%") |
100-
call.getTarget().hasQualifiedName("regexp", fn) and
101-
this = DataFlow::extractTupleElement(call, 0).getASuccessor*()
102-
or
103-
call.getTarget().(Method).hasQualifiedName("regexp", "Regexp", fn) and
104-
this = call.getASuccessor*()
105-
)
100+
matchfn.getACall() = call and
101+
this = matchfn.getResult().getNode(call).getASuccessor*()
106102
}
107103

108104
override predicate checks(Expr e, boolean branch) {
109-
e = call.getAnArgument().asExpr() and
105+
e = matchfn.getValue().getNode(call).asExpr() and
110106
(branch = false or branch = true)
111107
}
112108
}

0 commit comments

Comments
 (0)