logstash-filter-xml 4.2.0 → 4.2.1

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
  SHA256:
3
- metadata.gz: 41486355fca6576c993aabd98476dd39888ba6467b8f91f3a4e76d3d45da06b0
4
- data.tar.gz: 13ea42b6f0b45fcf03051b468965b342e6d02b72c5ee41a8bb5ae08423dfe714
3
+ metadata.gz: c200fc7ce008ce13a62be488be3e2b683afc4df6cb93a9d7bfcd54f5f9480d1e
4
+ data.tar.gz: d2d2bd14a0a79ca27d17ce59cad5464b62ba3bc7963feb0e2b6be987d3fc9b4c
5
5
  SHA512:
6
- metadata.gz: 938a1e47c3739672583e4cad10c6083a092335bb3191a6479b4da757d14d9dca02542446f1bb2db3d87cbf77860f2cb7e9b1759a4fad5b82baaaf73cd6c83902
7
- data.tar.gz: 67e01e1ce39cd128bad8f1450d542f8c5ecf79ad3268675fb01f415d26c196f0b3ff7b71ac880ba248474b6be8a82310fe24aa76d1f3dbcdcf404767be20c839
6
+ metadata.gz: 4f0c8ebb2e173d759d52574ffb61ed93d7fea20ae455d8fcee0e15171ebafad0fe094be9351061cdb55f203390cc533d5780e3803492b0ed11d719371a1aecc5
7
+ data.tar.gz: 42a633c4a27b41bdf785e19eeff71cce3a26d986e9237fe70960f899c384bbaf3f22d3d57a4949a974fe1e6f6d49b5e2e6280c92e1d91c9aa2f6a640ce157d10
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 4.2.1
2
+ - patch rexml to improve performance of multi-threaded xml parsing [#84](https://github.com/logstash-plugins/logstash-filter-xml/pull/84)
3
+ #84
4
+
1
5
  ## 4.2.0
2
6
  - Update Nokogiri dependency version [#78](https://github.com/logstash-plugins/logstash-filter-xml/pull/78)
3
7
 
@@ -0,0 +1,27 @@
1
+ require 'xmlsimple'
2
+ require 'stringio'
3
+
4
+ module REXML
5
+ class SourceFactory
6
+ # Generates a Source object
7
+ # @param arg Either a String, or an IO
8
+ # @return a Source, or nil if a bad argument was given
9
+ def SourceFactory::create_from(arg)
10
+ if arg.respond_to? :read and
11
+ arg.respond_to? :readline and
12
+ arg.respond_to? :nil? and
13
+ arg.respond_to? :eof?
14
+ IOSource.new(arg)
15
+ elsif arg.respond_to? :to_str
16
+ # remove this require to speed up multi-threaded parsing
17
+ #require 'stringio'
18
+ IOSource.new(StringIO.new(arg))
19
+ elsif arg.kind_of? Source
20
+ arg
21
+ else
22
+ raise "#{arg.class} is not a valid input stream. It must walk \n"+
23
+ "like either a String, an IO, or a Source."
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/filters/base"
3
3
  require "logstash/namespace"
4
+ require "logstash/filters/xml/patch_rexml"
4
5
 
5
6
  # XML filter. Takes a field that contains XML and expands it into
6
7
  # an actual datastructure.
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-xml'
4
- s.version = '4.2.0'
4
+ s.version = '4.2.1'
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"
@@ -15,55 +15,55 @@ describe LogStash::Filters::Xml do
15
15
  }
16
16
  CONFIG
17
17
 
18
- sample("raw" => '<foo key="value"/>') do
18
+ sample({"raw" => '<foo key="value"/>'}) do
19
19
  insist { subject.get("tags") }.nil?
20
20
  insist { subject.get("data")} == {"key" => "value"}
21
21
  end
22
22
 
23
23
  #From parse xml with array as a value
24
- sample("raw" => '<foo><key>value1</key><key>value2</key></foo>') do
24
+ sample({"raw" => '<foo><key>value1</key><key>value2</key></foo>'}) do
25
25
  insist { subject.get("tags") }.nil?
26
26
  insist { subject.get("data")} == {"key" => ["value1", "value2"]}
27
27
  end
28
28
 
29
29
  #From parse xml with hash as a value
30
- sample("raw" => '<foo><key1><key2>value</key2></key1></foo>') do
30
+ sample({"raw" => '<foo><key1><key2>value</key2></key1></foo>'}) do
31
31
  insist { subject.get("tags") }.nil?
32
32
  insist { subject.get("data")} == {"key1" => [{"key2" => ["value"]}]}
33
33
  end
34
34
 
35
35
  # parse xml in single item array
36
- sample("raw" => ["<foo bar=\"baz\"/>"]) do
36
+ sample({"raw" => ["<foo bar=\"baz\"/>"]}) do
37
37
  insist { subject.get("tags") }.nil?
38
38
  insist { subject.get("data")} == {"bar" => "baz"}
39
39
  end
40
40
 
41
41
  # fail in multi items array
42
- sample("raw" => ["<foo bar=\"baz\"/>", "jojoba"]) do
42
+ sample({"raw" => ["<foo bar=\"baz\"/>", "jojoba"]}) do
43
43
  insist { subject.get("tags") }.include?("_xmlparsefailure")
44
44
  insist { subject.get("data")} == nil
45
45
  end
46
46
 
47
47
  # fail in empty array
48
- sample("raw" => []) do
48
+ sample({"raw" => []}) do
49
49
  insist { subject.get("tags") }.include?("_xmlparsefailure")
50
50
  insist { subject.get("data")} == nil
51
51
  end
52
52
 
53
53
  # fail for non string field
54
- sample("raw" => {"foo" => "bar"}) do
54
+ sample({"raw" => {"foo" => "bar"}}) do
55
55
  insist { subject.get("tags") }.include?("_xmlparsefailure")
56
56
  insist { subject.get("data")} == nil
57
57
  end
58
58
 
59
59
  # fail for non string single item array
60
- sample("raw" => [{"foo" => "bar"}]) do
60
+ sample({"raw" => [{"foo" => "bar"}]}) do
61
61
  insist { subject.get("tags") }.include?("_xmlparsefailure")
62
62
  insist { subject.get("data")} == nil
63
63
  end
64
64
 
65
65
  #From bad xml
66
- sample("raw" => '<foo /') do
66
+ sample({"raw" => '<foo /'}) do
67
67
  insist { subject.get("tags") }.include?("_xmlparsefailure")
68
68
  end
69
69
  end
@@ -79,7 +79,7 @@ describe LogStash::Filters::Xml do
79
79
  }
