Skip to content

Commit bae11fd

Browse files
committed
Remove manual resolving obsolete by injecting the hierarchy
1 parent 2296673 commit bae11fd

File tree

1 file changed

+2
-94
lines changed
  • soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/taintWrappers/resolvers

1 file changed

+2
-94
lines changed

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

Lines changed: 2 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,6 @@ private boolean getSummaries(final String methodSig, final ClassSummaries summar
9494
}
9595
}
9696

97-
// In case we don't have a real hierarchy, we must reconstruct one from the
98-
// summaries
99-
String curClass = clazz.getName();
100-
while (curClass != null) {
101-
ClassMethodSummaries classSummaries = flows.getClassFlows(curClass);
102-
if (classSummaries != null) {
103-
// Check for flows in the current class
104-
if (summaries.merge(flows.getMethodFlows(curClass, methodSig)))
105-
return true;
106-
107-
// Check for interfaces
108-
if (checkInterfacesFromSummary(methodSig, summaries, curClass))
109-
return true;
110-
111-
curClass = classSummaries.getSuperClass();
112-
} else
113-
break;
114-
}
115-
11697
return false;
11798
}
11899

@@ -180,39 +161,8 @@ private boolean checkInterfaces(String methodSig, ClassSummaries summaries, Soot
180161
}
181162
}
182163

183-
// We might not have hierarchy information in the scene, so let's check the
184-
// summary itself
185-
return checkInterfacesFromSummary(methodSig, summaries, clazz.getName());
186-
}
187-
188-
/**
189-
* Checks for summaries on the interfaces implemented by the given class. This
190-
* method relies on the hierarchy data from the summary XML files, rather than
191-
* the Soot scene
192-
*
193-
* @param methodSig The subsignature of the method for which to get summaries
194-
* @param summaries The summary object to which to add the discovered summaries
195-
* @param className The interface for which to look for summaries
196-
* @return True if summaries were found, false otherwise
197-
*/
198-
protected boolean checkInterfacesFromSummary(String methodSig, ClassSummaries summaries,
199-
String className) {
200-
List<String> interfaces = new ArrayList<>();
201-
interfaces.add(className);
202-
while (!interfaces.isEmpty()) {
203-
final String intfName = interfaces.remove(0);
204-
ClassMethodSummaries classSummaries = flows.getClassFlows(intfName);
205-
if (classSummaries != null && classSummaries.hasInterfaces()) {
206-
for (String intf : classSummaries.getInterfaces()) {
207-
// Do we have a summary on the current interface?
208-
if (summaries.merge(flows.getMethodFlows(intf, methodSig)))
209-
return true;
210-
211-
// Recursively check for more interfaces
212-
interfaces.add(intf);
213-
}
214-
}
215-
}
164+
// We inject the hierarchy from summaries before the data flow analysis, thus the
165+
// soot hierarchy already contains the manual information provided in the xmls.
216166
return false;
217167
}
218168

@@ -246,7 +196,6 @@ private Set<SootClass> getAllChildClasses(SootClass sc) {
246196
Set<SootClass> doneSet = new HashSet<SootClass>();
247197
Set<SootClass> classes = new HashSet<>();
248198

249-
final Scene scene = Scene.v();
250199
while (!workList.isEmpty()) {
251200
SootClass curClass = workList.remove(0);
252201
if (!doneSet.add(curClass))
@@ -255,36 +204,13 @@ private Set<SootClass> getAllChildClasses(SootClass sc) {
255204
if (curClass.isInterface()) {
256205
List<SootClass> hierarchyImplementers = hierarchy.getImplementersOf(curClass);
257206
workList.addAll(hierarchyImplementers);
258-
if (curClass.isPhantom() && hierarchyImplementers.isEmpty()) {
259-
// Query the hierarchy data in the summaries
260-
flows.getImplementersOfInterface(curClass.getName()).stream().map(c -> scene.getSootClassUnsafe(c))
261-
.filter(c -> c != null).forEach(c -> {
262-
workList.add(c);
263-
});
264-
}
265207

266208
List<SootClass> subinterfaces = hierarchy.getSubinterfacesOf(curClass);
267209
workList.addAll(subinterfaces);
268-
if (curClass.isPhantom() && subinterfaces.isEmpty()) {
269-
// Query the hierarchy data in the summaries
270-
flows.getSubInterfacesOf(curClass.getName()).stream().map(c -> scene.getSootClassUnsafe(c))
271-
.filter(c -> c != null).forEach(c -> {
272-
workList.add(c);
273-
});
274-
}
275210
} else {
276211
List<SootClass> hierarchyClasses = hierarchy.getSubclassesOf(curClass);
277212
workList.addAll(hierarchyClasses);
278213
classes.add(curClass);
279-
280-
if (curClass.isPhantom() && hierarchyClasses.isEmpty()) {
281-
// Query the hierarchy data in the summaries
282-
flows.getSubclassesOf(curClass.getName()).stream().map(c -> scene.getSootClassUnsafe(c))
283-
.filter(c -> c != null).forEach(c -> {
284-
workList.add(c);
285-
classes.add(c);
286-
});
287-
}
288214
}
289215
}
290216

@@ -305,7 +231,6 @@ private Set<SootClass> getAllParentClasses(SootClass sc) {
305231
Set<SootClass> doneSet = new HashSet<SootClass>();
306232
Set<SootClass> classes = new HashSet<>();
307233

308-
final Scene scene = Scene.v();
309234
while (!workList.isEmpty()) {
310235
SootClass curClass = workList.remove(0);
311236
if (!doneSet.add(curClass))
@@ -314,27 +239,10 @@ private Set<SootClass> getAllParentClasses(SootClass sc) {
314239
if (curClass.isInterface()) {
315240
List<SootClass> hierarchyClasses = hierarchy.getSuperinterfacesOf(curClass);
316241
workList.addAll(hierarchyClasses);
317-
318-
if (curClass.isPhantom() && hierarchyClasses.isEmpty()) {
319-
// Query the hierarchy data in the summaries
320-
flows.getSuperinterfacesOf(curClass.getName()).stream().map(c -> scene.getSootClassUnsafe(c))
321-
.filter(c -> c != null).forEach(c -> {
322-
workList.add(c);
323-
});
324-
}
325242
} else {
326243
List<SootClass> hierarchyClasses = hierarchy.getSuperclassesOf(curClass);
327244
workList.addAll(hierarchyClasses);
328245
classes.add(curClass);
329-
330-
if (curClass.isPhantom() && hierarchyClasses.isEmpty()) {
331-
// Query the hierarchy data in the summaries
332-
flows.getSuperclassesOf(curClass.getName()).stream().map(c -> scene.getSootClassUnsafe(c))
333-
.filter(c -> c != null).forEach(c -> {
334-
workList.add(c);
335-
classes.add(c);
336-
});
337-
}
338246
}
339247
}
340248

0 commit comments

Comments
 (0)