Class: SlackInteractiveClient::MessageStopGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/slack_interactive_client/message_stop_guard.rb

Constant Summary collapse

FILTERED_SUBSTITUTION =
'[FILTERED]'
SENSITIVE_KEY_SUFFIXES =
%w[
  number numbers ssn email date_of_birth secret token salt identity identity_fingerprint
].freeze

Class Method Summary collapse

Class Method Details

.build_sensitive_value_patternsObject

Builds a list of regex patterns for sensitive values



12
13
14
15
16
# File 'lib/slack_interactive_client/message_stop_guard.rb', line 12

def self.build_sensitive_value_patterns
  SENSITIVE_KEY_SUFFIXES.map do |key_suffix|
    /(?<key>#{key_suffix}[:\\'"=>\s]*)(?<value>[\w-]+)/i
  end
end

.scrubberObject

Returns a lambda that scrubs sensitive information from a message



19
20
21
22
23
24
25
26
27
# File 'lib/slack_interactive_client/message_stop_guard.rb', line 19

def self.scrubber
  pii_patterns = build_sensitive_value_patterns

  lambda do |raw_msg|
    pii_patterns.reduce(raw_msg) do |msg, pii_regex|
      msg.gsub(pii_regex) { |m| $~[:key] + FILTERED_SUBSTITUTION }
    end
  end
end