Class: Raven::Processor::SanitizeData

Inherits:
Raven::Processor show all
Defined in:
lib/raven/processor/sanitizedata.rb

Constant Summary collapse

DEFAULT_FIELDS =
%w(authorization password passwd secret ssn social(.*)?sec).freeze
CREDIT_CARD_RE =
/\b(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}\b/.freeze
QUERY_STRING =
['query_string', :query_string].freeze
JSON_STARTS_WITH =
["[", "{"].freeze

Constants inherited from Raven::Processor

INT_MASK, REGEX_SPECIAL_CHARACTERS, STRING_MASK

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SanitizeData

Returns a new instance of SanitizeData.



14
15
16
17
18
19
# File 'lib/raven/processor/sanitizedata.rb', line 14

def initialize(client)
  super
  self.sanitize_fields = client.configuration.sanitize_fields
  self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
  self.sanitize_fields_excluded = client.configuration.sanitize_fields_excluded
end

Instance Attribute Details

#sanitize_credit_cardsObject

Returns the value of attribute sanitize_credit_cards.



12
13
14
# File 'lib/raven/processor/sanitizedata.rb', line 12

def sanitize_credit_cards
  @sanitize_credit_cards
end

#sanitize_fieldsObject

Returns the value of attribute sanitize_fields.



12
13
14
# File 'lib/raven/processor/sanitizedata.rb', line 12

def sanitize_fields
  @sanitize_fields
end

#sanitize_fields_excludedObject

Returns the value of attribute sanitize_fields_excluded.



12
13
14
# File 'lib/raven/processor/sanitizedata.rb', line 12

def sanitize_fields_excluded
  @sanitize_fields_excluded
end

Instance Method Details

#process(value, key = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/raven/processor/sanitizedata.rb', line 21

def process(value, key = nil)
  case value
  when Hash
    sanitize_hash_value(key, value)
  when Array
    sanitize_array_value(key, value)
  when Integer
    matches_regexes?(key, value.to_s) ? INT_MASK : value
  when String
    sanitize_string_value(key, value)
  else
    value
  end
end