question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mark some properties as sensitive

See original GitHub issue

Is your feature request related to a problem? Please describe.

Actually when we use FluentValidation and there are errors the value is stored in clear text.

If we log this errors we could have some sensitive data like passwords, credit card number, …

For exemple here is a logged error in Seq :

{
  "AttemptedValue": "toto",
  "CustomState": null,
  "ErrorCode": "EqualValidator",
  "ErrorMessage": "La confirmation n''est pas identique au mot de passe.",
  "FormattedMessagePlaceholderValues": {
    "ComparisonProperty": "Password",
    "ComparisonValue": "titi",
    "PropertyName": "Confirm Password",
    "PropertyValue": "toto"
  },
  "PropertyName": "ConfirmPassword",
  "Severity": "Error"
}

Describe the solution you’d like

We can hide properties from logging in Serilog using Destructurama (https://github.com/destructurama/attributed)

public class CustomizedMaskedLogs
{
    /// <summary>
    /// 123456789 results in "***"
    /// </summary>
    [LogMasked]
    public string Password { get; set; }

    /// <summary>
    /// 123456789 results in "***"
    /// </summary>
    [LogMasked]
    public string ConfirmPassword { get; set; }
}

Then the log would look like this :

{
  "AttemptedValue": "***",
  "CustomState": null,
  "ErrorCode": "EqualValidator",
  "ErrorMessage": "La confirmation n''est pas identique au mot de passe.",
  "FormattedMessagePlaceholderValues": {
    "ComparisonProperty": "Password",
    "ComparisonValue": "***",
    "PropertyName": "Confirm Password",
    "PropertyValue": "***"
  },
  "PropertyName": "ConfirmPassword",
  "Severity": "Error"
}

Even if it would be very convenient for me, I’m not sure this would be the best way to mark the data as sensitive for FluentValidation.

Describe alternatives you’ve considered

One option could be to mark them as sensitive

RuleFor(m => m.Password).NotEmpty().Sensitive();

Additional Context

No response

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JeremySkinnercommented, Jun 14, 2023

I don’t think an interface adds any value here.

An interface with a single method has the same end result as a settable func - both provide a contract, the difference being an interface provides a contract for a class and a delegate provides a contract for a method; one is an object-oriented approach, the other is a more functional approach. The end result is the same - you’re replacing the method implementation.

1reaction
JeremySkinnercommented, Jul 4, 2023

I’ve pushed out 11.6.0 with this change

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to mark an attribute of an object as sensitive?
Hi @hartzell,. Unfortunately sensitivity is a property of values, not of types. The sensitive = true on variables is effectively a shorthand for ......
Read more >
Mark field as sensitive
It would be great to set a property on a field in a feature class/table as "sensitive", i.e. the field contains sensitive information....
Read more >
allow custom resource properties to be marked as sensitive
The resource manages a lot of things about the users, so I use converge_if_changed :property_name a lot. The only one I care about...
Read more >
c# - How to write an attribute for replacing sensitive data on ...
the problem is that in your Write method public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options).
Read more >
How can I make sensitive property "private" to a subset of ...
For my customer, we need to hide specific records properties with sensitive information for some users. I know that, with user & team...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found