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 decoded copies until no escapes change, so nested URL encoding and
serialization escapes 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. Inspection is
bounded to 64 decoding passes; encoding that still changes at that bound
fails closed as RedactionCanaryError::InspectionLimitExceeded.