logstash-filter-xml 4.0.5 → 4.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/LICENSE +1 -1
- data/lib/logstash/filters/xml.rb +11 -8
- data/logstash-filter-xml.gemspec +1 -1
- data/spec/filters/xml_spec.rb +20 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b00b3a1873a98c6e633b1b35bcd64a21eefe8f57fe3c28efcf4103c5a3855685
|
4
|
+
data.tar.gz: a363f65d3e9f2206221d076b8bfc6c2a4f560e952cb0415c4cea6eb5ab1762b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '099b6efdb5ad0ea40d18fa91c08a961e8a736cd12df8ee1a07e993c10f8e61dcd3227b7ceb274dc569f24a7417d905f08d607849bcee5005e54c17829d4ed123'
|
7
|
+
data.tar.gz: e8cede0fb4dc11a5b31aa4bc079ae4ab7b75f112b8acda4be47a582db0cf80120c84d62a40ee856c5264c50cb2bb46e55a0892b3d11e3c2eec97efa0572471a8
|
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
data/lib/logstash/filters/xml.rb
CHANGED
@@ -156,21 +156,24 @@ class LogStash::Filters::Xml < LogStash::Filters::Base
|
|
156
156
|
# String instead of a NodeSet. We normalize that here.
|
157
157
|
normalized_nodeset = nodeset.kind_of?(Nokogiri::XML::NodeSet) ? nodeset : [nodeset]
|
158
158
|
|
159
|
+
# Initialize empty resultset
|
160
|
+
data = []
|
161
|
+
|
159
162
|
normalized_nodeset.each do |value|
|
160
163
|
# some XPath functions return empty arrays as string
|
161
|
-
|
162
|
-
return if value.is_a?(Array) && value.length == 0
|
164
|
+
next if value.is_a?(Array) && value.length == 0
|
163
165
|
|
164
166
|
if value
|
165
167
|
matched = true
|
166
|
-
# TODO: (colin) this can probably be optimized to avoid the Event get/set at every loop iteration anf
|
167
|
-
# the array should probably be created once, filled in the loop and set at after the loop but the return
|
168
|
-
# statement above screws this strategy and is likely a bug anyway so I will not touch this until I can
|
169
|
-
# deep a big deeper and verify there is a sufficient test harness to refactor this.
|
170
|
-
data = event.get(xpath_dest) || []
|
171
168
|
data << value.to_s
|
172
|
-
event.set(xpath_dest, data)
|
173
169
|
end
|
170
|
+
|
171
|
+
end
|
172
|
+
# set the destination attribute, if it's an array with a bigger size than one, leave as is. otherwise make it a string. added force_array param to provide same functionality as writing it in an xml target
|
173
|
+
if data.size == 1 && !@force_array
|
174
|
+
event.set(xpath_dest, data[0])
|
175
|
+
else
|
176
|
+
event.set(xpath_dest, data)
|
174
177
|
end
|
175
178
|
end
|
176
179
|
end
|
data/logstash-filter-xml.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-xml'
|
4
|
-
s.version = '4.0.
|
4
|
+
s.version = '4.0.6'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Parses XML into 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"
|
data/spec/filters/xml_spec.rb
CHANGED
@@ -310,6 +310,26 @@ describe LogStash::Filters::Xml do
|
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
|
+
describe "parse disabling forcing with nested elements" do
|
314
|
+
config <<-CONFIG
|
315
|
+
filter {
|
316
|
+
xml {
|
317
|
+
source => "xmldata"
|
318
|
+
store_xml => "false"
|
319
|
+
force_array => "false"
|
320
|
+
xpath => [
|
321
|
+
"/element/field1/text()", "field1"
|
322
|
+
]
|
323
|
+
}
|
324
|
+
}
|
325
|
+
CONFIG
|
326
|
+
|
327
|
+
# Single value
|
328
|
+
sample("xmldata" => '<element><field1>bbb</field1><field2>789</field2><field3>e3f<field3></element>') do
|
329
|
+
insist { subject.get("field1") } == "bbb"
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
313
333
|
context "Using suppress_empty option" do
|
314
334
|
describe "suppress_empty => false" do
|
315
335
|
config <<-CONFIG
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.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:
|
11
|
+
date: 2018-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.6.
|
115
|
+
rubygems_version: 2.6.13
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Parses XML into fields
|