Class BaseSourceSinkManager
java.lang.Object
soot.jimple.infoflow.sourcesSinks.manager.BaseSourceSinkManager
- All Implemented Interfaces:
IConditionalFlowManager,IOneSourceAtATimeManager,IReversibleSourceSinkManager,ISourceSinkManager
public abstract class BaseSourceSinkManager
extends Object
implements IReversibleSourceSinkManager, IOneSourceAtATimeManager, IConditionalFlowManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumTypes of sources supported by this SourceSinkManager -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<soot.SootMethod,CallbackDefinition> protected Set<soot.SootMethod>protected soot.util.MultiMap<soot.SootMethod,soot.SootClass> protected soot.SootMethodprotected final Set<soot.SootMethod>protected booleanprotected Iterator<soot.SootMethod>protected BaseSourceSinkManager.SourceTypeprotected final com.google.common.cache.LoadingCache<soot.SootClass,Collection<soot.SootClass>> protected Set<soot.SootClass>protected Set<soot.SootMethod>protected soot.util.MultiMap<String,ISourceSinkDefinition> protected soot.util.MultiMap<soot.SootField,ISourceSinkDefinition> protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> protected soot.util.MultiMap<soot.jimple.Stmt,ISourceSinkDefinition> protected Map<soot.SootMethod,ISourceSinkDefinition> protected soot.util.MultiMap<String,ISourceSinkDefinition> protected soot.util.MultiMap<soot.SootField,ISourceSinkDefinition> protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> protected final InfoflowConfiguration.SourceSinkConfigurationprotected soot.util.MultiMap<soot.jimple.Stmt,ISourceSinkDefinition> protected IValueProvider -
Constructor Summary
ConstructorsConstructorDescriptionBaseSourceSinkManager(Collection<? extends ISourceSinkDefinition> sources, Collection<? extends ISourceSinkDefinition> sinks, Set<? extends CallbackDefinition> callbackMethods, InfoflowConfiguration config) Creates a new instance of theBaseSourceSinkManagerclass with strong matching, i.e. the methods in the code must exactly match those in the list.BaseSourceSinkManager(Collection<? extends ISourceSinkDefinition> sources, Collection<? extends ISourceSinkDefinition> sinks, InfoflowConfiguration config) Creates a new instance of theBaseSourceSinkManagerclass with either strong or weak matching. -
Method Summary
Modifier and TypeMethodDescriptionprotected ISourceSinkDefinitioncheckCallbackParamSource(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) Checks whether the given statement obtains data from a callback sourceprotected Collection<heros.solver.Pair<AccessPath,ISourceSinkDefinition>> createInverseSinkInfoPairs(soot.jimple.Stmt sCallSite, InfoflowManager manager, Collection<ISourceSinkDefinition> defs) protected Collection<heros.solver.Pair<AccessPath,ISourceSinkDefinition>> createSourceInfoPairs(soot.jimple.Stmt sCallSite, InfoflowManager manager, Collection<ISourceSinkDefinition> defs) voidexcludeMethod(soot.SootMethod toExclude) Excludes the given method from the source/sink analysis.protected CallbackDefinitiongetCallbackDefinition(soot.SootMethod method) Checks whether the given method is registered as a callback method.protected Collection<ISourceSinkDefinition>getInverseSinkDefinition(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) getInverseSinkInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager) Determines if a method called by the Stmt is a sink method or not.protected Collection<ISourceSinkDefinition>getInverseSourceDefinition(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) getInverseSourceInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) Determines whether this is a source resulting in a leak for backwards search.protected Collection<ISourceSinkDefinition>getInverseSourceMethod(soot.SootMethod method) protected Collection<ISourceSinkDefinition>getSinkDefinitions(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) Gets the sink definition for the given call site and tainted access pathgetSinkInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) Checks if the given access path at this statement will leak.protected Collection<ISourceSinkDefinition>getSource(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) Checks whether the given statement is a source, i.e. introduces new information into the application.protected Collection<ISourceSinkDefinition>getSourceDefinition(soot.SootMethod method) Checks whether the given method is registered as a source methodgetSourceInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager) Determines if a method called by the Stmt is a source method or not.protected Collection<ISourceSinkDefinition>getSourceMethod(soot.SootMethod method) Checks whether the given method is registered as a source method.protected ISourceSinkDefinitiongetUISourceDefinition(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) Checks whether the given call site indicates a UI source, e.g. a password input.booleanChecks whether there is another source with which to run the data flow analysisvoidInitialization method that is called after the Soot instance has been created and before the actual data flow tracking is started.booleanisConditionalSink(soot.jimple.Stmt stmt, soot.SootClass baseClass) Checks whether stmt is a conditional sink and needs a secondary flow.protected abstract booleanisEntryPointMethod(soot.SootMethod method) Checks whether the given method is an entry point, i.e., a lifecycle methodbooleanGets whether this source/sink manager shall run with one source at a time instead of all of them togetherbooleanisSecondarySink(soot.jimple.Stmt stmt) Checks if a sink is reached in the secondary flowvoidAdvances the iterator to the next source.voidregisterSecondarySink(soot.jimple.Stmt stmt) Register a secondary sink at runtime.voidregisterSecondarySink(soot.SootMethod sm) Register a secondary sink at runtime.voidResets the iterator.voidsetOneSourceAtATimeEnabled(boolean enabled) Sets whether this source/sink manager shall run with one source at a time instead of all of them together
-
Field Details
-
sourceDefs
-
sinkDefs
-
sourceMethods
-
sourceCallbackMethods
-
sourceStatements
-
sinkMethods
-
sinkReturnMethods
-
callbackMethods
-
sourceFields
-
sinkFields
-
sinkStatements
-
conditionalSinks
-
conditionalSinkToExcludedClasses
protected soot.util.MultiMap<soot.SootMethod,soot.SootClass> conditionalSinkToExcludedClasses -
secondarySinkMethods
-
secondarySinkClasses
-
sourceSinkConfig
-
excludedMethods
-
oneSourceAtATime
protected boolean oneSourceAtATime -
osaatType
-
osaatIterator
-
currentSource
protected soot.SootMethod currentSource -
valueProvider
-
parentClassesAndInterfaces
protected final com.google.common.cache.LoadingCache<soot.SootClass,Collection<soot.SootClass>> parentClassesAndInterfaces
-
-
Constructor Details
-
BaseSourceSinkManager
public BaseSourceSinkManager(Collection<? extends ISourceSinkDefinition> sources, Collection<? extends ISourceSinkDefinition> sinks, InfoflowConfiguration config) Creates a new instance of theBaseSourceSinkManagerclass with either strong or weak matching.- Parameters:
sources- The list of source methodssinks- The list of sink methodsconfig- The configuration of the data flow analyzer
-
BaseSourceSinkManager
public BaseSourceSinkManager(Collection<? extends ISourceSinkDefinition> sources, Collection<? extends ISourceSinkDefinition> sinks, Set<? extends CallbackDefinition> callbackMethods, InfoflowConfiguration config) Creates a new instance of theBaseSourceSinkManagerclass with strong matching, i.e. the methods in the code must exactly match those in the list.- Parameters:
sources- The list of source methodssinks- The list of sink methodscallbackMethods- The list of callback methods whose parameters are sources through which the application receives data from the operating systemconfig- The configuration of the data flow analyzer
-
-
Method Details
-
getSinkDefinitions
protected Collection<ISourceSinkDefinition> getSinkDefinitions(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) Gets the sink definition for the given call site and tainted access path- Parameters:
sCallSite- The call sitemanager- The manager object providing access to the configuration and the interprocedural control flow graphap- The incoming tainted access path- Returns:
- The sink definition of the method that is called at the given call site if such a definition exists, otherwise null
-
getInverseSourceDefinition
protected Collection<ISourceSinkDefinition> getInverseSourceDefinition(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) -
getSinkInfo
Description copied from interface:ISourceSinkManagerChecks if the given access path at this statement will leak.- Specified by:
getSinkInfoin interfaceISourceSinkManager- Parameters:
sCallSite- The call site to checkmanager- The manager object for interacting with the solverap- The access path to check. Pass null to check whether the given statement can be a sink for any given access path.- Returns:
- A SinkInfo object containing additional information if this call is a sink, otherwise null
-
getInverseSourceInfo
public SinkInfo getInverseSourceInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap) Description copied from interface:IReversibleSourceSinkManagerDetermines whether this is a source resulting in a leak for backwards search. Creating a SinkInfo using source signatures.- Specified by:
getInverseSourceInfoin interfaceIReversibleSourceSinkManager- Parameters:
sCallSite- a Stmt which should include an invokeExrp calling a methodmanager- The manager object for interacting with the solverap- The access path to check. Pass null to check whether the given statement can be a sink for any given access path.- Returns:
- A SourceInfo object containing additional information if this call is a source, otherwise null
-
getSourceInfo
Description copied from interface:ISourceSinkManagerDetermines if a method called by the Stmt is a source method or not. If so, additional information is returned- Specified by:
getSourceInfoin interfaceISourceSinkManager- Parameters:
sCallSite- a Stmt which should include an invokeExrp calling a methodmanager- The manager object for interacting with the solver- Returns:
- A SourceInfo object containing additional information if this call is a source, otherwise null
-
getInverseSinkInfo
Description copied from interface:IReversibleSourceSinkManagerDetermines if a method called by the Stmt is a sink method or not. If so, additional information is returned to introduce a taint. Creating a SourceInfo using sink signatures- Specified by:
getInverseSinkInfoin interfaceIReversibleSourceSinkManager- Parameters:
sCallSite- The call site to checkmanager- The manager object for interacting with the solver- Returns:
- A SinkInfo object containing additional information if this call is a sink, otherwise null
-
createSourceInfoPairs
protected Collection<heros.solver.Pair<AccessPath,ISourceSinkDefinition>> createSourceInfoPairs(soot.jimple.Stmt sCallSite, InfoflowManager manager, Collection<ISourceSinkDefinition> defs) -
createInverseSinkInfoPairs
protected Collection<heros.solver.Pair<AccessPath,ISourceSinkDefinition>> createInverseSinkInfoPairs(soot.jimple.Stmt sCallSite, InfoflowManager manager, Collection<ISourceSinkDefinition> defs) -
getSourceMethod
Checks whether the given method is registered as a source method. If so, returns the corresponding definition, otherwise null.- Parameters:
method- The method to check- Returns:
- The respective source definition if the given method is a source method, otherwise null
-
getInverseSourceMethod
-
getSourceDefinition
Checks whether the given method is registered as a source method- Parameters:
method- The method to check- Returns:
- True if the given method is a source method, otherwise false
-
getCallbackDefinition
Checks whether the given method is registered as a callback method. If so, the corresponding source definition is returned, otherwise null is returned.- Parameters:
method- The method to check- Returns:
- The source definition object if the given method is a callback method, otherwise null
-
getSource
Checks whether the given statement is a source, i.e. introduces new information into the application. If so, the source definition is returned, otherwise null- Parameters:
sCallSite- The statement to check for a sourcecfg- An interprocedural CFG containing the statement- Returns:
- The definition of the discovered source if the given statement is a source, null otherwise
-
getInverseSinkDefinition
protected Collection<ISourceSinkDefinition> getInverseSinkDefinition(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) -
checkCallbackParamSource
protected ISourceSinkDefinition checkCallbackParamSource(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg) Checks whether the given statement obtains data from a callback source- Parameters:
sCallSite- The statement to checkcfg- The interprocedural control flow graph- Returns:
- The source and sink definition that corresponds to the detected callback source if the given statement is a source, otherwise null
-
isEntryPointMethod
protected abstract boolean isEntryPointMethod(soot.SootMethod method) Checks whether the given method is an entry point, i.e., a lifecycle method- Parameters:
method- the method- Returns:
- true if the method is an entry point
-
getUISourceDefinition
Checks whether the given call site indicates a UI source, e.g. a password input. If so, creates anISourceSinkDefinitionfor it- Parameters:
sCallSite- The call site that may potentially read data from a sensitive UI controlcfg- The bidirectional control flow graph- Returns:
- The generated
ISourceSinkDefinitionif the given call site reads data from a UI source, null otherwise
-
initialize
public void initialize()Description copied from interface:ISourceSinkManagerInitialization method that is called after the Soot instance has been created and before the actual data flow tracking is started.- Specified by:
initializein interfaceISourceSinkManager
-
setOneSourceAtATimeEnabled
public void setOneSourceAtATimeEnabled(boolean enabled) Description copied from interface:IOneSourceAtATimeManagerSets whether this source/sink manager shall run with one source at a time instead of all of them together- Specified by:
setOneSourceAtATimeEnabledin interfaceIOneSourceAtATimeManager- Parameters:
enabled- True to return only one source at a time and hide all other ones, otherwise false
-
isOneSourceAtATimeEnabled
public boolean isOneSourceAtATimeEnabled()Description copied from interface:IOneSourceAtATimeManagerGets whether this source/sink manager shall run with one source at a time instead of all of them together- Specified by:
isOneSourceAtATimeEnabledin interfaceIOneSourceAtATimeManager- Returns:
- True to return only one source at a time and hide all other ones, otherwise false
-
resetCurrentSource
public void resetCurrentSource()Description copied from interface:IOneSourceAtATimeManagerResets the iterator. This means that the source/sink manager starts again with the first source.- Specified by:
resetCurrentSourcein interfaceIOneSourceAtATimeManager
-
nextSource
public void nextSource()Description copied from interface:IOneSourceAtATimeManagerAdvances the iterator to the next source.- Specified by:
nextSourcein interfaceIOneSourceAtATimeManager
-
hasNextSource
public boolean hasNextSource()Description copied from interface:IOneSourceAtATimeManagerChecks whether there is another source with which to run the data flow analysis- Specified by:
hasNextSourcein interfaceIOneSourceAtATimeManager- Returns:
- True if there is another source with which to run the data flow analysis, otherwise false
-
excludeMethod
public void excludeMethod(soot.SootMethod toExclude) Excludes the given method from the source/sink analysis. No sources or sinks will be detected in excluded methods.- Parameters:
toExclude- The method to exclude
-
isSecondarySink
public boolean isSecondarySink(soot.jimple.Stmt stmt) Description copied from interface:IConditionalFlowManagerChecks if a sink is reached in the secondary flow- Specified by:
isSecondarySinkin interfaceIConditionalFlowManager- Parameters:
stmt- Sink Statement- Returns:
- true if stmt is a secondary sink
-
registerSecondarySink
public void registerSecondarySink(soot.jimple.Stmt stmt) Description copied from interface:IConditionalFlowManagerRegister a secondary sink at runtime.- Specified by:
registerSecondarySinkin interfaceIConditionalFlowManager- Parameters:
stmt- Secondary sink statement
-
registerSecondarySink
public void registerSecondarySink(soot.SootMethod sm) Description copied from interface:IConditionalFlowManagerRegister a secondary sink at runtime.- Specified by:
registerSecondarySinkin interfaceIConditionalFlowManager- Parameters:
sm- Secondary sink method
-
isConditionalSink
public boolean isConditionalSink(soot.jimple.Stmt stmt, soot.SootClass baseClass) Description copied from interface:IConditionalFlowManagerChecks whether stmt is a conditional sink and needs a secondary flow. Ensures that the statement contains a InstanceInvokeExpr.- Specified by:
isConditionalSinkin interfaceIConditionalFlowManager- Parameters:
stmt- Sink StatementbaseClass- Class of the tainted base- Returns:
- true if stmt is a conditional sink
-