|
Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
|
Log sanitizer for masking sensitive data. More...
#include <log_sanitizer.h>

Public Member Functions | |
| log_sanitizer & | add_pattern (sensitive_data_type type) |
| Add a built-in pattern for sensitive data detection. | |
| log_sanitizer & | add_custom_pattern (std::string_view name, std::string_view regex_pattern, std::string_view replacement="[REDACTED]", bool preserve_partial=false) |
| Add a custom sanitization pattern. | |
| log_sanitizer & | remove_pattern (std::string_view name) |
| Remove a pattern by name. | |
| std::string | sanitize (std::string_view input) const |
| Sanitize a string by masking all detected sensitive data. | |
| bool | contains_sensitive_data (std::string_view input) const |
| Check if a string contains sensitive data. | |
| std::vector< std::string > | active_patterns () const |
| Get list of active pattern names. | |
| log_sanitizer & | clear () |
| Clear all patterns. | |
| log_sanitizer & | add_common_patterns () |
| Add all common patterns at once. | |
Private Member Functions | |
| void | add_credit_card_pattern () |
| void | add_ssn_pattern () |
| void | add_api_key_pattern () |
| void | add_password_pattern () |
| void | add_email_pattern () |
| void | add_ip_address_pattern () |
| void | add_phone_number_pattern () |
Static Private Member Functions | |
| static std::string | apply_rule (const std::string &input, const sanitization_rule &rule) |
Private Attributes | |
| std::vector< sanitization_rule > | rules_ |
Log sanitizer for masking sensitive data.
Thread-safe sanitizer that detects and masks sensitive information in log messages. Supports both built-in patterns for common sensitive data types and custom patterns for organization-specific needs.
Built-in patterns:
Definition at line 82 of file log_sanitizer.h.
|
inline |
Get list of active pattern names.
Definition at line 190 of file log_sanitizer.h.
References rules_.
|
inlineprivate |
Definition at line 244 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inline |
Add all common patterns at once.
Definition at line 212 of file log_sanitizer.h.
References add_pattern(), kcenon::logger::security::api_key, kcenon::logger::security::credit_card, kcenon::logger::security::email, kcenon::logger::security::password, and kcenon::logger::security::ssn.
Referenced by kcenon::logger::security::make_default_sanitizer().


|
inlineprivate |
Definition at line 224 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inline |
Add a custom sanitization pattern.
| name | Identifier for the pattern |
| regex_pattern | Regular expression to match sensitive data |
| replacement | Replacement string (use $1, $2 for capture groups) |
| preserve_partial | If true, preserve last few characters |
Definition at line 127 of file log_sanitizer.h.
References rules_.
|
inlineprivate |
Definition at line 262 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inlineprivate |
Definition at line 271 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inlineprivate |
Definition at line 253 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inline |
Add a built-in pattern for sensitive data detection.
| type | The type of sensitive data to detect |
Definition at line 89 of file log_sanitizer.h.
References add_api_key_pattern(), add_credit_card_pattern(), add_email_pattern(), add_ip_address_pattern(), add_password_pattern(), add_phone_number_pattern(), add_ssn_pattern(), kcenon::logger::security::api_key, kcenon::logger::security::credit_card, kcenon::logger::security::custom, kcenon::logger::security::email, kcenon::logger::security::ip_address, kcenon::logger::security::password, kcenon::logger::security::phone_number, and kcenon::logger::security::ssn.
Referenced by add_common_patterns().


|
inlineprivate |
Definition at line 280 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inlineprivate |
Definition at line 234 of file log_sanitizer.h.
References rules_.
Referenced by add_pattern().

|
inlinestaticprivate |
Definition at line 289 of file log_sanitizer.h.
References kcenon::logger::security::sanitization_rule::pattern, and kcenon::logger::security::sanitization_rule::replacement.
Referenced by sanitize().

|
inline |
Clear all patterns.
Definition at line 203 of file log_sanitizer.h.
References clear(), and rules_.
Referenced by clear().


|
inline |
Check if a string contains sensitive data.
| input | The string to check |
Definition at line 177 of file log_sanitizer.h.
References rules_.
|
inline |
Remove a pattern by name.
| name | Name of the pattern to remove |
Definition at line 145 of file log_sanitizer.h.
References rules_.
|
inline |
Sanitize a string by masking all detected sensitive data.
| input | The string to sanitize |
Definition at line 160 of file log_sanitizer.h.
References apply_rule(), and rules_.

|
private |
Definition at line 222 of file log_sanitizer.h.
Referenced by active_patterns(), add_api_key_pattern(), add_credit_card_pattern(), add_custom_pattern(), add_email_pattern(), add_ip_address_pattern(), add_password_pattern(), add_phone_number_pattern(), add_ssn_pattern(), clear(), contains_sensitive_data(), remove_pattern(), and sanitize().