-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Allow users to set replaceGroups on regex PII rules
#103885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #103885 +/- ##
===========================================
- Coverage 80.69% 80.58% -0.12%
===========================================
Files 9297 9292 -5
Lines 398973 396716 -2257
Branches 25286 25284 -2
===========================================
- Hits 321954 319693 -2261
- Misses 76559 76563 +4
Partials 460 460 |
replaceGroups on regex PII rules
| checked={values.replaceCaptured === 'true'} | ||
| disabled={!hasCaptureGroups(values.pattern)} | ||
| onChange={e => | ||
| onChange('replaceCaptured', e.target.checked.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate that replaceCaptured has to be a string, but it is forced by the following type:
| export type EditableRule = Omit<Record<KeysOfUnion<Rule>, string>, 'id'>; |
static/app/views/settings/components/dataScrubbing/modals/modalManager.tsx
Show resolved
Hide resolved
| export function hasCaptureGroups(pattern: string) { | ||
| const m = pattern.match(/\(.*\)/); | ||
| return m !== null && m.length > 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Incorrect regex capture group detection logic
The hasCaptureGroups function incorrectly identifies capture groups by matching any parentheses with /\(.*\)/. This matches non-capturing groups like (?:...), lookaheads like (?=...), and even escaped literal parentheses \(, treating them all as capturing groups when they're not. This causes the checkbox to remain enabled for patterns that don't actually have capture groups.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fair point, but I only use this as a minimal condition to enable the checkbox. The user still needs to willingly check it to enable replacement.
priscilawebdev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
Relay already has the ability to configure what part of a pattern match to scrub, but so far it has not been exposed to users. Add a checkbox to the UI to allow scrubbing the first match group instead of the entire expression.
Fixes INGEST-625