Expand description
The linked forbidden-strings scanner: one load per invocation, typed redacted findings. What: The repository’s forbidden-strings scanner, linked in and loaded once per invocation. Why: The TypeScript wrapper wrote each candidate to a temporary file, started the scanner as a child process and parsed its standard error. Here candidate bytes go straight to the scanner library, and its own typed findings come back. Nothing is re-derived: rule loading, the rule cache, matching, redaction and the fail-closed findings all stay the scanner’s.
What the linking executable owes the scanner (package/cli/forbidden-strings/README.md,
“In-process candidate scans”):
an unwinding panic strategy,
which this file checks at
build time,
and a panic hook that prints no payload,
installed before the first scan.
The scanner catches its own loader and matcher panics;
this module adds no catch of its own.
In TS you’d write (pseudocode):
// const scanner = CandidateScanner.load(rules, true); const scan = scanner.scan(candidate, bytes);Structs§
- Candidate
Scanner - What:
The loaded scanner.
The field is private:
the only way to obtain a value is
load. Why: Holding the loaded rules in one value is what makes “load once, scan many” a property of the type: scanning borrows it and cannot reload. - Rules
Source - What:
Which rules file to load and whether its absence is an error.
PathBufowns the path (sibling&Pathwould borrow the caller’s). Why: The standalone scanner tolerates a missing default rules file when the built-in baseline is on, and never a missing file that was named explicitly. The same two facts are passed to the library. - Scanner
Error - What:
One scanner failure:
its cause and a complete explanation.
Stringowns the text (sibling&strwould borrow a temporary). Why: The explanation of a load failure is the scanner’s own redacted message, which names a path or an opaque rule index and never rule text.
Enums§
- Scanner
Failure - What:
Why a scan could not be set up or carried out.
#[derive(...)]generates copying, debug printing and==. Why: Both causes stop policy evaluation: no rules means nothing was checked, and a pathname that cannot be handed to the scanner was not checked.