Skip to main content

Use case

Regression probe for the custom Presidio PatternRecognizer registered for US_SSN. Presidio’s built-in SSN recognizer scores bare dashed format (123-45-6789) well below the default threshold, so Declaw ships a custom recognizer that fires at a lower confidence. This example uses httpbin.org/post as an echo mirror to verify that SSN patterns are caught and redacted before reaching the upstream.

What you’ll learn

  • Configuring PIIConfig with rehydrate_response=False so the echo response shows exactly what the upstream received
  • Using httpbin.org/post as a zero-dependency mirror for redaction tests
  • Verifying that SSN, email, and person-name PII types are all redacted

Prerequisites

Code walkthrough

Create a security policy with PII redaction enabled and rehydration disabled. Rehydration must be off so the echoed response shows the raw redacted tokens:
The probe script POSTs a JSON body containing an SSN, email, and name to httpbin.org/post, which echoes the body back verbatim:
Run the probe inside a sandbox and check the echo:

Expected output

All three identifiers are replaced with [REDACTED_*] tokens before the request reaches httpbin. If the SSN passes through unredacted, the probe exits with a non-zero code.

Full source

See cookbook/examples/pii-ssn-redaction/main.py in the repo.