Class: Raven::Processor::SanitizeData

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

Constant Summary collapse

STRING_MASK =
'********'
INT_MASK =
0
FIELDS_RE =
/(authorization|password|passwd|secret|ssn|social(.*)?sec)/i
VALUES_RE =
/^\d{16}$/

Instance Method Summary collapse

Methods inherited from Raven::Processor

#initialize

Constructor Details

This class inherits a constructor from Raven::Processor

Instance Method Details

#process(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/raven/processor/sanitizedata.rb', line 8

def process(value)
  value.merge(value) do |k, v|
    if v.is_a?(Hash)
      process(v)
    elsif v.is_a?(String) && (json_hash = parse_json_or_nil(v))
      #if this string is actually a json obj, convert and sanitize
      process(json_hash).to_json
    elsif v.is_a?(Integer) && (VALUES_RE.match(v.to_s) || FIELDS_RE.match(k))
      INT_MASK
    elsif VALUES_RE.match(v.to_s) || FIELDS_RE.match(k)
      STRING_MASK
    else
      v
    end
  end
end