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
  • Field Details

    • sourceDefs

      protected soot.util.MultiMap<String,ISourceSinkDefinition> sourceDefs
    • sinkDefs

      protected soot.util.MultiMap<String,ISourceSinkDefinition> sinkDefs
    • sourceMethods

      protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> sourceMethods
    • sourceCallbackMethods

      protected Map<soot.SootMethod,ISourceSinkDefinition> sourceCallbackMethods
    • sourceStatements

      protected soot.util.MultiMap<soot.jimple.Stmt,ISourceSinkDefinition> sourceStatements
    • sinkMethods

      protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> sinkMethods
    • sinkReturnMethods

      protected soot.util.MultiMap<soot.SootMethod,ISourceSinkDefinition> sinkReturnMethods
    • callbackMethods

      protected Map<soot.SootMethod,CallbackDefinition> callbackMethods
    • sourceFields

      protected soot.util.MultiMap<soot.SootField,ISourceSinkDefinition> sourceFields
    • sinkFields

      protected soot.util.MultiMap<soot.SootField,ISourceSinkDefinition> sinkFields
    • sinkStatements

      protected soot.util.MultiMap<soot.jimple.Stmt,ISourceSinkDefinition> sinkStatements
    • conditionalSinks

      protected Set<soot.SootMethod> conditionalSinks
    • conditionalSinkToExcludedClasses

      protected soot.util.MultiMap<soot.SootMethod,soot.SootClass> conditionalSinkToExcludedClasses
    • secondarySinkMethods

      protected Set<soot.SootMethod> secondarySinkMethods
    • secondarySinkClasses

      protected Set<soot.SootClass> secondarySinkClasses
    • sourceSinkConfig

      protected final InfoflowConfiguration.SourceSinkConfiguration sourceSinkConfig
    • excludedMethods

      protected final Set<soot.SootMethod> excludedMethods
    • oneSourceAtATime

      protected boolean oneSourceAtATime
    • osaatType

      protected BaseSourceSinkManager.SourceType osaatType
    • osaatIterator

      protected Iterator<soot.SootMethod> osaatIterator
    • currentSource

      protected soot.SootMethod currentSource
    • valueProvider

      protected IValueProvider valueProvider
    • parentClassesAndInterfaces

      protected final com.google.common.cache.LoadingCache<soot.SootClass,Collection<soot.SootClass>> parentClassesAndInterfaces
  • Constructor Details

  • 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 site
      manager - The manager object providing access to the configuration and the interprocedural control flow graph
      ap - 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

      public SinkInfo getSinkInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager, AccessPath ap)
      Description copied from interface: ISourceSinkManager
      Checks if the given access path at this statement will leak.
      Specified by:
      getSinkInfo in interface ISourceSinkManager
      Parameters:
      sCallSite - The call site to check
      manager - The manager object for interacting with the solver
      ap - 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: IReversibleSourceSinkManager
      Determines whether this is a source resulting in a leak for backwards search. Creating a SinkInfo using source signatures.
      Specified by:
      getInverseSourceInfo in interface IReversibleSourceSinkManager
      Parameters:
      sCallSite - a Stmt which should include an invokeExrp calling a method
      manager - The manager object for interacting with the solver
      ap - 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

      public SourceInfo getSourceInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager)
      Description copied from interface: ISourceSinkManager
      Determines if a method called by the Stmt is a source method or not. If so, additional information is returned
      Specified by:
      getSourceInfo in interface ISourceSinkManager
      Parameters:
      sCallSite - a Stmt which should include an invokeExrp calling a method
      manager - The manager object for interacting with the solver
      Returns:
      A SourceInfo object containing additional information if this call is a source, otherwise null
    • getInverseSinkInfo

      public SourceInfo getInverseSinkInfo(soot.jimple.Stmt sCallSite, InfoflowManager manager)
      Description copied from interface: IReversibleSourceSinkManager
      Determines 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:
      getInverseSinkInfo in interface IReversibleSourceSinkManager
      Parameters:
      sCallSite - The call site to check
      manager - 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

      protected Collection<ISourceSinkDefinition> getSourceMethod(soot.SootMethod method)
      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

      protected Collection<ISourceSinkDefinition> getInverseSourceMethod(soot.SootMethod method)
    • getSourceDefinition

      protected Collection<ISourceSinkDefinition> getSourceDefinition(soot.SootMethod method)
      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

      protected CallbackDefinition getCallbackDefinition(soot.SootMethod method)
      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

      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. If so, the source definition is returned, otherwise null
      Parameters:
      sCallSite - The statement to check for a source
      cfg - 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 check
      cfg - 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

      protected ISourceSinkDefinition getUISourceDefinition(soot.jimple.Stmt sCallSite, IInfoflowCFG cfg)
      Checks whether the given call site indicates a UI source, e.g. a password input. If so, creates an ISourceSinkDefinition for it
      Parameters:
      sCallSite - The call site that may potentially read data from a sensitive UI control
      cfg - The bidirectional control flow graph
      Returns:
      The generated ISourceSinkDefinition if the given call site reads data from a UI source, null otherwise
    • initialize

      public void initialize()
      Description copied from interface: ISourceSinkManager
      Initialization method that is called after the Soot instance has been created and before the actual data flow tracking is started.
      Specified by:
      initialize in interface ISourceSinkManager
    • setOneSourceAtATimeEnabled

      public void setOneSourceAtATimeEnabled(boolean enabled)
      Description copied from interface: IOneSourceAtATimeManager
      Sets whether this source/sink manager shall run with one source at a time instead of all of them together
      Specified by:
      setOneSourceAtATimeEnabled in interface IOneSourceAtATimeManager
      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: IOneSourceAtATimeManager
      Gets whether this source/sink manager shall run with one source at a time instead of all of them together
      Specified by:
      isOneSourceAtATimeEnabled in interface IOneSourceAtATimeManager
      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: IOneSourceAtATimeManager
      Resets the iterator. This means that the source/sink manager starts again with the first source.
      Specified by:
      resetCurrentSource in interface IOneSourceAtATimeManager
    • nextSource

      public void nextSource()
      Description copied from interface: IOneSourceAtATimeManager
      Advances the iterator to the next source.
      Specified by:
      nextSource in interface IOneSourceAtATimeManager
    • hasNextSource

      public boolean hasNextSource()
      Description copied from interface: IOneSourceAtATimeManager
      Checks whether there is another source with which to run the data flow analysis
      Specified by:
      hasNextSource in interface IOneSourceAtATimeManager
      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: IConditionalFlowManager
      Checks if a sink is reached in the secondary flow
      Specified by:
      isSecondarySink in interface IConditionalFlowManager
      Parameters:
      stmt - Sink Statement
      Returns:
      true if stmt is a secondary sink
    • registerSecondarySink

      public void registerSecondarySink(soot.jimple.Stmt stmt)
      Description copied from interface: IConditionalFlowManager
      Register a secondary sink at runtime.
      Specified by:
      registerSecondarySink in interface IConditionalFlowManager
      Parameters:
      stmt - Secondary sink statement
    • registerSecondarySink

      public void registerSecondarySink(soot.SootMethod sm)
      Description copied from interface: IConditionalFlowManager
      Register a secondary sink at runtime.
      Specified by:
      registerSecondarySink in interface IConditionalFlowManager
      Parameters:
      sm - Secondary sink method
    • isConditionalSink

      public boolean isConditionalSink(soot.jimple.Stmt stmt, soot.SootClass baseClass)
      Description copied from interface: IConditionalFlowManager
      Checks whether stmt is a conditional sink and needs a secondary flow. Ensures that the statement contains a InstanceInvokeExpr.
      Specified by:
      isConditionalSink in interface IConditionalFlowManager
      Parameters:
      stmt - Sink Statement
      baseClass - Class of the tainted base
      Returns:
      true if stmt is a conditional sink