Skip to content

Commit 3f298f3

Browse files
committed
Add basic tests for Android intents as flow sources
1 parent 54c1480 commit 3f298f3

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:versionCode="1"
5+
android:versionName="1.0"
6+
package="com.example.myapp">
7+
8+
<!-- Beware that these values are overridden by the build.gradle file -->
9+
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="26" />
10+
11+
<application
12+
android:allowBackup="true"
13+
android:icon="@mipmap/ic_launcher"
14+
android:roundIcon="@mipmap/ic_launcher_round"
15+
android:label="@string/app_name"
16+
android:supportsRtl="true"
17+
android:theme="@style/AppTheme">
18+
19+
<!-- This name is resolved to com.example.myapp.MainActivity
20+
based upon the package attribute -->
21+
<activity android:name=".IntentSources">
22+
<intent-filter>
23+
<action android:name="android.intent.action.MAIN" />
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
28+
<activity
29+
android:name=".DisplayMessageActivity"
30+
android:parentActivityName=".MainActivity" />
31+
</application>
32+
</manifest>
33+
34+
<!--
35+
/*
36+
* This file is licensed under the Apache License, Version 2.0
37+
* (the "License"); you may not use this file except in compliance with
38+
* the License. You may obtain a copy of the License at
39+
*
40+
* http://www.apache.org/licenses/LICENSE-2.0
41+
*
42+
* Unless required by applicable law or agreed to in writing, software
43+
* distributed under the License is distributed on an "AS IS" BASIS,
44+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45+
* See the License for the specific language governing permissions and
46+
* limitations under the License.
47+
*/
48+
-->
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE/CWE-078/ExecTainted.ql
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.example.myapp;
2+
3+
import android.app.Activity;
4+
5+
public class IntentSources extends Activity {
6+
7+
public void test() {
8+
9+
String trouble = this.getIntent().getStringExtra("key");
10+
Runtime.getRuntime().exec(trouble);
11+
12+
}
13+
14+
public void test2() {
15+
16+
String trouble = getIntent().getStringExtra("key");
17+
Runtime.getRuntime().exec(trouble);
18+
19+
}
20+
21+
public void test3() {
22+
23+
String trouble = getIntent().getExtras().getString("key");
24+
Runtime.getRuntime().exec(trouble);
25+
26+
}
27+
28+
}
29+
30+
class OtherClass {
31+
32+
public void test(IntentSources is) {
33+
String trouble = is.getIntent().getStringExtra("key");
34+
Runtime.getRuntime().exec(trouble);
35+
}
36+
37+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0

0 commit comments

Comments
 (0)