added predicates in the AndroidManifest library and adjusted tests

This commit is contained in:
Jami Cogswell
2022-08-03 08:58:16 -04:00
parent 229324fde0
commit 6e10fcf519
8 changed files with 94 additions and 13 deletions

View File

@@ -2,20 +2,19 @@ import java
import semmle.code.xml.AndroidManifest
import TestUtilities.InlineExpectationsTest
class DebuggableAttributeTrueTest extends InlineExpectationsTest {
DebuggableAttributeTrueTest() { this = "DebuggableAttributeEnabledTest" }
class DebuggableAttributeEnabledTest extends InlineExpectationsTest {
DebuggableAttributeEnabledTest() { this = "DebuggableAttributeEnabledTest" }
override string getARelevantTag() { result = "hasDebuggableAttributeEnabled" }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasDebuggableAttributeEnabled" and
exists(AndroidXmlAttribute androidXmlAttr |
androidXmlAttr.getName() = "debuggable" and
androidXmlAttr.getValue() = "true" and
not androidXmlAttr.getLocation().getFile().getRelativePath().matches("%build%")
exists(AndroidApplicationXmlElement androidAppElem |
androidAppElem.isDebuggable() and
not androidAppElem.getFile().isInBuildDirectory()
|
androidXmlAttr.getLocation() = location and
element = androidXmlAttr.toString() and
androidAppElem.getAttribute("debuggable").getLocation() = location and
element = androidAppElem.getAttribute("debuggable").toString() and
value = ""
)
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.happybirthday">
<!-- $ hasDebuggableAttributeEnabled --> <application
android:debuggable="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.happybirthday">
<!-- Safe: manifest file located in build directory --> <application
android:debuggable="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>