80
80
  CONFIG
81
81
 
82
- sample("raw" => '<foo key="value"/>') do
82
+ sample({"raw" => '<foo key="value"/>'}) do
83
83
  insist { subject.get("tags") }.nil?
84
84
  insist { subject.get("data")} == nil
85
85
  end
@@ -97,13 +97,13 @@ describe LogStash::Filters::Xml do
97
97
  CONFIG
98
98
 
99
99
  # Single value
100
- sample("raw" => '<foo><key>value</key></foo>') do
100
+ sample({"raw" => '<foo><key>value</key></foo>'}) do
101
101
  insist { subject.get("tags") }.nil?
102
102
  insist { subject.get("xpath_field")} == ["value"]
103
103
  end
104
104
 
105
105
  #Multiple values
106
- sample("raw" => '<foo><key>value1</key><key>value2</key></foo>') do
106
+ sample({"raw" => '<foo><key>value1</key><key>value2</key></foo>'}) do
107
107
  insist { subject.get("tags") }.nil?
108
108
  insist { subject.get("xpath_field")} == ["value1","value2"]
109
109
  end
@@ -121,25 +121,25 @@ describe LogStash::Filters::Xml do
121
121
  }
122
122
  CONFIG
123
123
 
124
- sample("xmldata" => '<foo key="value"/>') do
124
+ sample({"xmldata" => '<foo key="value"/>'}) do
125
125
  insist { subject.get("tags") }.nil?
126
126
  insist { subject.get("data") } == {"key" => "value"}
127
127
  end
128
128
 
129
129
  #From parse xml with array as a value
130
- sample("xmldata" => '<foo><key>value1</key><key>value2</key></foo>') do
130
+ sample({"xmldata" => '<foo><key>value1</key><key>value2</key></foo>'}) do
131
131
  insist { subject.get("tags") }.nil?
132
132
  insist { subject.get("data") } == {"key" => ["value1", "value2"]}
133
133
  end
134
134
 
135
135
  #From parse xml with hash as a value
136
- sample("xmldata" => '<foo><key1><key2>value</key2></key1></foo>') do
136
+ sample({"xmldata" => '<foo><key1><key2>value</key2></key1></foo>'}) do
137
137
  insist { subject.get("tags") }.nil?
138
138
  insist { subject.get("data") } == {"key1" => [{"key2" => ["value"]}]}
139
139
  end
140
140
 
141
141
  #From bad xml
