Class TaintSource


  • public class TaintSource
    extends Object
    A regex-matched method call site that introduces tainted data, either through its return value or through one argument.
    • Method Detail

      • getName

        public String getName()
        Returns:
        the name
      • getOwnerPattern

        public String getOwnerPattern()
        Returns:
        the owner pattern
      • getMethodPattern

        public String getMethodPattern()
        Returns:
        the method pattern
      • getDescriptorPattern

        public String getDescriptorPattern()
        Returns:
        the descriptor pattern
      • getTaintedArgumentIndex

        public int getTaintedArgumentIndex()
        Returns:
        the tainted argument index
      • isTaintsReturnValue

        public boolean isTaintsReturnValue()
        Returns:
        whether taints return value
      • getTaintType

        public TaintType getTaintType()
        Returns:
        the taint type
      • matchesOwner

        public boolean matchesOwner​(String owner)
        Tests an owner against the owner pattern, compiling and caching it on first use.
        Parameters:
        owner - internal class name to test
        Returns:
        true if the pattern is absent or matches in full
      • matchesMethod

        public boolean matchesMethod​(String method)
        Tests a method name against the method pattern, compiling and caching it on first use.
        Parameters:
        method - method name to test
        Returns:
        true if the pattern is absent or matches in full
      • matchesDescriptor

        public boolean matchesDescriptor​(String descriptor)
        Tests a descriptor against the descriptor pattern, compiling and caching it on first use.
        Parameters:
        descriptor - method descriptor to test
        Returns:
        true if the pattern is absent or matches in full
      • matches

        public boolean matches​(String owner,
                               String method,
                               String descriptor)
        Tests a full call target against all three patterns.
        Parameters:
        owner - internal class name to test
        method - method name to test
        descriptor - method descriptor to test
        Returns:
        true if every present pattern matches
      • httpParameter

        public static TaintSource httpParameter()
        Returns:
        a USER_INPUT source for servlet request parameter reads
      • httpHeader

        public static TaintSource httpHeader()
        Returns:
        a USER_INPUT source for servlet request header reads
      • httpCookie

        public static TaintSource httpCookie()
        Returns:
        a USER_INPUT source for servlet request cookie reads
      • consoleInput

        public static TaintSource consoleInput()
        Returns:
        a USER_INPUT source for Scanner reads
      • fileRead

        public static TaintSource fileRead()
        Returns:
        a FILE_INPUT source for java.io stream and reader reads
      • environmentVariable

        public static TaintSource environmentVariable()
        Returns:
        an ENVIRONMENT source for System.getenv and System.getProperty
      • databaseQuery

        public static TaintSource databaseQuery()
        Returns:
        a DATABASE source for ResultSet column getters
      • networkInput

        public static TaintSource networkInput()
        Returns:
        a NETWORK source for socket and connection input streams
      • custom

        public static TaintSource custom​(String name,
                                         String owner,
                                         String method,
                                         TaintType type)
        Builds a return-value-tainting source from caller-supplied patterns.
        Parameters:
        name - display name
        owner - owner regex
        method - method name regex
        type - taint kind the source introduces
        Returns:
        the configured source