Sha256: 1c0af0a4a70165c22a93f9646ea77d81f708c8e4bd6cae9be71afc4b8c4fcc3a
Contents?: true
Size: 881 Bytes
Versions: 8
Compression:
Stored size: 881 Bytes
Contents
module Startback module Support class Redactor DEFAULT_OPTIONS = { # Words used to stop dumping for, e.g., security reasons blacklist: "token password secret credential email address" } def initialize(options = {}) @options = DEFAULT_OPTIONS.merge(options) end def redact(data) case data when Hash, OpenStruct Hash[data.map{|(k,v)| [k, (k.to_s =~ blacklist_rx) ? '---redacted---' : redact(v)] }] when Enumerable data.map{|elm| redact(elm) }.compact else data end end private def blacklist_rx @blacklist_rx ||= Regexp.new( @options[:blacklist].split(/\s+/).join("|"), Regexp::IGNORECASE ) end end # class Redactor end # module Support end # module Startback
Version data entries
8 entries across 8 versions & 1 rubygems