Class: Airbrake::Filters::KeysBlocklist Private

Inherits:
Object
  • Object
show all
Includes:
KeysFilter
Defined in:
lib/airbrake-ruby/filters/keys_blocklist.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

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

Examples:

filter = Airbrake::Filters::KeysBlocklist.new(
  [:email, /credit/i, 'password']
)
airbrake.add_filter(filter)
airbrake.notify(StandardError.new('App crashed!'), {
  user: 'John'
  password: 's3kr3t',
  email: '[email protected]',
  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 Also:

Constant Summary

Constants included from KeysFilter

Airbrake::Filters::KeysFilter::FILTERABLE_CONTEXT_KEYS, Airbrake::Filters::KeysFilter::FILTERABLE_KEYS, Airbrake::Filters::KeysFilter::FILTERED, Airbrake::Filters::KeysFilter::VALID_PATTERN_CLASSES

Instance Attribute Summary

Attributes included from KeysFilter

#weight

Instance Method Summary collapse

Methods included from KeysFilter

#call

Methods included from Loggable

#logger

Constructor Details

#initializeKeysBlocklist

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of KeysBlocklist.



31
32
33
34
# File 'lib/airbrake-ruby/filters/keys_blocklist.rb', line 31

def initialize(*)
  super
  @weight = -110
end

Instance Method Details

#should_filter?(key) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true if the key matches at least one pattern, false otherwise.

Returns:

  • (Boolean)

    true if the key matches at least one pattern, false otherwise



38
39
40
41
42
43
44
45
46
# File 'lib/airbrake-ruby/filters/keys_blocklist.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