Skip to content

Commit 0a83ced

Browse files
committed
Unit tests for android:allowBackup query
1 parent 6485e73 commit 0a83ced

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

java/ql/test/query-tests/security/CWE-312/AllowBackupEnabledTest.expected

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class AllowBackupEnabledTest {
2+
3+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java
2+
import semmle.code.xml.AndroidManifest
3+
import TestUtilities.InlineExpectationsTest
4+
5+
class AllowBackupEnabledTest extends InlineExpectationsTest {
6+
AllowBackupEnabledTest() { this = "AllowBackupEnabledTest" }
7+
8+
override string getARelevantTag() { result = "hasAllowBackupEnabled" }
9+
10+
override predicate hasActualResult(Location location, string element, string tag, string value) {
11+
tag = "hasAllowedBackupEnabled" and
12+
exists(AndroidApplicationXmlElement androidAppElem |
13+
androidAppElem.allowsBackup() and
14+
not androidAppElem.getFile().(AndroidManifestXmlFile).isInBuildDirectory()
15+
|
16+
androidAppElem.getAttribute("allowBackup").getLocation() = location and
17+
element = androidAppElem.getAttribute("debuggable").toString() and
18+
value = ""
19+
)
20+
}
21+
}

java/ql/test/query-tests/security/CWE-312/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:versionCode="1"
55
android:versionName="0.1" >
66

7-
<application>
7+
<application android:allowBackup="true">
88
<activity android:name=".CleartextStorageAndroidDatabaseTest"></activity>
99
<activity android:name=".CleartextStorageAndroidFileSystemTest"></activity>
1010
<activity android:name=".CleartextStorageSharedPrefsTest"></activity>

0 commit comments

Comments
 (0)