v0.3.0 — PII Detection & Redaction
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 scanandprompt-shield pii redactwith--json-outputsupport - 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:
PIIRedactorusable 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
piicommand group withscanandredactsubcommands - AgentGuard: Entity-type-aware redaction when d023 detections are present
- OWASP mapping: d023 → LLM02 (Sensitive Information Disclosure)
- Config:
d023_pii_detectionblock with per-entity enable/disable
Tests
- 46 new tests (24 detector + 14 redactor + 8 CLI)
- Full suite: 482 tests passing