Class: Fluent::DecryptionFilter

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

Instance Method Summary collapse

Instance Method Details

#check_encfield(field, enc_fld_list) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/fluent/plugin/filter_decryption.rb', line 40

def check_encfield(field, enc_fld_list)
  if @field == 'ALL'
    return true
  else
    return enc_fld_list.include?(field)
  end
end

#configure(conf) ⇒ Object



13
14
15
# File 'lib/fluent/plugin/filter_decryption.rb', line 13

def configure(conf)
  super
end

#filter(tag, time, record) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fluent/plugin/filter_decryption.rb', line 26

def filter(tag, time, record)
  fields = @field.split(',')
  record.map {|k, v|
    if check_encfield(k, fields)
      uv = Base64.decode64(v)
      salt = uv[0,8]
      encrypted_text = uv[8, uv.size]
      [k, Encryptor.decrypt(algorithm: @algorithm, value: encrypted_text, key: @key, iv: @iv, salt: salt)]
    else
      [k, v]
    end
  }.to_h
end

#shutdownObject



22
23
24
# File 'lib/fluent/plugin/filter_decryption.rb', line 22

def shutdown
  super
end

#startObject



16
17
18
19
20
# File 'lib/fluent/plugin/filter_decryption.rb', line 16

def start
  super
  @key = Digest::SHA256.hexdigest("#{@passphrase}")
  @iv = Digest::SHA256.hexdigest("#{@key}#{@passphrase}")
end