Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for substitute attributes in lieu of NotLogged and LogMasked #28

Closed
daiplusplus opened this issue Dec 8, 2018 · 2 comments
Labels
wontfix This will not be worked on

Comments

@daiplusplus
Copy link

daiplusplus commented Dec 8, 2018

My frontend projects (which reference Serilog and Destructurama) have dependencies on libraries which expose objects containing sensitive data, however I'm not able to annotate the types in those libraries with the Destructurama [NotLogged] and [LogMasked] attributes. Incidentally the backend library I'm using right now does annotate sensitive data with its own CompanyName.ProductName.SensitiveDataAttribute class.

I did try implementing my own destructuring policy but quickly found myself out of my depth.

I realise a better solution is if Destructurama allow us to specify custom attributes to respect for logging and masking, something like:

var log = new LoggerConfiguration()
    .Destructure.UsingAttributes( o => {
        // o.CustomNotLoggedAttribute = typeof(MyProject.SensitiveDataAttribute),
        o.CustomLogMaskedConfiguration.AttributeType = typeof(MyProject.SensitiveDataAttribute);
        o.CustomLogMaskedConfiguration.ShowFirst = 1;
        o.CustomLogMaskedConfiguration.ShowLast = 1;
        o.CustomLogMaskedConfiguration.PreserveLength = true;
    } );

This design allows a non-parameterised custom attribute type for LogMasked while default values for Text, ShowFirst, ShowLast, and PreserveLength can be specified.

@daiplusplus daiplusplus changed the title Add support for custom attributes Add support for substitute attributes in lieu of NotLogged and LogMasked Dec 8, 2018
Copy link

This issue was marked as stale since it has not been active for a long time

@github-actions github-actions bot added the stale label Jan 22, 2024
@sungam3r sungam3r removed the stale label Jan 22, 2024
@sungam3r
Copy link
Member

I did try implementing my own destructuring policy

@daiplusplus Indeed, custom destructuring policy is the right way here. In your example of configuration there is a custom attribute, but the rest of the settings are explicitly set, and not through this attribute. This will only complicate the design and create many questions. The custom destructuring policy will better solve your problem.

@sungam3r sungam3r added the wontfix This will not be worked on label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants