serilog-contrib / Serilog.Enrichers.Sensitive

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

Ability to use StructureValue masking #13

Closed colmprunty closed 1 year ago

colmprunty commented 2 years ago

Adding a draft PR to get some feedback on this before I do unit tests or anything else.

I have a use case where I want to log all the properties in a class, but mask particular ones, and it would make my life a lot easier if I could just drop in the class. I've added to the demo to make clear what I'm trying to do here.

Apologies for the whitespace formatting, I can probably try sort that out if this feature is something you find useful.

sandermvanvliet commented 2 years ago

Hi @colmprunty,

this seems like a good addition. In my original use case we never had destructured objects which is why it hasn’t been part of the masking yet.

I’ll take a look later this week and will give some feedback 👍

colmprunty commented 2 years ago

Hello there, had a minute to look at this?

sandermvanvliet commented 1 year ago

@colmprunty sorry it took a bit for me to get back to you.

In the meantime I had some time to plug away at this, I had to extend serilog-contrib/SerilogSinksInMemory to add support for asserting on properties that contain destructured objects so that I could write some test cases for this.

That's been released and I've finally gotten around to actually implementing this which turned out to be fairly simple. You can take a look at this commit 10612d00c3cb3061d7a7d6ec28578cd32d6accdc that has the implementation.

I realise this looks a bit like a "ok thanks, let me do this myself" kind of approach but in testing feasibility of this I actually had the implementation already.

So thanks very much for the suggestion, it's something I completely overlooked :+1:

sandermvanvliet commented 1 year ago

Released in 1.4.0 and improved in 1.5.0

colmprunty commented 1 year ago

Hey I didn't get around to commenting on this, but no worries, as long as it gets done.