scansift
Exact, local triage of SARIF static-analysis results, as three Hermes tools.
SARIF 2.1.0 is the common output format of static analyzers and security
scanners: CodeQL, Semgrep, ruff, Bandit, ESLint, Trivy, Checkov, gosec, Snyk
Code, Clang Static Analyzer and many more. A real scan is thousands of results
in a JSON file of many megabytes. ruff over Hermes' agent/, tools/ and
gateway/ with every rule on writes 145 MB and 179,417 results. scansift reads
the file on disk and returns exact answers, and tells you which results a change
introduced.
Why a tool and not a prompt or skill
-
New results, not all results.
sarif_diffcompares a branch scan with a
baseline scan. Real output for ruff on two Hermes commits 40 apart: 214 new,
17 gone, 179,203 unchanged. 204 of the 214 new results are on lines git says
those commits changed; the rest are whole-function rules reported at a
definition.Results are matched:
- by SARIF fingerprints when both scans carry them, in the same file: a full
fingerprintsvalue in common, or everypartialFingerprintskey both
carry agreeing (CodeQL's column fingerprint alone is a small number many
results share); - otherwise by tool, rule, file, logical location, message (numbers masked)
and code snippet; - never by line number, which moves with any edit above.
A result whose level rose (warning to error) is listed under
escalated, and
it counts for thefail_ongate.Identical results in one file (thirty "line too long" messages) are paired in
line order, accounting for how far edits moved the lines around them. That way
the result reported as new is the one on the edited line, not just any one of
thirty. - by SARIF fingerprints when both scans carry them, in the same file: a full
-
Two checkouts, one answer. Analyzers often write absolute paths
(/tmp/build-4f2/src/app.py).sarif_difffinds the pair of checkout roots
under which the most files of the two scans line up and compares repository
paths. Paths outside the checkout (/usr/include/stdio.h) still match as
they are. Files in different directories are never matched to each other,
even when they share a name. -
What the format says, applied exactly:
- Levels come from the result. Failing that, they come from the
invocation'sruleConfigurationOverrides, then the rule's default, then
SARIF's default. A kind other thanfaildefaults tonone. - Rules are looked up by index (in the driver or an extension named by index,
name or guid), then by id, a hierarchical id's parent (CA1000/1), then name. - Messages are rebuilt from
messageStringsand their{0}arguments, with
doubled braces read as literal braces. Locations named byartifacts[index]
are resolved. - A suppression without a status, or with status
accepted, hides a result;
underReviewandrejecteddo not. - GitHub's
security-severityis banded into critical, high, medium and low. - An analysis that reports it failed, or that logged errors, is flagged.
Missing results then are not evidence of clean code.
- Levels come from the result. Failing that, they come from the
Tools
All three always return a JSON string. A bad path or a file that is not SARIF
2.x returns { "ok": false, "error": "..." } rather than raising. path
(base/head) is a .sarif / .sarif.json file, or a directory searched for
them. Dotfiles and other JSON are ignored.
sarif_summary
| arg | type | required | default | meaning |
|---|---|---|---|---|
path | string | yes | - | SARIF file or directory |
top | integer | no | 15 | rules and files to rank (cap 200) |
Returns:
results, andactive(not suppressed, kind fail, open or review);by_level,by_kindandsuppressed;security_severityandbaseline_state;- the
rulesandfileswith the most results, worst level first; analysis_errors.
sarif_findings
| arg | type | required | default | meaning |
|---|---|---|---|---|
path | string | yes | - | SARIF file or directory |
rules | string[] | no | - | only these rule ids |
levels | string[] | no | all | error, warning, note, none |
files | string[] | no | - | file patterns, * matches any characters |
contains | string | no | - | text in the message (case-insensitive) |
include_suppressed | boolean | no | false | also list suppressed results |
offset / limit | integer | no | 0 / 25 | paging (limit cap 500) |
Each result has:
rule,rule_name,level,file,line,columnandmessage;snippet,security_severityandhelp, when the file has them;tool.
Most severe first.
sarif_diff
| arg | type | required | default | meaning |
|---|---|---|---|---|
base | string | yes | - | baseline SARIF file or directory |
head | string | yes | - | new SARIF file or directory |
fail_on | string | no | - | error, warning or note: passed is false if a new result is at this level or worse |
limit | integer | no | 25 | results per list (cap 500) |
Returns:
newandgone, each with counts by level and by rule, plus the results
themselves;unchangedandmatched_by;noteswhen the scans come from different tools or an analysis reported errors.
Suppressed results are left out on both sides.
Limits
- SARIF 2.x only. SARIF 1.0 (2016) files are refused with a message.
- Without fingerprints or snippets (ruff writes neither), two identical results
in one file are told apart only by their line order. That is right for code
that was edited, but not for code that was moved. - A relative URI is taken as the repository path. That is SARIF's
%SRCROOT%convention. Two scans whoseuriBaseIdroots point at different
sub-directories of a repository are not comparable result by result. - Results are compared within the same tool. A scan from another tool, or another
version of a tool with renamed rules, shows as all new and all gone.notes
says when the tools differ.
Safety
- Read-only. It reads only the paths you pass: regular files up to 256 MiB, and
500 files per directory. - No network, no credentials, no subprocess (it never runs an analyzer), no
background work, no self-update. Standard library only. - Honours Hermes' core read denylist (credential stores, project
.envfiles,
NT/device namespace paths). Each path, including each file found in a
directory, is checked as given and as an absolute path before anything is
opened. Device, fd and/procpaths are refused, also through symlinks, and
symlinked directories are not walked.
Install
hermes plugins install rodricksz4h5/scansift --enable
License
MIT
README from the reviewed commit ace9188; it updates when the author re-pins.

rodricksz4h5