mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix: Address Greptile review feedback
- Tighten ca_postal_code keyword_pattern: replace broad "address" with specific compound terms (mailing/street/shipping/home address) - Add missing "PIPEDA" tag to policy_templates.json for discoverability - Add us_phone pattern to test_ca_policy_e2e.py setup to match deployed template - Add phone number e2e test for complete coverage Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
74ed48d5d7
commit
ce96d78203
3 changed files with 27 additions and 1 deletions
|
|
@ -595,7 +595,7 @@
|
|||
"pattern": "\\b[ABCEGHJ-NPRSTVXY]\\d[ABCEGHJ-NPRSTV-Z][\\-\\s]?\\d[ABCEGHJ-NPRSTV-Z]\\d\\b",
|
||||
"category": "Canadian PII Patterns",
|
||||
"description": "Detects Canadian postal codes (A1A 1A1 format, excludes invalid first-letter characters per Canada Post spec)",
|
||||
"keyword_pattern": "\\b(?:postal\\s*code|zip\\s*code|mailing\\s*address|address|code\\s*postal|postcode)\\b",
|
||||
"keyword_pattern": "\\b(?:postal\\s*code|zip\\s*code|mailing\\s*address|street\\s*address|shipping\\s*address|home\\s*address|code\\s*postal|postcode)\\b",
|
||||
"allow_word_numbers": false
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2704,6 +2704,7 @@
|
|||
"tags": [
|
||||
"PII Protection",
|
||||
"Canada",
|
||||
"PIPEDA",
|
||||
"FIPPA"
|
||||
],
|
||||
"estimated_latency_ms": 1
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@ class TestCanadianPIIPolicyE2E:
|
|||
pattern_name="email",
|
||||
action=ContentFilterAction.MASK,
|
||||
),
|
||||
ContentFilterPattern(
|
||||
pattern_type="prebuilt",
|
||||
pattern_name="us_phone",
|
||||
action=ContentFilterAction.MASK,
|
||||
),
|
||||
ContentFilterPattern(
|
||||
pattern_type="prebuilt",
|
||||
pattern_name="ca_postal_code",
|
||||
|
|
@ -344,6 +349,26 @@ class TestCanadianPIIPolicyE2E:
|
|||
assert "REDACTED" not in output
|
||||
assert output == text
|
||||
|
||||
# =====================
|
||||
# Phone Number tests
|
||||
# =====================
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_phone_number_masked(self):
|
||||
"""North American phone number is detected and masked"""
|
||||
guardrail = self.setup_canadian_guardrail()
|
||||
|
||||
text = "Call me at (416) 555-1234 to discuss."
|
||||
result = await guardrail.apply_guardrail(
|
||||
inputs={"texts": [text]},
|
||||
request_data={},
|
||||
input_type="request",
|
||||
)
|
||||
output = result.get("texts", [])[0]
|
||||
|
||||
assert "REDACTED" in output
|
||||
assert "(416) 555-1234" not in output
|
||||
|
||||
# =====================
|
||||
# Postal Code tests
|
||||
# =====================
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue