Skip to content

Commit 9c82966

Browse files
committed
Move detection of Android app to one place
1 parent c7ad0ad commit 9c82966

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

java/ql/lib/semmle/code/java/frameworks/android/Android.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import java
66
private import semmle.code.xml.AndroidManifest
77

8+
/** Holds if this database is of an Android application. */
9+
predicate isAndroid() { exists(AndroidManifestXmlFile m) }
10+
811
/**
912
* Gets a reflexive/transitive superType
1013
*/

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import semmle.code.java.dataflow.TaintTracking
66
import semmle.code.java.frameworks.Networking
77
import semmle.code.java.security.Encryption
88
import semmle.code.java.security.HttpsUrls
9+
private import semmle.code.java.frameworks.android.Android as Android
910

1011
/** An Android Network Security Configuration XML file. */
1112
class AndroidNetworkSecurityConfigFile extends XmlFile {
@@ -19,8 +20,12 @@ class AndroidNetworkSecurityConfigFile extends XmlFile {
1920
}
2021
}
2122

22-
/** Holds if this database is of an Android application. */
23-
predicate isAndroid() { exists(AndroidManifestXmlFile m) }
23+
/**
24+
* DEPRECATED. Use `semmle.code.java.frameworks.android.Android::isAndroid` instead.
25+
*
26+
* Holds if this database is of an Android application.
27+
*/
28+
deprecated predicate isAndroid() { Android::isAndroid() }
2429

2530
/** Holds if the given domain name is trusted by the Network Security Configuration XML file. */
2631
private predicate trustedDomainViaXml(string domainName) {
@@ -122,7 +127,7 @@ private module UntrustedUrlFlow = TaintTracking::Global<UntrustedUrlConfig>;
122127

123128
/** Holds if `node` is a network communication call for which certificate pinning is not implemented. */
124129
predicate missingPinning(MissingPinningSink node, string domain) {
125-
isAndroid() and
130+
Android::isAndroid() and
126131
exists(DataFlow::Node src | UntrustedUrlFlow::flow(src, node) |
127132
if trustedDomain(_) then domain = getDomain(src.asExpr()) else domain = ""
128133
)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@
66
import java
77
import semmle.code.java.dataflow.DataFlow
88
import semmle.code.java.security.CleartextStorageQuery
9-
import semmle.code.xml.AndroidManifest
109
private import semmle.code.java.dataflow.ExternalFlow
1110
private import semmle.code.java.dataflow.FlowSinks
1211
private import semmle.code.java.dataflow.FlowSources
12+
private import semmle.code.java.frameworks.android.Android
1313

1414
private class AndroidFilesystemCleartextStorageSink extends CleartextStorageSink {
1515
AndroidFilesystemCleartextStorageSink() {
1616
filesystemInput(_, this.asExpr()) and
17-
// Make sure we are in an Android application.
18-
exists(AndroidManifestXmlFile manifest)
17+
isAndroid()
1918
}
2019
}
2120

0 commit comments

Comments
 (0)