Download the PHP package leocavalcante/redact-sensitive without Composer
On this page you can find all versions of the php package leocavalcante/redact-sensitive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leocavalcante/redact-sensitive
More information about leocavalcante/redact-sensitive
Files in leocavalcante/redact-sensitive
Package redact-sensitive
Short Description Monolog processor to protect sensitive information from logging
License MIT
Informations about the package redact-sensitive
Redact Sensitive
🙈 A Monolog processor that protects sensitive data from miss logging.
Avoids logging something like {"api_key":"mysupersecretapikey"}
by masking partially or completely sensitive data:
Install
Usage
1. Prepare your sensitive keys
It is a map of key names and how much of it can be displayed, for example:
Shows the first 4 characters of the api_key
.
If you want to display the last chars, you can use negative values like ['api_key' => -4]
, then it will display the last 4 characters.
2. Create a Processor using the keys
You can now create a new Processor with the given keys:
3. Set the Processor to a Monolog\Logger
Examples
Completely hidden
You can hide it completely by passing 0
to the key.
Custom format
Feel free to customize a replacement character *
and/or provide your own template.
Custom template allows to discard the masked characters altogether:
Length limit
Use lengthLimit
to truncate redacted sensitive information, such as lengthy tokens.
Right to left
And, as said before, you can mask the value from right to left using negative values.
Nested values
It should work with nested objects and arrays as well.
Thanks
Feel free to open any issues or PRs.
MIT © 2021