logstash-filter-kv 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/docs/index.asciidoc +3 -1
- data/lib/logstash/filters/kv.rb +4 -4
- data/logstash-filter-kv.gemspec +1 -1
- data/spec/filters/kv_spec.rb +87 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e108f33865f7afc5f0b397d3ba6ae37b93cf664c6e8f6a8d9bf74650c987954c
|
4
|
+
data.tar.gz: aded17fb29c331fe4d68ae280d2ed884e968ae180e6539a313c66b8399952be4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e122414de884300d596a3d7da38f6408e1a1a42d32894013dd8c8fea533bcf18ac90619cc0ca544c68c552ab0a8e1c8891d1d15d2ee60aeb4c028b7f396443be
|
7
|
+
data.tar.gz: d667872a513d33403b7b26e69a876787ae985c515dac645948f3536f67d7b04175ec727a7f76b97d804b3934f0ee8699cd7d849a1b93f692b3c067647331ed39
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 4.1.2
|
2
|
+
- bugfix: improves trim_key and trim_value to trim any _sequence_ of matching characters from the beginning and ends of the corresponding keys and values; a previous implementation limitited trim to a single character from each end, which was surprising.
|
3
|
+
- bugfix: fixes issue where we can fail to correctly break up a sequence that includes a partially-quoted value followed by another fully-quoted value by slightly reducing greediness of quoted-value captures.
|
4
|
+
|
1
5
|
## 4.1.1
|
2
6
|
- bugfix: correctly handle empty values between value separator and field separator (#58)
|
3
7
|
|
data/docs/index.asciidoc
CHANGED
@@ -56,6 +56,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
56
56
|
| <<plugins-{type}s-{plugin}-default_keys>> |<<hash,hash>>|No
|
57
57
|
| <<plugins-{type}s-{plugin}-exclude_keys>> |<<array,array>>|No
|
58
58
|
| <<plugins-{type}s-{plugin}-field_split>> |<<string,string>>|No
|
59
|
+
| <<plugins-{type}s-{plugin}-field_split_pattern>> |<<string,string>>|No
|
59
60
|
| <<plugins-{type}s-{plugin}-include_brackets>> |<<boolean,boolean>>|No
|
60
61
|
| <<plugins-{type}s-{plugin}-include_keys>> |<<array,array>>|No
|
61
62
|
| <<plugins-{type}s-{plugin}-prefix>> |<<string,string>>|No
|
@@ -69,6 +70,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
69
70
|
| <<plugins-{type}s-{plugin}-trim_key>> |<<string,string>>|No
|
70
71
|
| <<plugins-{type}s-{plugin}-trim_value>> |<<string,string>>|No
|
71
72
|
| <<plugins-{type}s-{plugin}-value_split>> |<<string,string>>|No
|
73
|
+
| <<plugins-{type}s-{plugin}-value_split_pattern>> |<<string,string>>|No
|
72
74
|
|=======================================================================
|
73
75
|
|
74
76
|
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
@@ -444,4 +446,4 @@ See `field_split_pattern` for examples.
|
|
444
446
|
|
445
447
|
|
446
448
|
[id="plugins-{type}s-{plugin}-common-options"]
|
447
|
-
include::{include_path}/{type}.asciidoc[]
|
449
|
+
include::{include_path}/{type}.asciidoc[]
|
data/lib/logstash/filters/kv.rb
CHANGED
@@ -331,8 +331,8 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
331
331
|
)
|
332
332
|
end
|
333
333
|
|
334
|
-
@trim_value_re = Regexp.new("^[#{@trim_value}]
|
335
|
-
@trim_key_re = Regexp.new("^[#{@trim_key}]
|
334
|
+
@trim_value_re = Regexp.new("^[#{@trim_value}]+|[#{@trim_value}]+$") if @trim_value
|
335
|
+
@trim_key_re = Regexp.new("^[#{@trim_key}]+|[#{@trim_key}]+$") if @trim_key
|
336
336
|
|
337
337
|
@remove_char_value_re = Regexp.new("[#{@remove_char_value}]") if @remove_char_value
|
338
338
|
@remove_char_key_re = Regexp.new("[#{@remove_char_key}]") if @remove_char_key
|
@@ -422,8 +422,8 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|
422
422
|
open_pattern = /#{Regexp.quote(quote_sequence)}/
|
423
423
|
close_pattern = /#{Regexp.quote(close_quote_sequence)}/
|
424
424
|
|
425
|
-
# matches a sequence of zero or more characters
|
426
|
-
quoted_value_pattern = /
|
425
|
+
# matches a sequence of zero or more characters are _not_ the `close_quote_sequence`
|
426
|
+
quoted_value_pattern = /[^#{Regexp.quote(close_quote_sequence)}]*/
|
427
427
|
|
428
428
|
/#{open_pattern}(#{quoted_value_pattern})#{close_pattern}/
|
429
429
|
end
|
data/logstash-filter-kv.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-kv'
|
4
|
-
s.version = '4.1.
|
4
|
+
s.version = '4.1.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Parses key-value pairs"
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
data/spec/filters/kv_spec.rb
CHANGED
@@ -730,6 +730,59 @@ describe LogStash::Filters::KV do
|
|
730
730
|
end
|
731
731
|
end
|
732
732
|
|
733
|
+
describe "trim_key/trim_value options : trim multiple matching characters from either end" do
|
734
|
+
subject do
|
735
|
+
plugin = LogStash::Filters::KV.new(options)
|
736
|
+
plugin.register
|
737
|
+
plugin
|
738
|
+
end
|
739
|
+
|
740
|
+
let(:data) { {"message" => message} }
|
741
|
+
let(:event) { LogStash::Event.new(data) }
|
742
|
+
|
743
|
+
|
744
|
+
context 'repeated same-character sequence' do
|
745
|
+
let(:message) { "key1= value1 with spaces | key2 with spaces =value2" }
|
746
|
+
let(:options) {
|
747
|
+
{
|
748
|
+
"field_split" => "|",
|
749
|
+
"value_split" => "=",
|
750
|
+
"trim_value" => " ",
|
751
|
+
"trim_key" => " "
|
752
|
+
}
|
753
|
+
}
|
754
|
+
|
755
|
+
it 'trims all the right bits' do
|
756
|
+
subject.filter(event)
|
757
|
+
expect(event.get('key1')).to eq('value1 with spaces')
|
758
|
+
expect(event.get('key2 with spaces')).to eq('value2')
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
context 'multi-character sequence' do
|
763
|
+
let(:message) { "to=<foo@example.com>, orig_to=<bar@example.com>, %+relay=mail.example.com[private/dovecot-lmtp], delay=2.2, delays=1.9/0.01/0.01/0.21, dsn=2.0.0, status=sent (250 2.0.0 <foo@example.com> YERDHejiRSXFDSdfUXTV Saved) " }
|
764
|
+
let(:options) {
|
765
|
+
{
|
766
|
+
"field_split" => " ",
|
767
|
+
"value_split" => "=",
|
768
|
+
"trim_value" => "<>,",
|
769
|
+
"trim_key" => "%+"
|
770
|
+
}
|
771
|
+
}
|
772
|
+
|
773
|
+
it 'trims all the right bits' do
|
774
|
+
subject.filter(event)
|
775
|
+
expect(event.get('to')).to eq('foo@example.com')
|
776
|
+
expect(event.get('orig_to')).to eq('bar@example.com')
|
777
|
+
expect(event.get('relay')).to eq('mail.example.com[private/dovecot-lmtp]')
|
778
|
+
expect(event.get('delay')).to eq('2.2')
|
779
|
+
expect(event.get('delays')).to eq('1.9/0.01/0.01/0.21')
|
780
|
+
expect(event.get('dsn')).to eq('2.0.0')
|
781
|
+
expect(event.get('status')).to eq('sent')
|
782
|
+
end
|
783
|
+
end
|
784
|
+
end
|
785
|
+
|
733
786
|
describe "remove_char_key/remove_char_value options : remove all characters in keys/values whatever their position" do
|
734
787
|
subject do
|
735
788
|
plugin = LogStash::Filters::KV.new(options)
|
@@ -833,6 +886,40 @@ describe "multi character splitting" do
|
|
833
886
|
it_behaves_like "parsing all fields and values"
|
834
887
|
end
|
835
888
|
|
889
|
+
context 'multi-char field split pattern with value that begins quoted and contains more unquoted' do
|
890
|
+
let(:message) { 'foo=bar!!!!!baz="quoted stuff" and more unquoted!!!!!msg="fully-quoted with a part! of the separator"!!!!!blip="this!!!!!is it"!!!!!empty=""!!!!!non-empty="foo"' }
|
891
|
+
let(:options) {
|
892
|
+
{
|
893
|
+
"field_split_pattern" => "!!!!!"
|
894
|
+
}
|
895
|
+
}
|
896
|
+
it 'gets the right bits' do
|
897
|
+
subject.filter(event)
|
898
|
+
expect(event.get("foo")).to eq('bar')
|
899
|
+
expect(event.get("baz")).to eq('"quoted stuff" and more unquoted')
|
900
|
+
expect(event.get("msg")).to eq('fully-quoted with a part! of the separator')
|
901
|
+
expect(event.get("blip")).to eq('this!!!!!is it')
|
902
|
+
expect(event.get("empty")).to be_nil
|
903
|
+
expect(event.get("non-empty")).to eq('foo')
|
904
|
+
end
|
905
|
+
end
|
906
|
+
|
907
|
+
context 'standard field split pattern with value that begins quoted and contains more unquoted' do
|
908
|
+
let(:message) { 'foo=bar baz="quoted stuff" and more unquoted msg="some fully-quoted message " empty="" non-empty="foo"' }
|
909
|
+
let(:options) {
|
910
|
+
{
|
911
|
+
}
|
912
|
+
}
|
913
|
+
it 'gets the right bits' do
|
914
|
+
subject.filter(event)
|
915
|
+
expect(event.get("foo")).to eq('bar')
|
916
|
+
expect(event.get("baz")).to eq('quoted stuff') # NOTE: outside the quotes is truncated because field split pattern wins.
|
917
|
+
expect(event.get("msg")).to eq('some fully-quoted message ')
|
918
|
+
expect(event.get("empty")).to be_nil
|
919
|
+
expect(event.get("non-empty")).to eq('foo')
|
920
|
+
end
|
921
|
+
end
|
922
|
+
|
836
923
|
context "field and value split multi" do
|
837
924
|
let(:message) { "hello::world__foo::bar__baz::fizz__doublequoted::\"hello world\"__singlequoted::'hello world'__bracketsone::(hello world)__bracketstwo::[hello world]__bracketsthree::<hello world>" }
|
838
925
|
let(:options) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-kv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|