Class AbstractXMLSourceSinkParser

java.lang.Object
soot.jimple.infoflow.android.source.parsers.xml.AbstractXMLSourceSinkParser
Direct Known Subclasses:
XMLSourceSinkParser

public abstract class AbstractXMLSourceSinkParser extends Object
Abstract class for all Flowdroid XML parsers. Returns a Set of Methods when calling the function parse. Subclasses may implement parser specifics to different language engines.
Author:
Anna-Katharina Wickert, Joern Tillmans, Steven Arzt, Niklas Vogel
  • Field Details

  • Constructor Details

    • AbstractXMLSourceSinkParser

      public AbstractXMLSourceSinkParser()
  • Method Details

    • parseInputStream

      protected void parseInputStream(InputStream stream)
      Parses the given input stream to obtain the source/sink definitions
      Parameters:
      stream - The stream whose data to parse
    • buildSourceSinkLists

      protected abstract void buildSourceSinkLists()
      Builds the lists of sources and sinks from the data that we have parsed
    • runParse

      protected abstract void runParse(SAXParser parser, InputStream stream)
      Runs the parse method on the given parser
      Parameters:
      parser - Parser to run parse on
      stream - Input stream of XML file
    • addSourceSinkDefinition

      protected void addSourceSinkDefinition(String signature, IAccessPathBasedSourceSinkDefinition ssd)
      Adds a new source or sink definition
      Parameters:
      signature - The signature of the method or field that is considered a source or a sink
      ssd - The source or sink definition
    • getSources

      public Set<ISourceSinkDefinition> getSources()
    • getSinks

      public Set<ISourceSinkDefinition> getSinks()
    • getStream

      protected static InputStream getStream(String fileName) throws IOException
      Throws:
      IOException
    • getAllMethods

      public Set<ISourceSinkDefinition> getAllMethods()
    • addSourceSinkDefinition

      protected void addSourceSinkDefinition(String signature, ISourceSinkDefinition ssd)
    • createFieldSourceSinkDefinition

      protected abstract ISourceSinkDefinition createFieldSourceSinkDefinition(String signature, Set<AccessPathTuple> baseAPs)
      Factory method for FieldSourceSinkDefinition instances
      Parameters:
      signature - The signature of the target field
      baseAPs - The access paths that shall be considered as sources or sinks
      Returns:
      The newly created FieldSourceSinkDefinition instance
    • createFieldSourceSinkDefinition

      protected abstract ISourceSinkDefinition createFieldSourceSinkDefinition(String signature, Set<AccessPathTuple> baseAPs, Set<SourceSinkCondition> conditions)
      Factory method for FieldSourceSinkDefinition instances
      Parameters:
      signature - The signature of the target field
      baseAPs - The access paths that shall be considered as sources or sinks
      conditions - Conditions which has to be true for the definition to be valid
      Returns:
      The newly created FieldSourceSinkDefinition instance
    • createMethodSourceSinkDefinition

      protected abstract ISourceSinkDefinition createMethodSourceSinkDefinition(AbstractMethodAndClass method, Set<AccessPathTuple> baseAPs, Set<AccessPathTuple>[] paramAPs, Set<AccessPathTuple> returnAPs, MethodSourceSinkDefinition.CallType callType, ISourceSinkCategory category)
      Factory method for MethodSourceSinkDefinition instances
      Parameters:
      method - The method that is to be defined as a source or sink
      baseAPs - The access paths rooted in the base object that shall be considered as sources or sinks
      paramAPs - The access paths rooted in parameters that shall be considered as sources or sinks. The index in the set corresponds to the index of the formal parameter to which the respective set of access paths belongs.
      returnAPs - The access paths rooted in the return object that shall be considered as sources or sinks
      callType - The type of call (normal call, callback, etc.)
      Returns:
      The newly created MethodSourceSinkDefinition instance
    • createMethodSourceSinkDefinition

      protected abstract ISourceSinkDefinition createMethodSourceSinkDefinition(AbstractMethodAndClass method, Set<AccessPathTuple> baseAPs, Set<AccessPathTuple>[] paramAPs, Set<AccessPathTuple> returnAPs, MethodSourceSinkDefinition.CallType callType, ISourceSinkCategory category, Set<SourceSinkCondition> conditions)
      Factory method for MethodSourceSinkDefinition instances
      Parameters:
      method - The method that is to be defined as a source or sink
      baseAPs - The access paths rooted in the base object that shall be considered as sources or sinks
      paramAPs - The access paths rooted in parameters that shall be considered as sources or sinks. The index in the set corresponds to the index of the formal parameter to which the respective set of access paths belongs.
      returnAPs - The access paths rooted in the return object that shall be considered as sources or sinks
      callType - The type of call (normal call, callback, etc.)
      conditions - Conditions which has to be true for the definition to be valid
      Returns:
      The newly created MethodSourceSinkDefinition instance
    • parseSignature

      protected String parseSignature(Attributes attributes)
      Reads the method or field signature from the given attribute map
      Parameters:
      attributes - The attribute map from which to read the signature
      Returns:
      The signature that identifies a Soot method or field