logstash-filter-mutate 3.5.7 → 3.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/filters/mutate.rb +2 -1
- data/logstash-filter-mutate.gemspec +1 -1
- data/spec/filters/integration/multi_stage_spec.rb +1 -1
- data/spec/filters/mutate_spec.rb +48 -28
- 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: a35944145cf520f4dc7a0249e8d4c75e60abcf0c454545f0fb9a4a70af223bea
|
4
|
+
data.tar.gz: 431b8427123636a98fa9c51a4460157d6018cd594c927e95e9028048f49c2e3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c7c36f559f8733d38ba8d87f2017418b380c1178100fb4a7641cb5c80e5440b06e5e6aaed46b3f9c53be3a5aeaa245bb3f2fd90a90a41ddd105c3ff00046ffb
|
7
|
+
data.tar.gz: b8b4c405276c6714db052d3cd1a46a5286c4ef787dd9aad33b7861468e6d83410f13eea597dc41aee0a03d6e110a40ace196bb687efba0caa417114bfdeb6bb3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 3.5.8
|
2
|
+
- Fix "Can't modify frozen string" error when converting boolean to `string` [#171](https://github.com/logstash-plugins/logstash-filter-mutate/pull/171)
|
3
|
+
|
1
4
|
## 3.5.7
|
2
5
|
- Clarify that `split` and `join` also support strings [#164](https://github.com/logstash-plugins/logstash-filter-mutate/pull/164)
|
3
6
|
|
@@ -330,7 +330,8 @@ class LogStash::Filters::Mutate < LogStash::Filters::Base
|
|
330
330
|
# target encoding and only change if necessary, so calling
|
331
331
|
# valid_encoding? is redundant
|
332
332
|
# see https://twitter.com/jordansissel/status/444613207143903232
|
333
|
-
|
333
|
+
# use + since .to_s on nil/boolean returns a frozen string since ruby 2.7
|
334
|
+
(+value.to_s).force_encoding(Encoding::UTF_8)
|
334
335
|
end
|
335
336
|
|
336
337
|
def convert_boolean(value)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-mutate'
|
4
|
-
s.version = '3.5.
|
4
|
+
s.version = '3.5.8'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Performs mutations on fields"
|
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"
|
@@ -34,7 +34,7 @@ describe 'LogStash::Filters::Mutate' do
|
|
34
34
|
CONFIG
|
35
35
|
end
|
36
36
|
|
37
|
-
sample("message" => "hello WORLD", "lower1" => "PPQQRRSS", "lower2" => "pppqqq") do
|
37
|
+
sample({"message" => "hello WORLD", "lower1" => "PPQQRRSS", "lower2" => "pppqqq"}) do
|
38
38
|
result = results.first
|
39
39
|
expect(result.get("bar")).to eq('world')
|
40
40
|
expect(result.get("lower1")).to eq("ppqqrrss")
|
data/spec/filters/mutate_spec.rb
CHANGED
@@ -428,7 +428,7 @@ describe LogStash::Filters::Mutate do
|
|
428
428
|
}
|
429
429
|
}'
|
430
430
|
|
431
|
-
sample("unicorns" => 1234) do
|
431
|
+
sample({"unicorns" => 1234}) do
|
432
432
|
expect(subject.get("unicorns")).to eq "1234"
|
433
433
|
end
|
434
434
|
end
|
@@ -561,25 +561,25 @@ describe LogStash::Filters::Mutate do
|
|
561
561
|
end
|
562
562
|
|
563
563
|
context 'when field is the true value' do
|
564
|
-
sample('field' => true) do
|
564
|
+
sample({'field' => true}) do
|
565
565
|
expect(subject.get('field')).to eq(1.0)
|
566
566
|
end
|
567
567
|
end
|
568
568
|
|
569
569
|
context 'when field is the false value' do
|
570
|
-
sample('field' => false) do
|
570
|
+
sample({'field' => false}) do
|
571
571
|
expect(subject.get('field')).to eq(0.0)
|
572
572
|
end
|
573
573
|
end
|
574
574
|
|
575
575
|
context 'when field is nil' do
|
576
|
-
sample('field' => nil) do
|
576
|
+
sample({'field' => nil}) do
|
577
577
|
expect(subject.get('field')).to be_nil
|
578
578
|
end
|
579
579
|
end
|
580
580
|
|
581
581
|
context 'when field is not set' do
|
582
|
-
sample('field' => nil) do
|
582
|
+
sample({'field' => nil}) do
|
583
583
|
expect(subject.get('field')).to be_nil
|
584
584
|
end
|
585
585
|
end
|
@@ -634,25 +634,25 @@ describe LogStash::Filters::Mutate do
|
|
634
634
|
end
|
635
635
|
|
636
636
|
context 'when field is the true value' do
|
637
|
-
sample('field' => true) do
|
637
|
+
sample({'field' => true}) do
|
638
638
|
expect(subject.get('field')).to eq(1.0)
|
639
639
|
end
|
640
640
|
end
|
641
641
|
|
642
642
|
context 'when field is the false value' do
|
643
|
-
sample('field' => false) do
|
643
|
+
sample({'field' => false}) do
|
644
644
|
expect(subject.get('field')).to eq(0.0)
|
645
645
|
end
|
646
646
|
end
|
647
647
|
|
648
648
|
context 'when field is nil' do
|
649
|
-
sample('field' => nil) do
|
649
|
+
sample({'field' => nil}) do
|
650
650
|
expect(subject.get('field')).to be_nil
|
651
651
|
end
|
652
652
|
end
|
653
653
|
|
654
654
|
context 'when field is not set' do
|
655
|
-
sample('field' => nil) do
|
655
|
+
sample({'field' => nil}) do
|
656
656
|
expect(subject.get('field')).to be_nil
|
657
657
|
end
|
658
658
|
end
|
@@ -666,7 +666,7 @@ describe LogStash::Filters::Mutate do
|
|
666
666
|
}
|
667
667
|
}'
|
668
668
|
|
669
|
-
sample("unicorns" => "Magnificient, but extinct, animals") do
|
669
|
+
sample({"unicorns" => "Magnificient, but extinct, animals"}) do
|
670
670
|
expect(subject.get("unicorns")).to eq "Magnificient, and common, animals"
|
671
671
|
end
|
672
672
|
end
|
@@ -679,8 +679,8 @@ describe LogStash::Filters::Mutate do
|
|
679
679
|
}
|
680
680
|
}'
|
681
681
|
|
682
|
-
sample("unicorns" => [
|
683
|
-
"Magnificient extinct animals", "Other extinct ideas" ]
|
682
|
+
sample({"unicorns" => [
|
683
|
+
"Magnificient extinct animals", "Other extinct ideas" ]}
|
684
684
|
) do
|
685
685
|
expect(subject.get("unicorns")).to eq [
|
686
686
|
"Magnificient common animals",
|
@@ -698,7 +698,7 @@ describe LogStash::Filters::Mutate do
|
|
698
698
|
}
|
699
699
|
}'
|
700
700
|
|
701
|
-
sample("colors" => "One red car", "shapes" => "Four red squares") do
|
701
|
+
sample({"colors" => "One red car", "shapes" => "Four red squares"}) do
|
702
702
|
expect(subject.get("colors")).to eq "One blue car"
|
703
703
|
expect(subject.get("shapes")).to eq "Four red circles"
|
704
704
|
end
|
@@ -712,7 +712,7 @@ describe LogStash::Filters::Mutate do
|
|
712
712
|
}
|
713
713
|
}'
|
714
714
|
|
715
|
-
sample("colors" => "red3") do
|
715
|
+
sample({"colors" => "red3"}) do
|
716
716
|
expect(subject.get("colors")).to eq "redblue"
|
717
717
|
end
|
718
718
|
end
|
@@ -758,7 +758,7 @@ describe LogStash::Filters::Mutate do
|
|
758
758
|
}
|
759
759
|
CONFIG
|
760
760
|
|
761
|
-
sample("field_one" => "value", "x" => "one") do
|
761
|
+
sample({"field_one" => "value", "x" => "one"}) do
|
762
762
|
expect(subject).to_not include("field_one")
|
763
763
|
expect(subject).to include("destination")
|
764
764
|
end
|
@@ -773,7 +773,7 @@ describe LogStash::Filters::Mutate do
|
|
773
773
|
}
|
774
774
|
CONFIG
|
775
775
|
|
776
|
-
sample("field_one" => "value", "x" => "one") do
|
776
|
+
sample({"field_one" => "value", "x" => "one"}) do
|
777
777
|
expect(subject).to_not include("origin")
|
778
778
|
expect(subject).to include("field_one")
|
779
779
|
end
|
@@ -934,6 +934,26 @@ describe LogStash::Filters::Mutate do
|
|
934
934
|
end
|
935
935
|
end
|
936
936
|
|
937
|
+
describe "convert auto-frozen values to string" do
|
938
|
+
config <<-CONFIG
|
939
|
+
filter {
|
940
|
+
mutate {
|
941
|
+
convert => {
|
942
|
+
"true_field" => "string"
|
943
|
+
"false_field" => "string"
|
944
|
+
}
|
945
|
+
}
|
946
|
+
}
|
947
|
+
CONFIG
|
948
|
+
|
949
|
+
sample({ "true_field" => true, "false_field" => false }) do
|
950
|
+
expect(subject.get("true_field")).to eq "true"
|
951
|
+
expect(subject.get("true_field")).to be_a(String)
|
952
|
+
expect(subject.get("false_field")).to eq "false"
|
953
|
+
expect(subject.get("false_field")).to be_a(String)
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
937
957
|
#LOGSTASH-1529
|
938
958
|
describe "gsub on a String with dynamic fields (%{}) in pattern" do
|
939
959
|
config '
|
@@ -943,7 +963,7 @@ describe LogStash::Filters::Mutate do
|
|
943
963
|
}
|
944
964
|
}'
|
945
965
|
|
946
|
-
sample("unicorns" => "Unicorns of type blue are common", "unicorn_type" => "blue") do
|
966
|
+
sample({"unicorns" => "Unicorns of type blue are common", "unicorn_type" => "blue"}) do
|
947
967
|
expect(subject.get("unicorns")).to eq "Unicorns green are common"
|
948
968
|
end
|
949
969
|
end
|
@@ -957,7 +977,7 @@ describe LogStash::Filters::Mutate do
|
|
957
977
|
}
|
958
978
|
}'
|
959
979
|
|
960
|
-
sample("unicorns2" => "Unicorns of type blue are common", "unicorn_color" => "blue") do
|
980
|
+
sample({"unicorns2" => "Unicorns of type blue are common", "unicorn_color" => "blue"}) do
|
961
981
|
expect(subject.get("unicorns2")).to eq "Unicorns blue and green are common"
|
962
982
|
end
|
963
983
|
end
|
@@ -971,9 +991,9 @@ describe LogStash::Filters::Mutate do
|
|
971
991
|
}
|
972
992
|
}'
|
973
993
|
|
974
|
-
sample("unicorns_array" => [
|
994
|
+
sample({"unicorns_array" => [
|
975
995
|
"Unicorns of type blue are found in Alaska", "Unicorns of type blue are extinct" ],
|
976
|
-
"color" => "blue"
|
996
|
+
"color" => "blue" }
|
977
997
|
) do
|
978
998
|
expect(subject.get("unicorns_array")).to eq [
|
979
999
|
"Unicorns blue and green are found in Alaska",
|
@@ -990,7 +1010,7 @@ describe LogStash::Filters::Mutate do
|
|
990
1010
|
}
|
991
1011
|
}'
|
992
1012
|
|
993
|
-
sample("foo" => "bar") do
|
1013
|
+
sample({"foo" => "bar"}) do
|
994
1014
|
expect(subject.get("list")).to eq ["bar"]
|
995
1015
|
expect(subject.get("foo")).to eq "bar"
|
996
1016
|
end
|
@@ -1004,7 +1024,7 @@ describe LogStash::Filters::Mutate do
|
|
1004
1024
|
}
|
1005
1025
|
}'
|
1006
1026
|
|
1007
|
-
sample("foo" => "bar", "list" => []) do
|
1027
|
+
sample({"foo" => "bar", "list" => []}) do
|
1008
1028
|
expect(subject.get("list")).to eq ["bar"]
|
1009
1029
|
expect(subject.get("foo")).to eq "bar"
|
1010
1030
|
end
|
@@ -1018,7 +1038,7 @@ describe LogStash::Filters::Mutate do
|
|
1018
1038
|
}
|
1019
1039
|
}'
|
1020
1040
|
|
1021
|
-
sample("foo" => "bar", "list" => ["baz"]) do
|
1041
|
+
sample({"foo" => "bar", "list" => ["baz"]}) do
|
1022
1042
|
expect(subject.get("list")).to eq ["baz", "bar"]
|
1023
1043
|
expect(subject.get("foo")).to eq "bar"
|
1024
1044
|
end
|
@@ -1032,7 +1052,7 @@ describe LogStash::Filters::Mutate do
|
|
1032
1052
|
}
|
1033
1053
|
}'
|
1034
1054
|
|
1035
|
-
sample("foo" => ["bar"], "list" => ["baz"]) do
|
1055
|
+
sample({"foo" => ["bar"], "list" => ["baz"]}) do
|
1036
1056
|
expect(subject.get("list")).to eq ["baz", "bar"]
|
1037
1057
|
expect(subject.get("foo")).to eq ["bar"]
|
1038
1058
|
end
|
@@ -1046,7 +1066,7 @@ describe LogStash::Filters::Mutate do
|
|
1046
1066
|
}
|
1047
1067
|
}'
|
1048
1068
|
|
1049
|
-
sample("foo" => [], "list" => ["baz"]) do
|
1069
|
+
sample({"foo" => [], "list" => ["baz"]}) do
|
1050
1070
|
expect(subject.get("list")).to eq ["baz"]
|
1051
1071
|
expect(subject.get("foo")).to eq []
|
1052
1072
|
end
|
@@ -1060,7 +1080,7 @@ describe LogStash::Filters::Mutate do
|
|
1060
1080
|
}
|
1061
1081
|
}'
|
1062
1082
|
|
1063
|
-
sample("foo" => ["bar"], "list" => "baz") do
|
1083
|
+
sample({"foo" => ["bar"], "list" => "baz"}) do
|
1064
1084
|
expect(subject.get("list")).to eq ["baz", "bar"]
|
1065
1085
|
expect(subject.get("foo")).to eq ["bar"]
|
1066
1086
|
end
|
@@ -1074,7 +1094,7 @@ describe LogStash::Filters::Mutate do
|
|
1074
1094
|
}
|
1075
1095
|
}'
|
1076
1096
|
|
1077
|
-
sample("foo" => "bar", "list" => "baz") do
|
1097
|
+
sample({"foo" => "bar", "list" => "baz"}) do
|
1078
1098
|
expect(subject.get("list")).to eq ["baz", "bar"]
|
1079
1099
|
expect(subject.get("foo")).to eq "bar"
|
1080
1100
|
end
|
@@ -1094,7 +1114,7 @@ describe LogStash::Filters::Mutate do
|
|
1094
1114
|
}'
|
1095
1115
|
|
1096
1116
|
|
1097
|
-
sample("field1" => nil, "field2" => nil, "field3" => nil, "field4" => true) do
|
1117
|
+
sample({"field1" => nil, "field2" => nil, "field3" => nil, "field4" => true}) do
|
1098
1118
|
expect(subject.get("field1")).to eq("Hello")
|
1099
1119
|
expect(subject.get("field2")).to eq("Bye")
|
1100
1120
|
expect(subject.get("field3")).to eq("5")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-mutate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|