Skip to content

Commit

Permalink
C++: Fix join-order in 'HttpStringLiteral' charpred.
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasVP committed Dec 16, 2021
1 parent b49ca6a commit 53a1f93
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cpp/ql/src/Security/CWE/CWE-319/UseOfHttp.ql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class PrivateHostName extends string {
}
}

pragma[nomagic]
predicate privateHostNameFlowsToExpr(Expr e) {
TaintTracking::localExprTaint(any(StringLiteral p | p.getValue() instanceof PrivateHostName), e)
}

/**
* A string containing an HTTP URL not in a private domain.
*/
Expand All @@ -38,11 +43,9 @@ class HttpStringLiteral extends StringLiteral {
or
exists(string tail |
tail = s.regexpCapture("http://(.*)", 1) and not tail instanceof PrivateHostName
) and
not TaintTracking::localExprTaint(any(StringLiteral p |
p.getValue() instanceof PrivateHostName
), this.getParent*())
)
)
) and
not privateHostNameFlowsToExpr(this.getParent*())
}
}

Expand Down

0 comments on commit 53a1f93

Please sign in to comment.