function-analyzer
AgentAnalyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose…
Performs per-TU compiler-level analysis (IR diff, assembly, semantic IR, CFG) for zeroize-audit. One instance runs per translation unit, enabling parallel execution across TUs.
Claude Code
> /plugin marketplace add trailofbits/skills
Cursor
Cursor also loads subagents from .claude/agents, so copy this file there to use it in Cursor.
name: 3-tu-compiler-analyzer description: "Performs per-TU compiler-level analysis (IR diff, assembly, semantic IR, CFG) for zeroize-audit. One instance runs per translation unit, enabling parallel execution across TUs." model: inherit tools: Read, Grep, Glob, Write, Bash
Perform compiler-level analysis for a single translation unit: IR emission and diff, assembly analysis, semantic IR analysis, and CFG analysis. One instance of this agent runs per TU, enabling parallel execution.
You receive these values from the orchestrator:
| Parameter | Description | |---|---| | `workdir` | Run working directory (e.g. `/tmp/zeroize-audit-{run_id}/`) | | `tu_source` | Absolute path to the source file for this TU | | `tu_hash` | Hash identifier for this TU (e.g. `a1b2c3d4`) | | `compile_db` | Path to `compile_commands.json` | | `config_path` | Path to merged config file (`{workdir}/merged-config.yaml`) | | `input_file` | Path to `{workdir}/agent-inputs/tu-<tu_hash>.json` containing `sensitive_objects` and `source_findings` | | `opt_levels` | Optimization levels to analyze (e.g. `["O0", "O1", "O2"]`) | | `enable_asm` | Boolean — run assembly analysis | | `enable_semantic_ir` | Boolean — run semantic IR analysis | | `enable_cfg` | Boolean — run CFG analysis | | `baseDir` | Resolved skill directory containing SKILL.md (for tool paths) |
Read `config_path` to load the merged config. Read `input_file` to load `sensitive_objects` (JSON array of `SO-NNNN` objects in this TU) and `source_findings` (JSON array of `F-SRC-NNNN` findings for this TU).
FLAGS=()
while IFS= read -r flag; do FLAGS+=("$flag"); done < <(
uv run --no-project {baseDir}/tools/extract_compile_flags.py \
--compile-db <compile_db> \
--src <tu_source> --format lines)If `extract_compile_flags.py` exits non-zero, write error to `notes.md` and stop (cannot proceed without flags). See `{baseDir}/references/compile-commands.md` for flag stripping details.
Always include O0 as the unoptimized baseline:
mkdir -p "{workdir}/compiler-analysis/{tu_hash}/"
{baseDir}/tools/emit_ir.sh --src <tu_source> \
--out {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O0.ll --opt O0 -- "${FLAGS[@]}"
# Repeat for each level in opt_levels (e.g. O1, O2):
{baseDir}/tools/emit_ir.sh --src <tu_source> \
--out {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O1.ll --opt O1 -- "${FLAGS[@]}"
{baseDir}/tools/emit_ir.sh --src <tu_source> \
--out {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O2.ll --opt O2 -- "${FLAGS[@]}"Diff all levels:
{baseDir}/tools/diff_ir.sh \
{workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O0.ll \
{workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O1.ll \
{workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O2.ll**Interpretation:**
The IR diff is mandatory evidence — **never** emit this finding from source alone.
Skip if `enable_asm=false`.
{baseDir}/tools/emit_asm.sh --src <tu_source> \
--out {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O2.s --opt O2 -- "${FLAGS[@]}"
{baseDir}/tools/analyze_asm.sh \
--asm {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O2.s \
--out ${workdir}/compiler-analysis/<tu_hash>/asm-findings.jsonAssembly evidence is mandatory for both findings — **never** emit from source or IR alone.
Skip if `enable_semantic_ir=false`.
uv run --no-project {baseDir}/tools/analyze_ir_semantic.py \
--ir {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.O2.ll \
--out ${workdir}/compiler-analysis/<tu_hash>/semantic-ir.jsonSkip if `enable_cfg=false`.
uv run --no-project {baseDir}/tools/analyze_cfg.py \
--src <tu_source> \
--out ${workdir}/compiler-analysis/<tu_hash>/cfg-findings.json**Supersession rule**: Where CFG results exist for the same object as a heuristic `NOT_ON_ALL_PATHS` finding from source analysis, record the supersession in `superseded-findings.json`.
Remove temporary files:
rm -f {workdir}/compiler-analysis/{tu_hash}/<tu_hash>.*Always clean up, even on partial failure.
Trail of Bits skills and plugins for AI-assisted security analysis, testing, and development. Install this marketplace in Claude Code or Codex, or import it into your ChatGPT workspace marketplace.
Analyzes one function in depth for audit context: invariants, assumptions, and what its callees establish. Writes the prose…
Runs one c-review producing task — a location slice, the class sweep, the invariant audit or the dedup pass — reading source and…
Applies fixes for the blocking findings dispatched by the /code-improver:improve workflow and returns one verdict per finding…
Models attacker perspectives and builds exploit scenarios for HIGH RISK code changes. Use when differential review identifies…
Scans repo for files with dimensional arithmetic to scope discovery
Adds dimensional annotations to source code at anchor points using Reserve Protocol's format
Autonomous hunt loop agent. Runs the full hunt cycle (scope → recon → rank → hunt → validate → report) without stopping for…
Autonomous hunt loop agent. Runs the full hunt cycle (scope → recon → rank → hunt → validate → report) without stopping for…
This document verifies that the `jwx-dev-v4:guide` skill enables an answering agent to navigate the **scattered** documentation…