Skip to content

Commit 3adc0b5

Browse files
authored
Merge pull request #7426 from MathiasVP/fix-join-order-in-http-string-literal-charpred
C++: Fix join-order in `HttpStringLiteral` charpred
2 parents 96aef9f + 53a1f93 commit 3adc0b5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class PrivateHostName extends string {
2828
}
2929
}
3030

31+
pragma[nomagic]
32+
predicate privateHostNameFlowsToExpr(Expr e) {
33+
TaintTracking::localExprTaint(any(StringLiteral p | p.getValue() instanceof PrivateHostName), e)
34+
}
35+
3136
/**
3237
* A string containing an HTTP URL not in a private domain.
3338
*/
@@ -38,11 +43,9 @@ class HttpStringLiteral extends StringLiteral {
3843
or
3944
exists(string tail |
4045
tail = s.regexpCapture("http://(.*)", 1) and not tail instanceof PrivateHostName
41-
) and
42-
not TaintTracking::localExprTaint(any(StringLiteral p |
43-
p.getValue() instanceof PrivateHostName
44-
), this.getParent*())
45-
)
46+
)
47+
) and
48+
not privateHostNameFlowsToExpr(this.getParent*())
4649
}
4750
}
4851

0 commit comments

Comments
 (0)