Package com.tonic.analysis.cpg.taint
Class TaintSource
- java.lang.Object
-
- com.tonic.analysis.cpg.taint.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTaintSource.BuilderMutable accumulator for the fields of aTaintSource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TaintSource.Builderbuilder()static TaintSourceconsoleInput()static TaintSourcecustom(String name, String owner, String method, TaintType type)Builds a return-value-tainting source from caller-supplied patterns.static TaintSourcedatabaseQuery()static TaintSourceenvironmentVariable()static TaintSourcefileRead()StringgetDescriptorPattern()StringgetMethodPattern()StringgetName()StringgetOwnerPattern()intgetTaintedArgumentIndex()TaintTypegetTaintType()static TaintSourcehttpCookie()static TaintSourcehttpHeader()static TaintSourcehttpParameter()booleanisTaintsReturnValue()booleanmatches(String owner, String method, String descriptor)Tests a full call target against all three patterns.booleanmatchesDescriptor(String descriptor)Tests a descriptor against the descriptor pattern, compiling and caching it on first use.booleanmatchesMethod(String method)Tests a method name against the method pattern, compiling and caching it on first use.booleanmatchesOwner(String owner)Tests an owner against the owner pattern, compiling and caching it on first use.static TaintSourcenetworkInput()StringtoString()
-
-
-
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 testmethod- method name to testdescriptor- 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 nameowner- owner regexmethod- method name regextype- taint kind the source introduces- Returns:
- the configured source
-
builder
public static TaintSource.Builder builder()
- Returns:
- a new empty builder
-
-