fluent-plugin-string-scrub 0.1.0 → 1.0.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 +5 -5
- data/.travis.yml +11 -4
- data/Gemfile +0 -1
- data/README.md +1 -1
- data/fluent-plugin-string-scrub.gemspec +3 -3
- data/lib/fluent/plugin/filter_string_scrub.rb +4 -3
- data/lib/fluent/plugin/out_string_scrub.rb +6 -10
- data/test/helper.rb +3 -10
- data/test/plugin/test_filter_string-scrub.rb +6 -8
- data/test/plugin/test_out_string-scrub.rb +42 -62
- metadata +12 -7
- data/Gemfile.fluentd.lt.0.12 +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0432a5e1ae4e3970f96b80134b6ae8ffdad9fed1da59cac7807fe2562e8b65c0
|
4
|
+
data.tar.gz: 53ef421c743a333bea35e451c0151510a6d5b4fcac49468e8501029d617f5d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4130308daf2d991ed36a75a684333a8cb5fe99a009833f9a1589e5ab67d56374db2492725cc99b2067d7c1fa10d68700dffd1697a3f09f997ce11d0835a6872c
|
7
|
+
data.tar.gz: eea555503b11318fc088825cce59c85991d6216de287918740c329cdf6810576967ac374a862f587f44b50932a870957761c8fbf9acd8f14b4cc7787b8b6b26d
|
data/.travis.yml
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
language: ruby
|
2
|
+
script: bundle exec rake
|
3
|
+
sudo: false
|
2
4
|
rvm:
|
3
|
-
- 1
|
4
|
-
- 2.
|
5
|
-
- 2.
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
9
|
+
- 2.5.2
|
10
|
+
|
11
|
+
#- ruby-head
|
6
12
|
gemfile:
|
7
13
|
- Gemfile
|
8
|
-
|
14
|
+
before_install:
|
15
|
+
- gem update bundler
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -73,7 +73,7 @@ Fluentd >= v0.12 can use filter plugin.
|
|
73
73
|
|
74
74
|
## Contributing
|
75
75
|
|
76
|
-
1. Fork it ( https://github.com/
|
76
|
+
1. Fork it ( https://github.com/kataring/fluent-plugin-string-scrub/fork )
|
77
77
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
78
78
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
79
79
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -3,7 +3,7 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-string-scrub"
|
6
|
-
spec.version = "
|
6
|
+
spec.version = "1.0.0"
|
7
7
|
spec.authors = ["Noriaki Katayama"]
|
8
8
|
spec.email = ["kataring@gmail.com"]
|
9
9
|
spec.summary = %q{Fluentd Output filter plugin.}
|
@@ -15,9 +15,9 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.1".freeze)
|
18
19
|
|
19
20
|
spec.add_development_dependency "rake"
|
20
21
|
spec.add_development_dependency "test-unit"
|
21
|
-
spec.add_development_dependency "fluentd"
|
22
|
-
spec.add_runtime_dependency "string-scrub", "~> 0.0.5" if RUBY_VERSION.to_f < 2.1
|
22
|
+
spec.add_development_dependency "fluentd", [">= 0.14.0", "< 2"]
|
23
23
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/filter'
|
2
|
+
|
3
|
+
class Fluent::Plugin::StringScrubFilter < Fluent::Plugin::Filter
|
2
4
|
Fluent::Plugin.register_filter('string_scrub', self)
|
3
5
|
|
4
6
|
config_param :replace_char, :string, :default => ''
|
5
7
|
|
6
8
|
def initialize
|
7
9
|
super
|
8
|
-
require 'string/scrub' if RUBY_VERSION.to_f < 2.1
|
9
10
|
end
|
10
11
|
|
11
12
|
def configure(conf)
|
@@ -57,4 +58,4 @@ class Fluent::StringScrubFilter < Fluent::Filter
|
|
57
58
|
retry
|
58
59
|
end
|
59
60
|
end
|
60
|
-
end
|
61
|
+
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
|
1
|
+
require 'fluent/plugin/output'
|
2
|
+
|
3
|
+
class Fluent::Plugin::StringScrubOutput < Fluent::Plugin::Output
|
2
4
|
Fluent::Plugin.register_output('string_scrub', self)
|
3
5
|
|
6
|
+
helpers :event_emitter
|
7
|
+
|
4
8
|
config_param :tag, :string, :default => nil
|
5
9
|
config_param :remove_prefix, :string, :default => nil
|
6
10
|
config_param :add_prefix, :string, :default => nil
|
7
11
|
config_param :replace_char, :string, :default => ''
|
8
12
|
|
9
|
-
# Define `router` method of v0.12 to support v0.10 or earlier
|
10
|
-
unless method_defined?(:router)
|
11
|
-
define_method("router") { Fluent::Engine }
|
12
|
-
end
|
13
|
-
|
14
13
|
def initialize
|
15
14
|
super
|
16
|
-
require 'string/scrub' if RUBY_VERSION.to_f < 2.1
|
17
15
|
end
|
18
16
|
|
19
17
|
def configure(conf)
|
@@ -40,7 +38,7 @@ class Fluent::StringScrubOutput < Fluent::Output
|
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
43
|
-
def
|
41
|
+
def process(tag, es)
|
44
42
|
tag = if @tag
|
45
43
|
@tag
|
46
44
|
else
|
@@ -63,8 +61,6 @@ class Fluent::StringScrubOutput < Fluent::Output
|
|
63
61
|
next if scrubbed.nil?
|
64
62
|
router.emit(tag, time, scrubbed)
|
65
63
|
end
|
66
|
-
|
67
|
-
chain.next
|
68
64
|
end
|
69
65
|
|
70
66
|
def recv_record(record)
|
data/test/helper.rb
CHANGED
@@ -12,16 +12,9 @@ require 'test/unit'
|
|
12
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
require 'fluent/test'
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
def method_missing(method, *args)
|
19
|
-
# pass
|
20
|
-
end
|
21
|
-
}
|
22
|
-
$log = nulllogger
|
23
|
-
end
|
24
|
-
|
15
|
+
require 'fluent/version'
|
16
|
+
require 'fluent/test/driver/output'
|
17
|
+
require 'fluent/test/driver/filter'
|
25
18
|
require 'fluent/plugin/out_string_scrub'
|
26
19
|
require 'fluent/plugin/filter_string_scrub'
|
27
20
|
|
@@ -20,24 +20,22 @@ class StringScrubFilterTest < Test::Unit::TestCase
|
|
20
20
|
replace_char \u{FFFD}
|
21
21
|
]
|
22
22
|
|
23
|
-
def create_driver(conf=CONFIG
|
24
|
-
Fluent::Test::
|
23
|
+
def create_driver(conf=CONFIG)
|
24
|
+
Fluent::Test::Driver::Filter.new(Fluent::Plugin::StringScrubFilter).configure(conf)
|
25
25
|
end
|
26
26
|
|
27
27
|
def filter(config, msgs)
|
28
28
|
d = create_driver(config)
|
29
|
-
d.run {
|
29
|
+
d.run(default_tag: 'test.filter') {
|
30
30
|
msgs.each {|msg|
|
31
|
-
d.
|
31
|
+
d.feed(@time, msg)
|
32
32
|
}
|
33
33
|
}
|
34
|
-
filtered = d.
|
35
|
-
filtered.map {|m| m[
|
34
|
+
filtered = d.filtered
|
35
|
+
filtered.map {|m| m[1] }
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_filter1
|
39
|
-
return unless defined? Fluent::Filter
|
40
|
-
|
41
39
|
orig_message = 'testtesttest'
|
42
40
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
43
41
|
msg = {"message" => orig_message + invalid_utf8}
|
@@ -28,8 +28,8 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
28
28
|
replace_char \u{FFFD}
|
29
29
|
]
|
30
30
|
|
31
|
-
def create_driver(conf = CONFIG
|
32
|
-
Fluent::Test::
|
31
|
+
def create_driver(conf = CONFIG)
|
32
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::StringScrubOutput).configure(conf)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_configure
|
@@ -78,48 +78,28 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
78
78
|
}
|
79
79
|
end
|
80
80
|
|
81
|
-
def test_emit_fluentd_0_12
|
82
|
-
if Fluent::VERSION >= "0.12"
|
83
|
-
in_tag = 'input.log'
|
84
|
-
orig_message = 'testtesttest'
|
85
|
-
Fluent::Engine.root_agent.add_label('@foo')
|
86
|
-
d = create_driver(%[
|
87
|
-
@label @foo
|
88
|
-
], in_tag)
|
89
|
-
label = Fluent::Engine.root_agent.find_label('@foo')
|
90
|
-
assert_equal(label.event_router, d.instance.router)
|
91
|
-
|
92
|
-
d.run do
|
93
|
-
d.emit({'message' => orig_message})
|
94
|
-
end
|
95
|
-
emits = d.emits
|
96
|
-
tag, time, record = emits.first
|
97
|
-
assert_equal(in_tag, tag)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
81
|
def test_emit1_invalid_string
|
102
82
|
orig_message = 'testtesttest'
|
103
83
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
104
|
-
d1 = create_driver(CONFIG
|
105
|
-
d1.run do
|
106
|
-
d1.
|
84
|
+
d1 = create_driver(CONFIG)
|
85
|
+
d1.run(default_tag: 'input.log') do
|
86
|
+
d1.feed({'message' => orig_message + invalid_utf8})
|
107
87
|
end
|
108
|
-
emits = d1.
|
88
|
+
emits = d1.events
|
109
89
|
assert_equal 1, emits.length
|
110
|
-
|
90
|
+
|
111
91
|
e1 = emits[0]
|
112
92
|
assert_equal "scrubbed.log", e1[0]
|
113
93
|
assert_equal orig_message, e1[2]['message']
|
114
94
|
|
115
95
|
invalid_ascii = "\xff".force_encoding('US-ASCII')
|
116
|
-
d2 = create_driver(CONFIG
|
117
|
-
d2.run do
|
118
|
-
d2.
|
96
|
+
d2 = create_driver(CONFIG)
|
97
|
+
d2.run(default_tag: 'input.log2') do
|
98
|
+
d2.feed({'message' => orig_message + invalid_utf8})
|
119
99
|
end
|
120
|
-
emits = d2.
|
100
|
+
emits = d2.events
|
121
101
|
assert_equal 1, emits.length
|
122
|
-
|
102
|
+
|
123
103
|
e2 = emits[0]
|
124
104
|
assert_equal "scrubbed.log2", e2[0]
|
125
105
|
assert_equal orig_message, e2[2]['message']
|
@@ -128,11 +108,11 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
128
108
|
def test_emit2_replace_char
|
129
109
|
orig_message = 'testtesttest'
|
130
110
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
131
|
-
d1 = create_driver(CONFIG_REPLACE_CHAR
|
132
|
-
d1.run do
|
133
|
-
d1.
|
111
|
+
d1 = create_driver(CONFIG_REPLACE_CHAR)
|
112
|
+
d1.run(default_tag: 'input.log') do
|
113
|
+
d1.feed({'message' => orig_message + invalid_utf8})
|
134
114
|
end
|
135
|
-
emits = d1.
|
115
|
+
emits = d1.events
|
136
116
|
assert_equal 1, emits.length
|
137
117
|
|
138
118
|
e1 = emits[0]
|
@@ -140,11 +120,11 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
140
120
|
assert_equal orig_message + '?', e1[2]['message']
|
141
121
|
|
142
122
|
invalid_ascii = "\xff".force_encoding('US-ASCII')
|
143
|
-
d2 = create_driver(CONFIG_REPLACE_CHAR
|
144
|
-
d2.run do
|
145
|
-
d2.
|
123
|
+
d2 = create_driver(CONFIG_REPLACE_CHAR)
|
124
|
+
d2.run(default_tag: 'input.log2') do
|
125
|
+
d2.feed({'message' => orig_message + invalid_utf8})
|
146
126
|
end
|
147
|
-
emits = d2.
|
127
|
+
emits = d2.events
|
148
128
|
assert_equal 1, emits.length
|
149
129
|
|
150
130
|
e2 = emits[0]
|
@@ -155,11 +135,11 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
155
135
|
def test_emit3_struct_message
|
156
136
|
orig_message = 'testtesttest'
|
157
137
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
158
|
-
d1 = create_driver(CONFIG_REPLACE_CHAR
|
159
|
-
d1.run do
|
160
|
-
d1.
|
138
|
+
d1 = create_driver(CONFIG_REPLACE_CHAR)
|
139
|
+
d1.run(default_tag: 'input.log') do
|
140
|
+
d1.feed({'message' => {'message_child' => orig_message + invalid_utf8}})
|
161
141
|
end
|
162
|
-
emits = d1.
|
142
|
+
emits = d1.events
|
163
143
|
assert_equal 1, emits.length
|
164
144
|
|
165
145
|
e1 = emits[0]
|
@@ -170,11 +150,11 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
170
150
|
def test_emit4_unicode1
|
171
151
|
orig_message = 'testtesttest'
|
172
152
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
173
|
-
d1 = create_driver(CONFIG_UNICODE_1
|
174
|
-
d1.run do
|
175
|
-
d1.
|
153
|
+
d1 = create_driver(CONFIG_UNICODE_1)
|
154
|
+
d1.run(default_tag: 'input.log') do
|
155
|
+
d1.feed({'message' => {'message_child' => orig_message + invalid_utf8}})
|
176
156
|
end
|
177
|
-
emits = d1.
|
157
|
+
emits = d1.events
|
178
158
|
assert_equal 1, emits.length
|
179
159
|
|
180
160
|
e1 = emits[0]
|
@@ -183,11 +163,11 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
183
163
|
|
184
164
|
orig_message = 'testtesttest'
|
185
165
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
186
|
-
d1 = create_driver(CONFIG_UNICODE_2
|
187
|
-
d1.run do
|
188
|
-
d1.
|
166
|
+
d1 = create_driver(CONFIG_UNICODE_2)
|
167
|
+
d1.run(default_tag: 'input.log') do
|
168
|
+
d1.feed({'message' => {'message_child' => orig_message + invalid_utf8}})
|
189
169
|
end
|
190
|
-
emits = d1.
|
170
|
+
emits = d1.events
|
191
171
|
assert_equal 1, emits.length
|
192
172
|
|
193
173
|
e1 = emits[0]
|
@@ -198,25 +178,25 @@ class StringScrubOutputTest < Test::Unit::TestCase
|
|
198
178
|
def test_emit5_frozen_string
|
199
179
|
orig_message = 'testtesttest'
|
200
180
|
invalid_utf8 = "\xff".force_encoding('UTF-8')
|
201
|
-
d1 = create_driver(CONFIG
|
202
|
-
d1.run do
|
203
|
-
d1.
|
181
|
+
d1 = create_driver(CONFIG)
|
182
|
+
d1.run(default_tag: 'input.log') do
|
183
|
+
d1.feed({'message' => (orig_message + invalid_utf8).freeze})
|
204
184
|
end
|
205
|
-
emits = d1.
|
185
|
+
emits = d1.events
|
206
186
|
assert_equal 1, emits.length
|
207
|
-
|
187
|
+
|
208
188
|
e1 = emits[0]
|
209
189
|
assert_equal "scrubbed.log", e1[0]
|
210
190
|
assert_equal orig_message, e1[2]['message']
|
211
191
|
|
212
192
|
invalid_ascii = "\xff".force_encoding('US-ASCII')
|
213
|
-
d2 = create_driver(CONFIG
|
214
|
-
d2.run do
|
215
|
-
d2.
|
193
|
+
d2 = create_driver(CONFIG)
|
194
|
+
d2.run(default_tag: 'input.log2') do
|
195
|
+
d2.feed({'message' => (orig_message + invalid_utf8).freeze})
|
216
196
|
end
|
217
|
-
emits = d2.
|
197
|
+
emits = d2.events
|
218
198
|
assert_equal 1, emits.length
|
219
|
-
|
199
|
+
|
220
200
|
e2 = emits[0]
|
221
201
|
assert_equal "scrubbed.log2", e2[0]
|
222
202
|
assert_equal orig_message, e2[2]['message']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-string-scrub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noriaki Katayama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -44,14 +44,20 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.14.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '2'
|
48
51
|
type: :development
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
55
|
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
57
|
+
version: 0.14.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '2'
|
55
61
|
description: fluent plugin for string scrub.
|
56
62
|
email:
|
57
63
|
- kataring@gmail.com
|
@@ -62,7 +68,6 @@ files:
|
|
62
68
|
- ".gitignore"
|
63
69
|
- ".travis.yml"
|
64
70
|
- Gemfile
|
65
|
-
- Gemfile.fluentd.lt.0.12
|
66
71
|
- LICENSE.txt
|
67
72
|
- README.md
|
68
73
|
- Rakefile
|
@@ -84,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
89
|
requirements:
|
85
90
|
- - ">="
|
86
91
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
92
|
+
version: '2.1'
|
88
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
94
|
requirements:
|
90
95
|
- - ">="
|
@@ -92,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
97
|
version: '0'
|
93
98
|
requirements: []
|
94
99
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.7.8
|
96
101
|
signing_key:
|
97
102
|
specification_version: 4
|
98
103
|
summary: Fluentd Output filter plugin.
|
data/Gemfile.fluentd.lt.0.12
DELETED