logstash-filter-csv 3.0.5 → 3.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55248ee94900a2352a2900c98c891c5de8ebfe3b
4
- data.tar.gz: fe7817db9a950532cf8b32650413d6b8c74cbb71
3
+ metadata.gz: 9ff0bd6fdf58706e32acf77c116694d1274b7d11
4
+ data.tar.gz: 28b97ce191613e3245376d2c21475623c4a0f985
5
5
  SHA512:
6
- metadata.gz: 48756013179fb793a380dd17f4b078c4acb9332ecb2da455279214b8653bdfd27b01cb251252d6b12b062bc726426e214ae3bc0a18bac1a7bd5fd5879212893f
7
- data.tar.gz: c588100c860435e658c98ff3be641a3794374593558cf8715096687524e9ef9712416f1de32ce0444f75420dea288d3fee094401c53944b3098e103ddabd4a36
6
+ metadata.gz: a1533f34f35e0701ae830109a548f0ff1d260147c99e36f4fd82ebdb2700a22d7500da3edb48bc15c549c2e63fa529967017d7f11b3e4e009e1977ced0b21b29
7
+ data.tar.gz: a04d372cb6114b935828ec6de9ca6d2821c1afab13287819b200f2ca3f1196e638368be53e78e40da5878ad7a405f5d3d51ea2774de99c34982bc17c304dd020
@@ -1,3 +1,6 @@
1
+ ## 3.0.6
2
+ - Fix a bug where `[nested][field]` references were incorrectly used. (#24, #52)
3
+
1
4
  ## 3.0.5
2
5
  - Fix some documentation issues
3
6
 
@@ -105,7 +105,7 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
105
105
  @convert_symbols = @convert.inject({}){|result, (k, v)| result[k] = v.to_sym; result}
106
106
 
107
107
  # make sure @target is in the format [field name] if defined, i.e. surrounded by brakets
108
- @target = "[#{@target}]" if @target && @target !~ /^\[[^\[\]]+\]$/
108
+ @target = "[#{@target}]" if @target && !@target.start_with?("[")
109
109
 
110
110
  # if the zero byte character is entered in the config, set the value
111
111
  if (@quote_char == "\\x00")
@@ -151,10 +151,14 @@ class LogStash::Filters::CSV < LogStash::Filters::Base
151
151
  private
152
152
 
153
153
  # construct the correct Event field reference for given field_name, taking into account @target
154
- # @param field_name [String] the bare field name without brakets
154
+ # @param field_name [String] the field name.
155
155
  # @return [String] fully qualified Event field reference also taking into account @target prefix
156
156
  def field_ref(field_name)
157
- "#{@target}[#{field_name}]"
157
+ if field_name.start_with?("[")
158
+ "#{@target}#{field_name}"
159
+ else
160
+ "#{@target}[#{field_name}]"
161
+ end
158
162
  end
159
163
 
160
164
  def ignore_field?(index)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-csv'
4
- s.version = '3.0.5'
4
+ s.version = '3.0.6'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The CSV filter takes an event field containing CSV data, parses it, and stores it as individual fields (can optionally specify the names)."
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"
@@ -196,6 +196,25 @@ describe LogStash::Filters::CSV do
196
196
  expect(event.get("custom3")).to eq("val3")
197
197
  end
198
198
  end
199
+
200
+ context "that use [@metadata]" do
201
+ let(:metadata_field) { "[@metadata][one]" }
202
+ let(:config) do
203
+ {
204
+ "columns" => [ metadata_field, "foo" ]
205
+ }
206
+ end
207
+
208
+ let(:event) { LogStash::Event.new("message" => "hello,world") }
209
+
210
+ before do
211
+ plugin.filter(event)
212
+ end
213
+
214
+ it "should work correctly" do
215
+ expect(event.get(metadata_field)).to eq("hello")
216
+ end
217
+ end
199
218
  end
200
219
 
201
220
  describe "givin target" do
@@ -227,6 +246,41 @@ describe LogStash::Filters::CSV do
227
246
  expect(event.get("data")["column3"]).to eq("sesame street")
228
247
  end
229
248
  end
249
+
250
+ context "which uses [nested][fieldref] syntax" do
251
+ let(:target) { "[foo][bar]" }
252
+ let(:config) do
253
+ {
254
+ "target" => target
255
+ }
256
+ end
257
+
258
+ let(:event) { LogStash::Event.new("message" => "hello,world") }
259
+
260
+ before do
261
+ plugin.filter(event)
262
+ end
263
+
264
+ it "should set fields correctly in the target" do
265
+ expect(event.get("#{target}[column1]")).to eq("hello")
266
+ expect(event.get("#{target}[column2]")).to eq("world")
267
+ end
268
+
269
+ context "with nested fieldrefs as columns" do
270
+ let(:config) do
271
+ {
272
+ "target" => target,
273
+ "columns" => [ "[test][one]", "[test][two]" ]
274
+ }
275
+ end
276
+
277
+ it "should set fields correctly in the target" do
278
+ expect(event.get("#{target}[test][one]")).to eq("hello")
279
+ expect(event.get("#{target}[test][two]")).to eq("world")
280
+ end
281
+ end
282
+
283
+ end
230
284
  end
231
285
 
232
286
  describe "using field convertion" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement