Class: Airbrake::Utils::ParamsCleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake/utils/params_cleaner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ParamsCleaner

Public: Initialize a new Airbrake::Utils::ParamsCleaner

opts - The Hash options that contain filters and params (default: {}):

:blacklist_filters - The Array of param keys that should be filtered
:whitelist_filters - The Array of param keys that shouldn't be filtered
:to_clean - The Hash of unfiltered params
:blacklist_filters take precedence over the :whitelist_filters


14
15
16
17
18
19
20
# File 'lib/airbrake/utils/params_cleaner.rb', line 14

def initialize(opts = {})
  @blacklist_filters = (opts[:blacklist_filters] || []).flatten
  @blacklist_filters.map!{|f| f.is_a?(Symbol) ? f.to_s : f }
  @whitelist_filters = (opts[:whitelist_filters] || []).flatten
  @whitelist_filters.map!{|f| f.is_a?(Symbol) ? f.to_s : f }
  @to_clean = opts[:to_clean]
end

Instance Attribute Details

#blacklist_filters=(value) ⇒ Object (writeonly)

Sets the attribute blacklist_filters

Parameters:

  • value

    the value to set the attribute blacklist_filters to.



4
5
6
# File 'lib/airbrake/utils/params_cleaner.rb', line 4

def blacklist_filters=(value)
  @blacklist_filters = value
end

#cgi_dataObject (readonly)

Returns the value of attribute cgi_data.



5
6
7
# File 'lib/airbrake/utils/params_cleaner.rb', line 5

def cgi_data
  @cgi_data
end

#parametersObject (readonly)

Returns the value of attribute parameters.



5
6
7
# File 'lib/airbrake/utils/params_cleaner.rb', line 5

def parameters
  @parameters
end

#session_dataObject (readonly)

Returns the value of attribute session_data.



5
6
7
# File 'lib/airbrake/utils/params_cleaner.rb', line 5

def session_data
  @session_data
end

#to_clean=(value) ⇒ Object (writeonly)

Sets the attribute to_clean

Parameters:

  • value

    the value to set the attribute to_clean to.



4
5
6
# File 'lib/airbrake/utils/params_cleaner.rb', line 4

def to_clean=(value)
  @to_clean = value
end

#whitelist_filters=(value) ⇒ Object (writeonly)

Sets the attribute whitelist_filters

Parameters:

  • value

    the value to set the attribute whitelist_filters to.



4
5
6
# File 'lib/airbrake/utils/params_cleaner.rb', line 4

def whitelist_filters=(value)
  @whitelist_filters = value
end

Instance Method Details

#cleanObject

Public: Takes the params to_clean passed in an initializer

and filters them out by filters passed.

Also normalizes unserializable data.

Returns self, so that :parameters, :cgi_data, :session_data could be extracted



29
30
31
32
33
34
35
36
# File 'lib/airbrake/utils/params_cleaner.rb', line 29

def clean
  clean_parameters
  clean_session_data
  clean_cgi_data
  clean_rack_request_data

  self
end