142
- sample("xmldata" => '<foo /') do
142
+ sample({"xmldata" => '<foo /'}) do
143
143
  insist { subject.get("tags") }.include?("_xmlparsefailure")
144
144
  end
145
145
  end
@@ -155,7 +155,7 @@ describe LogStash::Filters::Xml do
155
155
  }
156
156
  CONFIG
157
157
 
158
- sample("xmldata" => '<foo key="value"/>') do
158
+ sample({"xmldata" => '<foo key="value"/>'}) do
159
159
  insist { subject.get("tags") }.nil?
160
160
  insist { subject.get("data")} == nil
161
161
  end
@@ -173,13 +173,13 @@ describe LogStash::Filters::Xml do
173
173
  CONFIG
174
174
 
175
175
  # Single value
176
- sample("xmldata" => '<foo><key>value</key></foo>') do
176
+ sample({"xmldata" => '<foo><key>value</key></foo>'}) do
177
177
  insist { subject.get("tags") }.nil?
178
178
  insist { subject.get("xpath_field") } == ["value"]
179
179
  end
180
180
 
181
181
  #Multiple values
182
- sample("xmldata" => '<foo><key>value1</key><key>value2</key></foo>') do
182
+ sample({"xmldata" => '<foo><key>value1</key><key>value2</key></foo>'}) do
183
183
  insist { subject.get("tags") }.nil?
184
184
  insist { subject.get("xpath_field") } == ["value1","value2"]
185
185
  end
@@ -197,7 +197,7 @@ describe LogStash::Filters::Xml do
197
197
  CONFIG
198
198
 
199
199
  # Single value
200
- sample("xmldata" => '<foo><key>Français</key></foo>') do
200
+ sample({"xmldata" => '<foo><key>Français</key></foo>'}) do
201
201
  insist { subject.get("tags") }.nil?
202
202
  insist { subject.get("xpath_field")} == ["Français"]
203
203
  end
@@ -216,7 +216,7 @@ describe LogStash::Filters::Xml do
216
216
  CONFIG
217
217
 
218
218
  # Single value
