fix: tighten pii filter behavior and rust masking strategy#3803
Merged
crivetimihai merged 4 commits intomainfrom Mar 23, 2026
Merged
fix: tighten pii filter behavior and rust masking strategy#3803crivetimihai merged 4 commits intomainfrom
crivetimihai merged 4 commits intomainfrom
Conversation
995087e to
a88b0a3
Compare
… README Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
Signed-off-by: lucarlig <luca.carlig@ibm.com>
a88b0a3 to
8416d9c
Compare
Member
Review NotesRebased onto current Code ReviewThe core fix is correct and well-designed. Changing
Applied consistently in both SecurityThis is a security improvement. Before this fix, even with Tests
Observations (non-blocking)
|
crivetimihai
approved these changes
Mar 23, 2026
Member
crivetimihai
left a comment
There was a problem hiding this comment.
Reviewed and approved. Rebased cleanly onto main, all tests pass, logic is correct, and the fix improves security posture for PII masking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
Closes #3724
Closes #3738
📝 Summary
This PR tightens the PII filter behavior across both the plugin layer and the Rust detector.
At the plugin level, it preserves the current enforcement/permissive flow while making the fallback path clearer: when the Rust detector is unavailable, the legacy Python detector now emits a one-time deprecation warning instead of silently taking over. The branch also expands test coverage around plugin configuration behavior, including masking modes, whitelist handling, detection metadata, and Python-fallback signaling.
At the Rust layer, it fixes the core masking bug where built-in detections were ignoring the configured
default_mask_strategyand forcing hardcoded partial masks. Built-in SSN/email/AWS detections now honor the configured default strategy, while custom patterns still keep their explicit mask-strategy overrides.The PII filter README is also updated to match current reality: correct test paths, current prompt invocation examples, and the correct local/compose ports for manual verification.
🏷️ Type of Change
🧪 Verification
make --no-print-directory pre-commitcargo testandpytest tests/unit/mcpgateway/plugins/plugins/pii_filter/test_pii_filter.py -q✅ Checklist
make black isort pre-commit)📓 Notes (optional)
default_mask_strategy=redact, built-in detections still returnedpartial.