Sha256: 5619cf74efe72b24d5323386f22a5a1273e9e5b81be3fa506e9f41f6e697642d
Contents?: true
Size: 925 Bytes
Versions: 6
Compression:
Stored size: 925 Bytes
Contents
require 'raven/processor' module Raven module Processor class SanitizeData < Processor MASK = '********' FIELDS_RE = /(authorization|password|passwd|secret)/i VALUES_RE = /^\d{16}$/ def apply(value, key=nil, &block) if value.is_a?(Hash) value.each.inject({}) do |memo, (k, v)| memo[k] = apply(v, k, &block) memo end elsif value.is_a?(Array) value.map do |value| apply(value, key, &block) end else block.call(key, value) end end def sanitize(key, value) if !value || value.empty? value elsif VALUES_RE.match(value) or FIELDS_RE.match(key) MASK else value end end def process(data) apply(data) do |key, value| sanitize(key, value) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems