Module: Airbrake::Filters::KeysFilter Private

Includes:
Loggable
Included in:
KeysAllowlist, KeysBlocklist
Defined in:
lib/airbrake-ruby/filters/keys_filter.rb

Overview

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

This is a filter helper that endows a class ability to filter notices’ payload based on the return value of the should_filter? method that a class that includes this module must implement.

Constant Summary collapse

FILTERED =

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

Returns The label to replace real values of filtered payload.

Returns:

  • (String)

    The label to replace real values of filtered payload

'[Filtered]'.freeze
VALID_PATTERN_CLASSES =

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

Returns the array of classes instances of which can compared with payload keys.

Returns:

  • (Array<String,Symbol,Regexp>)

    the array of classes instances of which can compared with payload keys

[String, Symbol, Regexp].freeze
FILTERABLE_KEYS =

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

Returns parts of a Notice’s payload that can be modified by blocklist/allowlist filters.

Returns:

  • (Array<Symbol>)

    parts of a Notice’s payload that can be modified by blocklist/allowlist filters

%i[environment session params].freeze
FILTERABLE_CONTEXT_KEYS =

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

Returns parts of a Notice’s context payload that can be modified by blocklist/allowlist filters.

Returns:

  • (Array<Symbol>)

    parts of a Notice’s context payload that can be modified by blocklist/allowlist filters

%i[
  user

  # Provided by Airbrake::Rack::HttpHeadersFilter
  headers
  referer
  httpMethod

  # Provided by Airbrake::Rack::ContextFilter
  userAddr
  userAgent
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger

Instance Attribute Details

#weightInteger (readonly)

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:

  • (Integer)


43
44
45
# File 'lib/airbrake-ruby/filters/keys_filter.rb', line 43

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ void

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.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/airbrake-ruby/filters/keys_filter.rb', line 61

def call(notice)
  unless @valid_patterns
    eval_proc_patterns!
    validate_patterns
  end

  FILTERABLE_KEYS.each do |key|
    notice[key] = filter_hash(notice[key])
  end

  FILTERABLE_CONTEXT_KEYS.each { |key| filter_context_key(notice, key) }

  return unless notice[:context][:url]

  filter_url(notice)
end

#initialize(patterns) ⇒ Object

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.

Creates a new KeysBlocklist or KeysAllowlist filter that uses the given patterns for filtering a notice’s payload.

Parameters:

  • patterns (Array<String,Regexp,Symbol>)


49
50
51
52
# File 'lib/airbrake-ruby/filters/keys_filter.rb', line 49

def initialize(patterns)
  @patterns = patterns
  @valid_patterns = false
end

#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:

  • (Boolean)

Raises:

  • (NotImplementedError)

    if called directly



79
80
81
# File 'lib/airbrake-ruby/filters/keys_filter.rb', line 79

def should_filter?(_key)
  raise NotImplementedError, 'method must be implemented in the included class'
end