Class: Fluent::EncryptionFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::EncryptionFilter
- Defined in:
- lib/fluent/plugin/filter_encryption.rb
Instance Method Summary collapse
- #check_encfield(field, enc_fld_list) ⇒ Object
- #configure(conf) ⇒ Object
- #filter(tag, time, record) ⇒ Object
- #shutdown ⇒ Object
- #start ⇒ Object
Instance Method Details
#check_encfield(field, enc_fld_list) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/fluent/plugin/filter_encryption.rb', line 41 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_encryption.rb', line 13 def configure(conf) super end |
#filter(tag, time, record) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/filter_encryption.rb', line 27 def filter(tag, time, record) @salt = OpenSSL::Random.random_bytes(8) fields = @field.split(',') record.map {|k, v| if check_encfield(k, fields) encrypted_value = @salt + Encryptor.encrypt(algorithm: @algorithm, value: v, key: @key, iv: @iv, salt: @salt) packed_value = Base64.encode64(encrypted_value) [k, packed_value] else [k, v] end }.to_h end |
#shutdown ⇒ Object
23 24 25 |
# File 'lib/fluent/plugin/filter_encryption.rb', line 23 def shutdown super end |
#start ⇒ Object
17 18 19 20 21 |
# File 'lib/fluent/plugin/filter_encryption.rb', line 17 def start super @key = Digest::SHA256.hexdigest("#{@passphrase}") @iv = Digest::SHA256.hexdigest("#{@key}#{@passphrase}") end |