Class InfoflowConfiguration

java.lang.Object
soot.jimple.infoflow.InfoflowConfiguration

public class InfoflowConfiguration extends Object
Central configuration class for FlowDroid
Author:
Steven Arzt
  • Field Details

    • logger

      protected static final org.slf4j.Logger logger
  • Constructor Details

    • InfoflowConfiguration

      public InfoflowConfiguration()
  • Method Details

    • merge

      public void merge(InfoflowConfiguration config)
      Merges the given configuration options into this configuration object
      Parameters:
      config - The configuration data to merge in
    • setPathAgnosticResults

      public void setPathAgnosticResults(boolean pathAgnosticResults)
      Sets whether results (source-to-sink connections) that only differ in their propagation paths shall be merged into a single result or not.
      Parameters:
      pathAgnosticResults - True if two results shall be regarded as equal if they connect the same source and sink, even if their propagation paths differ, otherwise false
    • getPathAgnosticResults

      public boolean getPathAgnosticResults()
      Gets whether results (source-to-sink connections) that only differ in their propagation paths shall be merged into a single result or not.
      Returns:
      True if two results shall be regarded as equal if they connect the same source and sink, even if their propagation paths differ, otherwise false
    • getOneResultPerAccessPath

      public static boolean getOneResultPerAccessPath()
      Gets whether different results shall be reported if they only differ in the access path the reached the sink or left the source
      Returns:
      True if results shall also be distinguished based on access paths
    • setOneResultPerAccessPath

      public static void setOneResultPerAccessPath(boolean oneResultPerAP)
      Gets whether different results shall be reported if they only differ in the access path the reached the sink or left the source
      Parameters:
      oneResultPerAP - True if results shall also be distinguished based on access paths
    • setStopAfterFirstKFlows

      public void setStopAfterFirstKFlows(int stopAfterFirstKFlows)
      Sets after how many flows the information flow analysis shall stop.
      Parameters:
      stopAfterFirstKFlows - number of flows after which to stop
    • getStopAfterFirstKFlows

      public int getStopAfterFirstKFlows()
      Gets after how many flows the information flow analysis shall stop.
      Returns:
      number of flows after which to stop
    • setStopAfterFirstFlow

      public void setStopAfterFirstFlow(boolean stopAfterFirstFlow)
      Sets whether the information flow analysis shall stop after the first flow has been found
      Parameters:
      stopAfterFirstFlow - True if the analysis shall stop after the first flow has been found, otherwise false.
    • getStopAfterFirstFlow

      public boolean getStopAfterFirstFlow()
      Gets whether the information flow analysis shall stop after the first flow has been found
      Returns:
      True if the information flow analysis shall stop after the first flow has been found, otherwise false
    • setInspectSources

      public void setInspectSources(boolean inspect)
      Sets whether the implementations of source methods shall be analyzed as well
      Parameters:
      inspect - True if the implementations of source methods shall be analyzed as well, otherwise false
    • getInspectSources

      public boolean getInspectSources()
      Gets whether the implementations of source methods shall be analyzed as well
      Returns:
      True if the implementations of source methods shall be analyzed as well, otherwise false
    • setInspectSinks

      public void setInspectSinks(boolean inspect)
      Sets whether the implementations of sink methods shall be analyzed as well
      Parameters:
      inspect - True if the implementations of sink methods shall be analyzed as well, otherwise false
    • getInspectSinks

      public boolean getInspectSinks()
      Sets whether the implementations of sink methods shall be analyzed as well
      Returns:
      True if the implementations of sink methods shall be analyzed as well, otherwise false
    • setImplicitFlowMode

      public void setImplicitFlowMode(InfoflowConfiguration.ImplicitFlowMode implicitFlowMode)
      Sets the mode that defines whether and how the solver shall handle implicit flows
      Parameters:
      implicitFlowMode - The mode that defines whether and how the solver shall handle implicit flows
    • getImplicitFlowMode

      public InfoflowConfiguration.ImplicitFlowMode getImplicitFlowMode()
      Gets the mode that defines whether and how the solver shall handle implicit flows
      Returns:
      The mode that defines whether and how the solver shall handle implicit flows
    • setStaticFieldTrackingMode

      public void setStaticFieldTrackingMode(InfoflowConfiguration.StaticFieldTrackingMode staticFieldTrackingMode)
      Sets how the data flow solver shall treat assignments to static fields
      Parameters:
      staticFieldTrackingMode - The mode that specifies the precision with which assignments to static fields shall be handled
    • getStaticFieldTrackingMode

      public InfoflowConfiguration.StaticFieldTrackingMode getStaticFieldTrackingMode()
      Gets how the data flow solver shall treat assignments to static fields
      Returns:
      The mode that specifies the precision with which assignments to static fields shall be handled
    • setSootIntegrationMode

      public void setSootIntegrationMode(InfoflowConfiguration.SootIntegrationMode sootIntegrationMode)
      Sets how FlowDroid shall interact with the underlying Soot instance. FlowDroid can either set up Soot on its own, or work with an existing instance.
      Parameters:
      sootIntegrationMode - The integration mode that FlowDroid shall use
    • getSootIntegrationMode

      public InfoflowConfiguration.SootIntegrationMode getSootIntegrationMode()
      Gets how FloweDroid shall interact with the underlying Soot instance. FlowDroid can either set up Soot on its own, or work with an existing instance.
      Returns:
      The integration mode that FlowDroid shall use
    • setFlowSensitiveAliasing

      public void setFlowSensitiveAliasing(boolean flowSensitiveAliasing)
      Sets whether a flow sensitive aliasing algorithm shall be used
      Parameters:
      flowSensitiveAliasing - True if a flow sensitive aliasing algorithm shall be used, otherwise false
    • getFlowSensitiveAliasing

      public boolean getFlowSensitiveAliasing()
      Gets whether a flow sensitive aliasing algorithm shall be used
      Returns:
      True if a flow sensitive aliasing algorithm shall be used, otherwise false
    • setEnableExceptionTracking

      public void setEnableExceptionTracking(boolean enableExceptions)
      Sets whether the solver shall track taints of thrown exception objects
      Parameters:
      enableExceptions - True if taints associated with exceptions shall be tracked over try/catch construct, otherwise false
    • getEnableExceptionTracking

      public boolean getEnableExceptionTracking()
      Gets whether the solver shall track taints of thrown exception objects
      Returns:
      True if the solver shall track taints of thrown exception objects, otherwise false
    • setEnableArrayTracking

      public void setEnableArrayTracking(boolean enableArrays)
      Sets whether the solver shall track tainted arrays and array elements
      Parameters:
      enableArrays - True if taints associated with arrays or array elements shall be tracked over try/catch construct, otherwise false
    • getEnableArrayTracking

      public boolean getEnableArrayTracking()
      Gets whether the solver shall track taints of arrays and array elements
      Returns:
      True if the solver shall track taints of arrays and array elements, otherwise false
    • setEnableArraySizeTainting

      public void setEnableArraySizeTainting(boolean arrayLengthTainting)
      Sets whether the length of a tainted array shall be considered tainted
      Parameters:
      arrayLengthTainting - True to taint the length of a tainted array, false otherwise
    • getEnableArraySizeTainting

      public boolean getEnableArraySizeTainting()
      Gets whether the length of a tainted array shall be considered tainted
      Returns:
      True to taint the length of a tainted array, false otherwise
    • setEnableInstanceOfTainting

      public void setEnableInstanceOfTainting(boolean enableInstanceOfTainting)
      Sets whether an "instanceof" check on a tainted object shall deliver a tainted result
      Parameters:
      enableInstanceOfTainting - True if the "instanceof" check on a tainted object shall deliver a tainted result, false otherwise
    • getEnableInstanceOfTainting

      public boolean getEnableInstanceOfTainting()
      Gets whether an "instanceof" check on a tainted object shall deliver a tainted result
      Returns:
      True if the "instanceof" check on a tainted object shall deliver a tainted result, false otherwise
    • setCallgraphAlgorithm

      public void setCallgraphAlgorithm(InfoflowConfiguration.CallgraphAlgorithm algorithm)
      Sets the callgraph algorithm to be used by the data flow tracker
      Parameters:
      algorithm - The callgraph algorithm to be used by the data flow tracker
    • getCallgraphAlgorithm

      public InfoflowConfiguration.CallgraphAlgorithm getCallgraphAlgorithm()
      Gets the callgraph algorithm to be used by the data flow tracker
      Returns:
      The callgraph algorithm to be used by the data flow tracker
    • setAliasingAlgorithm

      public void setAliasingAlgorithm(InfoflowConfiguration.AliasingAlgorithm algorithm)
      Sets the aliasing algorithm to be used by the data flow tracker
      Parameters:
      algorithm - The aliasing algorithm to be used by the data flow tracker
    • getAliasingAlgorithm

      public InfoflowConfiguration.AliasingAlgorithm getAliasingAlgorithm()
      Gets the aliasing algorithm to be used by the data flow tracker
      Returns:
      The aliasing algorithm to be used by the data flow tracker
    • getDataFlowDirection

      public InfoflowConfiguration.DataFlowDirection getDataFlowDirection()
      Gets the data flow direction to be used for the taint analysis
      Returns:
      The data flow direction to be used for the taint analysis
    • setDataFlowDirection

      public void setDataFlowDirection(InfoflowConfiguration.DataFlowDirection direction)
      Sets the data flow direction to be used for the taint analysis
      Parameters:
      direction - The data flow direction to be used for the taint analysis
    • isPatchInvokeDynamicInstructions

      public boolean isPatchInvokeDynamicInstructions()
      Gets whether FlowDroid shall re-write known dynamic invocation instructions into normal invocations
      Returns:
      True if FlowDroid shall re-write known dynamic invocation instructions, false otherwise
    • setPatchInvokeDynamicInstructions

      public void setPatchInvokeDynamicInstructions(boolean patchInvokeDynamicInstructions)
      Sets whether FlowDroid shall re-write known dynamic invocation instructions into normal invocations
      Parameters:
      patchInvokeDynamicInstructions - True if FlowDroid shall re-write known dynamic invocation instructions, false otherwise
    • setEnableTypeChecking

      public void setEnableTypeChecking(boolean enableTypeChecking)
      Sets whether type checking shall be done on casts and method calls
      Parameters:
      enableTypeChecking - True if type checking shall be performed, otherwise false
    • getEnableTypeChecking

      public boolean getEnableTypeChecking()
      Gets whether type checking shall be done on casts and method calls
      Returns:
      True if type checking shall be performed, otherwise false
    • setIgnoreFlowsInSystemPackages

      public void setIgnoreFlowsInSystemPackages(boolean ignoreFlowsInSystemPackages)
      Sets whether flows starting or ending in system packages such as Android's support library shall be ignored.
      Parameters:
      ignoreFlowsInSystemPackages - True if flows starting or ending in system packages shall be ignored, otherwise false.
    • getIgnoreFlowsInSystemPackages

      public boolean getIgnoreFlowsInSystemPackages()
      Gets whether flows starting or ending in system packages such as Android's support library shall be ignored.
      Returns:
      True if flows starting or ending in system packages shall be ignored, otherwise false.
    • setExcludeSootLibraryClasses

      public void setExcludeSootLibraryClasses(boolean excludeSootLibraryClasses)
      Sets whether classes that are declared library classes in Soot shall be excluded from the data flow analysis, i.e., no flows shall be tracked through them
      Parameters:
      excludeSootLibraryClasses - True to exclude Soot library classes from the data flow analysis, otherwise false
    • getExcludeSootLibraryClasses

      public boolean getExcludeSootLibraryClasses()
      Gets whether classes that are declared library classes in Soot shall be excluded from the data flow analysis, i.e., no flows shall be tracked through them
      Returns:
      True to exclude Soot library classes from the data flow analysis, otherwise false
    • setMaxThreadNum

      public void setMaxThreadNum(int threadNum)
      Sets the maximum number of threads to be used by the solver. A value of -1 indicates an unlimited number of threads, i.e., there will be as many threads as there are CPU cores on the machine.
      Parameters:
      threadNum - The maximum number of threads to be used by the solver, or -1 for an unlimited number of threads.
    • getMaxThreadNum

      public int getMaxThreadNum()
      Gets the maximum number of threads to be used by the solver. A value of -1 indicates an unlimited number of threads, i.e., there will be as many threads as there are CPU cores on the machine.
      Returns:
      The maximum number of threads to be used by the solver, or -1 for an unlimited number of threads.
    • getWriteOutputFiles

      public boolean getWriteOutputFiles()
      Gets whether FlowDroid shall write the Jimple files to disk after the data flow analysis
      Returns:
      True if the Jimple files shall be written to disk after the data flow analysis, otherwise false
    • setWriteOutputFiles

      public void setWriteOutputFiles(boolean writeOutputFiles)
      Gets whether FlowDroid shall write the Jimple files to disk after the data flow analysis
      Parameters:
      writeOutputFiles - True if the Jimple files shall be written to disk after the data flow analysis, otherwise false
    • setCodeEliminationMode

      public void setCodeEliminationMode(InfoflowConfiguration.CodeEliminationMode mode)
      Sets whether and how FlowDroid shall eliminate irrelevant code before running the taint propagation
      Parameters:
      mode - the mode of dead and irrelevant code eliminiation to be used
    • getCodeEliminationMode

      public InfoflowConfiguration.CodeEliminationMode getCodeEliminationMode()
      Gets whether and how FlowDroid shall eliminate irrelevant code before running the taint propagation
      Returns:
      the mode of dead and irrelevant code elimination to be used
    • getLogSourcesAndSinks

      public boolean getLogSourcesAndSinks()
      Gets whether the discovered sources and sinks shall be logged
      Returns:
      True if the discovered sources and sinks shall be logged, otherwise false
    • setLogSourcesAndSinks

      public void setLogSourcesAndSinks(boolean logSourcesAndSinks)
      Sets whether the discovered sources and sinks shall be logged
      Parameters:
      logSourcesAndSinks - True if the discovered sources and sinks shall be logged, otherwise false
    • getEnableReflection

      public boolean getEnableReflection()
      Gets whether reflective method calls shall be supported
      Returns:
      True if reflective method calls shall be supported, otherwise false
    • setEnableReflection

      public void setEnableReflection(boolean enableReflections)
      Sets whether reflective method calls shall be supported
      Parameters:
      enableReflections - True if reflective method calls shall be supported, otherwise false
    • getEnableLineNumbers

      public boolean getEnableLineNumbers()
      Gets whether line numbers associated with sources and sinks should be output in XML results
      Returns:
      True if line number should be output, otherwise false
    • setEnableLineNumbers

      public void setEnableLineNumbers(boolean enableLineNumbers)
      Sets whether line numbers associated with sources and sinks should be output in XML results
      Parameters:
      enableLineNumbers - True if line numbers associated with sources and sinks should be output in XML results, otherwise false
    • getEnableOriginalNames

      public boolean getEnableOriginalNames()
      Gets whether the usage of original variablenames (if available) is enabled
      Returns:
      True if the usage is enabled, otherwise false
    • setEnableOriginalNames

      public void setEnableOriginalNames(boolean enableOriginalNames)
      Sets whether the usage of original variablenames (if available) is enabled
      Parameters:
      enableOriginalNames - True if the usage of original variablenames (if available) is enabled, otherwise false
    • isTaintAnalysisEnabled

      public boolean isTaintAnalysisEnabled()
      Gets whether the taint analysis is enabled. If it is disabled, FlowDroid will initialize the Soot instance and then return immediately.
      Returns:
      True if data flow tracking shall be performed, false otherwise
    • setTaintAnalysisEnabled

      public void setTaintAnalysisEnabled(boolean taintAnalysisEnabled)
      Sets whether the taint analysis is enabled. If it is disabled, FlowDroid will initialize the Soot instance and then return immediately.
      Parameters:
      taintAnalysisEnabled - True if data flow tracking shall be performed, false otherwise
    • getAdditionalFlowsEnabled

      public boolean getAdditionalFlowsEnabled()
      Gets whether additional flows are enabled.
      Returns:
      True if additional flows are enabled
    • setAdditionalFlowsEnabled

      public void setAdditionalFlowsEnabled(boolean additionalFlowsEnabled)
      Sets whether additional flows are enabled.
      Parameters:
      additionalFlowsEnabled - True if additional flows shall be enabled
    • getFilterConditionalSinks

      public boolean getFilterConditionalSinks()
      Gets whether conditional sinks should be filtered if the condition was not met. If false, conditional sinks won't be filtered.
      Returns:
      True if conditional flows will be filtered
    • setFilterConditionalSinks

      public void setFilterConditionalSinks(boolean filterConditionalSinks)
      Sets whether conditional sinks should be filtered if the condition was not met. If false, conditional sinks won't be filtered.
      Parameters:
      filterConditionalSinks - True if conditional sinks should be filtered
    • getIncrementalResultReporting

      public boolean getIncrementalResultReporting()
      Gets whether the data flow results shall be reported incrementally instead of being only available after the full data flow analysis has been completed.
      Returns:
      True if incremental data flow results shall be available, otherwise false
    • setIncrementalResultReporting

      public void setIncrementalResultReporting(boolean incrementalReporting)
      Sets whether the data flow results shall be reported incrementally instead of being only available after the full data flow analysis has been completed.
      Parameters:
      incrementalReporting - True if incremental data flow results shall be available, otherwise false
    • getDataFlowTimeout

      public long getDataFlowTimeout()
      Gets the timeout in seconds after which the taint analysis shall be aborted. This timeout only applies to the taint analysis itself, not to the path reconstruction that happens afterwards.
      Returns:
      The timeout in seconds after which the analysis shall be aborted
    • setDataFlowTimeout

      public void setDataFlowTimeout(long timeout)
      Sets the timeout in seconds after which the analysis shall be aborted. This timeout only applies to the taint analysis itself, not to the path reconstruction that happens afterwards.
      Parameters:
      timeout - The timeout in seconds after which the analysis shall be aborted
    • getMemoryThreshold

      public double getMemoryThreshold()
      Gets the threshold at which the data flow analysis shall be terminated. If the JVM consumes more than this fraction of the heap, no more data flow edges are propagated, and the results obtained so far are returned.
      Returns:
      The threshold at which to abort the workers
    • setMemoryThreshold

      public void setMemoryThreshold(double memoryThreshold)
      Sets the threshold at which the data flow analysis shall be terminated. If the JVM consumes more than this fraction of the heap, no more data flow edges are propagated, and the results obtained so far are returned.
      Parameters:
      memoryThreshold - The threshold at which to abort the workers
    • getOneSourceAtATime

      public boolean getOneSourceAtATime()
      Gets whether one source shall be analyzed at a time instead of all sources together
      Returns:
      True if the analysis shall be run with one analysis at a time, false if the analysis shall be run with all sources together
    • setOneSourceAtATime

      public void setOneSourceAtATime(boolean oneSourceAtATime)
      Sets whether one source shall be analyzed at a time instead of all sources together
      Parameters:
      oneSourceAtATime - True if the analysis shall be run with one analysis at a time, false if the analysis shall be run with all sources together
    • getPathConfiguration

      public InfoflowConfiguration.PathConfiguration getPathConfiguration()
      Gets the configuration for dealing with the paths between source and sinks
      Returns:
      The configuration for dealing with the paths between source and sinks
    • getOutputConfiguration

      public InfoflowConfiguration.OutputConfiguration getOutputConfiguration()
      Gets the configuration for writing the data flow results into files
      Returns:
      The configuration for writing the data flow results into files
    • getSolverConfiguration

      public InfoflowConfiguration.SolverConfiguration getSolverConfiguration()
      Gets the configuration for the core IFDS data flow solver
      Returns:
      The configuration for the core IFDS data flow solver
    • getAccessPathConfiguration

      public InfoflowConfiguration.AccessPathConfiguration getAccessPathConfiguration()
      Gets the access path configuration that defines, e.g. low long access paths may be before being truncated
      Returns:
      The access path configuration
    • getBaseDirectory

      public static String getBaseDirectory()
      Gets the base directory used e.g. for SourcesSinks.xsd
      Returns:
      the base directory
    • setBaseDirectory

      public static void setBaseDirectory(String baseDirectory)
      Sets the base directory used e.g. for SourcesSinks.xsd
      Parameters:
      baseDirectory - path to the base directory as string
    • printSummary

      public void printSummary()
      Prints a summary of this data flow configuration
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getSourceSinkConfig

      public InfoflowConfiguration.SourceSinkConfiguration getSourceSinkConfig()
      Gets the configuration of the source/sink manager
      Returns:
      The configuration of the source/sink manager
    • getMaxAliasingBases

      public int getMaxAliasingBases()
    • setMaxAliasingBases

      public void setMaxAliasingBases(int value)
    • getPreciseCollectionStrategy

      public PreciseCollectionStrategy getPreciseCollectionStrategy()
      Returns whether precise tracking through collections is enabled and the corresponding strategy. Works best if constant propagation is enabled. Note that this option incurs a performance penalty and is usually not worth it.
      Returns:
      whether precise collection tracking is enabled
    • setPreciseCollectionTracking

      public void setPreciseCollectionTracking(PreciseCollectionStrategy value)
      Sets the option to enable precise tracking through collections. Works best if constant propagation is enabled. Note that this option incurs a performance penalty and is usually not worth it.
      Parameters:
      value - the strategy to use for precise collection tracking