Skip to content

Commit e1f3637

Browse files
authored
Merge pull request #75 from asger-semmle/server-side-url-redirect-performance
Approved by xiemaisi
2 parents b931e88 + 4dc1462 commit e1f3637

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/ServerSideUrlRedirect.qll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ module ServerSideUrlRedirect {
3636
}
3737

3838
/**
39-
* Gets a "prefix predecessor" of `nd`, that is, either a normal data flow predecessor
40-
* or the left operand of `nd` if it is a concatenation.
39+
* Gets the left operand of `nd` if it is a concatenation.
4140
*/
42-
private DataFlow::Node prefixPred(DataFlow::Node nd) {
43-
result = nd.getAPredecessor()
44-
or
41+
private DataFlow::Node getPrefixOperand(DataFlow::Node nd) {
4542
exists (Expr e | e instanceof AddExpr or e instanceof AssignAddExpr |
4643
nd = DataFlow::valueNode(e) and
4744
result = DataFlow::valueNode(e.getChildExpr(0))
@@ -53,7 +50,8 @@ module ServerSideUrlRedirect {
5350
*/
5451
private DataFlow::Node prefixCandidate(Sink sink) {
5552
result = sink or
56-
result = prefixPred(prefixCandidate(sink))
53+
result = getPrefixOperand(prefixCandidate(sink)) or
54+
result = prefixCandidate(sink).getAPredecessor()
5755
}
5856

5957
/**
@@ -62,7 +60,8 @@ module ServerSideUrlRedirect {
6260
private Expr getAPrefix(Sink sink) {
6361
exists (DataFlow::Node prefix |
6462
prefix = prefixCandidate(sink) and
65-
not exists(prefixPred(prefix)) and
63+
not exists(getPrefixOperand(prefix)) and
64+
not exists(prefix.getAPredecessor()) and
6665
result = prefix.asExpr()
6766
)
6867
}

0 commit comments

Comments
 (0)