Fix DataFilter false positives for UUIDs and MongoDB ObjectIds #518
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.
Fix DataFilter False Positives for UUIDs and ObjectIds ✅
Problem
The DataFilter incorrectly flagged UUIDs and MongoDB ObjectIds as credit card numbers (PANs), replacing them with
[filtered]. This happened when:Root Cause
The
filterPanNumbersmethod stripped all non-digit characters and then checked against PAN regex patterns, which caused false positives for valid identifiers.Solution
Added UUID and ObjectId detection before PAN checking:
The
filterPanNumbersmethod now:Changes Made
objectIdRegexto detect MongoDB ObjectIdsuuidRegexto detect UUIDs (enforcing consistent dash usage)filterPanNumbersto check UUID/ObjectId patterns firstTest Coverage
Tests now use problematic values that would be incorrectly filtered without the fix:
4a1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d(16 digits → Visa pattern)5A1B2C3D-4E5F-6A7B-8C9D-0E1F2A3B4C5D(16 digits → Mastercard pattern)4111111111111111abcdefab(16 digits → Visa pattern)5111111111111111ABCDEFAB(16 digits → Mastercard pattern)All tests would FAIL if lines 109-123 are commented out.
Security Summary
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.