Class MethodSourceSinkDefinition

java.lang.Object
soot.jimple.infoflow.sourcesSinks.definitions.AbstractSourceSinkDefinition
soot.jimple.infoflow.sourcesSinks.definitions.MethodSourceSinkDefinition
All Implemented Interfaces:
IAccessPathBasedSourceSinkDefinition, ISourceSinkDefinition

public class MethodSourceSinkDefinition extends AbstractSourceSinkDefinition implements IAccessPathBasedSourceSinkDefinition
A class to handle all access paths of sources and sinks for a certain method.
Author:
Daniel Magin, Steven Arzt
  • Field Details

  • Constructor Details

    • MethodSourceSinkDefinition

      public MethodSourceSinkDefinition(Set<AccessPathTuple> baseObjects, Set<AccessPathTuple>[] parameters, Set<AccessPathTuple> returnValues, MethodSourceSinkDefinition.CallType callType)
      Creates a new instance of the MethodSourceSinkDefinition class without a method. This constructor is intended to be used for sources that arise from UI elements or other programming constructs that are not directly associated with a single method being called.
    • MethodSourceSinkDefinition

      public MethodSourceSinkDefinition(SootMethodAndClass am)
      Creates a new instance of the MethodSourceSinkDefinition class
      Parameters:
      am - The method for which this object defines sources and sinks
    • MethodSourceSinkDefinition

      public MethodSourceSinkDefinition(SootMethodAndClass am, MethodSourceSinkDefinition.CallType callType)
      Creates a new instance of the MethodSourceSinkDefinition class
      Parameters:
      am - The method for which this object defines sources and sinks
      callType - The type of calls to define as sources or sinks
    • MethodSourceSinkDefinition

      public MethodSourceSinkDefinition(SootMethodAndClass am, Set<AccessPathTuple> baseObjects, Set<AccessPathTuple>[] parameters, Set<AccessPathTuple> returnValues, MethodSourceSinkDefinition.CallType callType)
      Creates a new instance of the MethodSourceSinkDefinition class
      Parameters:
      am - The method for which this object defines sources and sinks
      baseObjects - The source and sink definitions for the base object on which a method of this class is invoked
      parameters - The source and sink definitions for parameters of the current method
      callType - The type of calls to define as sources or sinks
      returnValues - The source definitions for the return value of the current method
    • MethodSourceSinkDefinition

      public MethodSourceSinkDefinition(SootMethodAndClass am, Set<AccessPathTuple> baseObjects, Set<AccessPathTuple>[] parameters, Set<AccessPathTuple> returnValues, MethodSourceSinkDefinition.CallType callType, ISourceSinkCategory category)
      Creates a new instance of the MethodSourceSinkDefinition class
      Parameters:
      am - The method for which this object defines sources and sinks
      baseObjects - The source and sink definitions for the base object on which a method of this class is invoked
      parameters - The source and sink definitions for parameters of the current method
      returnValues - The source definitions for the return value of the current method
      callType - The type of calls to define as sources or sinks
      category - The category to which this source or sink belongs
  • Method Details

    • getMethod

      public SootMethodAndClass getMethod()
      Gets the method for which this object defines sources and sinks
      Returns:
      The method for which this object defines sources and sinks
    • getCallType

      Gets the type of method invocations that are denoted by this source or sink
      Returns:
      The type of method invocations that are denoted by this source or sink
    • getBaseObjects

      public Set<AccessPathTuple> getBaseObjects()
      Gets the source and sink definitions for the base object on which a method of this class is invoked
      Returns:
      The source and sink definitions for the base object
    • getBaseObjectCount

      public int getBaseObjectCount()
      Gets the number of access paths defined as sources or sinks on base objects
      Returns:
      The number of access paths defined as sources or sinks on base objects
    • getParameters

      public Set<AccessPathTuple>[] getParameters()
      Gets the source and sink definitions for parameters of the current method
      Returns:
      The source and sink definitions for parameters
    • getParameterCount

      public int getParameterCount()
      Gets the number of access paths defined as sources or sinks on parameters
      Returns:
      The number of access paths defined as sources or sinks on parameters
    • getReturnValues

      public Set<AccessPathTuple> getReturnValues()
      Gets the source definitions for the return value of the current method
      Returns:
      The source definitions for the return value
    • getReturnValueCount

      public int getReturnValueCount()
      Gets the number of access paths defined as sources or sinks on return values
      Returns:
      The number of access paths defined as sources or sinks on return values
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: IAccessPathBasedSourceSinkDefinition
      Checks whether this source/sink definition is empty, i.e., has no concrete access paths
      Specified by:
      isEmpty in interface IAccessPathBasedSourceSinkDefinition
      Specified by:
      isEmpty in interface ISourceSinkDefinition
      Returns:
      True if this source/sink definition is empty, i.e., has no concrete access paths, otherwise false
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSourceOnlyDefinition

      public MethodSourceSinkDefinition getSourceOnlyDefinition()
      Description copied from interface: IAccessPathBasedSourceSinkDefinition
      Creates a definition which is a subset of this definition that only contains the sources
      Specified by:
      getSourceOnlyDefinition in interface IAccessPathBasedSourceSinkDefinition
      Specified by:
      getSourceOnlyDefinition in interface ISourceSinkDefinition
      Returns:
      The source-only subset of this definition
    • getSinkOnlyDefinition

      public MethodSourceSinkDefinition getSinkOnlyDefinition()
      Description copied from interface: IAccessPathBasedSourceSinkDefinition
      Creates a definition which is a subset of this definition that only contains the sinks
      Specified by:
      getSinkOnlyDefinition in interface IAccessPathBasedSourceSinkDefinition
      Specified by:
      getSinkOnlyDefinition in interface ISourceSinkDefinition
      Returns:
      The sink-only subset of this definition
    • buildNewDefinition

      protected MethodSourceSinkDefinition buildNewDefinition(Set<AccessPathTuple> baseAPTs, Set<AccessPathTuple>[] paramAPTs, Set<AccessPathTuple> returnAPTs)
      Factory method for creating a new method-based source/sink definition based on the current one. This method is used when transforming the current definition. Derived classes can override this method to create instances of the correct class.
      Parameters:
      baseAPTs - The access paths rooted in the base object
      paramAPTs - The access paths rooted in the method's parameters
      returnAPTs - The access paths rooted in the return value
      Returns:
      The new source/sink definition object
    • buildNewDefinition

      protected MethodSourceSinkDefinition buildNewDefinition(SootMethodAndClass methodAndclass, Set<AccessPathTuple> filteredBaseObjects, Set<AccessPathTuple>[] filteredParameters, Set<AccessPathTuple> filteredReturnValues, MethodSourceSinkDefinition.CallType callType)
    • addParameterDefinition

      public void addParameterDefinition(int paramIdx, Set<AccessPathTuple> paramDefs)
      Adds the given access path tuples to this source/sink definition for the given parameter index
      Parameters:
      paramIdx - The parameter index
      paramDefs - The access path tuples
    • getBaseObjectSource

      public MethodSourceSinkDefinition getBaseObjectSource()
      Gets the shared source definition that is not associated with any method and taints the base object
      Returns:
      The shared blank source definition that is not associated with any method and taints the base object
    • getBaseObjectSink

      public MethodSourceSinkDefinition getBaseObjectSink()
      Gets the shared sink definition that is not associated with any method and taints the base object
      Returns:
      The shared blank sink definition that is not associated with any method and taints the base object
    • hashCode

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

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

      public static MethodSourceSinkDefinition createParameterSource(int index, MethodSourceSinkDefinition.CallType callType)
      Creates a source definition that considers a parameter as tainted
      Parameters:
      index - The index of the parameter to consider as tainted
      callType - The type of call
      Returns:
      The newly created source definition
    • createReturnSource

      public static MethodSourceSinkDefinition createReturnSource(MethodSourceSinkDefinition.CallType callType)
      Creates a source definition that considers the return value as tainted
      Parameters:
      callType - The type of call
      Returns:
      The newly created source definition
    • simplify

      public MethodSourceSinkDefinition simplify()
      Checks whether this definition is equivalent to one of the simple predefined ones. If so, it returns the shared predefined object. Otherwise, it returns this object.
      Returns:
      A shared object that is equal to this one if possible, otherwise this object
    • getAllAccessPaths

      public Set<AccessPathTuple> getAllAccessPaths()
      Description copied from interface: IAccessPathBasedSourceSinkDefinition
      Gets all access paths referenced in this source or sink definition, regardless of their respective semantics
      Specified by:
      getAllAccessPaths in interface IAccessPathBasedSourceSinkDefinition
      Returns:
      All access paths referenced in this source or sink definition. The return value can be null if this definition does not reference any access paths.
    • filter

      Description copied from interface: IAccessPathBasedSourceSinkDefinition
      Filters the source/sink definition to only reference the given access paths
      Specified by:
      filter in interface IAccessPathBasedSourceSinkDefinition
      Parameters:
      accessPaths - The access path to which to limit the scope of this source/sink definition
      Returns:
      A copy of this source/sink definition that only references the given access paths