{"slug":"audit-augmentation","title":"audit-augmentation","summary":"Augments Trailmark code graphs with external audit findings from SARIF static analysis results, weAudit annotation files, and version-gated Trailmark 0.4.x binary-analysis graph exports. Maps findings to graph nodes by file and line overlap, creates severity-based subgraphs, and ","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-09-06T18:19:47.471861Z","repo":{"url":"https://github.com/trailofbits/skills","stars":8320,"forks":719,"license":"CC-BY-SA-4.0","updatedAt":"2026-11-20T09:52:08Z"},"bodyHtml":"<hr>\n<h2>name: audit-augmentation\ndescription: &gt;\nAugments Trailmark code graphs with external audit findings from SARIF static\nanalysis results, weAudit annotation files, and version-gated Trailmark 0.4.x\nbinary-analysis graph exports. Maps findings to graph nodes by\nfile and line overlap, creates severity-based subgraphs, and enables\ncross-referencing findings with pre-analysis data (blast radius, taint, etc.).\nUse when projecting SARIF results onto a code graph, overlaying weAudit\nannotations, importing binary graph findings, cross-referencing Semgrep,\nCodeQL, or binary-analysis findings with call graph data, or visualizing audit\nfindings in the context of code structure.</h2>\n<h1>Audit Augmentation</h1>\n<p>Projects findings from external tools (SARIF) and human auditors (weAudit)\nonto Trailmark code graphs as annotations and subgraphs. Trailmark 0.4.0+ can\nalso import an external binary-analysis graph JSON export via\n<code>engine.augment_binary()</code>.</p>\n<h2>When to Use</h2>\n<ul>\n<li>Importing Semgrep, CodeQL, or other SARIF-producing tool results into a graph</li>\n<li>Importing weAudit audit annotations into a graph</li>\n<li>Importing binary-analysis graph data into a source graph (Trailmark 0.4.0+)</li>\n<li>Cross-referencing static analysis findings with blast radius or taint data</li>\n<li>Querying which functions have high-severity findings</li>\n<li>Visualizing audit coverage alongside code structure</li>\n<li>Preparing one SARIF or weAudit result for <code>trailmark-finding-triage</code></li>\n</ul>\n<h2>When NOT to Use</h2>\n<ul>\n<li>Running static analysis tools (use semgrep/codeql directly, then import)</li>\n<li>Building the code graph itself (use the <code>trailmark</code> skill)</li>\n<li>Generating diagrams (use the <code>diagramming-code</code> skill after augmenting)</li>\n</ul>\n<h2>Rationalizations to Reject</h2>\n<table>\n<thead>\n<tr>\n<th>Rationalization</th>\n<th>Why It's Wrong</th>\n<th>Required Action</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>\"The user only asked about SARIF, skip pre-analysis\"</td>\n<td>Without pre-analysis, you can't cross-reference findings with blast radius or taint</td>\n<td>Always run <code>engine.preanalysis()</code> before augmenting</td>\n</tr>\n<tr>\n<td>\"Unmatched findings don't matter\"</td>\n<td>Unmatched findings may indicate parsing gaps or out-of-scope files</td>\n<td>Report unmatched count and investigate if high</td>\n</tr>\n<tr>\n<td>\"One severity subgraph is enough\"</td>\n<td>Different severities need different triage workflows</td>\n<td>Query all severity subgraphs, not just <code>error</code></td>\n</tr>\n<tr>\n<td>\"SARIF results speak for themselves\"</td>\n<td>Findings without graph context lack blast radius and taint reachability</td>\n<td>Cross-reference with pre-analysis subgraphs</td>\n</tr>\n<tr>\n<td>\"weAudit and SARIF overlap, pick one\"</td>\n<td>Human auditors and tools find different things</td>\n<td>Import both when available</td>\n</tr>\n<tr>\n<td>\"Tool isn't installed, I'll do it manually\"</td>\n<td>Manual analysis misses what tooling catches</td>\n<td>Install trailmark first</td>\n</tr>\n</tbody>\n</table>\n<hr>\n<h2>Installation</h2>\n<p><strong>MANDATORY:</strong> If <code>uv run trailmark</code> fails, install trailmark first:</p>\n<pre><code>uv tool install trailmark\n# Python snippets: uv run --with trailmark python -   (a tool env is not importable)\n</code></pre>\n<h2>Version Gate</h2>\n<p>SARIF and weAudit augmentation are v0.2-safe. Binary graph augmentation is\nTrailmark 0.4.0+ only. Before calling <code>engine.augment_binary()</code>, check:</p>\n<pre><code>if not hasattr(engine, \"augment_binary\"):\n    raise RuntimeError(\"Binary augmentation requires Trailmark &gt;= 0.4.0\")\n</code></pre>\n<p>On Trailmark 0.5.0+, known links between source functions and imported binary\nor external endpoints can also be declared once in <code>.trailmark/links.toml</code>\n(see the main <code>trailmark</code> skill's Repository Links section) instead of being\nre-derived per session. Declared external endpoints materialize as\n<code>proxy.external:&lt;symbol&gt;</code> nodes on every parse.</p>\n<h2>Quick Start</h2>\n<h3>CLI</h3>\n<pre><code># Augment with SARIF\nuv run trailmark augment {targetDir} --sarif results.sarif\n\n# Augment with weAudit\nuv run trailmark augment {targetDir} --weaudit .vscode/alice.weaudit\n\n# Both at once, output JSON\nuv run trailmark augment {targetDir} \\\n    --sarif results.sarif \\\n    --weaudit .vscode/alice.weaudit \\\n    --json\n</code></pre>\n<p>Binary graph augmentation is programmatic in Trailmark 0.4.0+; do not invent a\nCLI flag if <code>trailmark augment --help</code> does not show one.</p>\n<h3>Programmatic API</h3>\n<pre><code>from trailmark.query.api import QueryEngine\n\nengine = QueryEngine.from_directory(\"{targetDir}\", language=\"auto\")\n\n# Run pre-analysis first for cross-referencing\nengine.preanalysis()\n\n# Augment with SARIF\nresult = engine.augment_sarif(\"results.sarif\")\n# result: {matched_findings: 12, unmatched_findings: 3, subgraphs_created: [...]}\n\n# Augment with weAudit\nresult = engine.augment_weaudit(\".vscode/alice.weaudit\")\n\n# Augment with an external binary graph export (v0.4+)\nif hasattr(engine, \"augment_binary\"):\n    result = engine.augment_binary(\"binary_graph.json\")\n\n# Query findings\nengine.findings()                                       # All findings\nengine.subgraph(\"sarif:error\")                          # High-severity SARIF\nengine.subgraph(\"weaudit:high\")                         # High-severity weAudit\nengine.subgraph(\"sarif:semgrep\")                        # By tool name\nengine.annotations_of(\"function_name\")                  # Per-node lookup\n</code></pre>\n<p>If auto-detection is wrong for the target, rerun with an explicit language or\ncomma-separated list such as <code>python,rust</code>.</p>\n<h2>Workflow</h2>\n<pre><code>Augmentation Progress:\n- [ ] Step 1: Build graph and run pre-analysis\n- [ ] Step 2: Locate SARIF/weAudit/binary graph files\n- [ ] Step 3: Run augmentation\n- [ ] Step 4: Inspect results and subgraphs\n- [ ] Step 5: Cross-reference with pre-analysis\n</code></pre>\n<p><strong>Step 1:</strong> Build the graph and run pre-analysis for blast radius and taint\ncontext:</p>\n<pre><code>engine = QueryEngine.from_directory(\"{targetDir}\", language=\"auto\")\nengine.preanalysis()\n</code></pre>\n<p>If auto-detection is wrong for the target, rerun with an explicit language or\ncomma-separated list such as <code>python,rust</code>.</p>\n<p><strong>Step 2:</strong> Locate input files:</p>\n<ul>\n<li><strong>SARIF</strong>: Usually output by tools like <code>semgrep --sarif -o results.sarif</code>\nor <code>codeql database analyze --format=sarif-latest</code></li>\n<li><strong>weAudit</strong>: Stored in <code>.vscode/&lt;username&gt;.weaudit</code> within the workspace</li>\n<li><strong>Binary graph (v0.4+)</strong>: External JSON with <code>artifact</code>, <code>functions</code>, and\n<code>calls</code> fields. Trailmark imports this graph; it does not disassemble\nbinaries itself.</li>\n</ul>\n<p><strong>Step 3:</strong> Run augmentation via <code>engine.augment_sarif()</code> or\n<code>engine.augment_weaudit()</code>. For binary graphs, run <code>engine.augment_binary()</code>\nonly after the Version Gate succeeds. Check <code>unmatched_findings</code> in SARIF and\nweAudit results — these are findings whose file/line locations didn't overlap\nany parsed code unit.</p>\n<p><strong>Step 4:</strong> Query findings and subgraphs. Use <code>engine.findings()</code> to list all\nannotated nodes. Use <code>engine.subgraph_names()</code> to see available subgraphs.</p>\n<p><strong>Step 5:</strong> Cross-reference with pre-analysis data to prioritize:</p>\n<ul>\n<li>Findings on tainted nodes: overlap <code>sarif:error</code> with <code>tainted</code> subgraph</li>\n<li>Findings on high blast radius nodes: overlap with <code>high_blast_radius</code></li>\n<li>Findings on privilege boundaries: overlap with <code>privilege_boundary</code></li>\n</ul>\n<p>For one candidate finding that needs a reachability verdict or PoC handoff,\ncontinue with <code>trailmark-finding-triage</code> and use the augmented node as the\nbound candidate.</p>\n<h2>Annotation Format</h2>\n<p>Findings are stored as standard Trailmark annotations:</p>\n<ul>\n<li><strong>Kind</strong>: <code>finding</code> (tool-generated) or <code>audit_note</code> (human notes)</li>\n<li><strong>Source</strong>: <code>sarif:&lt;tool_name&gt;</code> or <code>weaudit:&lt;author&gt;</code></li>\n<li><strong>Description</strong>: Compact single-line:\n<code>[SEVERITY] rule-id: message (tool)</code></li>\n</ul>\n<h2>Subgraphs Created</h2>\n<table>\n<thead>\n<tr>\n<th>Subgraph</th>\n<th>Contents</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>sarif:error</code></td>\n<td>Nodes with SARIF error-level findings</td>\n</tr>\n<tr>\n<td><code>sarif:warning</code></td>\n<td>Nodes with SARIF warning-level findings</td>\n</tr>\n<tr>\n<td><code>sarif:note</code></td>\n<td>Nodes with SARIF note-level findings</td>\n</tr>\n<tr>\n<td><code>sarif:&lt;tool&gt;</code></td>\n<td>Nodes flagged by a specific tool</td>\n</tr>\n<tr>\n<td><code>weaudit:high</code></td>\n<td>Nodes with high-severity weAudit findings</td>\n</tr>\n<tr>\n<td><code>weaudit:medium</code></td>\n<td>Nodes with medium-severity weAudit findings</td>\n</tr>\n<tr>\n<td><code>weaudit:low</code></td>\n<td>Nodes with low-severity weAudit findings</td>\n</tr>\n<tr>\n<td><code>weaudit:findings</code></td>\n<td>All weAudit findings (entryType=0)</td>\n</tr>\n<tr>\n<td><code>weaudit:notes</code></td>\n<td>All weAudit notes (entryType=1)</td>\n</tr>\n<tr>\n<td><code>binary:&lt;artifact&gt;</code></td>\n<td>Binary function nodes imported from a v0.4+ binary graph</td>\n</tr>\n</tbody>\n</table>\n<h2>How Matching Works</h2>\n<p>Findings are matched to graph nodes by file path and line range overlap:</p>\n<ol>\n<li>Finding file path is normalized relative to the graph's <code>root_path</code></li>\n<li>Nodes whose <code>location.file_path</code> matches AND whose line range overlaps are\nselected</li>\n<li>The tightest match (smallest span) is preferred</li>\n<li>If a finding's location doesn't overlap any node, it counts as unmatched</li>\n</ol>\n<p>SARIF paths may be relative, absolute, or <code>file://</code> URIs — all are handled.\nweAudit uses 0-indexed lines which are converted to 1-indexed automatically.</p>\n<p>Binary graph imports create <code>origin=binary</code> function nodes, <code>origin=proxy</code>\nexternal proxy nodes for unresolved binary calls, and inferred\n<code>corresponds_to</code> edges when a binary function maps back to a source node. The\nexpected JSON shape is intentionally small:</p>\n<pre><code>{\n  \"artifact\": {\"name\": \"libexample\", \"architecture\": \"x86_64\", \"sha256\": \"...\"},\n  \"functions\": [\n    {\"symbol\": \"parse_packet\", \"address\": \"0x401000\",\n     \"source\": {\"file\": \"src/parser.c\", \"line\": 42}}\n  ],\n  \"calls\": [\n    {\"source\": \"parse_packet\", \"target\": \"malloc\", \"confidence\": \"inferred\"}\n  ]\n}\n</code></pre>\n<h2>Supporting Documentation</h2>\n<ul>\n<li><strong><a href=\"references/formats.md\">references/formats.md</a></strong> — SARIF 2.1.0 and\nweAudit file format field reference</li>\n</ul>\n","files":[{"path":"agents/openai.yaml","sizeBytes":245,"isText":true},{"path":"assets/trail-of-bits-mark.svg","sizeBytes":3084,"isText":false},{"path":"references/formats.md","sizeBytes":3609,"isText":true},{"path":"SKILL.md","sizeBytes":9335,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-09-17T16:00:22.941249Z","sha256":"E4007996D724A8AC7248D9CCB2F55E94EE8FE8910474A76358AED3C7F615EC17","sizeBytes":7151},"review":null,"source":{"repositoryUrl":"https://github.com/trailofbits/skills","path":"plugins/trailmark/skills/audit-augmentation","license":"CC-BY-SA-4.0","commit":"149d7b21f4067765b82e67029730b42d228ef4b4","subtreeSha":"6F6EEEADD0464D96B2F32902E931C0DC026D209744DD025009258F6945D75A1C","lastSyncedAt":"2026-11-20T20:46:16.927034Z"},"reviewedAt":"2026-09-17T16:05:55.25183Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/trailofbits/skills/tree/main/plugins/trailmark/skills/audit-augmentation"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install trailofbits-skills@llmmart"},{"target":"git","command":"git clone https://github.com/trailofbits/skills.git"}]}