fluent-plugin-encryption-filter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5df66064db0f0cfc1d62d7e122d4e78d7a6f9659
4
+ data.tar.gz: c946a455abeb90f0cfd4cd384f62850f91bb7f78
5
+ SHA512:
6
+ metadata.gz: c60cc389069cb85a00cc5854756841b989c0f9b5a0ffe54b3722160920ca706eee2cf0af9e293e54995528955c0537f59aae271842fa1b844c37410fe9c8da29
7
+ data.tar.gz: a53ee848ed3a7839e048e9d1d36a8fad8f8b9de3ec921f67b59c5091a0a647a7ba85ef340b014cc43ce4584c3e01729126fc0b37b8bf6c37c79ef466315c364e
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *~
11
+ #*
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-encryption-filter.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 j31640
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Fluent::Plugin::Encryption::Filter
2
+
3
+ Fluentd filter plugin to encrypt/decrypt fluentd messages
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fluent-plugin-encryption-filter'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fluent-plugin-encryption-filter
20
+
21
+ ## Configuration
22
+ ### Encryption
23
+ ```
24
+ <filter encrypt.**>
25
+ @type encryption
26
+ passphrase 'password'
27
+ algorithm 'aes-256-cbc'
28
+ field 'field1'
29
+ </filter>
30
+ ```
31
+
32
+ ### Decryption
33
+ ```
34
+ <filter decrypt.**>
35
+ @type decryption
36
+ passphrase 'password'
37
+ algorithm 'aes-256-cbc'
38
+ field 'field1'
39
+ </filter>
40
+ ```
41
+
42
+ ### Parameters
43
+ * passphrase: String
44
+ * algorithm: String
45
+ * field: String
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nidcode/fluent-plugin-encryption-filter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
50
+
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
55
+
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ #require 'fluent/plugin/encryption/filter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-encryption-filter"
8
+ spec.version = "0.0.1"
9
+ spec.authors = ["Akifumi Niida"]
10
+ spec.email = ["nidstyle3@gmail.com"]
11
+
12
+ spec.summary = %q{Filter plugin to encrypt.}
13
+ spec.description = %q{Filter plugin to encrypt.}
14
+ spec.homepage = "https://github.com/nidcode/fluent-plugin-encryption-filter"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "encryptor", "~> 3.0"
25
+ spec.add_runtime_dependency "fluentd", ">= 0.12"
26
+ end
@@ -0,0 +1,48 @@
1
+ require 'fluent/filter'
2
+ require 'digest/md5'
3
+ require 'encryptor'
4
+ require 'base64'
5
+
6
+ module Fluent
7
+ class DecryptionFilter < Filter
8
+ Fluent::Plugin.register_filter('decryption', self)
9
+ config_param :passphrase, :string, secret: true
10
+ config_param :field, :string, default: 'ALL'
11
+ config_param :algorithm, :string, default: 'aes-256-cbc'
12
+
13
+ def configure(conf)
14
+ super
15
+ end
16
+ def start
17
+ super
18
+ @key = Digest::SHA256.hexdigest("#{@passphrase}")
19
+ @iv = Digest::SHA256.hexdigest("#{@key}#{@passphrase}")
20
+ end
21
+
22
+ def shutdown
23
+ super
24
+ end
25
+
26
+ def filter(tag, time, record)
27
+ fields = @field.split(',')
28
+ record.map {|k, v|
29
+ if check_encfield(k, fields)
30
+ uv = Base64.decode64(v)
31
+ salt = uv[0,8]
32
+ encrypted_text = uv[8, uv.size]
33
+ [k, Encryptor.decrypt(algorithm: @algorithm, value: encrypted_text, key: @key, iv: @iv, salt: salt)]
34
+ else
35
+ [k, v]
36
+ end
37
+ }.to_h
38
+ end
39
+
40
+ def check_encfield(field, enc_fld_list)
41
+ if @field == 'ALL'
42
+ return true
43
+ else
44
+ return enc_fld_list.include?(field)
45
+ end
46
+ end
47
+ end if defined?(Filter) # Support only >= v0.12
48
+ end
@@ -0,0 +1,49 @@
1
+ require 'fluent/filter'
2
+ require 'digest/md5'
3
+ require 'encryptor'
4
+ require 'base64'
5
+
6
+ module Fluent
7
+ class EncryptionFilter < Filter
8
+ Fluent::Plugin.register_filter('encryption', self)
9
+ config_param :passphrase, :string, secret: true
10
+ config_param :field, :string, default: 'ALL'
11
+ config_param :algorithm, :string, default: 'aes-256-cbc'
12
+
13
+ def configure(conf)
14
+ super
15
+ end
16
+
17
+ def start
18
+ super
19
+ @key = Digest::SHA256.hexdigest("#{@passphrase}")
20
+ @iv = Digest::SHA256.hexdigest("#{@key}#{@passphrase}")
21
+ end
22
+
23
+ def shutdown
24
+ super
25
+ end
26
+
27
+ def filter(tag, time, record)
28
+ @salt = OpenSSL::Random.random_bytes(8)
29
+ fields = @field.split(',')
30
+ record.map {|k, v|
31
+ if check_encfield(k, fields)
32
+ encrypted_value = @salt + Encryptor.encrypt(algorithm: @algorithm, value: v, key: @key, iv: @iv, salt: @salt)
33
+ packed_value = Base64.encode64(encrypted_value)
34
+ [k, packed_value]
35
+ else
36
+ [k, v]
37
+ end
38
+ }.to_h
39
+ end
40
+
41
+ def check_encfield(field, enc_fld_list)
42
+ if @field == 'ALL'
43
+ return true
44
+ else
45
+ return enc_fld_list.include?(field)
46
+ end
47
+ end
48
+ end if defined?(Filter) # Support only >= v0.12
49
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-encryption-filter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Akifumi Niida
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: encryptor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fluentd
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0.12'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0.12'
69
+ description: Filter plugin to encrypt.
70
+ email:
71
+ - nidstyle3@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - CODE_OF_CONDUCT.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - fluent-plugin-encryption-filter.gemspec
83
+ - lib/fluent/plugin/filter_decryption.rb
84
+ - lib/fluent/plugin/filter_encryption.rb
85
+ homepage: https://github.com/nidcode/fluent-plugin-encryption-filter
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.8
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Filter plugin to encrypt.
109
+ test_files: []