Class: Chronos::Core::Sanitizer

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/core/sanitizer.rb

Overview

Removes secrets and personal data from event values before serialization.

Examples:

sanitizer.call("password" => "secret") #=> {"password"=>"[FILTERED]"}

Constant Summary collapse

FILTERED =
SensitiveValueFilter::FILTERED
MAX_DEPTH =
10
MAX_KEYS =
100
MAX_ITEMS =
100
MAX_NODES =
2_000

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Sanitizer

Returns a new instance of Sanitizer.



24
25
26
27
28
29
30
31
32
# File 'lib/chronos/core/sanitizer.rb', line 24

def initialize(config)
  @blocklist_names, @blocklist_patterns = compile_matchers(config.blocklist_keys)
  @allowlist_names, @allowlist_patterns = compile_matchers(config.allowlist_keys)
  @hash_names, @hash_patterns = compile_matchers(config.hash_keys)
  @filters = config.filters
  @sensitive_value_filter = SensitiveValueFilter.new(config.anonymize_ip)
  @hash_scope = config.project_id.to_s
  freeze
end

Instance Method Details

#call(value) ⇒ Object



34
35
36
37
38
# File 'lib/chronos/core/sanitizer.rb', line 34

def call(value)
  sanitize_value(value, nil, true, 0, :nodes => 0, :seen => {})
rescue StandardError
  FILTERED
end