/** * @param args */ public static void main(String[] args) { PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() { protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) { IFDSTabulationProblem<Unit,?,SootMethod,InterproceduralCFG<Unit,SootMethod>> problem = new IFDSPossibleTypes(new JimpleBasedInterproceduralCFG()); @SuppressWarnings({ "rawtypes", "unchecked" }) JimpleIFDSSolver<?,InterproceduralCFG<Unit,SootMethod>> solver = new JimpleIFDSSolver(problem); solver.solve(); } })); soot.Main.main(args); }
private static BiDiInterproceduralCFG<Unit, SootMethod> makeICFG(AnalysisDirection direction) { JimpleBasedInterproceduralCFG fwdIcfg = new JimpleBasedInterproceduralCFG(); if (direction == AnalysisDirection.FORWARDS) return fwdIcfg; else return new BackwardsInterproceduralCFG(fwdIcfg); }
public InfoflowCFG() { this(new JimpleBasedInterproceduralCFG()); }
@Override public void notifyMethodChanged(SootMethod m) { if (delegate instanceof JimpleBasedInterproceduralCFG) ((JimpleBasedInterproceduralCFG) delegate).initializeUnitToOwner(m); }
public PropagationProblem(JimpleBasedInterproceduralCFG icfg) { super(icfg); this.icfg = icfg; }
@Override protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) { PropagationTimers.v().totalTimer.start(); PropagationTimers.v().misc.start(); StringValueAnalysis.initialize(); JimpleBasedInterproceduralCFG iCfg = new PropagationIcfg(); AnalysisParameters.v().setIcfg(iCfg); PropagationProblem problem = new PropagationProblem(iCfg); for (SootMethod ep : Scene.v().getEntryPoints()) { if (ep.isConcrete()) { problem.getInitialSeeds().add(ep.getActiveBody().getUnits().getFirst()); } } int iterationCounter = 0; PropagationSolver solver = null; while (iterationCounter < MAX_ITERATIONS) { IterationSolver.v().initialize(solver); PropagationTimers.v().misc.end(); PropagationTimers.v().problemGeneration.start(); solver = new PropagationSolver(problem); PropagationTimers.v().problemGeneration.end(); PropagationTimers.v().ideSolution.start(); logger.info("Solving propagation problem (iteration " + iterationCounter + ")"); solver.solve(); PropagationTimers.v().ideSolution.end(); PropagationTimers.v().misc.start(); if (!AnalysisParameters.v().isIterative() || IterationSolver.v().hasFoundFixedPoint()) { iterationCounter = MAX_ITERATIONS; } else { ++iterationCounter; } } PropagationTimers.v().misc.end(); logger.info("Reached a fixed point"); Results.addResult(resultBuilder.buildResult(solver)); PropagationTimers.v().totalTimer.end(); if (logger.isDebugEnabled()) { CallGraph cg = Scene.v().getCallGraph(); Iterator<Edge> it = cg.listener(); while (it.hasNext()) { soot.jimple.toolkits.callgraph.Edge e = (soot.jimple.toolkits.callgraph.Edge) it.next(); logger.debug("" + e.src() + e.srcStmt() + " =" + e.kind() + "=> " + e.tgt()); } if (printer != null) { printer.print(solver); } } }
private Set<Pair<Value, Set<DefinitionStmt>>> computeResults(final String codeDir) { // extractVersion(codeDir); soot.G.reset(); final Set<Pair<Value, Set<DefinitionStmt>>> results = new HashSet<Pair<Value, Set<DefinitionStmt>>>(); PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() { protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) { // Scene.v().getSootClass(className).setApplicationClass(); System.out.println("Running IFDS on initial CFG..."); long nanoBeforeCFG = System.nanoTime(); InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG(); System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds."); IFDSTabulationProblem<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>> problem = new IFDSReachingDefinitions(icfg); IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod, InterproceduralCFG<Unit,SootMethod>> solver = new IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod, InterproceduralCFG<Unit,SootMethod>>(problem); long beforeSolver = System.nanoTime(); System.out.println("Running solver..."); solver.solve(); System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds."); SootMethod meth = Scene.v().getMainClass().getMethodByName("runMainAndExit"); Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast()); results.addAll(solver.ifdsResultsAt(ret)); } })); final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator + JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\jce.jar"; System.out.println("Soot classpath: " + sootcp); soot.Main.v().run(new String[] { "-W", "-main-class", CLASS_NAME, "-process-path", codeDir + File.separator + "bin", "-src-prec", "java", // "-pp", "-cp", sootcp, // "-no-bodies-for-excluded", // "-exclude", "java", // "-exclude", "javax", "-output-format", "none", "-p", "jb", "use-original-names:true", "-p", "cg.spark", "on", // "-p", "cg.spark", "verbose:true", CLASS_NAME } ); return results; }
private Set<Pair<Value, Set<DefinitionStmt>>> computeResults(final String codeDir) { // extractVersion(codeDir); soot.G.reset(); final Set<Pair<Value, Set<DefinitionStmt>>> results = new HashSet<Pair<Value, Set<DefinitionStmt>>>(); PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() { protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) { // Scene.v().getSootClass(className).setApplicationClass(); System.out.println("Running IFDS on initial CFG..."); long nanoBeforeCFG = System.nanoTime(); InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG(); System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds."); IFDSTabulationProblem<Unit, Pair<Value, Set<DefinitionStmt>>, SootMethod, InterproceduralCFG<Unit, SootMethod>> problem = new IFDSReachingDefinitions(icfg); IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod, InterproceduralCFG<Unit,SootMethod>> solver = new IFDSSolver<Unit,Pair<Value, Set<DefinitionStmt>>,SootMethod, InterproceduralCFG<Unit,SootMethod>>(problem); long beforeSolver = System.nanoTime(); System.out.println("Running solver..."); solver.solve(); System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds."); SootMethod meth = Scene.v().getMainClass().getMethodByName("main"); Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast()); results.addAll(solver.ifdsResultsAt(ret)); } })); final String sootcp = codeDir + File.separator + "bin" + File.pathSeparator + JUNIT_DIR + "/lib/hamcrest-core-1.3.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\jce.jar"; System.out.println("Soot classpath: " + sootcp); soot.Main.v().run(new String[] { "-W", "-main-class", CLASS_NAME, "-process-path", codeDir + File.separator + "classes", "-src-prec", "java", // "-pp", "-cp", sootcp, "-no-bodies-for-excluded", "-exclude", "java", "-exclude", "javax", "-output-format", "none", "-p", "jb", "use-original-names:true", "-p", "cg.spark", "on", // "-p", "cg.spark", "verbose:true", CLASS_NAME } ); return results; }
private Set<Local> computeResults(final String codeDir) { // extractVersion(codeDir); soot.G.reset(); final Set<Local> results = new HashSet<Local>(); PackManager.v().getPack("wjtp").add(new Transform("wjtp.ifds", new SceneTransformer() { protected void internalTransform(String phaseName, @SuppressWarnings("rawtypes") Map options) { // Scene.v().getSootClass(className).setApplicationClass(); System.out.println("Running IFDS on initial CFG..."); long nanoBeforeCFG = System.nanoTime(); InterproceduralCFG<Unit, SootMethod> icfg = new JimpleBasedInterproceduralCFG(); System.out.println("ICFG created in " + (System.nanoTime() - nanoBeforeCFG) / 1E9 + " seconds."); IFDSTabulationProblem<Unit, Local, SootMethod, InterproceduralCFG<Unit, SootMethod>> problem = new IFDSUninitializedVariables(icfg); IFDSSolver<Unit,Local,SootMethod,InterproceduralCFG<Unit,SootMethod>> solver = new IFDSSolver<Unit,Local,SootMethod,InterproceduralCFG<Unit,SootMethod>>(problem); long beforeSolver = System.nanoTime(); System.out.println("Running solver..."); solver.solve(); System.out.println("Solver done in " + ((System.nanoTime() - beforeSolver) / 1E9) + " seconds."); SootMethod meth = Scene.v().getMainClass().getMethodByName("runMainAndExit"); Unit ret = meth.getActiveBody().getUnits().getPredOf(meth.getActiveBody().getUnits().getLast()); results.addAll(solver.ifdsResultsAt(ret)); } })); final String sootcp = codeDir + File.pathSeparator + JUNIT_DIR + "/hamcrest-core-1.3.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/rt.jar" + File.pathSeparator + "/usr/lib/jvm/java-6-sun/jre/lib/jce.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\rt.jar" + File.pathSeparator + "C:\\Program Files\\Java\\jre7\\lib\\jce.jar"; System.out.println("Soot classpath: " + sootcp); soot.Main.v().run(new String[] { "-W", "-main-class", CLASS_NAME, "-process-path", codeDir, "-src-prec", "java", // "-pp", "-cp", sootcp, // "-no-bodies-for-excluded", // "-exclude", "java", // "-exclude", "javax", "-output-format", "none", "-p", "jb", "use-original-names:true", "-p", "cg.spark", "on", // "-p", "cg.spark", "verbose:true", CLASS_NAME } ); return results; }
/** * Sets the interprocedural control flow graph for the analysis. * * @param icfg The interprocedural CFG. */ public void setIcfg(JimpleBasedInterproceduralCFG icfg) { this.icfg = icfg; }
/** * Gets the interprocedural control flow graph for the analysis. * * @return The interprocedural control flow graph. */ public JimpleBasedInterproceduralCFG getIcfg() { return icfg; }