Class: PierLogging::Helpers::Redactor
- Inherits:
-
Object
- Object
- PierLogging::Helpers::Redactor
- Defined in:
- lib/pier_logging/helpers/redactor.rb
Constant Summary collapse
- REDACT_REPLACE_KEYS =
[ /passw(or)?d/i, /^pw$/, /^pass$/i, /secret/i, /token/i, /api[-._]?key/i, /session[-._]?id/i, /^connect\.sid$/, /authorization/i ].freeze
- REDACT_REPLACE_BY =
'*'.freeze
Class Method Summary collapse
Class Method Details
.redact(obj, replace_keys = nil, replace_by = REDACT_REPLACE_BY) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pier_logging/helpers/redactor.rb', line 21 def redact(obj, replace_keys = nil, replace_by = REDACT_REPLACE_BY) replace_keys ||= sensitive_keywords if obj.is_a?(Array) redact_array(obj, replace_keys, replace_by) elsif obj.is_a?(Hash) redact_hash(obj, replace_keys, replace_by) elsif obj.respond_to?(:to_hash) redact_hash(obj.to_hash, replace_keys, replace_by) else obj end end |