Skip to content

Commit 7a96727

Browse files
Jami CogswellJami Cogswell
authored andcommitted
add tests
1 parent 367c31b commit 7a96727

File tree

5 files changed

+326
-157
lines changed

5 files changed

+326
-157
lines changed

java/ql/test/library-tests/dataflow/taintsources/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- This name is resolved to com.example.myapp.MainActivity
2020
based upon the package attribute -->
21-
<activity android:name=".IntentSources">
21+
<activity android:name=".IntentSourcesActivity">
2222
<intent-filter>
2323
<action android:name="android.intent.action.MAIN" />
2424
<category android:name="android.intent.category.LAUNCHER" />
@@ -28,6 +28,18 @@
2828
<activity
2929
android:name=".DisplayMessageActivity"
3030
android:parentActivityName=".MainActivity" />
31+
32+
<service android:name=".IntentSourcesService">
33+
<intent-filter>
34+
<action android:name="android.intent.action.START_BACKGROUND"/>
35+
</intent-filter>
36+
</service>
37+
38+
<receiver android:name=".IntentSourcesReceiver">
39+
<intent-filter>
40+
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
41+
</intent-filter>
42+
</receiver>
3143
</application>
3244
</manifest>
3345

java/ql/test/library-tests/dataflow/taintsources/IntentSources.java renamed to java/ql/test/library-tests/dataflow/taintsources/IntentSourcesActivity.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.example.myapp;
22

33
import android.app.Activity;
4+
import android.content.Intent;
45

5-
public class IntentSources extends Activity {
6+
public class IntentSourcesActivity extends Activity {
67

7-
private static void sink(Object o) {}
8+
private static void sink(Object o) {
9+
}
810

911
public void test() throws java.io.IOException {
1012

@@ -26,14 +28,14 @@ public void test3() throws java.io.IOException {
2628
sink(trouble); // $hasRemoteTaintFlow
2729

2830
}
29-
3031
}
3132

3233
class OtherClass {
3334

34-
private static void sink(Object o) {}
35+
private static void sink(Object o) {
36+
}
3537

36-
public void test(IntentSources is) throws java.io.IOException {
38+
public void test(IntentSourcesActivity is) throws java.io.IOException {
3739
String trouble = is.getIntent().getStringExtra("key");
3840
sink(trouble); // $hasRemoteTaintFlow
3941
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.myapp;
2+
3+
import android.content.BroadcastReceiver;
4+
import android.content.Context;
5+
import android.content.Intent;
6+
7+
public class IntentSourcesReceiver extends BroadcastReceiver {
8+
9+
private static void sink(Object o) {
10+
}
11+
12+
@Override
13+
public void onReceive(Context context, Intent intent) {
14+
String trouble = intent.getStringExtra("data");
15+
sink(trouble); // $ hasRemoteTaintFlow
16+
}
17+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.example.myapp;
2+
3+
import android.app.Service;
4+
import android.content.Context;
5+
import android.content.Intent;
6+
import android.os.IBinder;
7+
8+
public class IntentSourcesService extends Service {
9+
10+
private static void sink(Object o) {
11+
}
12+
13+
@Override
14+
public void onStart(Intent intent, int startId) {
15+
String trouble = intent.getStringExtra("data");
16+
sink(trouble); // $ hasRemoteTaintFlow
17+
}
18+
19+
@Override
20+
public int onStartCommand(Intent intent, int flags, int startId) {
21+
String trouble = intent.getStringExtra("data");
22+
sink(trouble); // $ hasRemoteTaintFlow
23+
return -1;
24+
}
25+
26+
@Override
27+
public IBinder onBind(Intent intent) {
28+
String trouble = intent.getStringExtra("data");
29+
sink(trouble); // $ hasRemoteTaintFlow
30+
return null;
31+
}
32+
33+
@Override
34+
public boolean onUnbind(Intent intent) {
35+
String trouble = intent.getStringExtra("data");
36+
sink(trouble); // $ hasRemoteTaintFlow
37+
return false;
38+
}
39+
40+
@Override
41+
public void onRebind(Intent intent) {
42+
String trouble = intent.getStringExtra("data");
43+
sink(trouble); // $ hasRemoteTaintFlow
44+
}
45+
46+
@Override
47+
public void onTaskRemoved(Intent intent) {
48+
String trouble = intent.getStringExtra("data");
49+
sink(trouble); // $ hasRemoteTaintFlow
50+
}
51+
52+
}

0 commit comments

Comments
 (0)