feat(extension): configurable PII entity types and custom regex patterns#470
Open
yjouini wants to merge 2 commits into
Open
feat(extension): configurable PII entity types and custom regex patterns#470yjouini wants to merge 2 commits into
yjouini wants to merge 2 commits into
Conversation
…u#458, dataiku#459) Extension: - PII types card: fetch labels from backend, persist disabled set in chrome.storage.sync, send enabled_labels per-request so the backend only masks the chosen types - Custom patterns card: add/edit/remove user-defined regex rules with label, regex, description, and a custom replacement string; live preview against sample text - Labels list merges ML-model labels with custom-pattern labels so custom types appear in the entity-type grid Backend: - GET /api/pii/labels — returns all known labels (model + custom) - GET/POST /api/pii/patterns — list and create custom patterns - PUT/DELETE /api/pii/patterns/{id} — update or remove a pattern - custom_patterns table in SQLite with enabled/replacement columns; ALTER TABLE migrations handle existing databases - MaskText accepts enabled_labels to filter which types are masked (nil = all, used by the transparent proxy) - Custom regex runner (regex_detector.go) appended after ML entities; entity-level Replacement field lets each pattern specify its own placeholder instead of falling back to [LABEL] - deduplicateEntities removes overlapping spans before masking, preferring the longer match; same-length ties go to the custom regex entity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove Description field - Shorten placeholders, move examples to title tooltips - Add visible hint for Replacement default behavior - Remove text-overflow ellipsis so saved regexes aren't trimmed
9c83ffd to
16d0268
Compare
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.
Closes #458, Closes #459
Chrome extension
GET /api/pii/labels. Unchecked types are persisted tochrome.storage.syncand sent asenabled_labelswith each/api/pii/checkfrombackground.js. "Disable all / Enable all" toggle included.Backend — API
GET /api/pii/labelslabel_mappings.json(BIO-prefix stripped) merged with custom pattern labelsGET /api/pii/patternsPOST /api/pii/patternsPUT /api/pii/patterns/{id}DELETE /api/pii/patterns/{id}Backend — Internals
custom_patternstable withenabled/replacementcolumns.ALTER TABLEmigrations for existing databases.MaskTextacceptsenabledLabelsto filter which entity types are masked (nil= all, used by proxy pipeline). Custom regex runner appended after ML entities, respecting the same filter.EMPLOYEE_ID) produce[LABEL]instead of a generic placeholder, so the LLM retains semantic context.MaskPIIInTextFilteredexposed for the extension flow,MaskPIIInTextunchanged for the proxy pipeline.Testing
TestCustomPattern_CreateAndList,TestCustomPattern_Update,TestCustomPattern_Delete,TestCustomPattern_EmptyListIsNotNil, plus 5TestDeduplicateEntities_*cases. All Go tests pass:make test-goAll 55 Go tests pass:
make test-gofeature.select.pii.and.custom.regex.mp4