Skip to content

v0.3.0 — PII Detection & Redaction

Choose a tag to compare

@mthamil107 mthamil107 released this 24 Feb 13:17
· 148 commits to main since this release
6c3a4bc

What's New

PII Detection & Redaction

New d023_pii_detection detector and standalone PIIRedactor for detecting and redacting personally identifiable information before prompts reach the LLM. Mapped to OWASP LLM02 (Sensitive Information Disclosure).

  • 6 entity types: email, phone, SSN, credit card, API key, IP address (16 regex patterns)
  • Entity-type-aware redaction: [EMAIL_REDACTED], [SSN_REDACTED], [CREDIT_CARD_REDACTED], etc.
  • CLI commands: prompt-shield pii scan and prompt-shield pii redact with --json-output support
  • Per-entity configuration: enable/disable individual entity types and add custom patterns via YAML config
  • AgentGuard integration: automatic PII redaction in the sanitize flow
  • Standalone Python API: PIIRedactor usable directly without AgentGuard

New Files

File Purpose
src/prompt_shield/pii/entity_types.py EntityType enum, 16 default patterns, replacement strings
src/prompt_shield/pii/redactor.py PIIRedactor class with overlap dedup and entity-aware placeholders
src/prompt_shield/detectors/d023_pii_detection.py Regex-based PII detector, configurable via YAML
src/prompt_shield/models.py Added RedactionResult model

Modified

  • CLI: Added pii command group with scan and redact subcommands
  • AgentGuard: Entity-type-aware redaction when d023 detections are present
  • OWASP mapping: d023 → LLM02 (Sensitive Information Disclosure)
  • Config: d023_pii_detection block with per-entity enable/disable

Tests

  • 46 new tests (24 detector + 14 redactor + 8 CLI)
  • Full suite: 482 tests passing