Skip to content

Commit 989a6c9

Browse files
committed
added the ability to add custom watchers that may terminate the data flow analysis prematurely
1 parent 54bda3d commit 989a6c9

File tree

8 files changed

+522
-339
lines changed

8 files changed

+522
-339
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/SetupApplication.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import soot.Unit;
4141
import soot.jimple.Stmt;
4242
import soot.jimple.infoflow.AbstractInfoflow;
43+
import soot.jimple.infoflow.AnalysisPhase;
4344
import soot.jimple.infoflow.BackwardsInfoflow;
4445
import soot.jimple.infoflow.IInfoflow;
4546
import soot.jimple.infoflow.Infoflow;
@@ -93,6 +94,7 @@
9394
import soot.jimple.infoflow.handlers.ResultsAvailableHandler;
9495
import soot.jimple.infoflow.handlers.TaintPropagationHandler;
9596
import soot.jimple.infoflow.ipc.IIPCManager;
97+
import soot.jimple.infoflow.memory.AbstractSolverWatcher;
9698
import soot.jimple.infoflow.memory.FlowDroidMemoryWatcher;
9799
import soot.jimple.infoflow.memory.FlowDroidTimeoutWatcher;
98100
import soot.jimple.infoflow.memory.IMemoryBoundedSolver;
@@ -156,6 +158,7 @@ public class SetupApplication implements ITaintWrapperDataFlowAnalysis {
156158
protected Set<ResultsAvailableHandler> resultsAvailableHandlers = new HashSet<>();
157159
protected TaintPropagationHandler taintPropagationHandler = null;
158160
protected TaintPropagationHandler aliasPropagationHandler = null;
161+
protected MultiMap<AnalysisPhase, AbstractSolverWatcher> customWatchers = new HashMultiMap<>();
159162

160163
protected IUsageContextProvider usageContextProvider = null;
161164

@@ -1772,6 +1775,7 @@ public void performCodeInstrumentationAfterDCE(InfoflowManager manager,
17721775
info.setTaintPropagationHandler(taintPropagationHandler);
17731776
info.setAliasPropagationHandler(aliasPropagationHandler);
17741777
info.setUsageContextProvider(usageContextProvider);
1778+
info.addSolverWatchers(customWatchers);
17751779

17761780
// We use a specialized memory manager that knows about Android
17771781
info.setMemoryManagerFactory(new IMemoryManagerFactory() {
@@ -2089,4 +2093,15 @@ protected void tagUserCodeClasses() {
20892093
appClass.addTag(FlowDroidUserClass.v());
20902094
}
20912095
}
2096+
2097+
/**
2098+
* Registers an analysis watcher with the data flow engine
2099+
*
2100+
* @param watcher The watcher to register
2101+
* @param analysisPhase The analysis phase for which the watcher is applicable
2102+
*/
2103+
public void addSolverWatcher(AbstractSolverWatcher watcher, AnalysisPhase analysisPhase) {
2104+
this.customWatchers.put(analysisPhase, watcher);
2105+
}
2106+
20922107
}

0 commit comments

Comments
 (0)