Skip to content

Commit 33ea505

Browse files
committed
Further add expected results for regression-testing on DroidBench
1 parent e3c6905 commit 33ea505

4 files changed

Lines changed: 91 additions & 27 deletions

File tree

soot-infoflow-android/test/soot/jimple/infoflow/android/test/droidBench/InterAppCommunicationTest.java

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,105 @@
1212
public abstract class InterAppCommunicationTest extends JUnitTests {
1313
@Test(timeout=300000)
1414
public void runTestEchoer() throws IOException, XmlPullParserException {
15+
int expected = 3;
16+
if (mode != TestResultMode.DROIDBENCH)
17+
expected = 0;
1518
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Echoer.apk");
16-
Assert.assertEquals(3, res.size());
19+
Assert.assertEquals(expected, res.size());
1720
}
1821

1922
@Test(timeout=300000)
2023
public void runTestSendSMS() throws IOException, XmlPullParserException {
24+
int expected = 3;
25+
if (mode != TestResultMode.DROIDBENCH)
26+
expected = 2;
2127
InfoflowResults res = analyzeAPKFile("InterAppCommunication/SendSMS.apk");
22-
Assert.assertEquals(3, res.size());
28+
Assert.assertEquals(expected, res.size());
2329
}
2430

2531
@Test(timeout=300000)
2632
public void runTestStartActivityForResult1() throws IOException, XmlPullParserException {
33+
int expected = 6;
34+
if (mode != TestResultMode.DROIDBENCH)
35+
expected = 2;
2736
InfoflowResults res = analyzeAPKFile("InterAppCommunication/StartActivityForResult1.apk");
28-
Assert.assertEquals(6, res.size());
37+
Assert.assertEquals(expected, res.size());
2938
}
3039

3140
@Test(timeout=300000)
3241
public void runTestCollector() throws IOException, XmlPullParserException {
42+
int expected = 2;
43+
if (mode != TestResultMode.DROIDBENCH)
44+
expected = 0;
3345
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Collector/Collector.apk");
34-
Assert.assertEquals(2, res.size());
46+
Assert.assertEquals(expected, res.size());
3547
}
3648

3749
@Test(timeout=300000)
3850
public void runTestDeviceId_Broadcast1() throws IOException, XmlPullParserException {
51+
int expected = 1;
52+
if (mode != TestResultMode.DROIDBENCH)
53+
expected = 0;
3954
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Device Id leakage/DeviceId_Broadcast1.apk");
40-
Assert.assertEquals(1, res.size());
55+
Assert.assertEquals(expected, res.size());
4156
}
4257

4358
@Test(timeout=300000)
4459
public void runTestDeviceId_contentProvider1() throws IOException, XmlPullParserException {
60+
int expected = 1;
61+
// TODO: where are the false positives from?https://github.com/secure-software-engineering/DroidBench
62+
63+
if (mode == TestResultMode.FLOWDROID_BACKWARDS)
64+
expected = 2;
65+
else if (mode == TestResultMode.FLOWDROID_FORWARDS) {
66+
expected = 3;
67+
}
4568
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Device Id leakage/DeviceId_contentProvider1.apk");
46-
Assert.assertEquals(2, res.size());
69+
Assert.assertEquals(expected, res.size());
4770
}
4871

4972
@Test(timeout=300000)
5073
public void runTestDeviceId_OrderedIntent1() throws IOException, XmlPullParserException {
74+
int expected = 1;
75+
if (mode != TestResultMode.DROIDBENCH)
76+
expected = 0;
5177
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Device Id leakage/DeviceId_OrderedIntent1.apk");
52-
Assert.assertEquals(1, res.size());
78+
Assert.assertEquals(expected, res.size());
5379
}
5480

5581
@Test(timeout=300000)
5682
public void runTestDeviceId_Service() throws IOException, XmlPullParserException {
83+
int expected = 1;
84+
if (mode != TestResultMode.DROIDBENCH)
85+
expected = 0;
5786
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Device Id leakage/DeviceId_Service1.apk");
58-
Assert.assertEquals(1, res.size());
87+
Assert.assertEquals(expected, res.size());
5988
}
6089

6190
@Test(timeout=300000)
6291
public void runTestLocation1() throws IOException, XmlPullParserException {
92+
int expected = 2;
93+
if (mode != TestResultMode.DROIDBENCH)
94+
expected = 0;
6395
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Location leakage/Location1.apk");
64-
Assert.assertEquals(2, res.size());
96+
Assert.assertEquals(expected, res.size());
6597
}
6698

6799
@Test(timeout=300000)
68100
public void runTestLocation1_Broadcast() throws IOException, XmlPullParserException {
101+
int expected = 2;
102+
if (mode != TestResultMode.DROIDBENCH)
103+
expected = 0;
69104
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Location leakage/Location_Broadcast1.apk");
70-
Assert.assertEquals(2, res.size());
105+
Assert.assertEquals(expected, res.size());
71106
}
72107

73108
@Test(timeout=300000)
74109
public void runTestLocation_Service1() throws IOException, XmlPullParserException {
110+
int expected = 2;
111+
if (mode != TestResultMode.DROIDBENCH)
112+
expected = 0;
75113
InfoflowResults res = analyzeAPKFile("InterAppCommunication/Location leakage/Location_Service1.apk");
76-
Assert.assertEquals(2, res.size());
114+
Assert.assertEquals(expected, res.size());
77115
}
78116
}

