class Airbrake::Filters::KeysBlacklist

A default Airbrake notice filter. Filters only specific keys listed in the list of parameters in the payload of a notice.

@example

filter = Airbrake::Filters::KeysBlacklist.new(
  [:email, /credit/i, 'password']
)
airbrake.add_filter(filter)
airbrake.notify(StandardError.new('App crashed!'), {
  user: 'John'
  password: 's3kr3t',
  email: 'john@example.com',
  credit_card: '5555555555554444'
})

# The dashboard will display this parameter as is, but all other
# values will be filtered:
#   { user: 'John',
#     password: '[Filtered]',
#     email: '[Filtered]',
#     credit_card: '[Filtered]' }

@see KeysWhitelist @see KeysFilter @api private

Public Class Methods

new(*) click to toggle source
Calls superclass method Airbrake::Filters::KeysFilter::new
# File lib/airbrake-ruby/filters/keys_blacklist.rb, line 31
def initialize(*)
  super
  @weight = -110
end

Public Instance Methods

should_filter?(key) click to toggle source

@return [Boolean] true if the key matches at least one pattern, false

otherwise
# File lib/airbrake-ruby/filters/keys_blacklist.rb, line 38
def should_filter?(key)
  @patterns.any? do |pattern|
    if pattern.is_a?(Regexp)
      key.match(pattern)
    else
      key.to_s == pattern.to_s
    end
  end
end