Skip to content

Masking Not Applied for Enum and double Properties in Logs #139

@wellingtonmacena

Description

@wellingtonmacena

Describe the bug
When attempting to mask values for the Status property (enum EFundQuotaStatus) and the MyPropertyDouble property in the UpdateFundQuotaStatusInput class, the log output incorrectly displays null for both properties. The masking annotations ([LogMasked]) do not seem to apply as expected.

Expected behavior

The Status property should be logged with only the last 3 characters visible, as defined by the [LogMasked(Text = "REMOVED", ShowLast = 3)] annotation.
The MyPropertyDouble property should be logged with its length preserved and only the last 3 characters visible, as defined by the [LogMasked(Text = "REMOVED", ShowLast = 3, PreserveLength = true)] annotation.
Screenshots and any additional context
Log output example:

plaintext
Copy code

2024-12-18 12:19:02.182 -03:00 [INF] Handling UpdateFundQuotaStatus request:  
{"Status": null, "StatusMessage": "sta***age", "MyPropertyDouble": null, "$type": "UpdateFundQuotaStatusInput"}  
Relevant class definitions:

csharp

public class UpdateFundQuotaStatusInput  
{  
    [NotLogged]  
    public long OrderCode { get; set; }  

    [LogMasked(Text = "_REMOVED_", ShowLast = 3)]  
    public EFundQuotaStatus Status { get; set; }  

    [MaxLength(255)]  
    [LogMasked(ShowFirst = 3, ShowLast = 3)]  
    public string StatusMessage { get; set; }  

    [LogMasked(Text = "_REMOVED_", ShowLast = 3, PreserveLength = true)]  
    public double MyPropertyDouble { get; set; } = 1234567.890;  

    public override string ToString()  
    {  
        return $"OrderCode: {OrderCode}, Status: {Status}, Message: {StatusMessage}";  
    }  
}  

public enum EFundQuotaStatus : byte  
{  
    TESTE1,  
    TESTE12,  
    TESTE123,  
    TESTE1234,  
    TESTE12345,  
    TESTE123456,  
    TESTE1234567  
}  

Steps to reproduce the behavior:

Log an instance of the UpdateFundQuotaStatusInput class with Status set to a value from the EFundQuotaStatus enum and MyPropertyDouble set to any double value.
Check the log output.
Environment:

Operating System: Windows 11
Library/Framework Version: 5.0.0
Logging Tool: Serilog
Additional context
This issue impacts log readability and masking requirements for sensitive data.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions