Skip to content

Commit 807588a

Browse files
committed
Refactor AndroidCertificatePinningQuery
1 parent 768102e commit 807588a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

java/ql/lib/semmle/code/java/security/AndroidCertificatePinningQuery.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,29 @@ private class MissingPinningSink extends DataFlow::Node {
106106
}
107107

108108
/** Configuration for finding uses of non trusted URLs. */
109-
private class UntrustedUrlConfig extends TaintTracking::Configuration {
110-
UntrustedUrlConfig() { this = "UntrustedUrlConfig" }
111-
112-
override predicate isSource(DataFlow::Node node) {
109+
private module UntrustedUrlConfig implements DataFlow::ConfigSig {
110+
predicate isSource(DataFlow::Node node) {
113111
trustedDomain(_) and
114112
exists(string lit | lit = node.asExpr().(CompileTimeConstantExpr).getStringValue() |
115113
lit.matches("%://%") and // it's a URL
116114
not exists(string dom | trustedDomain(dom) and lit.matches("%" + dom + "%"))
117115
)
118116
}
119117

120-
override predicate isSink(DataFlow::Node node) { node instanceof MissingPinningSink }
118+
predicate isSink(DataFlow::Node node) { node instanceof MissingPinningSink }
121119
}
122120

121+
private module UntrustedUrlFlow = TaintTracking::Make<UntrustedUrlConfig>;
122+
123123
/** Holds if `node` is a network communication call for which certificate pinning is not implemented. */
124124
predicate missingPinning(DataFlow::Node node, string domain) {
125125
isAndroid() and
126126
node instanceof MissingPinningSink and
127127
(
128128
not trustedDomain(_) and domain = ""
129129
or
130-
exists(UntrustedUrlConfig conf, DataFlow::Node src |
131-
conf.hasFlow(src, node) and
130+
exists(DataFlow::Node src |
131+
UntrustedUrlFlow::hasFlow(src, node) and
132132
domain = getDomain(src.asExpr())
133133
)
134134
)

0 commit comments

Comments
 (0)