Skip to content
Skillpedia
Security8.0k Β· #12708

sarif-parsing

What it does

This skill helps the agent open and clean up the result files that security scanners produce. It is for developers and security staff who need to make sense of large scan reports.

When to use it

  • βœ“When you have a SARIF file from a scanner and want to know what it says.
  • βœ“When you run several scanners and want their alerts combined without duplicates.
  • βœ“When you want to filter scan output and feed it into a build or dashboard.

Skill link

https://github.com/trailofbits/skills/blob/main/plugins/static-analysis/skills/sarif-parsing/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/trailofbits/skills/blob/main/plugins/static-analysis/skills/sarif-parsing/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œI have a SARIF file from our scanner. Can you remove the duplicate alerts and list only the high-risk ones?”

5 new skills a week. 1 minute to read.

How it works

The agent reads the structure of the results file, groups findings by rule and location, and removes repeated entries. It can also convert the output to another format. It does not run scans itself.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

SARIF Parsing Best Practices

You are a SARIF parsing expert. Your role is to help users effectively read, analyze, and process SARIF files from static analysis tools.

When to Use

Use this skill when:

  • Reading or interpreting static analysis scan results in SARIF format
  • Aggregating findings from multiple security tools
  • Deduplicating or filtering security alerts
  • Extracting specific vulnerabilities from SARIF files
  • Integrating SARIF data into CI/CD pipelines
  • Converting SARIF output to other formats

When NOT to Use

Do NOT use this skill for:

  • Running static analysis scans (use CodeQL or Semgrep skills instead)
  • Writing CodeQL or Semgrep rules (use their respective skills)
  • Analyzing source code directly (SARIF is for processing existing scan results)
  • Triaging findings without SARIF input (use variant-analysis or audit skills)

SARIF Structure Overview

SARIF 2.1.0 is the current OASIS standard. Every SARIF file has this hierarchical structure:

sarifLog
β”œβ”€β”€ version: "2.1.0"
β”œβ”€β”€ $schema: (optional, enables IDE validation)
└── runs[] (array of analysis runs)
    β”œβ”€β”€ tool
    β”‚   β”œβ”€β”€ driver
    β”‚   β”‚   β”œβ”€β”€ name (required)
    β”‚   β”‚   β”œβ”€β”€ version
    β”‚   β”‚   └── rules[] (rule definitions)
    β”‚   └── extensions[] (plugins)
    β”œβ”€β”€ results[] (findings)
    β”‚   β”œβ”€β”€ ruleId
    β”‚   β”œβ”€β”€ ruleIndex (index into tool.driver.rules[])
    β”‚   β”œβ”€β”€ level (OPTIONAL, inherited from the rule when absent)
    β”‚   β”œβ”€β”€ message.text
    β”‚   β”œβ”€β”€ locations[]
    β”‚   β”‚   └── physicalLocation
    β”‚   β”‚       β”œβ”€β”€ artifactLocation.uri
    β”‚   β”‚       └── region (startLine, startColumn, etc.)
    β”‚   β”œβ”€β”€ fingerprints{}
    β”‚   └── partialFingerprints{}
    └── artifacts[] (scanned files metadata)

Severity Is Not Always on the Result

result.level is optional. CodeQL omits it on every result and records severity on the rule as defaultConfiguration.level, which the result inherits. Read result.level directly and a CodeQL run scores as clean however many errors it found, which is how a severity gate ends up exiting 0 on a failing repo.

Resolve severity in this order (SARIF 2.1.0 section 3.27.10):

  1. kind other than "fail" (a pass/notApplicable record), so "none"
  2. result.level, when present
  3. the matched rule's defaultConfiguration.level, joining ruleIndex into runs[].tool.driver.rules[], or matching ruleId against rules[].id when the tool omits ruleIndex
  4. "warning", the SARIF default

Every severity query in this skill starts from that resolution. In jq it is the LEVEL_FN definition in {baseDir}/resources/jq-queries.md; in Python it is resolve_level(result, run) in {baseDir}/resources/sarif_helpers.py.

Why Fingerprinting Matters

Without stable fingerprints, you can't track findings across runs:

  • Baseline comparison: "Is this a new finding or did we see it before?"
  • Regression detection: "Did this PR introduce new vulnerabilities?"
  • Suppression: "Ignore this known false positive in future runs"

Tools report different paths (/path/to/project/ vs /github/workspace/), so path-based matching fails. Fingerprints hash the content (code snippet, rule ID, relative location) to create stable identifiers regardless of environment.

Tool Selection Guide

Use Case Tool Install / run
Quick CLI queries jq brew install jq / apt install jq
Python scripting (simple) pysarif uv run --with pysarif python script.py
Python scripting (advanced) sarif-tools uv run --with sarif-tools python script.py
.NET applications SARIF SDK NuGet package
JavaScript/Node.js sarif-js npm package
Go applications garif go get github.com/chavacava/garif
Validation SARIF Validator sarifweb.azurewebsites.net

Strategy 1: Quick Analysis with jq

For rapid exploration and one-off queries:

# Pretty print the file
jq '.' results.sarif

# Count total findings
jq '[.runs[].results[]] | length' results.sarif

# List all rule IDs triggered
jq '[.runs[].results[].ruleId] | unique' results.sarif

# Severity resolution, needed by every query below that filters on level.
# See resources/jq-queries.md for the annotated version.
LEVEL_FN='
  def rule($run):
    . as $r
    | ($run.tool.driver.rules // []) as $rules
    | (if ($r.ruleIndex | type) == "number" and $r.ruleIndex >= 0
       then $rules
FAQ

Does it run a security scan?

No. It only processes results that already exist, so you need a scan first.

Can it combine results from different tools?

Yes. It can aggregate findings from several security tools into one list.

Can it be used in automated pipelines?

Yes. The skill covers how to add SARIF processing to CI and CD systems.

Details

Original description by the author

Parses and processes SARIF files from static analysis tools like CodeQL, Semgrep, or other scanners. Triggers on "parse sarif", "read scan results", "aggregate findings", "deduplicate alerts", or "process sarif output". Handles filtering, deduplication, format conversion, and CI/CD integration of SARIF data. Does NOT run scans β€” use the Semgrep or CodeQL skills for that.

repo: trailofbits/skills

Popularity

GitHub stars
8.0k
Ranking position
#12708
License
CC-BY-SA-4.0
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills