Class: Raven::Processor::SanitizeData
Constant Summary
collapse
- STRING_MASK =
'********'
- INT_MASK =
0
- DEFAULT_FIELDS =
%w(authorization password passwd secret ssn social(.*)?sec)
- CREDIT_CARD_RE =
/^(?:\d[ -]*?){13,16}$/
Instance Attribute Summary
#sanitize_fields
Instance Method Summary
collapse
#initialize
Instance Method Details
#process(value) ⇒ Object
8
9
10
|
# File 'lib/raven/processor/sanitizedata.rb', line 8
def process(value)
value.inject(value) { |memo,(k,v)| memo[k] = sanitize(k,v); memo }
end
|
#sanitize(k, v) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/raven/processor/sanitizedata.rb', line 12
def sanitize(k,v)
if v.is_a?(Hash)
process(v)
elsif v.is_a?(Array)
v.map{|a| sanitize(k, a)}
elsif k == 'query_string'
sanitize_query_string(v)
elsif v.is_a?(String) && (json = parse_json_or_nil(v))
json.is_a?(Hash) ? process(json).to_json : v
elsif v.is_a?(Integer) && (CREDIT_CARD_RE.match(v.to_s) || fields_re.match(k.to_s))
INT_MASK
elsif v.is_a?(String) && (CREDIT_CARD_RE.match(v.to_s) || fields_re.match(k.to_s))
STRING_MASK
else
v
end
end
|