Change allowBackup tests to use qlref test format

Due to some limitations of comments in XML, it is simpler to implement
the `android:allowBackup` tests using the qlref/expectations test format.
This commit is contained in:
Ed Minnix
2022-09-08 10:34:17 -04:00
parent e69a8269ad
commit 59909751ae
6 changed files with 7 additions and 20 deletions

View File

@@ -0,0 +1,2 @@
| TestExplicitlyEnabled/AndroidManifest.xml:6:5:27:19 | application | The 'android:allowBackup' attribute is enabled. |
| TestMissing/AndroidManifest.xml:6:5:27:19 | application | The 'android:allowBackup' attribute is enabled. |

View File

@@ -1,18 +0,0 @@
import java
import semmle.code.xml.AndroidManifest
import TestUtilities.InlineExpectationsTest
class AllowBackupEnabledTest extends InlineExpectationsTest {
AllowBackupEnabledTest() { this = "AllowBackupEnabledTest" }
override string getARelevantTag() { result = "hasAllowBackupEnabled" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasAllowedBackupEnabled" and
exists(AndroidApplicationXmlElement androidAppElem | androidAppElem.allowsBackup() |
androidAppElem.getAttribute("allowBackup").getLocation() = location and
element = androidAppElem.getAttribute("debuggable").toString() and
value = ""
)
}
}

View File

@@ -0,0 +1 @@
Security/CWE/CWE-312/AllowBackupAttributeEnabled.ql

View File

@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
<!-- $ hasAllowBackupEnabled --> <application
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"

View File

@@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myapplication">
<!-- $ hasAllowBackupEnabled --> <application
<application
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"

View File

@@ -0,0 +1,2 @@
// semmle-extractor-options: --javac-args -cp ${testdir}/../../../../../stubs/google-android-9.0.0
// codeql-extractor-kotlin-options: ${testdir}/../../../../../stubs/google-android-9.0.0