Skip to content

Commit 15ac8a7

Browse files
committed
refactored the SummarySourceSinkManager to use an external re-usable resolver
1 parent 273fbba commit 15ac8a7

File tree

6 files changed

+533
-389
lines changed

6 files changed

+533
-389
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
import java.util.HashMap;
44
import java.util.Map;
55

6+
import soot.Local;
7+
import soot.Value;
8+
import soot.jimple.AssignStmt;
9+
import soot.jimple.InstanceInvokeExpr;
10+
import soot.jimple.InvokeExpr;
11+
import soot.jimple.Stmt;
612
import soot.jimple.infoflow.methodSummary.data.summary.GapDefinition;
713
import soot.jimple.infoflow.methodSummary.data.summary.SourceSinkType;
814
import soot.jimple.infoflow.methodSummary.taintWrappers.AccessPathFragment;
@@ -251,4 +257,39 @@ public Object getUserData() {
251257
*/
252258
public abstract AbstractFlowSinkSource replaceGaps(Map<Integer, GapDefinition> replacementMap);
253259

260+
/**
261+
* Gets the base local for the access path that this source or sink definition
262+
* references
263+
*
264+
* @param stmt The context in which to map the definition to concrete locals
265+
* @return The local that resembles the base local of this source or sink
266+
* definition in the given context or <code>null</code> if this
267+
* definition is not valid in the given context
268+
*/
269+
public Local getBaseLocal(Stmt stmt) {
270+
if (stmt.containsInvokeExpr()) {
271+
InvokeExpr iexpr = stmt.getInvokeExpr();
272+
if (isField()) {
273+
if (iexpr instanceof InstanceInvokeExpr) {
274+
InstanceInvokeExpr iiexpr = (InstanceInvokeExpr) iexpr;
275+
return (Local) iiexpr.getBase();
276+
}
277+
} else if (isParameter()) {
278+
int idx = getParameterIndex();
279+
if (idx < iexpr.getArgCount()) {
280+
Value val = iexpr.getArg(idx);
281+
if (val instanceof Local)
282+
return (Local) val;
283+
}
284+
} else if (isReturn()) {
285+
if (stmt instanceof AssignStmt) {
286+
AssignStmt assignStmt = (AssignStmt) stmt;
287+
Value lop = assignStmt.getLeftOp();
288+
if (lop instanceof Local)
289+
return (Local) lop;
290+
}
291+
}
292+
}
293+
return null;
294+
}
254295
}

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/taintWrappers/AccessPathFragment.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ public String getLastFieldName() {
120120
return fields[fields.length - 1];
121121
}
122122

123+
/**
124+
* Gets the name of the first field in this access path fragment
125+
*
126+
* @return The name of the first field in this access path fragment
127+
*/
128+
public String getFirstFieldName() {
129+
if (fields == null || fields.length == 0)
130+
return null;
131+
return fields[0];
132+
}
133+
123134
/**
124135
* Gets the type of the last field in this access path fragment
125136
*
@@ -131,6 +142,17 @@ public String getLastFieldType() {
131142
return fieldTypes[fieldTypes.length - 1];
132143
}
133144

145+
/**
146+
* Gets the type of the first field in this access path fragment
147+
*
148+
* @return The type of the first field in this access path fragment
149+
*/
150+
public String getFirstFieldType() {
151+
if (fieldTypes == null || fieldTypes.length == 0)
152+
return null;
153+
return fieldTypes[0];
154+
}
155+
134156
/**
135157
* Gets whether this access path fragment is empty
136158
*

0 commit comments

Comments
 (0)