Skip to content

pixielabs/scan-suppressing-logger

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

ScanSuppressingLogger

Gem Version

Rails middleware to suppress logging and exception reporting for certain IP addresses or IP address ranges. Useful if your application is the target of automated security scans (e.g. a scheduled penetration test) that fills your logs with garbage errors and requests.

Suppresses the standard Rails logging, and also suppresses exception reporting for:

  • Rollbar
  • Sentry & more coming soon!

Installation

Add this line to your application's Gemfile:

gem 'scan-suppressing-logger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scan-suppressing-logger

Usage

Add to your config/environments/production.rb:

# config/environments/production.rb
config.middleware.swap Rails::Rack::Logger, ScanSuppressingLogger::Middleware, {
  networks: ['123.0.2.2/24', '86.54.222.1/16']
}

Pass an array of IP addresses or networks as strings to suppress logging for. These should be parseable by IPAddr.

Help! No such middleware to insert before: Rails::Rack::Logger

If you get this error it might be because something else is replacing the standard logger, or expecting it to be there. For example, if you have config.assets.quiet = true in your configuration, Sprockets tries to insert_before the standard logging middleware in an initializer. You'll need to configure this gem in an initializer instead:

# config/initializer/suppressing_logger.rb
Rails.application.config.middleware.swap Rails::Rack::Logger, ScanSuppressingLogger::Middleware, {
  networks: ['123.0.2.2/24', '86.54.222.1/16']
}

Development

After checking out the repo, run bin/setup to install dependencies.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/pixielabs/scan-suppressing-logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the ScanSuppressingLogger project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Suppress Rails logs and exceptions from automated scan requests.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published