CLI

The SAF command-line interface provides access to analysis capabilities from the terminal. The binary is named saf.

Global Options

OptionDescription
--json-errorsOutput errors as JSON for machine-readable consumption

Commands

saf index

Index input files via a frontend to produce AIR-JSON.

saf index program.ll
saf index program.ll --output bundle.air.json
saf index --frontend air-json bundle.air.json
OptionTypeDefaultDescription
<inputs>positional, requiredInput files to index
--frontend <frontend>llvm, air-jsonllvmFrontend to use for ingestion
--output <path>pathstdoutWrite AIR-JSON output to file instead of stdout

saf run

Run analysis passes on input programs. This is the primary command -- it ingests input files, builds internal representations (CFG, call graph, pointer analysis), runs the selected checkers, and produces findings.

saf run program.ll
saf run program.ll --mode fast
saf run program.ll --format sarif --output report.sarif
saf run program.ll --checkers memory-leak,null-deref --pta cspta --pta-k 2

Input Options

OptionTypeDefaultDescription
<inputs>positional, requiredInput files to analyze
--frontend <frontend>llvm, air-jsonllvmFrontend to use for ingestion
--specs <path>pathAdditional spec files or directories

Analysis Options

OptionTypeDefaultDescription
--mode <mode>fast, precisepreciseAnalysis mode
--checkers <list>stringallCheckers to run (comma-separated, or all / none)
--combinedflagRun combined PTA + abstract interpretation

Pointer Analysis Options

OptionTypeDefaultDescription
--pta <variant>andersen, cspta, fspta, ddaandersenPTA variant
--solver <backend>worklist, datalogworklistPTA solver backend
--pts-repr <repr>auto, btreeset, fxhash, roaring, bddautoPoints-to set representation
--pta-k <n>integer2k-CFA depth (cspta only)
--field-sensitivity <level>struct-fields, array-index, flatstruct-fieldsField sensitivity level
--max-pta-iterations <n>integerMaximum PTA iterations

Z3 Options

OptionTypeDefaultDescription
--path-sensitiveflagEnable Z3 path-sensitive checker filtering
--z3-proveflagProve assertions via Z3
--z3-refine-aliasflagRefine alias results via Z3
--z3-check-reachabilityflagCheck path reachability via Z3
--z3-timeout <ms>integer5000Z3 solver timeout in milliseconds

Typestate and Taint Options

OptionTypeDefaultDescription
--typestate <name>stringRun built-in typestate spec
--typestate-custom <path>pathRun custom typestate spec from YAML
--ifds-taint <path>pathRun IFDS taint analysis with config file

Output Options

OptionTypeDefaultDescription
--format <fmt>human, json, sarifhumanOutput format
--output <path>pathstdoutWrite output to file
--diagnosticsflagInclude checker/PTA diagnostics
--verboseflagShow timing, resource table, stats

saf query

Query analysis results. Requires --input and a subcommand.

saf query points-to --input program.ll 0x00ab1234...
saf query alias --input program.ll 0x001a... 0x002b...
saf query flows --input program.ll 0xsource... 0xsink...
saf query taint --input program.ll 0xsource... 0xsink...
saf query reachable --input program.ll 0xfunc1... 0xfunc2...
OptionTypeDefaultDescription
--input <files>path(s), requiredInput files to analyze
--frontend <frontend>llvm, air-jsonllvmFrontend to use for ingestion

Subcommands

SubcommandArgumentsDescription
points-to<pointer> (hex value ID)Points-to set for a value
alias<p> <q> (hex value IDs)May-alias check between two pointers
flows<source> <sink> (hex value IDs)Data-flow reachability
taint<source> <sink> (hex value IDs)Taint-flow query
reachable<func_ids>... (hex function IDs)Call-graph reachability from functions

saf export

Export graphs or findings in various formats.

saf export cfg --input program.ll
saf export callgraph --input program.ll --format dot --output cg.dot
saf export findings --input program.ll --format sarif --output report.sarif
saf export valueflow --input program.ll --format json --output vfg.json
OptionTypeDefaultDescription
<target>positional, requiredExport target (see below)
--input <files>path(s), requiredInput files to analyze
--format <fmt>json, sarif, dot, htmljsonOutput format
--output <path>pathstdoutWrite output to file instead of stdout
--function <name>stringFilter to a specific function (for CFG export)
--frontend <frontend>llvm, air-jsonllvmFrontend to use for ingestion

