class Raven::Processor::SanitizeData

Constants

CREDIT_CARD_RE
DEFAULT_FIELDS

Attributes

sanitize_credit_cards[RW]
sanitize_fields[RW]

Public Class Methods

new(client) click to toggle source
Calls superclass method Raven::Processor.new
# File lib/raven/processor/sanitizedata.rb, line 11
def initialize(client)
  super
  self.sanitize_fields = client.configuration.sanitize_fields
  self.sanitize_credit_cards = client.configuration.sanitize_credit_cards
end

Public Instance Methods

process(value, key = nil) click to toggle source
# File lib/raven/processor/sanitizedata.rb, line 17
def process(value, key = nil)
  case value
  when Hash
    !value.frozen? ? value.merge!(value) { |k, v| process v, k } : value.merge(value) { |k, v| process v, k }
  when Array
    !value.frozen? ? value.map! { |v| process v, key } : value.map { |v| process v, key }
  when Integer
    matches_regexes?(key, value.to_s) ? INT_MASK : value
  when String
    if value =~ fields_re && (json = parse_json_or_nil(value))
      # if this string is actually a json obj, convert and sanitize
      process(json).to_json
    elsif matches_regexes?(key, value)
      STRING_MASK
    elsif key == 'query_string' || key == :query_string
      sanitize_query_string(value)
    else
      value
    end
  else
    value
  end
end