Keep personally identifiable information (PII) out of your logs
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Version bump to 0.2.4 [skip ci] Dec 11, 2018
test Better ordering Dec 11, 2018
.gitignore First commit Mar 31, 2018
.travis.yml Updated to xenial Dec 17, 2018
CHANGELOG.md Updated to xenial Dec 17, 2018
Gemfile First commit Mar 31, 2018
LICENSE.txt Added last name to license [skip ci] May 6, 2018
README.md Updated readme Dec 11, 2018
Rakefile Better benchmarks [skip ci] Dec 10, 2018
logstop.gemspec Version bump to 0.2.4 [skip ci] Dec 11, 2018

README.md

Logstop

🔥 Keep personally identifiable information (PII) out of your logs

logger.info "Hi test@example.org!"
# => Hi [FILTERED]!

By default, scrubs:

  • email addresses
  • phone numbers
  • credit card numbers
  • Social Security numbers (SSNs)
  • passwords in URLs

Works with all types of logging - Ruby, ActiveRecord, ActiveJob, and more

User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."email" = ?  [["email", "[FILTERED]"]]

Works even when sensitive data is URL-encoded

Build Status

Installation

Add this line to your application’s Gemfile:

gem 'logstop'

And add it to your logger:

Logstop.guard(logger)

Rails

Create config/initializers/logstop.rb with:

Logstop.guard(Rails.logger)

Options

To scrub IP addresses, use:

Logstop.guard(logger, ip: true)

Add custom rules with:

scrubber = lambda do |msg|
  msg.gsub(/custom_regexp/, "[FILTERED]".freeze)
end

Logstop.guard(logger, scrubber: scrubber)

To scrub outside of logging, use:

Logstop.scrub(msg)

It supports the same options as guard.

Notes

This should be used in addition to config.filtered_parameters, not as a replacement.

To scrub existing log files, check out scrubadub.

To anonymize IP addresses, check out IP Anonymizer.

Learn more about securing sensitive data in Rails.

Resources

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development and testing:

git clone https://github.com/ankane/logstop.git
cd logstop
bundle install
rake test