mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Add the domain used to the alert message
This commit is contained in:
@@ -128,12 +128,21 @@ private class UntrustedUrlConfig extends TaintTracking::Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Holds if `node` is a network communication call for which certificate pinning is not implemented. */
|
/** Holds if `node` is a network communication call for which certificate pinning is not implemented. */
|
||||||
predicate missingPinning(DataFlow::Node node) {
|
predicate missingPinning(DataFlow::Node node, string domain) {
|
||||||
isAndroid() and
|
isAndroid() and
|
||||||
node instanceof MissingPinningSink and
|
node instanceof MissingPinningSink and
|
||||||
(
|
(
|
||||||
not exists(string s | trustedDomain(s))
|
not exists(string s | trustedDomain(s)) and
|
||||||
|
domain = ""
|
||||||
or
|
or
|
||||||
exists(UntrustedUrlConfig conf | conf.hasFlow(_, node))
|
exists(UntrustedUrlConfig conf, DataFlow::Node src |
|
||||||
|
conf.hasFlow(src, node) and
|
||||||
|
domain = getDomain(src.asExpr())
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Gets the domain name from the given string literal */
|
||||||
|
private string getDomain(CompileTimeConstantExpr expr) {
|
||||||
|
result = expr.getStringValue().regexpCapture("(https?://)?([^/]*)/?", 2)
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@
|
|||||||
import java
|
import java
|
||||||
import semmle.code.java.security.AndroidCertificatePinningQuery
|
import semmle.code.java.security.AndroidCertificatePinningQuery
|
||||||
|
|
||||||
from DataFlow::Node node, string msg
|
from DataFlow::Node node, string domain, string msg
|
||||||
where
|
where
|
||||||
missingPinning(node) and
|
missingPinning(node, domain) and
|
||||||
if exists(string x | trustedDomain(x))
|
if domain = ""
|
||||||
then msg = "(untrusted domain)"
|
then msg = "(no explicitly trusted domains)"
|
||||||
else msg = "(no trusted domains)"
|
else msg = "(" + domain + " is not trusted by a pin)"
|
||||||
select node, "This network call does not implement certificate pinning. " + msg
|
select node, "This network call does not implement certificate pinning. " + msg
|
||||||
|
|||||||
Reference in New Issue
Block a user