Skip to main content

Module baseline

Module baseline 

Source
Expand description

Baseline support: capture the findings of an existing codebase once, then suppress them on later scans so only newly introduced findings are reported.

Each baselined finding is identified by a hash of its rule id, its path relative to the baseline file, its matched text, and a couple of trimmed context lines. Line and column numbers are deliberately excluded so that inserting code above a finding does not invalidate the baseline.

Structs§

Baseline
The on-disk baseline file.
BaselineEntry
One baselined finding.

Enums§

BaselineError

Constants§

BASELINE_FILE
Name of the baseline file looked up in the working directory and its parents.

Functions§

build
Build a baseline from a scan result.
filter
Drop the findings already recorded in baseline and return the remaining ones along with how many were filtered.
find_baseline_file
Walk up from start and return the first existing baseline file.
finding_hash
Stable identity hash of a finding.
hash_findings
Hash every finding, reading each source file at most once.
load
Read and validate a baseline file.
project_root
Best guess at the project root: the closest ancestor holding a slopguard.toml, else the closest holding a .git, else start itself.
relative_path
Normalize a finding’s path so that scan ., scan ./src and scan /abs/path all hash to the same string.
write
Write a baseline as pretty-printed JSON with a trailing newline.