fluent-plugin-windows-eventlog 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 359baf1a9205ef362e4504df9408456929e11476b8b7ca8f31b930fa75f67996
4
- data.tar.gz: 3022117b4b9650f09e7856cfbb82a39267818bb71b46fb016ca0f71deb26c4d9
3
+ metadata.gz: f42851f147127453f0392e3e14ab31ed86983508c75453d9b41d2674441d8abc
4
+ data.tar.gz: fbfe63f1ee0034df3fd4346376b728b6728105b76130c82902768e67b4b5c1fe
5
5
  SHA512:
6
- metadata.gz: c37d3b7a0a0c8b39e889efdda75fd7d22e6227b7a60eb1c47e9f2b459458c3144725a9d68f7e4ad6215315f62ce0829dde6730f7fccc4d37d93b2a47e7e8951f
7
- data.tar.gz: b1cad59577bcec5188c0009545d0a89087210abf8b5bc1f946453607ab0b3f8b87aff1dfacbbf066d0d3b61c0505b9ffdde9da3ab788ca9dd2bc53be1ee65f1e
6
+ metadata.gz: a8326aa48c8661fcc9165e708db19ea3a4dd5ff0ec1407c35b7a6ef4db29fda70816eaba2c0a7b2e4e8c1255d47626b1330d8e1725c869e1ed7c5601e1681070
7
+ data.tar.gz: 22d9526b59591eca30044c625107a8aecc51c5e9b85448607450fec333e7630c44dccf4cc737539b5131d78bff1c2225f6ab0eb0f618832ffb06bc0b70c9ecd0
@@ -1,3 +1,6 @@
1
+ # Release v0.5.3 - 2020/03/17
2
+ * in_windows_eventlog2: Add Qualifiers key handling options
3
+
1
4
  # Release v0.5.2 - 2020/02/28
2
5
  * in_windows_eventlog2: Add parameter to read from all channels shortcut
3
6
 
data/README.md CHANGED
@@ -141,6 +141,7 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
141
141
  tag winevt.raw
142
142
  render_as_xml false # default is true.
143
143
  rate_limit 200 # default is -1(Winevt::EventLog::Subscribe::RATE_INFINITE).
144
+ # preserve_qualifiers_on_hash true # default is false.
144
145
  <storage>
145
146
  @type local # @type local is the default.
146
147
  persistent true # default is true. Set to false to use in-memory storage.
@@ -149,6 +150,11 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
149
150
  </storage>
150
151
  <parse>
151
152
  @type winevt_xml # @type winevt_xml is the default. winevt_xml and none parsers are supported for now.
153
+ # When set up it as true, this plugin preserves "Qualifiers" and "EventID" keys.
154
+ # When set up it as false, this plugin calculates actual "EventID" from "Qualifiers" and removing "Qualifiers".
155
+ # With the following equation:
156
+ # (EventID & 0xffff) | (Qualifiers & 0xffff) << 16
157
+ preserve_qualifiers true
152
158
  </parse>
153
159
  # <subscribe>
154
160
  # channles application, system
@@ -177,7 +183,9 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
177
183
  |`parse_description`| (option) parse `description` field and set parsed result into the record. `Description` and `EventData` fields are removed|
178
184
  |`read_from_head` | **Deprecated** (option) Start to read the entries from the oldest, not from when fluentd is started. Defaults to `false`.|
179
185
  |`read_existing_events` | (option) Read the entries which already exist before fluentd is started. Defaults to `false`.|
186
+ |`render_as_xml` | (option) Render Windows EventLog as XML or Ruby Hash object directly. Defaults to `true`.|
180
187
  |`rate_limit` | (option) Specify rate limit to consume EventLog. Default is `Winevt::EventLog::Subscribe::RATE_INFINITE`.|
188
+ |`preserve_qualifiers_on_hash` | (option) When set up it as true, this plugin preserves "Qualifiers" and "EventID" keys. When set up it as false, this plugin calculates actual "EventID" from "Qualifiers" and removing "Qualifiers". Default is `false`.|
181
189
  |`read_all_channels`| (option) Read from all channels. Default is `false`|
182
190
  |`<subscribe>` | Setting for subscribe channels. |
183
191
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-windows-eventlog"
7
- spec.version = "0.5.2"
7
+ spec.version = "0.5.3"
8
8
  spec.authors = ["okahashi117", "Hiroshi Hatake", "Masahiro Nakagawa"]
9
9
  spec.email = ["naruki_okahashi@jbat.co.jp", "cosmo0920.oucc@gmail.com", "repeatedly@gmail.com"]
10
10
  spec.summary = %q{Fluentd Input plugin to read windows event log.}
@@ -49,6 +49,7 @@ module Fluent::Plugin
49
49
  end
50
50
 
51
51
  def configure(conf)
52
+ log.warn "in_windows_eventlog is deprecated. It will be removed in the future version."
52
53
  super
53
54
  @chs = @channels.map {|ch| ch.strip.downcase }.uniq
54
55
  if @chs.empty?
@@ -40,6 +40,7 @@ module Fluent::Plugin
40
40
  config_param :parse_description, :bool, default: false
41
41
  config_param :render_as_xml, :bool, default: true
42
42
  config_param :rate_limit, :integer, default: Winevt::EventLog::Subscribe::RATE_INFINITE
43
+ config_param :preserve_qualifiers_on_hash, :bool, default: false
43
44
  config_param :read_all_channels, :bool, default: false
44
45
 
45
46
  config_section :subscribe, param_name: :subscribe_configs, required: false, multi: true do
@@ -95,12 +96,11 @@ module Fluent::Plugin
95
96
  if @keynames.empty?
96
97
  @keynames = KEY_MAP.keys
