Перейти к содержанию
Skillpedia
Безопасность8.0k · #12708

sarif-parsing

Что он делает

Этот скилл помогает агенту открывать и приводить в порядок файлы результатов, которые создают сканеры безопасности. Он нужен разработчикам и сотрудникам безопасности, которым нужно разобраться в больших отчетах сканирования.

Когда использовать

  • ✓Когда у вас есть файл SARIF от сканера и вы хотите понять, что в нем написано.
  • ✓Когда вы запускаете несколько сканеров и хотите объединить их оповещения без дублей.
  • ✓Когда вы хотите отфильтровать вывод сканирования и передать его в сборку или дашборд.

Ссылка на скилл

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

Скопируйте и вставьте её в ваш ИИ (Claude, ChatGPT или Cursor) с просьбой следовать инструкциям.

Как использовать

Самый простой способ: скопируйте сообщение и вставьте его в свой ИИ. Он прочитает скилл и выполнит инструкции.

Готовое сообщение для вставки

Используй этот скилл, чтобы помочь мне: https://github.com/trailofbits/skills/blob/main/plugins/static-analysis/skills/sarif-parsing/SKILL.md Прочитай файл SKILL.md по этой ссылке и следуй его инструкциям в моей задаче.
Хотите, чтобы ваш ИИ сам находил такие скиллы?Установите бесплатный MCP Skillpedia: одна строка, и перед каждой задачей он ищет среди 15 000+ скиллов.Установить за 1 минуту →

Пример запроса к вашему ИИ

“У меня есть файл SARIF от нашего сканера. Можешь убрать дублирующиеся оповещения и показать только высокий риск?”

5 новых скиллов в неделю. 1 минута чтения.

Как это работает

Агент читает структуру файла результатов, группирует находки по правилу и месту и убирает повторы. Он также может преобразовать вывод в другой формат. Сами сканирования он не запускает.

Технический текст (оригинальный SKILL.md)

Оригинальный текст автора на английском, прямо с 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
Частые вопросы

Он запускает сканирование безопасности?

Нет. Он только обрабатывает уже существующие результаты, поэтому сначала нужно сканирование.

Может ли он объединять результаты разных инструментов?

Да. Он может собрать находки из нескольких инструментов безопасности в один список.

Можно ли использовать его в автоматических конвейерах?

Да. Скилл описывает, как добавить обработку SARIF в системы CI и CD.

Подробности

Оригинальное описание автора

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

Популярность

Звёзды на GitHub
8.0k
Место в рейтинге
#12708
Лицензия
CC-BY-SA-4.0
Обновлён
02.11.2026

Полезен ли этот скилл?

0

Войдите , чтобы голосовать.

Комментарии

  • …

Другие скиллы из этого репозитория

Похожие скиллы