Documentation ¶
Overview ¶
Library for working with SOAAP results.
See:
Index ¶
- Constants
- func GraphAnalyses() []string
- func UpdateCalls(current *[]Call, calls ...Call)
- type Analyser
- type CVE
- type Call
- type CallGraph
- func ApplyAnalysis(spec string, cg *CallGraph, results *Results, depth int, report func(string)) (CallGraph, error)
- func Filter(cg CallGraph, spec string) (CallGraph, error)
- func Legend() CallGraph
- func LoadGraph(f *os.File, report func(string)) (CallGraph, error)
- func NewCallGraph() CallGraph
- func PrivAccessGraph(results Results, progress func(string)) (CallGraph, error)
- func VulnGraph(results Results, progress func(string)) (CallGraph, error)
- func (cg *CallGraph) AddCall(call Call)
- func (cg *CallGraph) AddCalls(call Call, weight int)
- func (cg *CallGraph) AddFlow(flow Call)
- func (cg *CallGraph) AddFlows(flow Call, weight int)
- func (cg *CallGraph) AddIntersecting(g CallGraph, depth int) error
- func (cg *CallGraph) AddNode(node GraphNode)
- func (cg CallGraph) Ancestors(root string, depth int) strset
- func (cg *CallGraph) CollectNodes(root string, selector func(GraphNode) strset, depth int) strset
- func (cg CallGraph) Filter(keep strset) CallGraph
- func (cg CallGraph) Intersect(g CallGraph, depth int, keepBacktrace bool) (CallGraph, error)
- func (cg CallGraph) Save(f *os.File) error
- func (cg CallGraph) Simplified() CallGraph
- func (cg CallGraph) Size() (int, int, int)
- func (cg *CallGraph) Union(g CallGraph) error
- func (cg CallGraph) WriteDot(out io.Writer, groupBy string) error
- type CallSite
- type CallTrace
- type DataSource
- type GraphNode
- func (n GraphNode) AllInputs() strset
- func (n GraphNode) AllOutputs() strset
- func (n GraphNode) Callees() strset
- func (n GraphNode) Callers() strset
- func (n GraphNode) DataSinks() strset
- func (n GraphNode) DataSources() strset
- func (n GraphNode) Dot() string
- func (n GraphNode) IsSimple() bool
- func (n *GraphNode) Update(g GraphNode)
- type PrivAccess
- type Results
- type SandboxName
- type SourceLocation
- type Vuln
Constants ¶
const ( Contained = "#ffff33" PrivateData = "#3399ff" Sandboxed = "#66ff66" Unspecified = "#999999" Vulnerable = "#ff6666" )
Colours that represent different kinds of sandboxes, data, etc.
Variables ¶
This section is empty.
Functions ¶
func GraphAnalyses ¶
func GraphAnalyses() []string
func UpdateCalls ¶
Types ¶
type Call ¶
type Call struct { // Identifier of the caller. Caller string // Identifier of the callee. Callee string // Location of the call. CallSite SourceLocation // The name of the sandbox the call is occurring in // (or the empty string if unsandboxed). Sandbox string }
type CallGraph ¶
type CallGraph struct {
// contains filtered or unexported fields
}
func ApplyAnalysis ¶
func ApplyAnalysis(spec string, cg *CallGraph, results *Results, depth int, report func(string)) (CallGraph, error)
Apply an analysis to a CallGraph using an already-loaded Results file.
Possible analyses include:
- "+graphtype": union with "graphtype" from the Results
- "^graphtype": intersection with "graphtype" from the Results
- ".graphtype": union-of-intersection with "graphtype"
- ":spec": filter leaf nodes according to "spec" (see Filter)
where "graphtype" can be:
- vuln: the callgraph of previously-vulnerable code
- privaccess: the call-and-data-flow graph of access to private data
func Filter ¶
Filter a graph according to a colon-separated list of filter specifications, where each element can be:
- "*": add all leaf nodes in the graph
- "+regex": keep leaf nodes that match a pattern
- "-regex": remove leaf nodes that match a pattern
Examples:
":*:-foo:-bar" keeps all leaf nodes except "foo" and "bar" ":+.*foo.*:+.*bar.*" keeps only those leaf nodes (plus ancestors) with "foo" and "bar" in their names
func NewCallGraph ¶
func NewCallGraph() CallGraph
Create a new, empty CallGraph with enough capacity to hold some calls.
func PrivAccessGraph ¶
Construct a callgraph of sandbox-private data accesses outside of sandboxes.
func (*CallGraph) AddIntersecting ¶
Add intersecting nodes to this graph, where the call traces leading to any two leaf nodes must intersect within `depth` calls.
func (CallGraph) Ancestors ¶
Find ancestors of this node by walking both its call graph and its data flow graph.
Note that this is different from walking the call-and-data-flow graph: it's possible to have calls in one direction and flows in the other, yielding cycles in the combined graph.
func (*CallGraph) CollectNodes ¶
func (CallGraph) Intersect ¶
Compute the intersection of two CallGraphs, where the call traces leading to any two leaf nodes must intersect within `depth` calls.
If `keepBacktrace` is true, in addition to the intersecting nodes, the new graph will also contain the full backtrace from each node to its root.
func (CallGraph) Simplified ¶
Simplify a CallGraph by collapsing call chains and dropping any unreferenced calls.
type CallSite ¶
type CallSite struct { Function string Location SourceLocation Trace int TraceName string `json:"trace_ref"` }
A node in the call graph.
This is a location of either a SOAAP warning or else a call to another function in a warning's call stack.
type CallTrace ¶
A single call trace, from a warning location to the root function.
Common elements of multiple traces may be refactored into separate traces: if this trace has a predecessor, it is identified by `Next`.
type DataSource ¶
type DataSource struct { Location SourceLocation Trace int TraceRef string `json:"trace_ref"` }
type GraphNode ¶
type GraphNode struct { Name string // The name of the function this node is in / represents. Function string // The library that the function is defined in. Library string // The sandbox that this code is being executed in. // // Note that SOAAP can discriminate among the same function executing // in different sandboxes. Sandbox string // A vulnerability (current or previous) is known at this location. CVE strset // The name of the sandbox(es) that own the data being accessed. Owners strset CallsIn []Call CallsOut []Call FlowsIn []Call FlowsOut []Call Tags strset }
A node in a call graph.
This is derived from a call site or other program location, but can have an arbitrary name and description appropriate to a particular analysis.
func (GraphNode) AllOutputs ¶
func (n GraphNode) AllOutputs() strset
func (GraphNode) DataSources ¶
func (n GraphNode) DataSources() strset
func (GraphNode) Dot ¶
Construct a GraphViz Dot description of a GraphNode.
This applies SOAAP-specific styling depending on a node's tags.
func (GraphNode) IsSimple ¶
A node is "simple" (or uninteresting, or boring) if none of the following "interesting" characteristics apply:
- it has multiple inputs (it joins chains together)
- it has no inputs (it's a root node)
- it has multiple outputs (it splits chains apart)
- it has no outputs (it's a leaf node)
- it has been marked as previously-vulnerable
- it accesses private data
type PrivAccess ¶
type PrivAccess struct { CallSite Sandboxes []SandboxName `json:"sandbox_private"` Sources []DataSource }
Information SOAAP reports about access to sandbox-private data outside of the sandbox.
func (PrivAccess) DataOwners ¶
func (p PrivAccess) DataOwners() strset
type Results ¶
type Results struct { Vulnerabilities []Vuln `json:"vulnerability_warning"` PrivateAccess []PrivAccess `json:"private_access"` Traces []CallTrace `json:"traces"` }
The results of running SOAAP on an application.
The fields of this structure represent different analyses that SOAAP performs, as well as the complete graph of function calls that are referenced from these analyses.
func LoadResults ¶
Load SOAAP results from an os.File (either binary- or JSON-encoded).
func ParseJSON ¶
Parse a JSON file emitted by SOAAP.
The `progress` callback will be notified when major events occur (top-level JSON parsing begins/ends, traces are parsed, etc.).
func (Results) ExtractGraph ¶
type SandboxName ¶
type SandboxName struct {
Name string
}
type SourceLocation ¶
A location in source code.
func (SourceLocation) String ¶
func (l SourceLocation) String() string