- Notifications
You must be signed in to change notification settings - Fork4
A redacting Ruby logger to prevent the leaking of secrets via logs
License
github/redacting-logger
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A redacting Ruby logger to prevent the leaking of secrets via logs
This Gem wraps the official Ruby
logger
utility
You can download this Gem fromGitHub Packages orRubyGems
Via a Gemfile:
source"https://rubygems.org"gem"redacting-logger","~> X.X.X"# Replace X.X.X with the latest version
require"redacting_logger"# Create a new loggerlogger=RedactingLogger.new(redact_patterns:[/topsecret/])# Log a message that contains some redacted patternlogger.info("This is a topsecret message.")
This will output:
I, [timestamp] INFO -- : This is a [REDACTED] message.
require"redacting_logger"# Create a new loggerlogger=RedactingLogger.new( $stdout,# The device to log to (defaults to $stdout if not provided)redact_patterns:[/REDACTED_PATTERN1/,/REDACTED_PATTERN2/],# An array of Regexp patterns to redact from the logslevel:Logger::INFO,# The log level to useredacted_msg:"[REDACTED]",# The message to replace the redacted patterns withuse_default_patterns:true# Whether to use the default built-in patterns or not)# Log a message that contains some redacted patternslogger.info("This is a message with a REDACTED_PATTERN1 and REDACTED_PATTERN2 in it.")
This will output:
I, [timestamp] INFO -- : This is a message with a [REDACTED] and [REDACTED] in it.
This Gem comes pre-built with a few redaction patterns to help you get started. These patterns can be located inlib/patterns/default.rb
A few examples of these patterns are:
- GitHub Personal Access Tokens
- GitHub Temporary Actions Tokens
- RSA Private Keys
- JWT Tokens
You can disable these default patterns with:
logger=RedactingLogger.new(use_default_patterns:false# Whether to use the default built-in patterns or not)
About
A redacting Ruby logger to prevent the leaking of secrets via logs
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors5
Uh oh!
There was an error while loading.Please reload this page.