219
- sample("xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>') do
219
+ sample({"xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>'}) do
220
220
  insist { subject.get("xpath_field") } == ["<h:div>Content</h:div>"]
221
221
  end
222
222
  end
@@ -235,7 +235,7 @@ describe LogStash::Filters::Xml do
235
235
  CONFIG
236
236
 
237
237
  # Single value
238
- sample("xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>') do
238
+ sample({"xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>'}) do
239
239
  insist { subject.get("xpath_field") } == ["<h:div>Content</h:div>"]
240
240
  end
241
241
  end
@@ -254,7 +254,7 @@ describe LogStash::Filters::Xml do
254
254
  CONFIG
255
255
 
256
256
  # Single value
257
- sample("xmldata" => '<foo><h:div xmlns:h="http://www.w3.org/TR/html4/">Content</h:div></foo>') do
257
+ sample({"xmldata" => '<foo><h:div xmlns:h="http://www.w3.org/TR/html4/">Content</h:div></foo>'}) do
258
258
  insist { subject.get("xpath_field") } == ["<h:div xmlns:h=\"http://www.w3.org/TR/html4/\">Content</h:div>"]
259
259
  end
260
260
  end
@@ -272,7 +272,7 @@ describe LogStash::Filters::Xml do
272
272
  CONFIG
273
273
 
274
274
  # Single value
275
- sample("xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>') do
275
+ sample({"xmldata" => '<foo xmlns:h="http://www.w3.org/TR/html4/"><h:div>Content</h:div></foo>'}) do
276
276
  insist { subject.get("xpath_field") } == ["<div>Content</div>"]
277
277
  end
278
278
  end
@@ -289,7 +289,7 @@ describe LogStash::Filters::Xml do
289
289
  CONFIG
290
290
 
291
291
  # Single value
292
- sample("xmldata" => '<foo><bar>Content</bar></foo>') do
292
+ sample({"xmldata" => '<foo><bar>Content</bar></foo>'}) do
293
293
  insist { subject.get("parseddata") } == { "bar" => ["Content"] }
294
294
  end
295
295
  end
@@ -306,7 +306,7 @@ describe LogStash::Filters::Xml do
306
306
  CONFIG
307
307
 
308
308
  # Single value
309
- sample("xmldata" => '<foo><bar>Content</bar></foo>') do
309
+ sample({"xmldata" => '<foo><bar>Content</bar></foo>'}) do
310
310
  insist { subject.get("parseddata") } == { "bar" => "Content" }
311
311
  end
312
312
  end
@@ -326,7 +326,7 @@ describe LogStash::Filters::Xml do
326
326
  CONFIG
327
327
 
328
328
  # Single value
329
- sample("xmldata" => '<element><field1>bbb</field1><field2>789</field2><field3>e3f<field3></element>') do
329
+ sample({"xmldata" => '<element><field1>bbb</field1><field2>789</field2><field3>e3f<field3></element>'}) do
330
330
  insist { subject.get("field1") } == "bbb"
331
331
  end
332
332
  end
@@ -343,7 +343,7 @@ describe LogStash::Filters::Xml do
343
343
  }
344
344
  CONFIG
345
345
 
346
- sample("xmldata" => '<foo><key>value1</key><key></key></foo>') do
346
+ sample({"xmldata" => '<foo><key>value1</key><key></key></foo>'}) do
347
347
  insist { subject.get("tags") }.nil?
348
348
  insist { subject.get("data") } == {"key" => ["value1", {}]}
349
349
  end
@@ -360,7 +360,7 @@ describe LogStash::Filters::Xml do
360
360
  }
361
361
  CONFIG
362
362
 
363
- sample("xmldata" => '<foo><key>value1</key><key></key></foo>') do
363
+ sample({"xmldata" => '<foo><key>value1</key><key></key></foo>'}) do
364
364
  insist { subject.get("tags") }.nil?
365
365
  insist { subject.get("data") } == {"key" => ["value1"]}
366
366
  end
@@ -380,7 +380,7 @@ describe LogStash::Filters::Xml do
380
380
  }
381
381
  CONFIG
382
382
 
383
- sample("xmldata" => '<opt><x>text1</x><y a="2">text2</y></opt>') do
383
+ sample({"xmldata" => '<opt><x>text1</x><y a="2">text2</y></opt>'}) do
384
384
  insist { subject.get("tags") }.nil?
385
385
  insist { subject.get("data") } == { 'x' => 'text1', 'y' => { 'a' => '2', 'content' => 'text2' } }
386
386
  end
@@ -397,7 +397,7 @@ describe LogStash::Filters::Xml do
397
397
  }
398
398
  CONFIG
399
399
 
400
- sample("xmldata" => '<opt><x>text1</x><y a="2">text2</y></opt>') do
400
+ sample({"xmldata" => '<opt><x>text1</x><y a="2">text2</y></opt>'}) do
401
401
  insist { subject.get("tags") }.nil?
402
402
  insist { subject.get("data") } == { 'x' => { 'content' => 'text1' }, 'y' => { 'a' => '2', 'content' => 'text2' } }
403
403
  end
@@ -413,7 +413,7 @@ describe LogStash::Filters::Xml do
413
413
  }
414
414
  CONFIG
415
415
 
416
- sample("raw" => '<foobar></foobar>') do
416
+ sample({"raw" => '<foobar></foobar>'}) do
417
417
  insist { subject.get("tags") }.nil?
418
418
  insist { subject.get("xpath_field")}.nil?
419
419
  end
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.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -17,8 +17,8 @@ dependencies:
17
17
  - !ruby/object:Gem::Version
18
18
  version: 8.4.0
19
19
  name: logstash-core
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
@@ -34,8 +34,8 @@ dependencies:
34
34
  - !ruby/object:Gem::Version
35
35
  version: '2.99'
36
36
  name: logstash-core-plugin-api
37
- prerelease: false
38
37
  type: :runtime
38
+ prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
@@ -51,8 +51,8 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: 1.13.8
53
53
  name: nokogiri
54
- prerelease: false
55
54
  type: :runtime
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - ">="
@@ -65,8 +65,8 @@ dependencies:
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  name: xml-simple
68
- prerelease: false
69
68
  type: :runtime
69
+ prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - ">="
@@ -79,8 +79,8 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  name: logstash-devutils
82
- prerelease: false
83
82
  type: :development
83
+ prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
@@ -93,8 +93,8 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  name: insist
96
- prerelease: false
97
96
  type: :development
97
+ prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
@@ -116,6 +116,7 @@ files:
116
116
  - README.md
117
117
  - docs/index.asciidoc
118
118
  - lib/logstash/filters/xml.rb
119
+ - lib/logstash/filters/xml/patch_rexml.rb
119
120
  - logstash-filter-xml.gemspec
120
121
  - spec/filters/xml_spec.rb
121
122
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  - !ruby/object:Gem::Version
140
141
  version: '0'
141
142
  requirements: []
142
- rubygems_version: 3.2.29
143
+ rubygems_version: 3.3.26
143
144
  signing_key:
144
145
  specification_version: 4
145
146
  summary: Parses XML into fields