Skip to content

Commit 29e34ac

Browse files
committed
ContentProvider Incomplete Permissions Test Cases
1 parent f2bda15 commit 29e34ac

File tree

7 files changed

+153
-0
lines changed

7 files changed

+153
-0
lines changed

java/ql/test/query-tests/security/CWE-276/android/incomplete_provider_permissions/ContentProviderIncompletePermissionsTest.expected

Whitespace-only changes.
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 ContentProviderIncompletePermissionsTest extends InlineExpectationsTest {
6+
ContentProviderIncompletePermissionsTest() { this = "ContentProviderIncompletePermissionsTest" }
7+
8+
override string getARelevantTag() { result = "hasIncompletePermissions" }
9+
10+
override predicate hasActualResult(Location location, string element, string tag, string value) {
11+
tag = "hasIncompletePermissions" and
12+
exists(AndroidProviderXmlElement provider |
13+
provider.getLocation() = location and
14+
provider.toString() = element and
15+
value = ""
16+
|
17+
not provider.getFile().(AndroidManifestXmlFile).isInBuildDirectory() and
18+
provider.hasIncompletePermissions()
19+
)
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.myapplication">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
15+
android:theme="@style/Theme.MyApplication"
16+
tools:targetApi="31">
17+
<!-- Safe: provider has full permissions set --> <provider
18+
android:name=".MyContentProvider2"
19+
android:authorities="morestuff"
20+
android:enabled="true"
21+
android:exported="true"
22+
android:permission="android.permission.MANAGE_DOCUMENTS"></provider>
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.myapplication">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
15+
android:theme="@style/Theme.MyApplication"
16+
tools:targetApi="31">
17+
18+
<!-- $ hasIncompletePermissions --><provider
19+
android:name=".MyContentProvider"
20+
android:authorities="table"
21+
android:enabled="true"
22+
android:exported="true"
23+
android:readPermission="android.permission.MANAGE_DOCUMENTS"></provider>
24+
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.myapplication">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
15+
android:theme="@style/Theme.MyApplication"
16+
tools:targetApi="31">
17+
18+
<!-- Safe: has both read and write permission --><provider
19+
android:name=".MyContentProvider"
20+
android:authorities="table"
21+
android:enabled="true"
22+
android:exported="true"
23+
android:readPermission="android.permission.MANAGE_DOCUMENTS"
24+
android:writePermission="android.permission.MANAGE_DOCUMENTS"></provider>
25+
26+
</application>
27+
28+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.myapplication">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
15+
android:theme="@style/Theme.MyApplication"
16+
tools:targetApi="31">
17+
18+
<!-- $ hasIncompletePermissions --><provider
19+
android:name=".MyContentProvider"
20+
android:authorities="table"
21+
android:enabled="true"
22+
android:exported="true"
23+
android:writePermission="android.permission.MANAGE_DOCUMENTS"></provider>
24+
25+
</application>
26+
27+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.example.myapplication">
5+
6+
<application
7+
android:allowBackup="false"
8+
android:dataExtractionRules="@xml/data_extraction_rules"
9+
android:fullBackupContent="@xml/backup_rules"
10+
android:icon="@mipmap/ic_launcher"
11+
android:label="@string/app_name"
12+
android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true"
14+
15+
android:theme="@style/Theme.MyApplication"
16+
tools:targetApi="31">
17+
<!-- Safe: files in the build directory are ignored --> <provider
18+
android:name=".MyContentProvider2"
19+
android:authorities="morestuff"
20+
android:enabled="true"
21+
android:exported="true"
22+
android:writePermission="android.permission.MANAGE_DOCUMENTS"></provider>
23+
</application>
24+
25+
</manifest>

0 commit comments

Comments
 (0)