Skip to content

Commit 856f217

Browse files
authored
Refactor HttpStringLiteral
Materialize HTTP string candidates before computing recursive parent relations, allowing the RA plan to restrict getParent*() and the subsequent private-host antijoin to the filtered candidate set.
1 parent f7617ab commit 856f217

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@ predicate privateHostNameFlowsToExpr(Expr e) {
3838
/**
3939
* A string containing an HTTP URL not in a private domain.
4040
*/
41-
class HttpStringLiteral extends StringLiteral {
42-
HttpStringLiteral() {
41+
private class HttpStringLiteralCandidate extends StringLiteral {
42+
HttpStringLiteralCandidate() {
4343
exists(string s | this.getValue() = s |
4444
s = "http"
4545
or
4646
exists(string tail |
4747
tail = s.regexpCapture("http://(.*)", 1) and not tail instanceof PrivateHostName
4848
)
49-
) and
50-
not privateHostNameFlowsToExpr(this.getParent*())
49+
)
5150
}
5251
}
5352

53+
class HttpStringLiteral extends HttpStringLiteralCandidate {
54+
HttpStringLiteral() { not privateHostNameFlowsToExpr(this.getParent*()) }
55+
}
56+
5457
/**
5558
* Taint tracking configuration for HTTP connections.
5659
*/

0 commit comments

Comments
 (0)