@Override public boolean equals(Object other) { if (this == other) return true; if (other == null || getClass() != other.getClass()) return false; SourceContextAndPath scap = (SourceContextAndPath) other; if (this.hashCode != 0 && scap.hashCode != 0 && this.hashCode != scap.hashCode) return false; if (this.callStack == null) { if (scap.callStack != null) return false; } else if (!this.callStack.equals(scap.callStack)) return false; if (!Infoflow.getPathAgnosticResults() && !this.path.equals(scap.path)) return false; return super.equals(other); }
@Override public boolean equals(Object o) { if (super.equals(o)) return true; if (o == null || !(o instanceof ResultSinkInfo)) return false; ResultSinkInfo si = (ResultSinkInfo) o; if (this.sink == null) { if (si.sink != null) return false; } else if (!this.sink.equals(si.sink)) return false; return !Infoflow.getOneResultPerAccessPath() || this.accessPath.equals(si.accessPath); }
@Test(timeout=300000) public void parameterFlowTest(){ Infoflow infoflow = initInfoflow(true); List<String> epoint = new ArrayList<String>(); epoint.add("<soot.jimple.infoflow.test.InFunctionCode: int paraToParaFlow(int,int," + "soot.jimple.infoflow.test.InFunctionCode$DataClass," + "soot.jimple.infoflow.test.InFunctionCode$DataClass)>"); DefaultSourceSinkManager ssm = new DefaultSourceSinkManager(sources, sinks); ssm.setParameterTaintMethods(epoint); ssm.setReturnTaintMethods(epoint); infoflow.computeInfoflow(appPath, libPath, new DefaultEntryPointCreator(epoint), ssm); Assert.assertNotNull(infoflow.getResults()); Assert.assertTrue(infoflow.getResults().isPathBetween("b", SOURCE_INT_PARAMETER2)); Assert.assertFalse(infoflow.getResults().isPathBetween("b", SOURCE_INT_PARAMETER)); }
@Test(timeout=300000) public void concreteLinkedSetPos0Test(){ System.out.println("Running test case concreteLinkedSetPos0Test..."); Infoflow infoflow = initInfoflow(); int oldAPLength = Infoflow.getAccessPathLength(); Infoflow.setAccessPathLength(1); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.SetTestCode: void concreteWriteReadLinkedPos0Test()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Infoflow.setAccessPathLength(oldAPLength); // this is a global setting! Restore it when we're done System.out.println("Test case concreteLinkedSetPos0Test done."); }
@Test(timeout=300000) public void setIteratorTest(){ System.out.println("Running test case setIteratorTest..."); Infoflow infoflow = initInfoflow(); int oldAPLength = Infoflow.getAccessPathLength(); Infoflow.setAccessPathLength(1); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.SetTestCode: void iteratorTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Infoflow.setAccessPathLength(oldAPLength); // this is a global setting! Restore it when we're done System.out.println("Test case setIteratorTest done."); }
@Test(timeout=600000) public void stringBuilderTest2_NoJDK(){ Infoflow infoflow = initInfoflow(true); infoflow.setSootConfig(new IInfoflowConfig() { @Override public void setSootOptions(Options options) { List<String> excludeList = new ArrayList<String>(); excludeList.add("java."); excludeList.add("javax."); options.set_exclude(excludeList); options.set_prepend_classpath(false); } }); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.StringTestCode: void methodStringBuilder2()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=600000) public void testStringConstructor(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.StringTestCode: void methodStringConstructor()>"); List<String> sources = new LinkedList<String>(); sources.add("<java.lang.String: void <init>(java.lang.String)>"); List<String> sinks = new LinkedList<String>(); sinks.add("<java.lang.Runtime: java.lang.Process exec(java.lang.String)>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); assertNotNull(infoflow.getResults()); assertTrue(infoflow.getResults().isPathBetweenMethods(sinks.get(0), sources.get(0))); }
@Test(timeout=300000) public void convertTest(){ long timeBefore = System.nanoTime(); System.out.println("Starting convertTest..."); Infoflow infoflow = initInfoflow(); int oldAPLength = Infoflow.getAccessPathLength(); Infoflow.setAccessPathLength(1); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); infoflow.setEnableStaticFieldTracking(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void convertTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Infoflow.setAccessPathLength(oldAPLength); // this is a global setting! Restore it when we're done System.out.println("convertTest took " + (System.nanoTime() - timeBefore) / 1E9 + " seconds"); }
@Test public void exceptionControlFlowTestNoJDK1() throws IOException { Infoflow infoflow = initInfoflow(); infoflow.setTaintWrapper(new EasyTaintWrapper(new File("EasyTaintWrapperSource.txt"))); infoflow.setSootConfig(new IInfoflowConfig() { @Override public void setSootOptions(Options options) { List<String> excludeList = new ArrayList<String>(); excludeList.add("java."); excludeList.add("javax."); options.set_exclude(excludeList); options.set_prepend_classpath(false); } }); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ExceptionTestCode: void exceptionControlFlowTest1()>"); infoflow.computeInfoflow(appPath, null, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout = 300000) public void aliasStrongUpdateTest2() { final String sinkMethod = "<soot.jimple.infoflow.test.HeapTestCode: " + "void leakData(soot.jimple.infoflow.test.HeapTestCode$Data)>"; final String sourceMethod = "<soot.jimple.infoflow.test.HeapTestCode: " + "soot.jimple.infoflow.test.HeapTestCode$Data getSecretData()>"; Infoflow infoflow = initInfoflow(); infoflow.setInspectSources(false); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void aliasStrongUpdateTest2()>"); infoflow.computeInfoflow(appPath, libPath, epoints, Collections.singleton(sourceMethod), Collections.singleton(sinkMethod)); Assert.assertTrue(infoflow.isResultAvailable()); InfoflowResults map = infoflow.getResults(); Assert.assertEquals(1, map.size()); Assert.assertTrue(map.containsSinkMethod(sinkMethod)); Assert.assertTrue(map.isPathBetweenMethods(sinkMethod, sourceMethod)); }
@Test(timeout = 300000) public void innerClassTest() { boolean oldUseRecAP = Infoflow.getUseRecursiveAccessPaths(); Infoflow.setUseRecursiveAccessPaths(false); Infoflow infoflow = initInfoflow(); infoflow.setInspectSources(false); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void innerClassTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); Infoflow.setUseRecursiveAccessPaths(oldUseRecAP); negativeCheckInfoflow(infoflow); }
@Test(timeout = 300000) public void aliasesTest() { Infoflow infoflow = initInfoflow(); infoflow.setAliasingAlgorithm(AliasingAlgorithm.PtsBased); int oldLength = Infoflow.getAccessPathLength(); Infoflow.setAccessPathLength(3); infoflow.setInspectSources(false); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void testAliases()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Infoflow.setAccessPathLength(oldLength); }
@Test(timeout=300000) public void staticFieldTest5(){ Infoflow infoflow = initInfoflow(); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void staticFieldTest4()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout = 300000) public void arrayLengthTest() { Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ArrayTestCode: void arrayLengthTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void negativeCallTest(){ Infoflow infoflow = initInfoflow(); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void negativeCallTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); negativeCheckInfoflow(infoflow); }
@Test(timeout=300000) public void defaultlifecycle2Test(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.InheritanceTestCode: void testInheritance1()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout = 300000) public void basic9() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.basic.Basic9: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.setEnableStaticFieldTracking(false); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void aliasTypeTest(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.TypeTestCode: void aliasTypeTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Assert.assertTrue((infoflow.getResults().isPathBetweenMethods(sink, sourceDeviceId))); }
@Test(timeout=600000) public void concreteTreeSetPos0Test(){ System.out.println("Running test case concreteTreeSetPos0Test..."); Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.SetTestCode: void concreteWriteReadTreePos0Test()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); System.out.println("Test case concreteTreeSetPos0Test done."); }
@Test(timeout=300000) public void mapIteratorTest(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.MapTestCode: void iteratorTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void aliasReturnTest(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.TypeTestCode: void aliasReturnTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void callTypeTest(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.TypeTestCode: void callTypeTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void concreteNegativeTest(){ System.out.println("Running test case concreteNegativeTest..."); Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.SetTestCode: void concreteWriteReadNegativeTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); negativeCheckInfoflow(infoflow); System.out.println("Test case concreteNegativeTest done."); }
@Test(timeout = 300000) public void basic30() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.basic.Basic30: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.setEnableStaticFieldTracking(false); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); checkInfoflow(infoflow, 1); }
@Test public void collections9() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.collections.Collections9: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); negativeCheckInfoflow(infoflow); // this test fails because we taint whole list instead of single items.. }
@Test(timeout=300000) public void intMultiTest2(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.MultiTestCode: void intMultiTest2()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); Assert.assertTrue(infoflow.getResults().isPathBetweenMethods(sinkInt, sourceIMEI)); Assert.assertTrue(infoflow.getResults().isPathBetweenMethods(sinkInt, sourceIMSI)); Assert.assertEquals(1, infoflow.getResults().size()); }
@Test(timeout = 300000) public void negativeTest() { Infoflow infoflow = initInfoflow(); infoflow.setAliasingAlgorithm(AliasingAlgorithm.PtsBased); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void negativeTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); negativeCheckInfoflow(infoflow); }
@Test(timeout = 300000) public void staticAliasTest2() { Infoflow infoflow = initInfoflow(); infoflow.setInspectSources(false); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.HeapTestCode: void staticAliasTest2()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test public void datastructures2() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.datastructures.Datastructures2: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout = 300000) public void staticFieldOverwriteTest() { Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.OverwriteTestCode: void staticFieldOverwrite()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); negativeCheckInfoflow(infoflow); }
@Test(timeout = 300000) public void clinitTest1() { Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.StaticTestCode: void clinitTest1()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void recursionTest(){ Infoflow infoflow = initInfoflow(); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void recursionTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void staticFieldTest4(){ Infoflow infoflow = initInfoflow(); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void staticFieldTest4()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void simpleNegativeTest(){ Infoflow infoflow = initInfoflow(); infoflow.setEnableImplicitFlows(true); infoflow.setInspectSinks(false); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void simpleNegativeTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); negativeCheckInfoflow(infoflow); }
@Test public void inter3() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.inter.Inter3: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void equalsTest2(){ EasyTaintWrapper wrapper = easyWrapper.clone(); wrapper.setAlwaysModelEqualsHashCode(true); Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.EasyWrapperTestCode: void equalsTest2()>"); infoflow.setTaintWrapper(wrapper); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void pathSkipTest2(){ Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.OtherTestCode: void pathSkipTest2()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); Assert.assertTrue(infoflow.getResults().isPathBetweenMethods(sink, sourcePwd)); Assert.assertFalse(infoflow.getResults().isPathBetweenMethods(sink, sourceDeviceId)); }
@Test(timeout = 300000) public void secondCallBackTest() { Infoflow infoflow = initInfoflow(); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.CallbackTestCode: void tryNext()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }
@Test public void collections14() { List<String> epoints = new ArrayList<String>(); epoints.add("<securibench.micro.collections.Collections14: void doGet(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)>"); Infoflow infoflow = initInfoflow(epoints); infoflow.computeInfoflow(appPath, libPath, entryPointCreator, sources, sinks); checkInfoflow(infoflow, 1); }
@Test(timeout=300000) public void conditionalAliasingTest(){ Infoflow infoflow = initInfoflow(); infoflow.setInspectSinks(false); infoflow.setEnableImplicitFlows(true); List<String> epoints = new ArrayList<String>(); epoints.add("<soot.jimple.infoflow.test.ImplicitFlowTestCode: void conditionalAliasingTest()>"); infoflow.computeInfoflow(appPath, libPath, epoints, sources, sinks); checkInfoflow(infoflow, 1); }