Expand description
Privacy-first scanning core for secrets and sensitive data.
silens-scan provides deterministic detection, reporting, querying and
share-safe transformation of UTF-8 text. Applications own I/O and storage;
the crate operates on caller-provided text and does not retain matched
secret values inside public Finding values.
§Quick start
use silens_scan::Scanner;
let scanner = Scanner::default();
let results = scanner.scan([
("config.env", "TOKEN=example"),
("settings.toml", "mode = \"production\""),
]);
assert_eq!(results.len(), 2);
println!("{}", results.summary());§Result model
A scan returns ScanResults<K>, preserving the caller’s source key K.
Each source owns an immutable ScanReport, whose Finding values expose
rule metadata, severity, confidence, optional Remediation and a
Location.
Source coordinates use:
- zero-based, half-open UTF-8 byte offsets;
- one-based lines;
- one-based Unicode scalar columns.
Findings intentionally do not contain the matched source value.
§Querying
ScanResults::query builds a lazy ScanQuery over borrowed findings.
Filters can be composed before optionally materializing an explicitly sorted
SortedScanQuery.
use silens_scan::{ScanSort, Scanner, Severity};
let scanner = Scanner::default();
let results = scanner.scan([("config.env", "TOKEN=example")]);
let findings = results
.query()
.minimum_severity(Severity::High)
.sort(ScanSort::Location);
for (source, finding) in findings.iter() {
println!("{source}: {}", finding.rule_id());
}§Transformations
transform provides explicit share-safe transformations:
transform::redactfor conservative replacement;transform::templatefor semantic placeholders;transform::pseudonymizefor deterministic keyed pseudonyms;transform::synthesizefor deterministic keyed synthetic values;transform::ShareBundlefor transformed keyed batches plus manifest metadata.
use silens_scan::{Rule, Scanner, Severity, transform::redact};
let scanner = Scanner::builder()
.rule(Rule::literal("credential", "SECRET", Severity::High))
.build()?;
let source = "TOKEN=SECRET";
let results = scanner.scan([("memory", source)]);
let report = results.single_report().expect("one report");
assert_eq!(redact(source, report)?, "TOKEN=[REDACTED]");
§Optional features
serde enables serialization support for public data contracts.
parallel enables [Scanner::parallel_scan], which distributes independent
inputs through Rayon while preserving input order and the same per-source
semantics as serial scanning.
§Application boundary
File loading, network access, repository integration, authentication, persistence and UI are intentionally outside this crate. This keeps the scanner reusable in local-first native, WASM/PWA, desktop and service applications. Privacy-first Rust engine for detecting secrets and sensitive data.
Silens Scan is a deterministic, local-first scanning core. It accepts UTF-8 text and returns structured findings without filesystem, network, terminal, browser or cloud responsibilities.
§Example
use silens_scan::{Rule, Scanner, Severity};
let scanner = Scanner::builder()
.rule(Rule::prefix(
"example-token",
"example_live_",
Severity::Critical,
))
.build()?;
let results = scanner.scan([
("memory", "TOKEN=example_live_123456"),
]);
let report = results.single_report().expect("one source was scanned");
assert_eq!(report.len(), 1);
With the optional parallel feature, the same batch can be scanned with
[Scanner::parallel_scan] while preserving input order.
Re-exports§
pub use transform::redact;
Modules§
Structs§
- Finding
- A single detection produced by a scanner.
- Location
- Exact location of a detected span in a UTF-8 source string.
- Redaction
- Replacement text used when presenting or exporting a detected span.
- Rule
- Owned declarative detection rule.
- RuleId
- Stable identifier assigned to a detection rule.
- Rule
Spec - Allocation-free definition of a built-in rule.
- Scan
Entry - Result produced for one identified UTF-8 source.
- Scan
Query - Borrowed query over findings produced by a batch scan.
- Scan
Report - Findings produced by scanning one UTF-8 source.
- Scan
Results - Ordered results for a batch of identified UTF-8 sources.
- Scan
Summary - Aggregate statistics derived from
ScanResults. - Scanner
- Immutable scanner that executes a precompiled set of detection rules.
- Scanner
Builder - Builder used to configure and compile an immutable
Scanner. - Sorted
Scan Query - Materialized, sorted view of findings selected by a
ScanQuery.
Enums§
- Confidence
- Indicates how reliable a detection is.
- Remediation
- Recommended response to a detected sensitive value.
- Rule
Error - Error produced while constructing an individual
Rule. - Rule
Kind - Declarative matching strategy used by a static
RuleSpec. - Scan
Sort - Ordering applied when a scan query is materialized.
- Scanner
Build Error - Error returned when a
Scannercannot be compiled from its configured rules. - Severity
- Indicates the impact of a detected finding.