Class: Necropsy::Analyzers::Dynamic::RedisCredentialRedactor
- Inherits:
-
Object
- Object
- Necropsy::Analyzers::Dynamic::RedisCredentialRedactor
- Defined in:
- lib/necropsy/analyzers/dynamic/redis_input_limits.rb
Constant Summary collapse
- REDACTED =
'[REDACTED]'
Instance Method Summary collapse
-
#initialize(source) ⇒ RedisCredentialRedactor
constructor
A new instance of RedisCredentialRedactor.
- #redact(message) ⇒ Object
Constructor Details
#initialize(source) ⇒ RedisCredentialRedactor
Returns a new instance of RedisCredentialRedactor.
97 98 99 100 101 |
# File 'lib/necropsy/analyzers/dynamic/redis_input_limits.rb', line 97 def initialize(source) @source = source.to_s @safe_source = @source.sub(%r{(?<=://)[^/@\s]+@}, "#{REDACTED}@") @secrets = credentials(@source) end |
Instance Method Details
#redact(message) ⇒ Object
103 104 105 106 |
# File 'lib/necropsy/analyzers/dynamic/redis_input_limits.rb', line 103 def redact() sanitized = .to_s.gsub(@source, @safe_source) @secrets.reduce(sanitized) { |text, secret| text.gsub(secret, REDACTED) } end |