Add support for negative lookups to constraints. #38
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.
Constraints are used to specifically state if am entry should be anonymized, but there are cases where the opposite scenario is needed, where an explicit declaration should not be anonymized.
This PR introduces the concept of negative constraints, specifically
not like
(or justnot
and similar shorthands), when anot
rule is hit, it will not perform anonymization for the given value, this can be useful for example when needing to anonymize, but wanting to keep your username and password for your personal account.Taking the example above, the following field rule would only replace the username and password for accounts that do not have the username marius:
It is of course still possible to mix multiple constraints, but as soon as a rule that would prevent anonymization is found, it will short-circuit the remaining rules.
The example above is bad, because it looks for the user_login and needs it to not match a value, this could potentially suddenly trigger based on an anonymized value put in, and should instead be matched against a later column (
user_email
in field 5 for example, but left it like this intentionally for emphasis).In addition to the
not like
, two other entries are also found now:regex
andregex not like
. The explicitnot like
variant is because Go regex does not support negative lookahead or lookbehind, so it can not be used to do a negative lookup within a single rule type.