Mark some properties as sensitive
See original GitHub issueIs 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:
- Created 3 months ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
I’ve pushed out 11.6.0 with this change