serilog-contrib / Serilog.Enrichers.Sensitive

A Serilog LogEvent enricher that masks sensitive data
MIT License
111 stars 23 forks source link

Feature request - add customMaskingOperator option to items in maskProperties list. #29

Open mistyn8 opened 1 year ago

mistyn8 commented 1 year ago

Thought it would be a good idea, to say

options.MaskProperties.Add("_Password", PasswordMaskingOperator);

That way we can have the same extensiblity to say leave first and last char exposed?

Or maybe extending on the mask, rather than just a simple replace have some options? options.MaskProperties.Add("_Password", new maskoptions {showFirst:2, showLast:2, preservelenght:true)});

(I admit taking inspiration from https://github.com/destructurama/attributed/blob/dev/src/Destructurama.Attributed/Attributed/LogMaskedAttribute.cs)

IMCubator-CI commented 6 months ago

100% agree

sandermvanvliet commented 6 months ago

I've taken a stab at this, have a look at WhenMaskingWithOptions.cs for how this will work.

There is a problem that this currently breaks the JSON configuration capabilities so this might change.