serilog-contrib/Serilog.Enrichers.Sensitive

[Feature Request] Allow to specify MaskValue per every Masking Operator, instead of "global" MaskValue

Closed this issue · 1 comments

Default configuration

{
    "Serilog": {
        "Using": [
            "Serilog.Enrichers.Sensitive"
        ],
        "Enrich": [
            {
                "Name": "WithSensitiveDataMasking",
                "Args": {
                    "options": {
                        "MaskValue": "***\\",
                        "MaskProperties": [ "file" ],
                        "MaskingOperators": [ "BitMono.Host.Extensions.FileMaskingOperator, BitMono.Host" ]
                    }
                },
            "FromLogContext"
        ],
        "MinimumLevel": "Debug"
    }
}

Add another Sensitive Data Operator

{
    "Serilog": {
        "Using": [
            "Serilog.Enrichers.Sensitive"
        ],
        "Enrich": [
            {
                "Name": "WithSensitiveDataMasking",
                "Args": {
                    "options": {
                        "MaskValue": "***\\",
                        "MaskProperties": [ "file" ],
                        "MaskingOperators": [ "BitMono.Host.Extensions.FileMaskingOperator, BitMono.Host" ]
                    }
                },
                "Name": "WithSensitiveDataMasking",
                "Args": {
                    "options": {
                        "MaskValue": "???\\",
                        "MaskProperties": [ "directory" ],
                        "MaskingOperators": [ "BitMono.Host.Extensions.DirectoryMaskingOperator, BitMono.Host" ]
                    }
                }
            },
            "FromLogContext"
        ],
        "MinimumLevel": "Debug"
    }
}

as a result: System.FormatException: A duplicate key 'Serilog:Enrich:0:Name' was found.

Ah, sorry, the feature was implemented automatically :D

{
    "Name": "WithSensitiveDataMasking",
    "Args": {
        "options": {
            "MaskValue": "***\\",
            "MaskProperties": [ "file" ],
            "MaskingOperators": [ "BitMono.Host.Extensions.FileMaskingOperator, BitMono.Host" ]
        }
    },
},
{
    "Name": "WithSensitiveDataMasking",
    "Args": {
        "options": {
            "MaskValue": "***\\",
            "MaskProperties": [ "directory" ],
            "MaskingOperators": [ "BitMono.Host.Extensions.DirectoryMaskingOperator, BitMono.Host" ]
        }
    }
},

Closing it