Skip to content

Commit 1a58260

Browse files
committed
Add two reduced testcases
1 parent fe448cf commit 1a58260

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

soot-infoflow/test/soot/jimple/infoflow/test/HeapTestCode.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,4 +1543,32 @@ public void aliasWithOverwriteTest4() {
15431543
cm.publish(j.f.str);
15441544
}
15451545

1546+
class Inner {
1547+
String secret;
1548+
}
1549+
1550+
Inner field = new Inner();
1551+
public void innerFieldReductionTestNegative() {
1552+
// Inner class constructor has this has an implicit parameter. Backward, here this.field.secret is tainted and
1553+
// propagated into the inner constructor. Then, inside the constructor at the following line
1554+
// this(HeapTestCode$Inner).<soot.jimple.infoflow.test.HeapTestCode$Inner: soot.jimple.infoflow.test.HeapTestCode this$0> = this$0;
1555+
// the access path this$0.<HeapTestCode: Inner field>.<Inner: String secret> is first extended to
1556+
// this(HeapTestCode$Inner).<HeapTestCode$Inner: HeapTestCode this$0>.<HeapTestCode: HeapTestCode$Inner field>.<HeapTestCode$Inner: String secret>
1557+
// and then reduced due to recursive types to
1558+
// this(HeapTestCode$Inner).<HeapTestCode$Inner: String secret>
1559+
// but that case is definitely not a recursive data structure and wrong.
1560+
Inner local = new Inner();
1561+
local.secret = TelephonyManager.getDeviceId();
1562+
ConnectionManager cm = new ConnectionManager();
1563+
cm.publish(field.secret);
1564+
}
1565+
1566+
public void innerFieldReductionTestNegative2() {
1567+
// Same bug as in innerFieldReductionTestNegative but this structured
1568+
// such that the bug is triggered in the forward analysis.
1569+
field.secret = TelephonyManager.getDeviceId();
1570+
Inner local = new Inner();
1571+
ConnectionManager cm = new ConnectionManager();
1572+
cm.publish(local.secret);
1573+
}
15461574
}

soot-infoflow/test/soot/jimple/infoflow/test/junit/HeapTests.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import soot.jimple.infoflow.data.AccessPath;
3838
import soot.jimple.infoflow.data.SootMethodAndClass;
3939
import soot.jimple.infoflow.entryPointCreators.DefaultEntryPointCreator;
40+
import soot.jimple.infoflow.entryPointCreators.SequentialEntryPointCreator;
4041
import soot.jimple.infoflow.results.InfoflowResults;
4142
import soot.jimple.infoflow.sourcesSinks.definitions.MethodSourceSinkDefinition;
4243
import soot.jimple.infoflow.sourcesSinks.manager.ISourceSinkManager;
@@ -1229,4 +1230,21 @@ public void aliasWithOverwriteTest4() {
12291230
checkInfoflow(infoflow, 1);
12301231
}
12311232

1233+
@Test(timeout = 300000)
1234+
public void innerFieldReductionTestNegative() {
1235+
IInfoflow infoflow = initInfoflow();
1236+
List<String> epoints = new ArrayList<String>();
1237+
epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void innerFieldReductionTestNegative()>");
1238+
infoflow.computeInfoflow(appPath, libPath, new SequentialEntryPointCreator(epoints), sources, sinks);
1239+
negativeCheckInfoflow(infoflow);
1240+
}
1241+
1242+
@Test(timeout = 300000)
1243+
public void innerFieldReductionTestNegative2() {
1244+
IInfoflow infoflow = initInfoflow();
1245+
List<String> epoints = new ArrayList<String>();
1246+
epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void innerFieldReductionTestNegative2()>");
1247+
infoflow.computeInfoflow(appPath, libPath, new SequentialEntryPointCreator(epoints), sources, sinks);
1248+
negativeCheckInfoflow(infoflow);
1249+
}
12321250
}

0 commit comments

Comments
 (0)