Expand description
Structured reporting for sanitization runs.
Generates a JSON report summarising what the sanitization tool did without ever including original secret values. The report captures:
- Metadata: tool version, CLI flags, timestamp.
- Per-file details: matches found, replacements applied, bytes processed, and per-pattern match counts.
- Aggregated summary: totals across all files plus wall-clock duration.
§Thread Safety
ReportBuilder is Send + Sync. Multiple threads can record file
results concurrently via ReportBuilder::record_file, which takes
an internal Mutex only long enough to push a single entry.
§Example
use sanitize_engine::report::{ReportBuilder, ReportMetadata, FileReport};
use std::collections::HashMap;
let meta = ReportMetadata {
version: "0.2.0".into(),
timestamp: "2026-03-01T00:00:00Z".into(),
deterministic: true,
dry_run: false,
strict: false,
chunk_size: 1_048_576,
threads: Some(4),
secrets_file: Some("secrets.enc".into()),
};
let builder = ReportBuilder::new(meta);
builder.record_file(FileReport {
path: "data.log".into(),
matches: 42,
replacements: 42,
bytes_processed: 10_000,
bytes_output: 10_200,
pattern_counts: HashMap::from([("email".into(), 30), ("ipv4".into(), 12)]),
method: "scanner".into(),
});
let report = builder.finish();
let json = report.to_json_pretty().unwrap();
assert!(json.contains("\"total_matches\": 42"));Structs§
- File
Report - Per-file result details.
- Report
Builder - Thread-safe builder that accumulates per-file results and produces
a final
SanitizeReport. - Report
Metadata - Tool metadata embedded in every report.
- Report
Summary - Aggregated summary across all processed files.
- Sanitize
Report - Top-level sanitization report.