Security¶
PII detection and redaction utilities.
PII Scanner¶
agentprobe.security.pii
¶
PII detection and redaction utilities.
Provides pattern-based scanning for common PII types (email, phone, SSN, credit card, IP address) with scan and redact operations.
PIIMatch
¶
Bases: BaseModel
A single PII detection match.
Attributes:
| Name | Type | Description |
|---|---|---|
pii_type |
str
|
Category of PII detected. |
value |
str
|
The matched text. |
start |
int
|
Start index in the source text. |
end |
int
|
End index in the source text. |
Source code in src/agentprobe/security/pii.py
PIIRedactor
¶
Scans text for PII and optionally redacts matches.
Supports configurable PII types and custom patterns.
Attributes:
| Name | Type | Description |
|---|---|---|
enabled_types |
Set of PII type names to detect. |
Source code in src/agentprobe/security/pii.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__init__(enabled_types=None, custom_patterns=None)
¶
Initialize the PII redactor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled_types
|
set[str] | None
|
PII types to enable. None enables all built-in types. |
None
|
custom_patterns
|
dict[str, Pattern[str]] | None
|
Additional named patterns to check. |
None
|
Source code in src/agentprobe/security/pii.py
scan(text)
¶
Scan text for PII matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to scan. |
required |
Returns:
| Type | Description |
|---|---|
list[PIIMatch]
|
List of PII matches found, sorted by position. |
Source code in src/agentprobe/security/pii.py
redact(text)
¶
Redact all detected PII from text.
Replaces each match with a type-specific label (e.g. [EMAIL]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to redact. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Text with PII replaced by labels. |
Source code in src/agentprobe/security/pii.py
has_pii(text)
¶
Check if text contains any detectable PII.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to check. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if PII was detected. |