soot-infoflow-android/test/soot/jimple/infoflow/android/test/droidBench/InterComponentCommunicationTest.java

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,33 @@ public void runTestActivityCommunication1() throws IOException, XmlPullParserExc
3232
@Test(timeout=300000)
3333

3434
public void runTestActivityCommunication2() throws IOException, XmlPullParserException {
35+
int expected = 1;
36+
if (mode != TestResultMode.DROIDBENCH)
37+
expected = 0;
3538
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication2.apk");
3639
Assert.assertNotNull(res);
37-
Assert.assertEquals(1, res.size());
40+
Assert.assertEquals(expected, res.size());
3841
}
3942

4043
@Test(timeout=300000)
41-
4244
public void runTestActivityCommunication3() throws IOException, XmlPullParserException {
45+
int expected = 1;
46+
if (mode != TestResultMode.DROIDBENCH)
47+
expected = 0;
4348
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication3.apk");
4449
Assert.assertNotNull(res);
45-
Assert.assertEquals(1, res.size());
50+
Assert.assertEquals(expected, res.size());
4651
}
4752

4853
@Test(timeout=300000)
4954

5055
public void runTestActivityCommunication4() throws IOException, XmlPullParserException {
56+
int expected = 1;
57+
if (mode != TestResultMode.DROIDBENCH)
58+
expected = 0;
5159
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication4.apk");
5260
Assert.assertNotNull(res);
53-
Assert.assertEquals(1, res.size());
61+
Assert.assertEquals(expected, res.size());
5462
}
5563

5664
@Test(timeout=300000)
@@ -64,25 +72,32 @@ public void runTestActivityCommunication5() throws IOException, XmlPullParserExc
6472
@Test(timeout=300000)
6573

6674
public void runTestActivityCommunication6() throws IOException, XmlPullParserException {
75+
int expected = 1;
76+
if (mode != TestResultMode.DROIDBENCH)
77+
expected = 0;
6778
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication6.apk");
6879
Assert.assertNotNull(res);
69-
Assert.assertEquals(1, res.size());
80+
Assert.assertEquals(expected, res.size());
7081
}
7182

7283
@Test(timeout=300000)
73-
7484
public void runTestActivityCommunication7() throws IOException, XmlPullParserException {
85+
int expected = 1;
86+
if (mode != TestResultMode.DROIDBENCH)
87+
expected = 0;
7588
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication7.apk");
7689
Assert.assertNotNull(res);
77-
Assert.assertEquals(1, res.size());
90+
Assert.assertEquals(expected, res.size());
7891
}
7992

