protected void internalApply() { CGOptions options = new CGOptions(PhaseOptions.v().getPhaseOptions(this)); if (!Scene.v().hasCustomEntryPoints()) { if (!options.implicit_entry()) { Scene.v().setEntryPoints(EntryPoints.v().application()); } if (options.all_reachable()) { List<SootMethod> entryPoints = new ArrayList<SootMethod>(); entryPoints.addAll(EntryPoints.v().all()); entryPoints.addAll(EntryPoints.v().methodsOfApplicationClasses()); Scene.v().setEntryPoints(entryPoints); } } super.internalApply(); ClinitElimTransformer trimmer = new ClinitElimTransformer(); if (options.trim_clinit()) { for (SootClass cl : Scene.v().getClasses(SootClass.BODIES)) { for (SootMethod m : cl.getMethods()) { if (m.isConcrete() && m.hasActiveBody()) { trimmer.transform(m.getActiveBody()); } } } } } }
@Override public void computeInfoflow(String appPath, String libPath, IEntryPointCreator entryPointCreator, ISourceSinkManager sourcesSinks) { if (sourcesSinks == null) { logger.error("Sources are empty!"); return; } initializeSoot(appPath, libPath, entryPointCreator.getRequiredClasses()); // entryPoints are the entryPoints required by Soot to calculate Graph - // if there is no main method, we have to create a new main method and // use it as entryPoint and store our real entryPoints this.dummyMainMethod = entryPointCreator.createDummyMain(); this.additionalEntryPointMethods = entryPointCreator.getAdditionalMethods(); Scene.v().setEntryPoints(Collections.singletonList(dummyMainMethod)); // Run the analysis runAnalysis(sourcesSinks, null); }
@Override public void computeInfoflow(String appPath, String libPath, String entryPoint, ISourceSinkManager sourcesSinks) { if (sourcesSinks == null) { logger.error("Sources are empty!"); return; } initializeSoot(appPath, libPath, SootMethodRepresentationParser.v() .parseClassNames(Collections.singletonList(entryPoint), false).keySet(), entryPoint); if (!Scene.v().containsMethod(entryPoint)) { logger.error("Entry point not found: " + entryPoint); return; } SootMethod ep = Scene.v().getMethod(entryPoint); if (ep.isConcrete()) ep.retrieveActiveBody(); else { logger.debug("Skipping non-concrete method " + ep); return; } this.dummyMainMethod = null; Scene.v().setEntryPoints(Collections.singletonList(ep)); Options.v().set_main_class(ep.getDeclaringClass().getName()); // Compute the additional seeds if they are specified Set<String> seeds = Collections.emptySet(); if (entryPoint != null && !entryPoint.isEmpty()) seeds = Collections.singleton(entryPoint); ipcManager.updateJimpleForICC(); // Run the analysis runAnalysis(sourcesSinks, seeds); }
protected void internalApply() { CGOptions options = new CGOptions( PhaseOptions.v().getPhaseOptions(this) ); if(!Scene.v().hasCustomEntryPoints()) { if(!options.implicit_entry()) { Scene.v().setEntryPoints(EntryPoints.v().application()); } if( options.all_reachable() ) { List<SootMethod> entryPoints = new ArrayList<SootMethod>(); entryPoints.addAll( EntryPoints.v().all() ); entryPoints.addAll( EntryPoints.v().methodsOfApplicationClasses() ); Scene.v().setEntryPoints( entryPoints ); } } super.internalApply(); ClinitElimTransformer trimmer = new ClinitElimTransformer(); if( options.trim_clinit() ) { for (SootClass cl : Scene.v().getClasses(SootClass.BODIES)) { for( Iterator mIt = cl.getMethods().iterator(); mIt.hasNext(); ) { final SootMethod m = (SootMethod) mIt.next(); if( m.isConcrete() && m.hasActiveBody() ) { trimmer.transform( m.getActiveBody() ); } } } } } }
protected void internalApply() { CGOptions options = new CGOptions( PhaseOptions.v().getPhaseOptions(this) ); if(!Scene.v().hasCustomEntryPoints()) { if(!options.implicit_entry()) { Scene.v().setEntryPoints(EntryPoints.v().application()); } if( options.all_reachable() ) { List<SootMethod> entryPoints = new ArrayList<SootMethod>(); entryPoints.addAll( EntryPoints.v().all() ); entryPoints.addAll( EntryPoints.v().methodsOfApplicationClasses() ); Scene.v().setEntryPoints( entryPoints ); } } super.internalApply(); ClinitElimTransformer trimmer = new ClinitElimTransformer(); if( options.trim_clinit() ) { for (SootClass cl : Scene.v().getClasses(SootClass.BODIES)) { for( Iterator mIt = cl.getMethods().iterator(); mIt.hasNext(); ) { final SootMethod m = (SootMethod) mIt.next(); if( m.isConcrete() && m.hasActiveBody() ) { trimmer.transform( m.getActiveBody() ); } } } } } }
Scene.v().setEntryPoints(entryPoints);
/** * Creates the main method based on the current callback information, injects it * into the Soot scene. * * @param The class name of a component to create a main method containing only * that component, or null to create main method for all components */ private void createMainMethod(SootClass component) { // There is no need to create a main method if we don't want to generate // a callgraph if (config.getSootIntegrationMode() == SootIntegrationMode.UseExistingCallgraph) return; // Always update the entry point creator to reflect the newest set // of callback methods entryPointCreator = createEntryPointCreator(component); SootMethod dummyMainMethod = entryPointCreator.createDummyMain(); Scene.v().setEntryPoints(Collections.singletonList(dummyMainMethod)); if (!dummyMainMethod.getDeclaringClass().isInScene()) Scene.v().addClass(dummyMainMethod.getDeclaringClass()); // addClass() declares the given class as a library class. We need to // fix this. dummyMainMethod.getDeclaringClass().setApplicationClass(); }
Scene.v().setEntryPoints(entryPoints);
@Override protected void initializeAnalysis(A commandLineArguments) { addSceneTransformer(); Options.v().set_no_bodies_for_excluded(true); Options.v().set_allow_phantom_refs(true); Options.v().set_output_format(Options.output_format_none); Options.v().set_whole_program(true); Options.v().set_soot_classpath( commandLineArguments.getInput() + File.pathSeparator + commandLineArguments.getClasspath()); Options.v().setPhaseOption("cg.spark", "on"); // do not merge variables (causes problems with PointsToSets) Options.v().setPhaseOption("jb.ulp", "off"); // Options.v().setPhaseOption("jb.ne", "off"); Options.v().setPhaseOption("jb.uce", "remove-unreachable-traps:true"); Options.v().setPhaseOption("cg", "trim-clinit:false"); Options.v().set_prepend_classpath(true); Options.v().set_src_prec(Options.src_prec_java); for (String analysisClass : AnalysisParameters.v().getAnalysisClasses()) { SootClass sootClass = Scene.v().loadClassAndSupport(analysisClass); Scene.v().forceResolve(analysisClass, SootClass.BODIES); sootClass.setApplicationClass(); } Scene.v().loadNecessaryClasses(); Scene.v().setMainClassFromOptions(); Scene.v().setEntryPoints(EntryPoints.v().application()); }