Package com.tonic.analysis.cpg.taint
Class TaintPath
- java.lang.Object
-
- com.tonic.analysis.cpg.taint.TaintPath
-
public class TaintPath extends Object
A single tainted data flow from a source to a sink, with the CPG nodes traversed and any sanitizers seen along the way.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTaintPath.BuilderAccumulator for the endpoints and hop list of a TaintPath.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSanitizer(String sanitizer)Records a sanitizer applied along this path.static TaintPath.Builderbuilder()booleanequals(Object o)StringformatPath()Builds a multi-line report listing the source, every hop, the sink, and any sanitizers.List<CPGNode>getPath()intgetPathLength()Set<String>getSanitizers()SeveritygetSeverity()Severity of the sink, downgraded to INFO once the path is sanitized.TaintSinkgetSink()StringgetSinkLocation()Renders the sink node position as "method:line", falling back to the node label.CPGNodegetSinkNode()TaintSourcegetSource()StringgetSourceLocation()Renders the source node position as "method:line", falling back to the node label.CPGNodegetSourceNode()VulnerabilityTypegetVulnerabilityType()inthashCode()booleanisSanitized()StringtoShortString()Builds a one-line summary of the flow, its severity, hop count, and sanitization state.StringtoString()
-
-
-
Method Detail
-
getSource
public TaintSource getSource()
- Returns:
- the source
-
getSink
public TaintSink getSink()
- Returns:
- the sink
-
getSourceNode
public CPGNode getSourceNode()
- Returns:
- the source node
-
getSinkNode
public CPGNode getSinkNode()
- Returns:
- the sink node
-
builder
public static TaintPath.Builder builder()
- Returns:
- a new empty builder
-
getPathLength
public int getPathLength()
- Returns:
- the number of nodes on the path
-
isSanitized
public boolean isSanitized()
- Returns:
- true if at least one sanitizer was recorded
-
addSanitizer
public void addSanitizer(String sanitizer)
Records a sanitizer applied along this path.- Parameters:
sanitizer- name of the sanitizing routine
-
getVulnerabilityType
public VulnerabilityType getVulnerabilityType()
- Returns:
- the vulnerability type reported by the sink
-
getSeverity
public Severity getSeverity()
Severity of the sink, downgraded to INFO once the path is sanitized.- Returns:
- the effective severity
-
getSourceLocation
public String getSourceLocation()
Renders the source node position as "method:line", falling back to the node label.- Returns:
- the formatted location, or "unknown" when there is no source node
-
getSinkLocation
public String getSinkLocation()
Renders the sink node position as "method:line", falling back to the node label.- Returns:
- the formatted location, or "unknown" when there is no sink node
-
formatPath
public String formatPath()
Builds a multi-line report listing the source, every hop, the sink, and any sanitizers.- Returns:
- the formatted report
-
toShortString
public String toShortString()
Builds a one-line summary of the flow, its severity, hop count, and sanitization state.- Returns:
- the summary line
-
-