8093
@Test(timeout=300000)
81-
8294
public void runTestActivityCommunication8() throws IOException, XmlPullParserException {
95+
int expected = 1;
96+
if (mode != TestResultMode.DROIDBENCH)
97+
expected = 0;
8398
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ActivityCommunication8.apk");
8499
Assert.assertNotNull(res);
85-
Assert.assertEquals(1, res.size());
100+
Assert.assertEquals(expected, res.size());
86101
}
87102

88103
@Test(timeout=300000)
@@ -119,29 +134,37 @@ public void runTestIntentSink1() throws IOException, XmlPullParserException {
119134
@Test(timeout=300000)
120135
//("startActivity() is no longer a sink")
121136
public void runTestIntentSink2() throws IOException, XmlPullParserException {
137+
int expected = 1;
138+
if (mode != TestResultMode.DROIDBENCH)
139+
expected = 0;
122140
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/IntentSink2.apk");
123141
Assert.assertNotNull(res);
124-
Assert.assertEquals(1, res.size());
142+
Assert.assertEquals(expected, res.size());
125143
}
126144

127145
@Test(timeout=300000)
128146

129147
public void runTestIntentSource1() throws IOException, XmlPullParserException {
148+
int expected = 1;
149+
if (mode != TestResultMode.DROIDBENCH)
150+
expected = 0;
130151
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/IntentSource1.apk");
131152
Assert.assertNotNull(res);
132-
Assert.assertEquals(1, res.size());
153+
Assert.assertEquals(expected, res.size());
133154
}
134155

135156
@Test(timeout=300000)
136157

137158
public void runTestServiceCommunication1() throws IOException, XmlPullParserException {
159+
int expected = 1;
160+
if (mode != TestResultMode.DROIDBENCH)
161+
expected = 0;
138162
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/ServiceCommunication1.apk");
139163
Assert.assertNotNull(res);
140-
Assert.assertEquals(1, res.size());
164+
Assert.assertEquals(expected, res.size());
141165
}
142166

143167
@Test(timeout=300000)
144-
145168
public void runTestSharedPreferences1() throws IOException, XmlPullParserException {
146169
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/SharedPreferences1.apk");
147170
Assert.assertNotNull(res);
@@ -159,9 +182,12 @@ public void runTestSingletons1() throws IOException, XmlPullParserException {
159182
@Test(timeout=300000)
160183

161184
public void runTestUnresolvableIntent1() throws IOException, XmlPullParserException {
185+
int expected = 1;
186+
if (mode != TestResultMode.DROIDBENCH)
187+
expected = 0;
162188
InfoflowResults res = analyzeAPKFile("InterComponentCommunication/UnresolvableIntent1.apk");
163189
Assert.assertNotNull(res);
164-
Assert.assertEquals(2, res.size());
190+
Assert.assertEquals(expected, res.size());
165191
}
166192

167193
}

soot-infoflow-android/test/soot/jimple/infoflow/android/test/droidBench/JUnitTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ public InfoflowResults analyzeAPKFile(String fileName, String iccModel,
156156
configCallback.configureAnalyzer(setupApplication.getConfig());
157157
setupApplication.getConfig().setEnableArraySizeTainting(true);
158158
setupApplication.setTaintWrapper(new EasyTaintWrapper(taintWrapperFile));
159-
160159
if (mode == TestResultMode.FLOWDROID_BACKWARDS)
161160
setupApplication.getConfig().setDataFlowDirection(InfoflowConfiguration.DataFlowDirection.Backwards);
162161

soot-infoflow-android/test/soot/jimple/infoflow/android/test/droidBench/LifecycleTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public void runTestActivitySavedState1() throws IOException, XmlPullParserExcept
8686
@Override
8787
public void configureAnalyzer(InfoflowAndroidConfiguration config) {
8888
config.getSourceSinkConfig().setEnableLifecycleSources(true);
89-
config.getSourceSinkConfig().setCallbackSourceMode(CallbackSourceMode.AllParametersAsSources);
89+
// TODO: why shouldn't it get two results here?
90+
// config.getSourceSinkConfig().setCallbackSourceMode(CallbackSourceMode.AllParametersAsSources);
9091
}
9192

9293
});

0 commit comments

Comments
 (0)