Class AbstractInfoflow

java.lang.Object
soot.jimple.infoflow.AbstractInfoflow
All Implemented Interfaces:
IInfoflow, ITaintWrapperDataFlowAnalysis
Direct Known Subclasses:
BackwardsInfoflow, Infoflow

public abstract class AbstractInfoflow extends Object implements IInfoflow
Abstract base class for all data/information flow analyses in FlowDroid
Author:
Steven Arzt
  • Field Details

  • Constructor Details

    • AbstractInfoflow

      public AbstractInfoflow()
      Creates a new instance of the abstract info flow problem
    • AbstractInfoflow

      public AbstractInfoflow(BiDirICFGFactory icfgFactory, File androidPath, boolean forceAndroidJar)
      Creates a new instance of the abstract info flow problem
      Parameters:
      icfgFactory - The interprocedural CFG to be used by the InfoFlowProblem
      androidPath - If forceAndroidJar is false, this is the base directory of the platform files in the Android SDK. If forceAndroidJar is true, this is the full path of a single android.jar file.
      forceAndroidJar - True if a single platform JAR file shall be forced, false if Soot shall pick the appropriate platform version
  • Method Details

    • getConfig

      public InfoflowConfiguration getConfig()
      Description copied from interface: IInfoflow
      Gets the configuration to be used for the data flow analysis
      Specified by:
      getConfig in interface IInfoflow
      Returns:
      The configuration to be used for the data flow analysis
    • setConfig

      public void setConfig(InfoflowConfiguration config)
      Description copied from interface: IInfoflow
      Sets the configuration to be used for the data flow analysis
      Specified by:
      setConfig in interface IInfoflow
      Parameters:
      config - The configuration to be used for the data flow analysis
    • setTaintWrapper

      public void setTaintWrapper(ITaintPropagationWrapper wrapper)
      Description copied from interface: ITaintWrapperDataFlowAnalysis
      Sets the taint wrapper to be used for propagating taints over unknown (library) callees. If this value is null, no taint wrapping is used.
      Specified by:
      setTaintWrapper in interface ITaintWrapperDataFlowAnalysis
      Parameters:
      wrapper - The taint wrapper to use or null to disable taint wrapping
    • setNativeCallHandler

      public void setNativeCallHandler(INativeCallHandler handler)
      Description copied from interface: IInfoflow
      Sets the handler class to be used for modeling the effects of native methods on the taint state
      Specified by:
      setNativeCallHandler in interface IInfoflow
      Parameters:
      handler - The native call handler to use
    • getTaintWrapper

      public ITaintPropagationWrapper getTaintWrapper()
      Description copied from interface: ITaintWrapperDataFlowAnalysis
      Gets the taint wrapper to be used for propagating taints over unknown (library) callees. If this value is null, no taint wrapping is used.
      Specified by:
      getTaintWrapper in interface ITaintWrapperDataFlowAnalysis
      Returns:
      The taint wrapper to use or null if taint wrapping is disabled
    • addPreprocessor

      public void addPreprocessor(PreAnalysisHandler preprocessor)
      Description copied from interface: IInfoflow
      Add a preprocessor that need to be executed in order before the information flow.
      Specified by:
      addPreprocessor in interface IInfoflow
      Parameters:
      preprocessor - the pre-processor
    • addPostProcessor

      public void addPostProcessor(PostAnalysisHandler postprocessor)
      Description copied from interface: IInfoflow
      Adds a post-processor that shall be executed after the data flow analysis has finished
      Specified by:
      addPostProcessor in interface IInfoflow
      Parameters:
      postprocessor - The post-processor to execute on the results
    • computeInfoflow

      public void computeInfoflow(String appPath, String libPath, IEntryPointCreator entryPointCreator, List<String> sources, List<String> sinks)
      Description copied from interface: IInfoflow
      Computes the information flow on a list of entry point methods. This list is used to construct an artificial main method following the Android life cycle for all methods that are detected to be part of Android's application infrastructure (e.g. android.app.Activity.onCreate)
      Specified by:
      computeInfoflow in interface IInfoflow
      Parameters:
      appPath - The path containing the client program's files
      libPath - The path to the main folder of the (unpacked) library class files
      entryPointCreator - the entry point creator to use for generating the dummy main method
      sources - list of source class+method (as string conforms to SootMethod representation)
      sinks - list of sink class+method (as string conforms to SootMethod representation)
    • computeInfoflow

      public void computeInfoflow(String appPath, String libPath, Collection<String> entryPoints, Collection<String> sources, Collection<String> sinks)
      Description copied from interface: IInfoflow
      Computes the information flow on a list of entry point methods. This list is used to construct an artificial main method following the Android life cycle for all methods that are detected to be part of Android's application infrastructure (e.g. android.app.Activity.onCreate)
      Specified by:
      computeInfoflow in interface IInfoflow
      Parameters:
      appPath - The path containing the client program's files
      libPath - the path to the main folder of the (unpacked) library class files
      entryPoints - the entryPoints (string conforms to SootMethod representation)
      sources - list of source class+method (as string conforms to SootMethod representation)
      sinks - list of sink class+method (as string conforms to SootMethod representation)
    • computeInfoflow

      public void computeInfoflow(String libPath, String appPath, String entryPoint, Collection<String> sources, Collection<String> sinks)
      Description copied from interface: IInfoflow
      Computes the information flow on a single method. This method is directly taken as the entry point into the program, even if it is an instance method.
      Specified by:
      computeInfoflow in interface IInfoflow
      Parameters:
      libPath - The path containing the client program's files
      appPath - the path to the main folder of the (unpacked) library class files
      entryPoint - the main method to analyze
      sources - list of source class+method (as string conforms to SootMethod representation)
      sinks - list of sink class+method (as string conforms to SootMethod representation)
    • initializeSoot

      protected void initializeSoot(String appPath, String libPath, Collection<String> classes)
      Initializes Soot.
      Parameters:
      appPath - The application path containing the analysis client
      libPath - The Soot classpath containing the libraries
      classes - The set of classes that shall be checked for data flow analysis seeds. All sources in these classes are used as seeds.
    • initializeSoot

      protected void initializeSoot(String appPath, String libPath, Collection<String> classes, String extraSeed)
      Initializes Soot.
      Parameters:
      appPath - The application path containing the analysis client
      libPath - The Soot classpath containing the libraries
      classes - The set of classes that shall be checked for data flow analysis seeds. All sources in these classes are used as seeds. If a non-empty extra seed is given, this one is used too.
    • setSourcePrec

      protected void setSourcePrec()
    • setGeomPtaSpecificOptions

      public static void setGeomPtaSpecificOptions()
    • setSootConfig

      public void setSootConfig(IInfoflowConfig config)
      Description copied from interface: IInfoflow
      Sets the Soot configuration callback to be used for this analysis
      Specified by:
      setSootConfig in interface IInfoflow
      Parameters:
      config - The configuration callback to be used for the analysis
    • setIPCManager

      public void setIPCManager(IIPCManager ipcManager)
      Specified by:
      setIPCManager in interface IInfoflow
    • setPathBuilderFactory

      public void setPathBuilderFactory(IPathBuilderFactory factory)
      Description copied from interface: IInfoflow
      Sets the path builder factory to be used in subsequent data flow analyses
      Specified by:
      setPathBuilderFactory in interface IInfoflow
      Parameters:
      factory - The path bilder factory to use for constructing path reconstruction algorithms
    • constructCallgraph

      protected void constructCallgraph()
      Constructs the callgraph
    • patchDynamicInvokeInstructions

      protected static void patchDynamicInvokeInstructions(soot.Body body)
      Patches the dynamic invocation instructions in the given method body
      Parameters:
      body - The method body in which to patch the dynamic invocation instructions
    • getLibraryClassPatcher

      protected LibraryClassPatcher getLibraryClassPatcher()
    • setMemoryManagerFactory

      public void setMemoryManagerFactory(IMemoryManagerFactory factory)
      Description copied from interface: IInfoflow
      Sets the factory to be used for creating memory managers
      Specified by:
      setMemoryManagerFactory in interface IInfoflow
      Parameters:
      factory - The memory manager factory to use
    • computeInfoflow

      public void computeInfoflow(String appPath, String libPath, IEntryPointCreator entryPointCreator, ISourceSinkManager sourcesSinks)
      Description copied from interface: IInfoflow
      Computes the information flow on a list of entry point methods. This list is used to construct an artificial main method following the Android life cycle for all methods that are detected to be part of Android's application infrastructure (e.g. android.app.Activity.onCreate)
      Specified by:
      computeInfoflow in interface IInfoflow
      Parameters:
      appPath - The path containing the client program's files
      libPath - the path to the main folder of the (unpacked) library class files
      entryPointCreator - the entry point creator to use for generating the dummy main method
      sourcesSinks - manager class for identifying sources and sinks in the source code
    • computeInfoflow

      public void computeInfoflow(String appPath, String libPath, String entryPoint, ISourceSinkManager sourcesSinks)
      Description copied from interface: IInfoflow
      Computes the information flow on a single method. This method is directly taken as the entry point into the program, even if it is an instance method.
      Specified by:
      computeInfoflow in interface IInfoflow
      Parameters:
      appPath - The path containing the client program's files
      libPath - the path to the main folder of the (unpacked) library class files
      entryPoint - the main method to analyze
      sourcesSinks - manager class for identifying sources and sinks in the source code
    • runAnalysis

      protected void runAnalysis(ISourceSinkManager sourcesSinks)
      Conducts a taint analysis on an already initialized callgraph
      Parameters:
      sourcesSinks - The sources and sinks to be used
    • runAnalysis

      protected void runAnalysis(ISourceSinkManager sourcesSinks, Set<String> additionalSeeds)
      Conducts a taint analysis on an already initialized callgraph
      Parameters:
      sourcesSinks - The sources and sinks to be used
      additionalSeeds - Additional seeds at which to create A ZERO fact even if they are not sources
    • createNewThread

      protected Thread createNewThread(Runnable r)
    • createInfoflowProblem

      protected abstract AbstractInfoflowProblem createInfoflowProblem(Abstraction zeroValue)
      Creates the problem for the IFDS taint propagation problem
      Parameters:
      zeroValue - The taint abstraction for the tautology
      Returns:
      The IDFS problem
    • createReverseInfoflowProblem

      protected AbstractInfoflowProblem createReverseInfoflowProblem(InfoflowManager manager, Abstraction zeroValue)
      Creates the reverse problem for the IFDS taint propagation problem
      Parameters:
      zeroValue - The taint abstraction for the tautology
      Returns:
      The IDFS problem
    • createDataFlowSolver

      protected IInfoflowSolver createDataFlowSolver(InterruptableExecutor executor, AbstractInfoflowProblem problem, InfoflowConfiguration.SolverConfiguration solverConfig)
      Creates the instance of the data flow solver
      Parameters:
      executor - The executor on which the solver shall run its tasks
      problem - The problem to be solved by the new solver
      solverConfig - The solver configuration
      Returns:
      The new data flow solver
    • scanStmtForSourcesSinks

      protected abstract AbstractInfoflow.SourceOrSink scanStmtForSourcesSinks(ISourceSinkManager sourcesSinks, soot.jimple.Stmt s)
      Checks whether the given statement is a source or a sink
      Parameters:
      sourcesSinks - The source/sink manager
      s - The statement to check
      Returns:
      An enumeration value that defines whether the given statement is a source, a sink, or neither
    • getMethodsForSeeds

      protected Collection<soot.SootMethod> getMethodsForSeeds(IInfoflowCFG icfg)
      Given a callgraph, obtains all methods that may contain sources, i.e., statements that can serve as seeds for the taint propagation.
      Parameters:
      icfg - The interprocedural control flow graph
      Returns:
      The methods that may contain seeds
    • isValidSeedMethod

      protected boolean isValidSeedMethod(soot.SootMethod sm)
      Gets whether the given method is a valid seen when scanning for sources and sinks. A method is a valid seed it it (or one of its transitive callees) can contain calls to source or sink methods.
      Parameters:
      sm - The method to check
      Returns:
      True if this method or one of its transitive callees can contain sources or sinks, otherwise false
    • isUserCodeClass

      protected boolean isUserCodeClass(String className)
      Checks whether the given class is user code and should not be filtered out. By default, this method assumes that all code is potentially user code.
      Parameters:
      className - The name of the class to check
      Returns:
      True if the given class is user code, false otherwise
    • eliminateDeadCode

      protected void eliminateDeadCode(ISourceSinkManager sourcesSinks)
      Runs all code optimizers
      Parameters:
      sourcesSinks - The SourceSinkManager
    • performCodeInstrumentationBeforeDCE

      protected void performCodeInstrumentationBeforeDCE(InfoflowManager dceManager, Set<soot.SootMethod> excludedMethods)
      Allows subclasses to perform additional code instrumentation tasks
      Parameters:
      dceManager - The manager class for dead code elimination and instrumentation
      excludedMethods - The methods that shall not be modified
    • performCodeInstrumentationAfterDCE

      protected void performCodeInstrumentationAfterDCE(InfoflowManager dceManager, Set<soot.SootMethod> excludedMethods)
      Allows subclasses to perform additional code instrumentation tasks
      Parameters:
      dceManager - The manager class for dead code elimination and instrumentation
      excludedMethods - The methods that shall not be modified
    • createDataFlowSolver

      protected IInfoflowSolver createDataFlowSolver(InterruptableExecutor executor, AbstractInfoflowProblem problem)
      Creates the IFDS solver for the forward data flow problem
      Parameters:
      executor - The executor in which to run the tasks or propagating IFDS edges
      problem - The implementation of the forward problem
      Returns:
      The solver that solves the forward taint analysis problem
    • pathConfigToShorteningMode

      protected PredecessorShorteningMode pathConfigToShorteningMode(InfoflowConfiguration.PathConfiguration pathConfiguration)
      Gets the path shortening mode that shall be applied given a certain path reconstruction configuration. This method computes the most aggressive path shortening that is possible without eliminating data that is necessary for the requested path reconstruction.
      Parameters:
      pathConfiguration - The path reconstruction configuration
      Returns:
      The computed path shortening mode
    • createMemoryManager

      protected IMemoryManager<Abstraction,soot.Unit> createMemoryManager()
      Creates the memory manager that helps reduce the memory consumption of the data flow analysis
      Returns:
      The memory manager object
    • releaseCallgraph

      protected void releaseCallgraph()
      Releases the callgraph and all intermediate objects associated with it
    • createPerformanceDataClass

      protected InfoflowPerformanceData createPerformanceDataClass()
      Factory method for creating the data object that will receive the data flow solver's performance data
      Returns:
      The data object for the performance data
    • setExecutorFactory

      public void setExecutorFactory(IExecutorFactory executorFactory)
      Description copied from interface: IInfoflow
      Sets the factory to be used for creating thread pool executors
      Specified by:
      setExecutorFactory in interface IInfoflow
      Parameters:
      executorFactory - The executor factory to use
    • setPropagationRuleManagerFactory

      public void setPropagationRuleManagerFactory(IPropagationRuleManagerFactory ruleManagerFactory)
      Description copied from interface: IInfoflow
      Sets the factory to be used for creating the propagation rule manager, which can then add features to the core data flow engine
      Specified by:
      setPropagationRuleManagerFactory in interface IInfoflow
      Parameters:
      ruleManagerFactory - The factory class for the propagation rule manager
    • getCollectedSources

      public Set<soot.jimple.Stmt> getCollectedSources()
      Description copied from interface: IInfoflow
      Gets the concrete set of sources that have been collected in preparation for the taint analysis. This method will return null if source and sink logging has not been enabled (see InfoflowConfiguration. setLogSourcesAndSinks()),
      Specified by:
      getCollectedSources in interface IInfoflow
      Returns:
      The set of sources collected for taint analysis
    • getCollectedSinks

      public Set<soot.jimple.Stmt> getCollectedSinks()
      Description copied from interface: IInfoflow
      Gets the concrete set of sinks that have been collected in preparation for the taint analysis. This method will return null if source and sink logging has not been enabled (see InfoflowConfiguration. setLogSourcesAndSinks()),
      Specified by:
      getCollectedSinks in interface IInfoflow
      Returns:
      The set of sinks collected for taint analysis
    • createResultsObject

      protected abstract InfoflowResults createResultsObject()
      Creates a new instance of the result class appropriate for the current data flow analysis
      Returns:
      The new result object
    • createAliasAnalysis

      protected abstract IAliasingStrategy createAliasAnalysis(ISourceSinkManager sourcesSinks, IInfoflowCFG iCfg, InterruptableExecutor executor, IMemoryManager<Abstraction,soot.Unit> memoryManager)
      Initializes the alias analysis
      Parameters:
      sourcesSinks - The set of sources and sinks
      iCfg - The interprocedural control flow graph
      executor - The executor in which to run concurrent tasks
      memoryManager - The memory manager for rducing the memory load during IFDS propagation
      Returns:
      The alias analysis implementation to use for the data flow analysis
    • createBackwardAliasAnalysis

      protected IAliasingStrategy createBackwardAliasAnalysis(InfoflowManager manager, ISourceSinkManager sourcesSinks, IInfoflowCFG iCfg, InterruptableExecutor executor, IMemoryManager<Abstraction,soot.Unit> memoryManager)
      Initializes the alias analysis for the backward direction
      Parameters:
      manager - The infoflow manager
      sourcesSinks - The set of sources and sinks
      iCfg - The interprocedural control flow graph
      executor - The executor in which to run concurrent tasks
      memoryManager - The memory manager for reducing the memory load during IFDS propagation
      Returns:
      The backward alias analysis implementation
    • createAliasController

      protected Aliasing createAliasController(IAliasingStrategy aliasingStrategy)
      Creates the controller object that handles aliasing operations. Derived classes can override this method to supply custom aliasing implementations.
      Parameters:
      aliasingStrategy - The aliasing strategy to use
      Returns:
      The new alias controller object
    • addResultsAvailableHandler

      public void addResultsAvailableHandler(ResultsAvailableHandler handler)
      Description copied from interface: IInfoflow
      Adds a handler that is called when information flow results are available
      Specified by:
      addResultsAvailableHandler in interface IInfoflow
      Parameters:
      handler - The handler to add
    • setTaintPropagationHandler

      public void setTaintPropagationHandler(TaintPropagationHandler handler)
      Description copied from interface: IInfoflow
      Sets a handler which is invoked whenever a taint is propagated
      Specified by:
      setTaintPropagationHandler in interface IInfoflow
      Parameters:
      handler - The handler to be invoked when propagating taints
    • setAliasPropagationHandler

      public void setAliasPropagationHandler(TaintPropagationHandler handler)
      Description copied from interface: IInfoflow
      Sets a handler which is invoked whenever an alias is propagated
      Specified by:
      setAliasPropagationHandler in interface IInfoflow
      Parameters:
      handler - The handler to be invoked when propagating aliases
    • removeResultsAvailableHandler

      public void removeResultsAvailableHandler(ResultsAvailableHandler handler)
      Description copied from interface: IInfoflow
      Removes a handler that is called when information flow results are available
      Specified by:
      removeResultsAvailableHandler in interface IInfoflow
      Parameters:
      handler - The handler to remove
    • getResults

      public InfoflowResults getResults()
      Description copied from interface: IInfoflow
      getResults returns the results found by the analysis
      Specified by:
      getResults in interface IInfoflow
      Returns:
      the results
    • isResultAvailable

      public boolean isResultAvailable()
      Description copied from interface: IInfoflow
      A result is available if the analysis has finished - so if this method returns false the analysis has not finished yet or was not started (e.g. no sources or sinks found)
      Specified by:
      isResultAvailable in interface IInfoflow
      Returns:
      boolean that states if a result is available
    • abortAnalysis

      public void abortAnalysis()
      Description copied from interface: IInfoflow
      Aborts the data flow analysis. This is useful when the analysis controller is running in a different thread and the main thread (e.g., a GUI) wants to abort the analysis
      Specified by:
      abortAnalysis in interface IInfoflow
    • setThrowExceptions

      public void setThrowExceptions(boolean b)
    • initializeInfoflowManager

      protected abstract InfoflowManager initializeInfoflowManager(ISourceSinkManager sourcesSinks, IInfoflowCFG iCfg, GlobalTaintManager globalTaintManager)
      Initializes the data flow manager with which propagation rules can interact with the data flow engine
      Parameters:
      sourcesSinks - The source/sink definitions
      iCfg - The interprocedural control flow graph
      globalTaintManager - The manager object for storing and processing global taints
      Returns:
      The data flow manager
    • initializeReverseInfoflowManager

      protected InfoflowManager initializeReverseInfoflowManager(IInfoflowCFG iCfg, GlobalTaintManager globalTaintManager)
    • onBeforeTaintPropagation

      protected void onBeforeTaintPropagation(IInfoflowSolver forwardSolver, IInfoflowSolver backwardSolver)
      Callback that is invoked when the main taint propagation is about to start
      Parameters:
      forwardSolver - The forward data flow solver
      backwardSolver - The backward data flow solver
    • onTaintPropagationCompleted

      protected void onTaintPropagationCompleted(IInfoflowSolver forwardSolver, IInfoflowSolver aliasSolver, IInfoflowSolver backwardSolver, IInfoflowSolver backwardAliasSolver)
      Callback that is invoked when the main taint propagation has completed. This method is called before memory cleanup happens.
      Parameters:
      forwardSolver - The forward data flow solver
      backwardSolver - The backward data flow solver
    • createPathBuilder

      protected IAbstractionPathBuilder createPathBuilder(InterruptableExecutor executor)
      Creates the path builder that shall be used for path reconstruction
      Parameters:
      executor - The execute in which to run the parallel path reconstruction tasks
      Returns:
      The path builder implementation
    • initializeRuleManagerFactory

      protected abstract IPropagationRuleManagerFactory initializeRuleManagerFactory()
      Initializes an appropriate instance of the rule manager factory
      Returns:
      The rule manager factory
    • initializeReverseRuleManagerFactory

      protected IPropagationRuleManagerFactory initializeReverseRuleManagerFactory()
      Initializes an appropriate instance of the rule manager factory
      Returns:
      The rule manager factory
    • setUsageContextProvider

      public void setUsageContextProvider(IUsageContextProvider usageContextProvider)
      Description copied from interface: IInfoflow
      Sets the usage context provider
      Specified by:
      setUsageContextProvider in interface IInfoflow
      Parameters:
      usageContextProvider - The usage context provider object