added unit tests

This commit is contained in:
Jami Cogswell
2022-08-10 17:07:58 -04:00
parent 58d3d89b2e
commit b88d545c49
4 changed files with 226 additions and 62 deletions

View File

@@ -12,9 +12,71 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31"> <!-- test -->
<!-- Safe: category LAUNCHER --> <activity
android:name=".MainActivity">
tools:targetApi="31">
<!-- $ hasImplicitExport --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- $ hasImplicitExport --> <receiver
android:name=".CheckInstall">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
</intent-filter>
</receiver>
<!-- $ hasImplicitExport --> <service
android:name=".backgroundService">
<intent-filter>
<action android:name="android.intent.action.START_BACKGROUND"/>
</intent-filter>
</service>
<!-- $ hasImplicitExport --> <provider
android:name=".MyCloudProvider">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: 'android:exported' explicitly set --> <activity
android:name=".Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: no intent filter --> <activity
android:name=".Activity">
</activity>
<!-- Safe: has 'permission' attribute --> <activity
android:name=".Activity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: 'provider' with read and write permissions set --> <provider
android:name=".MyCloudProvider"
android:readPermission=".TestRead"
android:writePermission=".TestWrite">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: has category 'android.intent.category.LAUNCHER' --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -22,32 +84,6 @@
</intent-filter>
</activity>
<!-- $ hasImplicitExport --> <activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<!-- Safe: 'android:exported' explicitly set --> <activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<!-- Safe: no intent filter --> <activity
android:name=".MainActivity">
</activity>
<!-- Safe: has 'permission' attribute --> <activity
android:name=".MainActivity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -1,5 +1,5 @@
import java
import semmle.code.xml.AndroidManifest
import semmle.code.java.security.ImplicitlyExportedAndroidComponent
import TestUtilities.InlineExpectationsTest
class ImplicitlyExportedAndroidComponentTest extends InlineExpectationsTest {
@@ -9,9 +9,11 @@ class ImplicitlyExportedAndroidComponentTest extends InlineExpectationsTest {
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasImplicitExport" and
exists(AndroidComponentXmlElement compElement | compElement.isImplicitlyExported() |
compElement.getLocation() = location and
element = compElement.toString() and
exists(ImplicitlyExportedAndroidComponent impExpAndroidComp |
impExpAndroidComp.isImplicitlyExported()
|
impExpAndroidComp.getLocation() = location and
element = impExpAndroidComp.toString() and
value = ""
)
}

View File

@@ -0,0 +1,90 @@
<?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">
<application
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"
android:permission=".Test">
<!-- Safe: 'application' element has 'permission' attribute --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: 'application' element has 'permission' attribute --> <receiver
android:name=".CheckInstall">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
</intent-filter>
</receiver>
<!-- Safe: 'application' element has 'permission' attribute --> <service
android:name=".backgroundService">
<intent-filter>
<action android:name="android.intent.action.START_BACKGROUND"/>
</intent-filter>
</service>
<!-- Safe: 'application' element has 'permission' attribute --> <provider
android:name=".MyCloudProvider">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: 'android:exported' explicitly set --> <activity
android:name=".Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: no intent filter --> <activity
android:name=".Activity">
</activity>
<!-- Safe: has 'permission' attribute --> <activity
android:name=".Activity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: 'provider' with read and write permissions set --> <provider
android:name=".MyCloudProvider"
android:readPermission=".TestRead"
android:writePermission=".TestWrite">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: has category 'android.intent.category.LAUNCHER' --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -12,9 +12,71 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31"> <!-- test -->
<!-- Safe: category LAUNCHER --> <activity
android:name=".MainActivity">
tools:targetApi="31">
<!-- Safe: in build directory --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: in build directory --> <receiver
android:name=".CheckInstall">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
</intent-filter>
</receiver>
<!-- Safe: in build directory --> <service
android:name=".backgroundService">
<intent-filter>
<action android:name="android.intent.action.START_BACKGROUND"/>
</intent-filter>
</service>
<!-- Safe: in build directory --> <provider
android:name=".MyCloudProvider">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: 'android:exported' explicitly set --> <activity
android:name=".Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: no intent filter --> <activity
android:name=".Activity">
</activity>
<!-- Safe: has 'permission' attribute --> <activity
android:name=".Activity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<!-- Safe: 'provider' with read and write permissions set --> <provider
android:name=".MyCloudProvider"
android:readPermission=".TestRead"
android:writePermission=".TestWrite">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>
</intent-filter>
</service>
<!-- Safe: has category 'android.intent.category.LAUNCHER' --> <activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -22,32 +84,6 @@
</intent-filter>
</activity>
<!-- Safe: in build directory --> <activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<!-- Safe: 'android:exported' explicitly set --> <activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<!-- Safe: no intent filter --> <activity
android:name=".MainActivity">
</activity>
<!-- Safe: has 'permission' attribute --> <activity
android:name=".MainActivity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>