kashifkhan0771 / utils

Common Utilities library for Go
MIT License
6 stars 7 forks source link

[FEATURE] Log Redaction for Sensitive Information #44

Open kashifkhan0771 opened 1 week ago

kashifkhan0771 commented 1 week ago

Feature Description

In certain applications, logs may contain sensitive or personally identifiable information (PII), such as passwords, credit card numbers, or email addresses, which should not be exposed in log files. This feature will enable automatic redaction of sensitive information from logs. It will allow the user to define patterns or keywords that, when detected in a log message, will be replaced with redacted placeholders (e.g., REDACTED).


Use Case


Proposed Solution

Users can define patterns (e.g., regex) or specify sensitive fields such as password, email, credit_card_number to be automatically redacted. Users can also define custom redaction rules based on specific requirements. For instance, some users may want to redact full fields while others might only redact part of the value (e.g., showing only the last four digits of a credit card).


Additional Context

N/A


Pseudo Code


logger := NewLogger()
logger.SetRedactionRules(map[string]string{
    "password": "***REDACTED***",
    "credit_card": "***REDACTED***",
})

logger.Info("User logged in with password: userpassword")
logger.Error("Sensitive data: credit_card=1234-5678-9876-5432")

// output:
[INFO] User logged in with password: ***REDACTED***
[ERROR] Sensitive data: credit_card=***REDACTED***
kashifkhan0771 commented 1 week ago

This is dependent on issue: https://github.com/kashifkhan0771/utils/issues/43