Skip to content

Commit e6181f6

Browse files
arthaudfacebook-github-bot
authored andcommitted
Add integration test for false positive due to attribute assignments (see #179)
Summary: As titled. Reviewed By: anwesht Differential Revision: D71311222 fbshipit-source-id: 7e718d7de5db5bb5d0e5518975951ff8eb029528
1 parent 188f89e commit e6181f6

File tree

4 files changed

+201
-1
lines changed

4 files changed

+201
-1
lines changed

source/tests/integration/end-to-end/code/strong_update/Flow.java

+13
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,20 @@ public Object field_getter() {
4545
}
4646

4747
public void no_issue_inlining() {
48+
this.field = Origin.source();
4849
field_setter(new Object());
4950
Origin.sink(field_getter());
5051
}
52+
53+
// TODO(T218206443): False positive with field assignment to non-tainted value
54+
55+
public void field_set_empty() {
56+
this.field = new Object();
57+
}
58+
59+
public void no_issue_field_set_empty() {
60+
this.field = Origin.source();
61+
field_set_empty();
62+
Origin.sink(this.field);
63+
}
5164
}

source/tests/integration/end-to-end/code/strong_update/expected_call_graph.json

+20
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@
225225
"Ljava/lang/Object;.<init>:()V"
226226
]
227227
},
228+
"Lcom/facebook/marianatrench/integrationtests/Flow;.field_set_empty:()V" :
229+
{
230+
"static" :
231+
[
232+
"Ljava/lang/Object;.<init>:()V"
233+
]
234+
},
228235
"Lcom/facebook/marianatrench/integrationtests/Flow;.issue_propagation:()V" :
229236
{
230237
"static" :
@@ -237,6 +244,18 @@
237244
"Lcom/facebook/marianatrench/integrationtests/Flow;.add_propagation:(Ljava/lang/Object;)V"
238245
]
239246
},
247+
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_field_set_empty:()V" :
248+
{
249+
"static" :
250+
[
251+
"Lcom/facebook/marianatrench/integrationtests/Origin;.sink:(Ljava/lang/Object;)V",
252+
"Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;"
253+
],
254+
"virtual" :
255+
[
256+
"Lcom/facebook/marianatrench/integrationtests/Flow;.field_set_empty:()V"
257+
]
258+
},
240259
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_generation:()V" :
241260
{
242261
"static" :
@@ -253,6 +272,7 @@
253272
"static" :
254273
[
255274
"Lcom/facebook/marianatrench/integrationtests/Origin;.sink:(Ljava/lang/Object;)V",
275+
"Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;",
256276
"Ljava/lang/Object;.<init>:()V"
257277
],
258278
"virtual" :

source/tests/integration/end-to-end/code/strong_update/expected_dependencies.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,27 @@
4343
[
4444
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_inlining:()V"
4545
],
46+
"Lcom/facebook/marianatrench/integrationtests/Flow;.field_set_empty:()V" :
47+
[
48+
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_field_set_empty:()V"
49+
],
4650
"Lcom/facebook/marianatrench/integrationtests/Flow;.field_setter:(Ljava/lang/Object;)V" :
4751
[
4852
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_inlining:()V"
4953
],
5054
"Lcom/facebook/marianatrench/integrationtests/Origin;.sink:(Ljava/lang/Object;)V" :
5155
[
5256
"Lcom/facebook/marianatrench/integrationtests/Flow;.issue_propagation:()V",
57+
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_field_set_empty:()V",
5358
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_generation:()V",
5459
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_inlining:()V"
5560
],
5661
"Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;" :
5762
[
5863
"Lcom/facebook/marianatrench/integrationtests/Flow;.add_generation:()V",
59-
"Lcom/facebook/marianatrench/integrationtests/Flow;.issue_propagation:()V"
64+
"Lcom/facebook/marianatrench/integrationtests/Flow;.issue_propagation:()V",
65+
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_field_set_empty:()V",
66+
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_inlining:()V"
6067
],
6168
"Lcom/facebook/secure/context/IntentLauncher;.<init>:()V" :
6269
[
@@ -101,6 +108,7 @@
101108
"Lcom/facebook/marianatrench/integrationtests/Flow;.<init>:()V",
102109
"Lcom/facebook/marianatrench/integrationtests/Flow;.add_generation:()V",
103110
"Lcom/facebook/marianatrench/integrationtests/Flow;.add_propagation:(Ljava/lang/Object;)V",
111+
"Lcom/facebook/marianatrench/integrationtests/Flow;.field_set_empty:()V",
104112
"Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_inlining:()V",
105113
"Lcom/facebook/marianatrench/integrationtests/Origin;.<init>:()V",
106114
"Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;",

source/tests/integration/end-to-end/code/strong_update/expected_output.json

+159
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,14 @@
10371037
}
10381038
]
10391039
}
1040+
{
1041+
"method" : "Lcom/facebook/marianatrench/integrationtests/Flow;.field_set_empty:()V",
1042+
"position" :
1043+
{
1044+
"line" : 55,
1045+
"path" : "Flow.java"
1046+
}
1047+
}
10401048
{
10411049
"inline_as_setter" :
10421050
{
@@ -1269,6 +1277,157 @@
12691277
}
12701278
]
12711279
}
1280+
{
1281+
"generations" :
1282+
[
1283+
{
1284+
"port" : "Argument(0).field",
1285+
"taint" :
1286+
[
1287+
{
1288+
"call_info" :
1289+
{
1290+
"call_kind" : "Origin",
1291+
"port" : "Return",
1292+
"position" :
1293+
{
1294+
"end" : 29,
1295+
"line" : 60,
1296+
"path" : "Flow.java",
1297+
"start" : 24
1298+
}
1299+
},
1300+
"kinds" :
1301+
[
1302+
{
1303+
"callee_interval" :
1304+
[
1305+
32,
1306+
33
1307+
],
1308+
"kind" : "Source",
1309+
"origins" :
1310+
[
1311+
{
1312+
"method" : "Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;",
1313+
"port" : "Return"
1314+
}
1315+
],
1316+
"preserves_type_context" : true
1317+
}
1318+
],
1319+
"local_positions" :
1320+
[
1321+
{
1322+
"end" : 32,
1323+
"line" : 60,
1324+
"start" : 17
1325+
}
1326+
]
1327+
}
1328+
]
1329+
}
1330+
],
1331+
"issues" :
1332+
[
1333+
{
1334+
"callee" : "Lcom/facebook/marianatrench/integrationtests/Origin;.sink:(Ljava/lang/Object;)V",
1335+
"position" :
1336+
{
1337+
"line" : 62,
1338+
"path" : "Flow.java"
1339+
},
1340+
"rule" : 1,
1341+
"sink_index" : "0",
1342+
"sinks" :
1343+
[
1344+
{
1345+
"call_info" :
1346+
{
1347+
"call_kind" : "Origin",
1348+
"port" : "Argument(0)",
1349+
"position" :
1350+
{
1351+
"end" : 25,
1352+
"line" : 62,
1353+
"path" : "Flow.java",
1354+
"start" : 16
1355+
}
1356+
},
1357+
"kinds" :
1358+
[
1359+
{
1360+
"callee_interval" :
1361+
[
1362+
32,
1363+
33
1364+
],
1365+
"kind" : "Sink",
1366+
"origins" :
1367+
[
1368+
{
1369+
"method" : "Lcom/facebook/marianatrench/integrationtests/Origin;.sink:(Ljava/lang/Object;)V",
1370+
"port" : "Argument(0)"
1371+
}
1372+
],
1373+
"preserves_type_context" : true
1374+
}
1375+
]
1376+
}
1377+
],
1378+
"sources" :
1379+
[
1380+
{
1381+
"call_info" :
1382+
{
1383+
"call_kind" : "Origin",
1384+
"port" : "Return",
1385+
"position" :
1386+
{
1387+
"end" : 29,
1388+
"line" : 60,
1389+
"path" : "Flow.java",
1390+
"start" : 24
1391+
}
1392+
},
1393+
"kinds" :
1394+
[
1395+
{
1396+
"callee_interval" :
1397+
[
1398+
32,
1399+
33
1400+
],
1401+
"kind" : "Source",
1402+
"origins" :
1403+
[
1404+
{
1405+
"method" : "Lcom/facebook/marianatrench/integrationtests/Origin;.source:()Ljava/lang/Object;",
1406+
"port" : "Return"
1407+
}
1408+
],
1409+
"preserves_type_context" : true
1410+
}
1411+
],
1412+
"local_positions" :
1413+
[
1414+
{
1415+
"end" : 32,
1416+
"line" : 60,
1417+
"start" : 17
1418+
}
1419+
]
1420+
}
1421+
]
1422+
}
1423+
],
1424+
"method" : "Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_field_set_empty:()V",
1425+
"position" :
1426+
{
1427+
"line" : 59,
1428+
"path" : "Flow.java"
1429+
}
1430+
}
12721431
{
12731432
"method" : "Lcom/facebook/marianatrench/integrationtests/Flow;.no_issue_generation:()V",
12741433
"position" :

0 commit comments

Comments
 (0)