Module: PactBroker::Webhooks::RedactLogs
- Defined in:
- lib/pact_broker/webhooks/redact_logs.rb
Constant Summary collapse
- HEADER_SUBSTITUTIONS =
[[/(Authorization: )(.*)/i, '\1[REDACTED]'], [ /(Token: )(.*)/i, '\1[REDACTED]']]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(logs, values) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/pact_broker/webhooks/redact_logs.rb', line 14 def self.call logs, values substitutions = HEADER_SUBSTITUTIONS + value_substitutions(values) substitutions.reduce(logs) do | agg_logs, (find, replace) | agg_logs.gsub(find, replace) end end |
.value_substitutions(values) ⇒ Object
22 23 24 |
# File 'lib/pact_broker/webhooks/redact_logs.rb', line 22 def self.value_substitutions(values) values.select(&:not_blank?).collect{ | value | [value, "********"] } end |
Instance Method Details
#redact_logs(logs, values) ⇒ Object
10 11 12 |
# File 'lib/pact_broker/webhooks/redact_logs.rb', line 10 def redact_logs(logs, values) RedactLogs.call(logs, values) end |