fluent-plugin-genhashvalue-alt 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +89 -0
- data/Rakefile +10 -0
- data/fluent-plugin-genhashvalue-alt.gemspec +26 -0
- data/lib/fluent/plugin/filter_genhashvalue_alt.rb +93 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dbd8640446adf16b6cd52545ec4814742320a59c387b29df973c89811be789b1
|
4
|
+
data.tar.gz: ac9db1687d3e775ec4a04bde2d3c3295b48f09a15cb4ccfdd05aa3f1cdb27d3b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37b538008667ac7fc6f8fd84ac66a3583bbc90771f056a0bcbdca2aa4138e1a12cd497e6a1da2a928c43ba3925843aba3fb4dd49bac2695558b554a24bd70a2f
|
7
|
+
data.tar.gz: 641209fcf5a5c75350004f2180635f4551f12057a72104abef7cac9a2a0cd36274bcc72ca9748f8adfcf4d650d507c33ab6b283318b75288388b25e9031da587
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 TODO: Write your name
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# Fluent::Plugin::GenHashValue-alt
|
2
|
+
|
3
|
+
fluentd filter plugin.
|
4
|
+
generate hash(md5/sha1/sha256/sha512) value. It forks from GenHashValue with 2 differences:
|
5
|
+
- murmurhash algorithm is not supported to ease deployment on windows machine (no need to build native plug)
|
6
|
+
- possibility to hash the whole record, not only a combination of keys
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'fluent-plugin-genhashvalue-alt'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install fluent-plugin-genhashvalue-alt
|
23
|
+
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
Example if you want to compute hash based on 2 keys (e.g key1 and key2) of your record:
|
28
|
+
|
29
|
+
<filter foo.**>
|
30
|
+
type genhashvalue_alt
|
31
|
+
|
32
|
+
keys key1,key2
|
33
|
+
hash_type md5 # md5/sha1/sha256/sha512
|
34
|
+
base64_enc true
|
35
|
+
base91_enc false
|
36
|
+
set_key _hash
|
37
|
+
separator _
|
38
|
+
inc_time_as_key true
|
39
|
+
inc_tag_as_key false
|
40
|
+
</filter>
|
41
|
+
|
42
|
+
Example if you want to compute hash on the entire record:
|
43
|
+
|
44
|
+
<filter foo.**>
|
45
|
+
type genhashvalue_alt
|
46
|
+
|
47
|
+
use_entire_record true
|
48
|
+
hash_type md5 # md5/sha1/sha256/sha512
|
49
|
+
base64_enc true
|
50
|
+
base91_enc false
|
51
|
+
set_key _hash
|
52
|
+
separator _
|
53
|
+
inc_time_as_key true
|
54
|
+
inc_tag_as_key false
|
55
|
+
</filter>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Input:
|
60
|
+
|
61
|
+
root@112133c12ee3:~/fluentd# echo '{"type":"log","descr":"description..."}' | ./bin/fluent-cat foo.test
|
62
|
+
root@112133c12ee3:~/fluentd# echo '{"type":"log","descr":"description..."}' | ./bin/fluent-cat foo.test
|
63
|
+
root@112133c12ee3:~/fluentd# echo '{"type":"log","descr":"description..."}' | ./bin/fluent-cat foo.test
|
64
|
+
|
65
|
+
Filterd:
|
66
|
+
|
67
|
+
2016-10-23 15:06:05 +0000 foo.test: {"type":"log","descr":"description...","_hash":"/B3pc4NBk6Z9Ph89k+ZL4Q=="}
|
68
|
+
2016-10-23 15:06:22 +0000 foo.test: {"type":"log","descr":"description...","_hash":"IgB25wc3M0QJfk0KteYygQ=="}
|
69
|
+
2016-10-23 15:06:37 +0000 foo.test: {"type":"log","descr":"description...","_hash":"vvDF6eWyX5Sc01AVw8P6Cw=="}
|
70
|
+
|
71
|
+
|
72
|
+
## Development
|
73
|
+
|
74
|
+
After checking out the repo, run first `ridk install` if your ruby has no dev kit installed yet. Then run `bundle install` to install dependencies. Then, run `rake test` to run the tests.
|
75
|
+
|
76
|
+
To release a new version, update the version number in `.gemspec`, and then create a git tag for the version, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
77
|
+
|
78
|
+
## Debug unit test
|
79
|
+
Run `gem install ruby-debug-ide` and `gem install debase`.
|
80
|
+
Then go to Debug tab in VS code and run the Test::Unit config. You should be able to reach your breakpoint
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Labou77Code/fluent-plugin-genhashvalue-alt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
85
|
+
|
86
|
+
|
87
|
+
## License
|
88
|
+
|
89
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -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
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fluent-plugin-genhashvalue-alt"
|
7
|
+
spec.version = "1.1.0"
|
8
|
+
spec.authors = ["Labou77Code"]
|
9
|
+
|
10
|
+
spec.summary = %q{generate hash value}
|
11
|
+
spec.description = %q{generate hash(md5/sha1/sha256/sha512) value}
|
12
|
+
spec.homepage = "https://github.com/Labou77Code/fluent-plugin-genhashvalue-alt"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features|\.vscode)/})
|
17
|
+
end
|
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", "~> 2.1"
|
23
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
24
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
|
25
|
+
spec.add_runtime_dependency "base91", '>= 0.0.1'
|
26
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'fluent/plugin/filter'
|
2
|
+
|
3
|
+
module Fluent::Plugin
|
4
|
+
class GenHashValueFilter < Filter
|
5
|
+
Fluent::Plugin.register_filter('genhashvalue_alt', self)
|
6
|
+
|
7
|
+
config_param :keys, :array, :default => []
|
8
|
+
config_param :use_entire_record, :bool, :default => false
|
9
|
+
config_param :set_key, :string, :default => '_hash'
|
10
|
+
config_param :inc_time_as_key, :bool, :default => true
|
11
|
+
config_param :inc_tag_as_key, :bool, :default => true
|
12
|
+
config_param :separator, :string, :default => '_'
|
13
|
+
config_param :hash_type, :string, :default => 'sha256'
|
14
|
+
config_param :base64_enc, :bool, :default => false
|
15
|
+
config_param :base91_enc, :bool, :default => false
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
super
|
19
|
+
require 'base64'
|
20
|
+
require 'base91'
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure(conf)
|
24
|
+
#$log.trace "configure #{conf}"
|
25
|
+
super
|
26
|
+
if !@use_entire_record
|
27
|
+
if @keys.empty?
|
28
|
+
raise Fluent::ConfigError, "When using record as hash seed, users must specify `keys`."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def start
|
34
|
+
super
|
35
|
+
# init
|
36
|
+
end
|
37
|
+
|
38
|
+
def shutdown
|
39
|
+
super
|
40
|
+
# destroy
|
41
|
+
end
|
42
|
+
|
43
|
+
def filter(tag, time, record)
|
44
|
+
s = ""
|
45
|
+
s += tag + separator if inc_tag_as_key
|
46
|
+
s += time.to_s + separator if inc_time_as_key
|
47
|
+
|
48
|
+
if @use_entire_record
|
49
|
+
record.each {|k,v| s += "|#{k}|#{v}"}
|
50
|
+
else
|
51
|
+
s += keys.map {|k| record[k]}.join(separator)
|
52
|
+
end
|
53
|
+
|
54
|
+
if base64_enc || base91_enc then
|
55
|
+
record[set_key] = hash_enc(hash_type, s)
|
56
|
+
else
|
57
|
+
record[set_key] = hash_hex(hash_type, s)
|
58
|
+
end
|
59
|
+
record
|
60
|
+
end
|
61
|
+
|
62
|
+
def hash_hex(type, str)
|
63
|
+
case type
|
64
|
+
when 'md5'
|
65
|
+
h = Digest::MD5.hexdigest(str)
|
66
|
+
when 'sha1'
|
67
|
+
h = Digest::SHA1.hexdigest(str)
|
68
|
+
when 'sha256'
|
69
|
+
h = Digest::SHA256.hexdigest(str)
|
70
|
+
when 'sha512'
|
71
|
+
h = Digest::SHA512.hexdigest(str)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def hash_enc(type, str)
|
76
|
+
case type
|
77
|
+
when 'md5'
|
78
|
+
h = Digest::MD5.digest(str)
|
79
|
+
when 'sha1'
|
80
|
+
h = Digest::SHA1.digest(str)
|
81
|
+
when 'sha256'
|
82
|
+
h = Digest::SHA256.digest(str)
|
83
|
+
when 'sha512'
|
84
|
+
h = Digest::SHA512.digest(str)
|
85
|
+
end
|
86
|
+
if base64_enc then
|
87
|
+
h = Base64::strict_encode64(h)
|
88
|
+
elsif base91_enc then
|
89
|
+
h = Base91::encode(h)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-genhashvalue-alt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Labou77Code
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-08 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: '2.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: fluentd
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.14.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 0.14.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: base91
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.0.1
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.0.1
|
75
|
+
description: generate hash(md5/sha1/sha256/sha512) value
|
76
|
+
email:
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- ".gitignore"
|
82
|
+
- ".travis.yml"
|
83
|
+
- CODE_OF_CONDUCT.md
|
84
|
+
- Gemfile
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.md
|
87
|
+
- Rakefile
|
88
|
+
- fluent-plugin-genhashvalue-alt.gemspec
|
89
|
+
- lib/fluent/plugin/filter_genhashvalue_alt.rb
|
90
|
+
homepage: https://github.com/Labou77Code/fluent-plugin-genhashvalue-alt
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.1.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: generate hash value
|
113
|
+
test_files: []
|