class Logasm::Preprocessors::Whitelist
Constants
- DEFAULT_WHITELIST
- MASKED_VALUE
- MASK_SYMBOL
- PRUNE_ACTION_NAMES
Public Class Methods
new(config = {})
click to toggle source
# File lib/logasm/preprocessors/whitelist.rb, line 17 def initialize(config = {}) trie = build_trie(config) @strategy = if PRUNE_ACTION_NAMES.include?(config[:action].to_s) Strategies::Prune.new(trie) else Strategies::Mask.new(trie) end end
Public Instance Methods
process(data)
click to toggle source
# File lib/logasm/preprocessors/whitelist.rb, line 27 def process(data) @strategy.process(data) end
Private Instance Methods
build_trie(config)
click to toggle source
# File lib/logasm/preprocessors/whitelist.rb, line 45 def build_trie(config) pointers = (config[:pointers] || []) + DEFAULT_WHITELIST pointers.reduce(JSONPointerTrie.new(config)) do |trie, pointer| validate_pointer(pointer) trie.insert(decode(pointer)) end end
decode(pointer)
click to toggle source
# File lib/logasm/preprocessors/whitelist.rb, line 39 def decode(pointer) pointer .gsub('~1', '/') .gsub('~0', '~') end
validate_pointer(pointer)
click to toggle source
# File lib/logasm/preprocessors/whitelist.rb, line 33 def validate_pointer(pointer) if pointer.slice(-1) == '/' raise InvalidPointerFormatException, 'Pointer should not contain trailing slash' end end