/** * Adds a special edge of kind {@link Kind#REFL_CONSTR_NEWINSTANCE} to all possible target constructors of this call to * {@link Constructor#newInstance(Object...)}. Those kinds of edges are treated specially in terms of how parameters are * assigned, as parameters to the reflective call are passed into the argument array of * {@link Constructor#newInstance(Object...)}. * * @see PAG#addCallTarget(Edge) */ @Override public void contructorNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> constructorSignatures = reflectionInfo.constructorNewInstanceSignatures(container); if (constructorSignatures == null || constructorSignatures.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Constructor.newInstance(..) call site; Soot did not expect this site to be reached"); } else { for (String constructorSignature : constructorSignatures) { SootMethod constructor = Scene.v().getMethod(constructorSignature); addEdge(container, newInstanceInvokeStmt, constructor, Kind.REFL_CONSTR_NEWINSTANCE); } } }
public OnFlyCallGraphBuilder(ContextManager cm, ReachableMethods rm) { this.cm = cm; this.rm = rm; worklist = rm.listener(); options = new CGOptions(PhaseOptions.v().getPhaseOptions("cg")); if (!options.verbose()) { logger.debug("" + "[Call Graph] For information on where the call graph may be incomplete," + "use the verbose option to the cg phase."); } if (options.reflection_log() == null || options.reflection_log().length() == 0) { if (options.types_for_invoke() && new SparkOptions(PhaseOptions.v().getPhaseOptions("cg.spark")).enabled()) { reflectionModel = new TypeBasedReflectionModel(); } else { reflectionModel = new DefaultReflectionModel(); } } else { reflectionModel = new TraceBasedReflectionModel(); } this.fh = Scene.v().getOrMakeFastHierarchy(); }
/** * Adds a special edge of kind {@link Kind#REFL_CONSTR_NEWINSTANCE} to all possible target constructors * of this call to {@link Constructor#newInstance(Object...)}. * Those kinds of edges are treated specially in terms of how parameters are assigned, * as parameters to the reflective call are passed into the argument array of * {@link Constructor#newInstance(Object...)}. * @see PAG#addCallTarget(Edge) */ public void contructorNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> constructorSignatures = reflectionInfo.constructorNewInstanceSignatures(container); if(constructorSignatures==null || constructorSignatures.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Constructor.newInstance(..) call site; Soot did not expect this site to be reached"); } else { for (String constructorSignature : constructorSignatures) { SootMethod constructor = Scene.v().getMethod(constructorSignature); addEdge( container, newInstanceInvokeStmt, constructor, Kind.REFL_CONSTR_NEWINSTANCE ); } } }
/** * Adds an edge to the constructor of the target class from this call to * {@link Class#newInstance()}. */ public void classNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> classNames = reflectionInfo.classNewInstanceClassNames(container); if(classNames==null || classNames.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Class.newInstance() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { SootClass cls = Scene.v().getSootClass(clsName); if( cls.declaresMethod(sigInit) ) { SootMethod constructor = cls.getMethod(sigInit); addEdge( container, newInstanceInvokeStmt, constructor, Kind.REFL_CLASS_NEWINSTANCE ); } } } }
/** * Adds a special edge of kind {@link Kind#REFL_CONSTR_NEWINSTANCE} to all possible target constructors * of this call to {@link Constructor#newInstance(Object...)}. * Those kinds of edges are treated specially in terms of how parameters are assigned, * as parameters to the reflective call are passed into the argument array of * {@link Constructor#newInstance(Object...)}. * @see PAG#addCallTarget(Edge) */ public void contructorNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> constructorSignatures = reflectionInfo.constructorNewInstanceSignatures(container); if(constructorSignatures==null || constructorSignatures.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Constructor.newInstance(..) call site; Soot did not expect this site to be reached"); } else { for (String constructorSignature : constructorSignatures) { SootMethod constructor = Scene.v().getMethod(constructorSignature); addEdge( container, newInstanceInvokeStmt, constructor, Kind.REFL_CONSTR_NEWINSTANCE ); } } }
/** * Adds an edge to the constructor of the target class from this call to * {@link Class#newInstance()}. */ public void classNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> classNames = reflectionInfo.classNewInstanceClassNames(container); if(classNames==null || classNames.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Class.newInstance() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { SootClass cls = Scene.v().getSootClass(clsName); if( cls.declaresMethod(sigInit) ) { SootMethod constructor = cls.getMethod(sigInit); addEdge( container, newInstanceInvokeStmt, constructor, Kind.REFL_CLASS_NEWINSTANCE ); } } } }
/** * Adds a special edge of kind {@link Kind#REFL_INVOKE} to all possible target methods * of this call to {@link Method#invoke(Object, Object...)}. * Those kinds of edges are treated specially in terms of how parameters are assigned, * as parameters to the reflective call are passed into the argument array of * {@link Method#invoke(Object, Object...)}. * @see PAG#addCallTarget(Edge) */ public void methodInvoke(SootMethod container, Stmt invokeStmt) { Set<String> methodSignatures = reflectionInfo.methodInvokeSignatures(container); if (methodSignatures == null || methodSignatures.isEmpty()) { registerGuard(container, invokeStmt, "Method.invoke(..) call site; Soot did not expect this site to be reached"); } else { for (String methodSignature : methodSignatures) { SootMethod method = Scene.v().getMethod(methodSignature); addEdge( container, invokeStmt, method, Kind.REFL_INVOKE ); } } }
/** * Adds a special edge of kind {@link Kind#REFL_INVOKE} to all possible target methods * of this call to {@link Method#invoke(Object, Object...)}. * Those kinds of edges are treated specially in terms of how parameters are assigned, * as parameters to the reflective call are passed into the argument array of * {@link Method#invoke(Object, Object...)}. * @see PAG#addCallTarget(Edge) */ public void methodInvoke(SootMethod container, Stmt invokeStmt) { Set<String> methodSignatures = reflectionInfo.methodInvokeSignatures(container); if (methodSignatures == null || methodSignatures.isEmpty()) { registerGuard(container, invokeStmt, "Method.invoke(..) call site; Soot did not expect this site to be reached"); } else { for (String methodSignature : methodSignatures) { SootMethod method = Scene.v().getMethod(methodSignature); addEdge( container, invokeStmt, method, Kind.REFL_INVOKE ); } } }
/** * Adds an edge to all class initializers of all possible receivers * of Class.forName() calls within source. */ public void classForName(SootMethod container, Stmt forNameInvokeStmt) { Set<String> classNames = reflectionInfo.classForNameClassNames(container); if(classNames==null || classNames.isEmpty()) { registerGuard(container, forNameInvokeStmt, "Class.forName() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { constantForName( clsName, container, forNameInvokeStmt ); } } }
/** * Adds an edge to all class initializers of all possible receivers * of Class.forName() calls within source. */ public void classForName(SootMethod container, Stmt forNameInvokeStmt) { Set<String> classNames = reflectionInfo.classForNameClassNames(container); if(classNames==null || classNames.isEmpty()) { registerGuard(container, forNameInvokeStmt, "Class.forName() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { constantForName( clsName, container, forNameInvokeStmt ); } } }
/** * Adds a special edge of kind {@link Kind#REFL_INVOKE} to all possible target methods of this call to * {@link Method#invoke(Object, Object...)}. Those kinds of edges are treated specially in terms of how parameters are * assigned, as parameters to the reflective call are passed into the argument array of * {@link Method#invoke(Object, Object...)}. * * @see PAG#addCallTarget(Edge) */ @Override public void methodInvoke(SootMethod container, Stmt invokeStmt) { Set<String> methodSignatures = reflectionInfo.methodInvokeSignatures(container); if (methodSignatures == null || methodSignatures.isEmpty()) { registerGuard(container, invokeStmt, "Method.invoke(..) call site; Soot did not expect this site to be reached"); } else { for (String methodSignature : methodSignatures) { SootMethod method = Scene.v().getMethod(methodSignature); addEdge(container, invokeStmt, method, Kind.REFL_INVOKE); } } }
/** * Adds an edge to the constructor of the target class from this call to {@link Class#newInstance()}. */ @Override public void classNewInstance(SootMethod container, Stmt newInstanceInvokeStmt) { Set<String> classNames = reflectionInfo.classNewInstanceClassNames(container); if (classNames == null || classNames.isEmpty()) { registerGuard(container, newInstanceInvokeStmt, "Class.newInstance() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { SootClass cls = Scene.v().getSootClass(clsName); SootMethod constructor = cls.getMethodUnsafe(sigInit); if (constructor != null) { addEdge(container, newInstanceInvokeStmt, constructor, Kind.REFL_CLASS_NEWINSTANCE); } } } }
/** * Adds an edge to all class initializers of all possible receivers of Class.forName() calls within source. */ @Override public void classForName(SootMethod container, Stmt forNameInvokeStmt) { Set<String> classNames = reflectionInfo.classForNameClassNames(container); if (classNames == null || classNames.isEmpty()) { registerGuard(container, forNameInvokeStmt, "Class.forName() call site; Soot did not expect this site to be reached"); } else { for (String clsName : classNames) { constantForName(clsName, container, forNameInvokeStmt); } } }