Class: Telm::Core::Redaction

Inherits:
Object
  • Object
show all
Defined in:
lib/telm/core/redaction.rb

Overview

Sensitive-column detection. On by default; the config lists take "table.column" strings and win over the pattern in both directions.

Constant Summary collapse

DEFAULT_PATTERN =
/password|token|secret|otp|ssn|digest|api_key/i
MASK =
"••••••"

Instance Method Summary collapse

Constructor Details

#initialize(config: Telm.config) ⇒ Redaction

Returns a new instance of Redaction.



11
12
13
14
# File 'lib/telm/core/redaction.rb', line 11

def initialize(config: Telm.config)
  @redacted = config.redacted_columns.map(&:to_s)
  @unredacted = config.unredacted_columns.map(&:to_s)
end

Instance Method Details

#redact?(table_name, column_name) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'lib/telm/core/redaction.rb', line 16

def redact?(table_name, column_name)
  qualified = "#{table_name}.#{column_name}"

  return false if @unredacted.include?(qualified)
  return true if @redacted.include?(qualified)

  DEFAULT_PATTERN.match?(column_name.to_s)
end