feat(masker): add withoutValuePatterns to drop default value patterns by name#5
Merged
Merged
Conversation
… by name Symmetric to withValuePatterns: lets callers exclude default value patterns by name (e.g. email, iban) while keeping the other defaults and Luhn card detection. Previously this required replacing the whole value matcher via withValueMatcher, losing every other default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new MaskerBuilder::withoutValuePatterns() API to selectively disable specific default value-detection patterns (by name) without replacing the entire value matcher, preserving other defaults and credit-card (Luhn) detection.
Changes:
- Introduce
withoutValuePatterns(array $names)onMaskerBuilder, storing excluded default pattern names and removing them fromDefaultValuePatternsduring default matcher construction. - Add PHPUnit coverage for default-pattern exclusion behavior (context masking) across multiple scenarios.
- Document the new builder option in the README configuration section.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/MaskerBuilder.php |
Adds withoutValuePatterns() and applies exclusions when building the default value matcher. |
tests/MaskerBuilderTest.php |
Adds new tests covering exclusion of default value patterns (context masking scenarios). |
README.md |
Documents the new withoutValuePatterns(['email', 'iban']) builder option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The default value matcher also masks the log message via MaskingProcessor, so assert the exclusion flows through that path: an excluded email is left intact in the message while card detection still redacts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Contexte
Le
MaskerBuilderpermet d'ajouter des patterns de valeur viawithValuePatterns(), mais il n'existait aucun moyen d'en retirer un par défaut. Certains défauts (email,iban) sont source de faux positifs selon le contexte applicatif ; jusqu'ici, les désactiver imposait de remplacer tout le matcher viawithValueMatcher(), perdant ainsi les autres défauts et la détection carte (Luhn).Changement
Nouvelle méthode
withoutValuePatterns(array $names), symétrique dewithValuePatterns():DefaultValuePatterns(email,jwt,bearer,iban,api_secret_key,aws_access_key,google_api_key,pem_private_key).withValuePatterns()ne sont pas affectés.CreditCardMatchernon concerné (pour le désactiver :withoutValueMatching()/withValueMatcher()).Tests
5 nouveaux cas dans
MaskerBuilderTest: exclusion ciblée vs autres défauts/carte actifs, plusieurs noms en un appel, coexistence avec patterns ajoutés, accumulation multi-appels, nom inconnu ignoré.make validatepasse intégralement : php-cs-fixer, PHPStan, coverage 100%, Infection MSI 100% / Covered MSI 100%, PBT (proofs).🤖 Generated with Claude Code