pub fn redact(
source: &str,
report: &ScanReport,
) -> Result<String, TransformError>Expand description
Redacts all findings in report using the standard [REDACTED] marker.
The returned string contains the original source outside detected spans. The source and matched values are never stored in the report or in transformation metadata.
§Errors
Returns TransformError when a finding contains an invalid or non-UTF-8
aligned byte span for source.
§Examples
use cribra::{Rule, Scanner, Severity, transform::redact};
let scanner = Scanner::builder()
.rule(Rule::literal("secret", "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]");