Skip to content

Commit 9a72ad4

Browse files
committed
Make FlowDroid's Android entry point creator more extensible
1 parent 8be54a4 commit 9a72ad4

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/AbstractAndroidEntryPointCreator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ public AbstractAndroidEntryPointCreator(IManifestHandler manifest) {
2929
@Override
3030
public SootMethod createDummyMain() {
3131
// Initialize the utility class
32-
this.entryPointUtils = new AndroidEntryPointUtils();
32+
this.entryPointUtils = createEntryPointUtils();
3333

3434
return super.createDummyMain();
3535
}
3636

37+
protected AndroidEntryPointUtils createEntryPointUtils() {
38+
return new AndroidEntryPointUtils();
39+
}
40+
3741
protected Stmt searchAndBuildMethod(String subsignature, Local classLocal) {
3842
return searchAndBuildMethod(subsignature, classLocal, Collections.<SootClass>emptySet());
3943
}

soot-infoflow-android/src/soot/jimple/infoflow/android/entryPointCreators/AndroidEntryPointUtils.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ public ComponentType getComponentType(SootClass currentClass) {
9696

9797
// Check the type of this class
9898
ComponentType ctype = ComponentType.Plain;
99-
FastHierarchy fh = Scene.v().getOrMakeFastHierarchy();
99+
FastHierarchy fh = getFastHierarchy();
100100

101101
if (fh != null) {
102102
// We first look for the specialized types
103103

104104
// (a1) android.app.Fragment
105-
if (osClassFragment != null && Scene.v().getOrMakeFastHierarchy().canStoreType(currentClass.getType(),
106-
osClassFragment.getType()))
105+
if (osClassFragment != null
106+
&& getFastHierarchy().canStoreType(currentClass.getType(), osClassFragment.getType()))
107107
ctype = ComponentType.Fragment;
108108
else if (osClassSupportFragment != null
109109
&& fh.canStoreType(currentClass.getType(), osClassSupportFragment.getType()))
@@ -168,7 +168,7 @@ else if (osClassContentProvider != null
168168
*/
169169
public boolean isApplicationClass(SootClass clazz) {
170170
return osClassApplication != null
171-
&& Scene.v().getOrMakeFastHierarchy().canStoreType(clazz.getType(), osClassApplication.getType());
171+
&& getFastHierarchy().canStoreType(clazz.getType(), osClassApplication.getType());
172172
}
173173

174174
/**
@@ -180,7 +180,7 @@ public boolean isApplicationClass(SootClass clazz) {
180180
*/
181181
public boolean isComponentFactoryClass(SootClass clazz) {
182182
return osClassComponentFactory != null
183-
&& Scene.v().getOrMakeFastHierarchy().canStoreType(clazz.getType(), osClassComponentFactory.getType());
183+
&& getFastHierarchy().canStoreType(clazz.getType(), osClassComponentFactory.getType());
184184
}
185185

186186
/**
@@ -291,7 +291,7 @@ private static Collection<? extends MethodOrMethodContext> getLifecycleMethods(S
291291
SootMethodRepresentationParser parser = SootMethodRepresentationParser.v();
292292

293293
Scene scene = Scene.v();
294-
FastHierarchy fh = Scene.v().getOrMakeFastHierarchy();
294+
FastHierarchy fh = scene.getOrMakeFastHierarchy();
295295
nextMethod: for (String sig : methods) {
296296
SootClass currentClass = sc;
297297
String name = parser.getMethodNameFromSubSignature(sig);
@@ -328,6 +328,14 @@ private static Collection<? extends MethodOrMethodContext> getLifecycleMethods(S
328328
return lifecycleMethods;
329329
}
330330

331+
/**
332+
* Returns the used fast hierarchy
333+
* @return the used fast hierarchy
334+
*/
335+
protected FastHierarchy getFastHierarchy() {
336+
return Scene.v().getOrMakeFastHierarchy();
337+
}
338+
331339
/**
332340
* Checks whether a method is potentially callable from JavaScript
333341
* @param m the method

0 commit comments

Comments
 (0)