Closed Eliemer closed 1 year ago
as an aside, maybe we can also add NeverMaskProperties
to exclude properties from regex operators that may match it
You can configure the enricher to only mask a specific property and ignore the rest like so:
new LoggerConfiguration()
.Enrich
.WithSensitiveDataMasking(
options =>
{
options.MaskingOperators.Clear();
options.MaskProperties.AddRange([ "Secrets"; "Password" ]);
});
That will remove all the default masking operators and always mask the Secrets and Password properties.
I don’t have a computer handy here to test so while I think this works it might not 😉
as an aside, maybe we can also add
NeverMaskProperties
to exclude properties from regex operators that may match it
Good suggestion 👍 I’ll include this in the next release
I've decided to not change the behavior of the configuration just yet as that would break usage if you already have implemented the package in your app. Suddenly the masking would not be active anymore and that's a surprise I don't want to spring on users.
In the meantime, if you don't want the default masking operators (or basically, good practice anyway) you should indicate the list of masking operators that are relevant to your application like so:
new LoggerConfiguration()
.Enrich
.WithSensitiveDataMasking(
options =>
{
options.MaskingOperators = new List<IMaskingOperator>
{
new EmailAddressMaskingOperator(),
new IbanMaskingOperator()
// etc etc
};
});
I've updated the README to reflect this.
In the meantime I've also added a ExcludeProperties
option which you can use to exclude properties from masking even if their values would match a masking operator.
I do not intend to mask emails in my logs, only using
MaskProperties
, but this enricher masks emails by default. I also don't have an option to opt-out of this operator either.The issue im having is I have a property that can sometimes be a valid email address but its not required to be. Its simply a human-readable identifier. In the cases that it is an email address, this enricher is masking that value