Skip to content

Commit 21ff6de

Browse files
committed
added a convenience method to create a summary query from a call site
1 parent 5fb28dc commit 21ff6de

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/data/sourceSink/AbstractFlowSinkSource.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,4 +292,5 @@ public Local getBaseLocal(Stmt stmt) {
292292
}
293293
return null;
294294
}
295+
295296
}

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/taintWrappers/resolvers/SummaryQuery.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package soot.jimple.infoflow.methodSummary.taintWrappers.resolvers;
22

3+
import soot.RefType;
34
import soot.SootClass;
5+
import soot.SootMethod;
6+
import soot.Type;
7+
import soot.jimple.InstanceInvokeExpr;
8+
import soot.jimple.InvokeExpr;
9+
import soot.jimple.Stmt;
410

511
/**
612
* Query that retrieves summaries for a given class and method.
@@ -20,6 +26,30 @@ public SummaryQuery(SootClass calleeClass, SootClass declaredClass, String subsi
2026
this.subsignature = subsignature;
2127
}
2228

29+
/**
30+
* Creates a new summary query from a given call site. This method can be used
31+
* to query summaries for all potential callees of the given call site.
32+
*
33+
* @param stmt The call site
34+
* @return The summary query that corresponds to the given call site
35+
*/
36+
public static SummaryQuery fromStmt(Stmt stmt) {
37+
if (stmt != null && stmt.containsInvokeExpr()) {
38+
InvokeExpr iexpr = stmt.getInvokeExpr();
39+
SootClass declaredClass = null;
40+
if (iexpr instanceof InstanceInvokeExpr) {
41+
InstanceInvokeExpr iiexpr = (InstanceInvokeExpr) iexpr;
42+
Type baseType = iiexpr.getBase().getType();
43+
if (baseType instanceof RefType)
44+
declaredClass = ((RefType) baseType).getSootClass();
45+
}
46+
SootMethod callee = iexpr.getMethod();
47+
SootClass calleeClass = callee.getDeclaringClass();
48+
return new SummaryQuery(calleeClass, declaredClass, callee.getSubSignature());
49+
}
50+
return null;
51+
}
52+
2353
@Override
2454
public String toString() {
2555
StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)