Sha256: 93f3d083baa832dd5b1d6e22c0f5b14012e7406bd6e0d7ed5f73e391331aef70
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
module Raven class Processor::SanitizeData < Processor STRING_MASK = '********' INT_MASK = 0 DEFAULT_FIELDS = %w(authorization password passwd secret ssn social(.*)?sec) VALUES_RE = /^\d{16}$/ def process(value) fields_re = /(#{(DEFAULT_FIELDS + @sanitize_fields).join("|")})/i value.inject(value) do |value,(k,v)| v = k if v.nil? if v.is_a?(Hash) || v.is_a?(Array) process(v) elsif v.is_a?(String) && (json = parse_json_or_nil(v)) #if this string is actually a json obj, convert and sanitize value = modify_in_place(value, [k,v], process(json).to_json) elsif v.is_a?(Integer) && (VALUES_RE.match(v.to_s) || fields_re.match(k.to_s)) value = modify_in_place(value, [k,v], INT_MASK) elsif VALUES_RE.match(v.to_s) || fields_re.match(k.to_s) value = modify_in_place(value, [k,v], STRING_MASK) else value end end value end private def modify_in_place(original_parent, original_child, new_child) if original_parent.is_a?(Array) index = original_parent.index(original_child[0]) original_parent[index] = new_child elsif original_parent.is_a?(Hash) original_parent[original_child[0]] = new_child end original_parent end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
sentry-raven-0.12.0 | lib/raven/processor/sanitizedata.rb |
mustwin-sentry-raven-0.11.2 | lib/raven/processor/sanitizedata.rb |