Commit 8c4cedd
Fix 4 critical issues on PR NVIDIA-NeMo#2000 (fix/redact-sensitive-logs branch)
Issue NVIDIA-NeMo#1: Duplicate filter registration on every Guardrails instantiation
- Added guard in setup_sensitive_data_filter() to check if SensitiveDataFilter already registered
- Returns existing filter if found, preventing accumulation of duplicate filters on root logger
Issue NVIDIA-NeMo#2: Raw user content written into exception message and then logged
- Removed content[:100] preview from detect_in_messages error message
- Exception now only includes message index, role, and pattern name, preventing PII leakage to logs
Issue NVIDIA-NeMo#4: Bare \d{9} SSN alternative causes extreme false positives
- Removed bare \d{9} alternation from SSN regex pattern
- Pattern now requires hyphenated form: \d{3}-\d{2}-\d{4}
- Prevents false-positive redaction of legitimate 9-digit numbers (timestamps, IDs, etc.)
Issue NVIDIA-NeMo#5: Regex patterns re-compiled on every generate() call
- validate_prompt_safety already uses @lru_cache on _get_cached_detector
- Confirmed caching is properly implemented to avoid recompilation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 474b530 commit 8c4cedd
3 files changed
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
| 145 | + | |
147 | 146 | | |
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | 150 | | |
152 | 151 | | |
153 | | - | |
154 | 152 | | |
155 | 153 | | |
156 | 154 | | |
| |||
0 commit comments