Module: BugBunny::Observability Private

Included in:
BugBunny, Consumer, Controller, Producer, Session
Defined in:
lib/bug_bunny/observability.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

SENSITIVE_KEYS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Patrones de keys que deben ser ocultados en los logs. Se usa substring matching en lowercase para cubrir variantes como “user_password”, “accessToken”, “X-Authorization”, etc. Excluye “pass” y “session” bare para evitar falsos positivos en keys como “passport_number” o “processing_session_count”.

%w[
  password passwd secret token api_key auth authorization
  credential private_key csrf session_id
].freeze

Class Method Summary collapse

Class Method Details

.sensitive_key?(key) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Determina si una key es sensible y debe filtrarse en los logs. Accesible como método de módulo para que otros componentes puedan reutilizarlo.

Parameters:

  • key (String, Symbol)

    La clave a evaluar.

Returns:

  • (Boolean)

    ‘true` si la key es sensible.



23
24
25
26
27
28
# File 'lib/bug_bunny/observability.rb', line 23

def self.sensitive_key?(key)
  # Normalize hyphens → underscores so HTTP headers like "X-Api-Key"
  # match the same patterns as Ruby symbol keys like :api_key.
  key_str = key.to_s.downcase.tr('-', '_')
  SENSITIVE_KEYS.any? { |sensitive| key_str.include?(sensitive) }
end