Class: Fluent::Plugin::PANAnonymizerFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_pan_anonymizer.rb

Instance Method Summary collapse

Constructor Details

#initializePANAnonymizerFilter

Returns a new instance of PANAnonymizerFilter.



16
17
18
# File 'lib/fluent/plugin/filter_pan_anonymizer.rb', line 16

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/fluent/plugin/filter_pan_anonymizer.rb', line 20

def configure(conf)
  super

  @pan_masker = @pan_configs.map do |i|
    i[:formats].map do |format|
      Fluent::PAN::Masker.new(format, i[:checksum_algorithm], i[:mask], i[:force])
    end
  end.flatten
end

#filter(tag, time, record) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fluent/plugin/filter_pan_anonymizer.rb', line 30

def filter(tag, time, record)
  record.map do |key, value|
    if @ignore_keys.include? key.to_s
      [key, value]
    else
      _value = value
      @pan_masker.each do |i|
        _value = i.mask_if_found_pan(_value)
      end
      [key, _value]
    end
  end.to_h
end