Export Targets

TargetDescription
cfgControl-flow graph
callgraphCall graph (inter-procedural)
defuseDef-use chains
valueflowValue-flow graph
svfgSparse Value-Flow Graph
findingsAnalysis findings / bug reports
ptaPoints-to analysis results

saf schema

Print the SAF schema (supported frontends, queries, checkers).

saf schema
saf schema --checkers
saf schema --frontends
saf schema --format json
OptionTypeDefaultDescription
--checkersflagList available checkers only
--frontendsflagList available frontends only
--format <fmt>human, json, sarifhumanOutput format

saf specs

Manage function specifications (list, validate, look up).

saf specs list
saf specs list --verbose
saf specs validate path/to/specs.yaml
saf specs lookup malloc

Subcommands

SubcommandArgumentsDescription
list[--verbose]List loaded function specifications
validate<path> (required)Validate spec file or directory
lookup<name> (required)Look up the spec for a function by name

saf incremental

Run incremental analysis with caching. Only recomputes what changed between runs.

saf incremental src/*.ll
saf incremental src/*.ll --cache-dir .saf-cache
saf incremental src/*.ll --plan
saf incremental src/*.ll --clean
saf incremental src/*.ll --export-summaries summaries.yaml
OptionTypeDefaultDescription
<inputs>positional, requiredInput files to analyze
--frontend <frontend>llvm, air-jsonllvmFrontend to use for ingestion
--mode <mode>sound, best-effortbest-effortPrecision mode for incremental analysis
--cache-dir <path>path.saf-cacheCache directory for incremental state
--planflagDry-run: show what would be recomputed without running analysis
--cleanflagClear the cache before analysis
--export-summaries <path>pathExport computed summaries as YAML to the given path

saf help

Show topic-based help guides.

saf help               # Overview of all commands and topics
saf help run           # How to run analyses and configure passes
saf help checkers      # Built-in bug checkers and how to select them
saf help pta           # Pointer analysis variants and configuration
saf help typestate     # Typestate checking and custom protocol specs
saf help taint         # Taint analysis modes and configuration
saf help z3            # Z3-based path sensitivity and refinement
saf help export        # Export targets, formats, and examples
saf help specs         # Function specification format and discovery
saf help incremental   # Incremental analysis and caching
saf help examples      # Common usage patterns and recipes

Available Topics

TopicDescription
runHow to run analyses and configure passes
checkersBuilt-in bug checkers and how to select them
ptaPointer analysis variants and configuration
typestateTypestate checking and custom protocol specs
taintTaint analysis modes and configuration
z3Z3-based path sensitivity and refinement
exportExport targets, formats, and examples
specsFunction specification format and discovery
incrementalIncremental analysis and caching
examplesCommon usage patterns and recipes

Exit Codes

CodeMeaning
0Success (no findings, or findings exported)
1Error (invalid input, analysis failure)
2Findings detected (when used in CI mode)

Examples

Quick Scan

# Run all checkers with defaults (Andersen PTA, precise mode)
saf run program.ll

CI/CD Integration

# Run all checkers and output SARIF for GitHub Code Scanning
saf run program.ll --format sarif --output results.sarif

# Check exit code for pass/fail
if saf run program.ll --format json | jq '.findings | length' | grep -q '^0$'; then
    echo "No findings"
else
    echo "Findings detected"
    exit 1
fi

Batch Analysis

# Analyze multiple files
for f in src/*.ll; do
    saf run "$f" --format sarif --output "results/$(basename "$f" .ll).sarif"
done

Path-Sensitive Analysis

# Reduce false positives with Z3-based path feasibility filtering
saf run program.ll --path-sensitive --z3-timeout 10000

Export Call Graph as DOT

saf export callgraph --input program.ll --format dot --output cg.dot
dot -Tpng cg.dot -o cg.png

Incremental Analysis

# First run caches results; subsequent runs only re-analyze changed files
saf incremental src/*.ll --cache-dir .saf-cache

Demand-Driven Points-To Query

saf query points-to --input program.ll 0x00ab1234abcd5678