serilog-contrib / Serilog.Enrichers.Sensitive

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

Not able to override MaskingOperators and MaskingProperties in Json Configuration to reset default behaviour #22

Closed SViradiya-MarutiTech closed 1 year ago

SViradiya-MarutiTech commented 1 year ago

Hi I was checking to clear default behavior of this Enrichers to not mask any thing as default. and provide list of properties to mask in C# configuration.

I was providing Json as below for testing.


"WithSensitiveDataMasking": {
        "Name": "WithSensitiveDataMasking",
        "Args": {
          "options": {
            "MaskValue": "**",
            "MaskingOperators": [],
            "MaskProperties": [],
            "Mode": "Globally"
          }
        }
      }

when testing with _logger.LogInformation("This is a secret email address: {Email}", "james.bond@universal-exports.co.uk"); or _logger.LogInformation("This is a secret email address: james.bond@universal-exports.co.uk");

It logs This is a secret email address: **

sandermvanvliet commented 1 year ago

I’m not sure what you’re trying to achieve here. It looks like you want to configure the sink to not mask anything at all?

Could you give me some idea about the use case you’re looking for?

SViradiya-MarutiTech commented 1 year ago

We have one common logging library where we read json configuration from AWS SSM, and configure Serilog. this library is shared to all other products to integrate. with this Enrichers we decided to we would override default behavior to not mask anything now, we will create one extension method which will take list of properties to mask and configure it in Sensitive enricher using WithSensitiveDataLogging method.

If we set every thing in JSON then we would need to update library every time when new properties are added from product teams, thats why we want to make c# configuration to mask properties on demand.

SViradiya-MarutiTech commented 1 year ago

Let me know if you have suggestions.

sandermvanvliet commented 1 year ago

I've managed to get it to work. Took a bit of debugging the Serilog configuration package to figure out how to do it.

Version 1.7.1 will land soon and that will allow you to set masking operators (and the other options) from an appsettings.json file.

sandermvanvliet commented 1 year ago

Release is out: see here Should be available through NuGet shortly.