97
98
  end
98
- @keynames.delete('Qualifiers') unless @render_as_xml
99
- @keynames.delete('EventData') if @parse_description
100
99
 
101
100
  @tag = tag
102
101
  @bookmarks_storage = storage_create(usage: "bookmarks")
103
102
  @winevt_xml = false
103
+ @parser = nil
104
104
  if @render_as_xml
105
105
  @parser = parser_create
106
106
  @winevt_xml = @parser.respond_to?(:winevt_xml?) && @parser.winevt_xml?
@@ -112,6 +112,16 @@ module Fluent::Plugin
112
112
  alias_method :on_notify, :on_notify_hash
113
113
  end
114
114
  end
115
+
116
+ if @render_as_xml && @preserve_qualifiers_on_hash
117
+ raise Fluent::ConfigError, "preserve_qualifiers_on_hash must be used with Hash object rendering(render_as_xml as false)."
118
+ end
119
+ if !@render_as_xml && !@preserve_qualifiers_on_hash
120
+ @keynames.delete('Qualifiers')
121
+ elsif @parser.respond_to?(:preserve_qualifiers?) && !@parser.preserve_qualifiers?
122
+ @keynames.delete('Qualifiers')
123
+ end
124
+ @keynames.delete('EventData') if @parse_description
115
125
  end
116
126
 
117
127
  def start
@@ -132,6 +142,9 @@ module Fluent::Plugin
132
142
  subscribe.read_existing_events = read_existing_events
133
143
  begin
134
144
  subscribe.subscribe(ch, "*", bookmark)
145
+ if !@render_as_xml && @preserve_qualifiers_on_hash && subscribe.respond_to?(:preserve_qualifiers=)
146
+ subscribe.preserve_qualifiers = @preserve_qualifiers_on_hash
147
+ end
135
148
  rescue Winevt::EventLog::Query::Error => e
136
149
  raise Fluent::ConfigError, "Invalid Bookmark XML is loaded. #{e}"
137
150
  end
@@ -89,6 +89,20 @@ class WindowsEventLog2InputTest < Test::Unit::TestCase
89
89
  assert_equal 2, d.instance.instance_variable_get(:@chs).select {|ch, flag| ch == "system"}.size
90
90
  assert_equal expected, d.instance.instance_variable_get(:@chs)
91
91
  end
92
+
93
+ test "invalid combination for preserving qualifiers" do
94
+ assert_raise(Fluent::ConfigError) do
95
+ create_driver config_element("ROOT", "", {"tag" => "fluent.eventlog",
96
+ "render_as_xml" => true,
97
+ "preserve_qualifiers_on_hash" => true,
98
+ }, [
99
+ config_element("storage", "", {
100
+ '@type' => 'local',
101
+ 'persistent' => false
102
+ }),
103
+ ])
104
+ end
105
+ end
92
106
  end
93
107
 
94
108
  data("application" => ["Application", "Application"],
@@ -253,6 +267,37 @@ DESC
253
267
  assert_equal("4", record["Level"])
254
268
  assert_equal("fluent-plugins", record["ProviderName"])
255
269
  end
270
+
271
+ def test_write_with_preserving_qualifiers
272
+ require 'winevt'
273
+
274
+ d = create_driver(config_element("ROOT", "", {"tag" => "fluent.eventlog",
275
+ "render_as_xml" => false,
276
+ 'preserve_qualifiers_on_hash' => true
277
+ }, [
278
+ config_element("storage", "", {
279
+ '@type' => 'local',
280
+ 'persistent' => false
281
+ }),
282
+ ]))
283
+
284
+ service = Fluent::Plugin::EventService.new
285
+ subscribe = Winevt::EventLog::Subscribe.new
286
+
287
+ omit "@parser.preserve_qualifiers does not respond" unless subscribe.respond_to?(:preserve_qualifiers?)
288
+
289
+ d.run(expect_emits: 1) do
290
+ service.run
291
+ end
292
+
293
+ assert(d.events.length >= 1)
294
+ event = d.events.last
295
+ record = event.last
296
+
297
+ assert_true(record.has_key?("Description"))
298
+ assert_true(record.has_key?("EventData"))
299
+ assert_true(record.has_key?("Qualifiers"))
300
+ end
256
301
  end
257
302
 
258
303
  class PersistBookMark < self
@@ -372,4 +417,33 @@ EOS
372
417
  assert_true(record.has_key?("Description"))
373
418
  assert_true(record.has_key?("EventData"))
374
419
  end
420
+
421
+ def test_write_with_winevt_xml_parser_without_qualifiers
422
+ d = create_driver(config_element("ROOT", "", {"tag" => "fluent.eventlog"}, [
423
+ config_element("storage", "", {
424
+ '@type' => 'local',
425
+ 'persistent' => false
426
+ }),
427
+ config_element("parse", "", {
428
+ '@type' => 'winevt_xml',
429
+ 'preserve_qualifiers' => false
430
+ }),
431
+ ]))
432
+
433
+ service = Fluent::Plugin::EventService.new
434
+
435
+ omit "@parser.preserve_qualifiers does not respond" unless d.instance.instance_variable_get(:@parser).respond_to?(:preserve_qualifiers?)
436
+
437
+ d.run(expect_emits: 1) do
438
+ service.run
439
+ end
440
+
441
+ assert(d.events.length >= 1)
442
+ event = d.events.last
443
+ record = event.last
444
+
445
+ assert_true(record.has_key?("Description"))
446
+ assert_true(record.has_key?("EventData"))
447
+ assert_false(record.has_key?("Qualifiers"))
448
+ end
375
449
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-windows-eventlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - okahashi117
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-28 00:00:00.000000000 Z
13
+ date: 2020-03-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler