/*** * Static method to create AndroidMethod from Soot method signature * * @param signature * The Soot method signature * @return The new AndroidMethod object */ public static AndroidMethod createFromSignature(String signature) { if (!signature.startsWith("<")) signature = "<" + signature; if (!signature.endsWith(">")) signature = signature + ">"; SootMethodAndClass smac = SootMethodRepresentationParser.v().parseSootMethodString(signature); return new AndroidMethod(smac.getMethodName(), smac.getParameters(), smac.getReturnType(), smac.getClassName()); }
String className = method.getClassName(); boolean isMethodWithoutReturnType = returnType == null || returnType.isEmpty(); if (isMethodWithoutReturnType) { String className = method.getClassName(); String subSignatureWithoutReturnType = (((MethodSourceSinkDefinition) sourceSinkDef) .getMethod().getSubSignature());
SootMethod methodToInvoke = findMethod(Scene.v().getSootClass(methodAndClass.getClassName()), methodAndClass.getSubSignature());
Local local = this.localVarsForClasses.get(methodAndClass.getClassName()); if (local == null) { System.err.println("Could not create call to application callback "
for (String method : entry.getValue()) { SootMethodAndClass methodAndClass = SootMethodRepresentationParser.v().parseSootMethodString(method); SootMethod currentMethod = findMethod(Scene.v().getSootClass(methodAndClass.getClassName()), methodAndClass.getSubSignature()); if (currentMethod == null) {
@Test(timeout=300000) public void testParser(){ String s = "<soot.jimple.infoflow.test.TestNoMain: java.lang.String function1()>"; SootMethodRepresentationParser parser = SootMethodRepresentationParser.v(); SootMethodAndClass result = parser.parseSootMethodString(s); assertEquals("soot.jimple.infoflow.test.TestNoMain", result.getClassName()); assertEquals("function1", result.getMethodName()); assertEquals("java.lang.String", result.getReturnType()); }
/** * Checks for errors inside this data flow summary */ public void validate() { source().validate(methodSig); sink().validate(methodSig); // Make sure that the types of gap base objects and incoming flows are // cast-compatible if (sink().getType() == SourceSinkType.GapBaseObject && sink().getGap() != null) { String sinkType = SootMethodRepresentationParser.v().parseSootMethodString(sink().getGap().getSignature()) .getClassName(); Type t1 = RefType.v(sink().getBaseType()); Type t2 = RefType.v(sinkType); if (!Scene.v().getFastHierarchy().canStoreType(t1, t2) // cast-up, // i.e. // Object to // String && !Scene.v().getFastHierarchy().canStoreType(t2, t1)) // cast-down, // i.e. // String // to // Object throw new RuntimeException("Target type of gap base flow is invalid"); } }
/** * Gets the flow summaries for the given gap definition, i.e., for the method in * the gap * * @param gap The gap definition * @return The flow summaries for the method in the given gap if they exist, * otherwise null */ private MethodSummaries getFlowSummariesForGap(GapDefinition gap) { // If we have the method in Soot, we can be more clever if (Scene.v().containsMethod(gap.getSignature())) { SootMethod gapMethod = Scene.v().getMethod(gap.getSignature()); ClassSummaries flows = getFlowSummariesForMethod(null, gapMethod, null); if (flows != null && !flows.isEmpty()) { MethodSummaries summaries = new MethodSummaries(); summaries.mergeSummaries(flows.getAllMethodSummaries()); return summaries; } } // If we don't have the method, we can only directly look for the // signature SootMethodAndClass smac = SootMethodRepresentationParser.v().parseSootMethodString(gap.getSignature()); ClassMethodSummaries cms = flows.getMethodFlows(smac.getClassName(), smac.getSubSignature()); return cms == null ? null : cms.getMethodSummaries(); }
else { SootMethodAndClass methodAndClass = SootMethodRepresentationParser.v().parseSootMethodString(method); if (!Scene.v().containsClass(methodAndClass.getClassName())) { logger.warn("Class for entry point {} not found, skipping...", method); continue; sm = findMethod(Scene.v().getSootClass(methodAndClass.getClassName()), methodAndClass.getSubSignature()); if (sm == null) {