Skip to main content

assert_redaction_canary_absent

Function assert_redaction_canary_absent 

Source
pub fn assert_redaction_canary_absent(
    serialized: &str,
    canary: &str,
) -> Result<(), RedactionCanaryError>
Expand description

Verify that a unique test canary is absent from final serialized output.

Pass the string returned by crate::render or an HTTP/body serializer, not the pre-redaction input value.

Every renderer escapes a string before it reaches the stream, so a canary can be present verbatim yet unfindable by a raw substring search: a PEM key carries newlines, a password may carry ", a Windows path carries \, and a canary inside a _url value is percent-encoded. This checks the raw text and a decoded copy of it, so the escaping a renderer applies cannot hide a leak. Decoding the haystack rather than enumerating the escaped spellings of the canary keeps the check from drifting when a renderer changes, and biases it the safe way: an over-eager decode can only raise a false alarm, never pass a real leak.