CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

trysac/sarif-merge

Merge SARIF 2.1.0 logs from several scanners into one de-duplicated log and mark results new, unchanged or absent versus a baseline. Use when the user has several .sarif files or asks what a scan newly introduced.

Quality

97%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files
name:
sarif-merge
description:
Merge SARIF 2.1.0 logs from several scanners into one de-duplicated log and mark results new, unchanged or absent versus a baseline. Use when the user has several .sarif files or asks what a scan newly introduced.

sarif-merge

Combine SARIF 2.1.0 files from different scanners into one log, and compare a scan with a previous one. Everything runs locally on files with Python 3.10+ (standard library only); no package install and no network access are needed.

When to use

  • The user has two or more .sarif files (for example SAST, secrets and dependency scanners) and wants a single log.
  • The user asks which findings are new compared with an earlier scan (baseline).
  • A CI step must fail only when a scan introduces new results.

Workflow

  1. Locate the input files and confirm each one is SARIF 2.1.0 ("version": "2.1.0").
  2. Merge: python3 scripts/sarif_merge.py merge a.sarif b.sarif --output merged.sarif
  3. Compare with a baseline: python3 scripts/sarif_merge.py baseline current.sarif baseline.sarif --output compared.sarif --fail-on-new
  4. Read runs[].properties.sarifMerge in the output (inputResults, duplicates) and results[].baselineState (new, unchanged, absent) to report the outcome.
  5. Report counts and the most relevant new results to the user. Never edit the input files.

Exit codes: 0 success, 1 new results found with --fail-on-new, 2 usage, I/O or invalid SARIF (the reason is printed to stderr).

How results are matched

Runs are grouped by tool driver name and version. Results are de-duplicated by a SHA-256 key built from the rule id plus partialFingerprints.primaryLocationLineHash when present, otherwise from the rule id, normalised file URI, start line and message text. Rule tables are merged and every ruleIndex is recomputed. Run-level artifacts arrays are dropped and artifactLocation.index values are removed so no index dangles. Details and limits are in references/merge-rules.md.

Limits

  • Only SARIF 2.1.0; other versions are rejected.
  • Up to 50 MiB per file and 100,000 results in total.
  • Results without a resolvable rule id are rejected as invalid.
  • It does not validate the full SARIF schema, only the structure it needs.

Project source: https://github.com/Trysac/u260-sarif-merge

Workspace
trysac
Visibility
Public
Created
Last updated
Source
CLI
Repository
No repository linked. Set repository in the plugin manifest, or publish from a GitHub Action to verify it.
Badge
trysac/sarif-merge badge