fluent-plugin-windows-eventlog 0.4.3 → 0.5.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +54 -2
- data/fluent-plugin-winevtlog.gemspec +2 -2
- data/lib/fluent/plugin/bookmark_sax_parser.rb +30 -0
- data/lib/fluent/plugin/in_windows_eventlog.rb +8 -2
- data/lib/fluent/plugin/in_windows_eventlog2.rb +65 -25
- data/test/data/eventid_6416 +27 -0
- data/test/helper.rb +1 -0
- data/test/plugin/test_bookmark_sax_parser.rb +41 -0
- data/test/plugin/test_in_windows_eventlog2.rb +116 -2
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2946ba1ffbe8219ffc2a06da14574510f677bc9de02fbb47744b7a38cae77671
|
4
|
+
data.tar.gz: 9655f498e66267796daf2f0fc0cc3c4262b426e5b86a1a52546223ce7d1446fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ae256e9f3bacc2c25b98224bf73872a0edea8de4ede5b56c3d0a966827fba7d10dc5ff99640ee1e8271a31560f82fa4f95f18a1eb63ffd63a2c98b5795d95c
|
7
|
+
data.tar.gz: 300b90957142a1bb66cf19b12cbdcc63c61eb1ef7f32a6408d9661d4d86fd6851ebb32ea3d35075bf6e5c0862ef00620fba7329d7cfc99e49d4aeb9afa98a72b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Release v0.5.1 - 2020/02/26
|
2
|
+
* in_windows_eventlog2: Add empty bookmark checking mechanism
|
3
|
+
|
4
|
+
# Release v0.5.0 - 2020/02/17
|
5
|
+
* in_windows_eventlog2: Support subscribe directive to handle read_existing_events paratemer each of channels.
|
6
|
+
* in_windows_eventlog2: Depends on winevt_c v0.7.0 or later.
|
7
|
+
|
8
|
+
# Release v0.4.6 - 2020/02/15
|
9
|
+
* Fix winevt_c dependency to prevent fetching winevt_c v0.7.0 or later.
|
10
|
+
|
11
|
+
# Release v0.4.5 - 2020/01/28
|
12
|
+
* in_windows_eventlog2: Handle empty key case in parsing description method.
|
13
|
+
|
14
|
+
# Release v0.4.4 - 2019/11/07
|
15
|
+
* in_windows_eventlog: Improve error handling and logging when failed to open Windows Event Log.
|
16
|
+
|
1
17
|
# Release v0.4.3 - 2019/10/31
|
2
18
|
* in_windows_eventlog2: Handle privileges record on #parse_desc
|
3
19
|
* in_windows_eventlog2: Raise error when handling invalid bookmark xml
|
data/README.md
CHANGED
@@ -135,7 +135,8 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
|
|
135
135
|
<source>
|
136
136
|
@type windows_eventlog2
|
137
137
|
@id windows_eventlog2
|
138
|
-
channels application,system
|
138
|
+
channels application,system # Also be able to use `<subscribe>` directive.
|
139
|
+
read_existing_events false
|
139
140
|
read_interval 2
|
140
141
|
tag winevt.raw
|
141
142
|
render_as_xml false # default is true.
|
@@ -149,6 +150,10 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
|
|
149
150
|
<parse>
|
150
151
|
@type winevt_xml # @type winevt_xml is the default. winevt_xml and none parsers are supported for now.
|
151
152
|
</parse>
|
153
|
+
# <subscribe>
|
154
|
+
# channles application, system
|
155
|
+
# read_existing_events false # read_existing_events should be applied each of subscribe directive(s)
|
156
|
+
# </subscribe>
|
152
157
|
</source>
|
153
158
|
|
154
159
|
**NOTE:** in_windows_eventlog2 always handles EventLog records as UTF-8 characters. Users don't have to specify encoding related parameters and they are not provided.
|
@@ -163,13 +168,60 @@ fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
|
|
163
168
|
|
164
169
|
|name | description |
|
165
170
|
|:----- |:----- |
|
166
|
-
|`channels` | (option) 'application' as default. One or more of {'application', 'system', 'setup', 'security'}. If you want to read 'setup' or 'security' logs, you must launch fluentd with administrator privileges.|
|
171
|
+
|`channels` | (option) No default value just empty array, but 'application' is used as default due to backward compatibility. One or more of {'application', 'system', 'setup', 'security'}. If you want to read 'setup' or 'security' logs, you must launch fluentd with administrator privileges.|
|
167
172
|
|`keys` | (option) A subset of [keys](#read-keys) to read. Defaults to all keys.|
|
168
173
|
|`read_interval` | (option) Read interval in seconds. 2 seconds as default.|
|
169
174
|
|`from_encoding` | (option) Input character encoding. `nil` as default.|
|
170
175
|
|`<storage>` | Setting for `storage` plugin for recording read position like `in_tail`'s `pos_file`.|
|
171
176
|
|`<parse>` | Setting for `parser` plugin for parsing raw XML EventLog records. |
|
172
177
|
|`parse_description`| (option) parse `description` field and set parsed result into the record. `Description` and `EventData` fields are removed|
|
178
|
+
|`read_from_head` | **Deprecated** (option) Start to read the entries from the oldest, not from when fluentd is started. Defaults to `false`.|
|
179
|
+
|`read_existing_events` | (option) Read the entries which already exist before fluentd is started. Defaults to `false`.|
|
180
|
+
|`read_existing_events` | (option) Read the entries which already exist before fluentd is started. Defaults to `false`.|
|
181
|
+
|`rate_limit` | (option) Specify rate limit to consume EventLog. Default is `Winevt::EventLog::Subscribe::RATE_INFINITE`.|
|
182
|
+
|`<subscribe>` | Setting for subscribe channels. |
|
183
|
+
|
184
|
+
##### subscribe section
|
185
|
+
|
186
|
+
|name | description |
|
187
|
+
|:----- |:----- |
|
188
|
+
|`channels` | One or more of {'application', 'system', 'setup', 'security'}. If you want to read 'setup' or 'security' logs, you must launch fluentd with administrator privileges. |
|
189
|
+
|`read_existing_events` | (option) Read the entries which already exist before fluentd is started. Defaults to `false`. |
|
190
|
+
|
191
|
+
|
192
|
+
**Motivation:** subscribe directive is designed for applying `read_existing_events` each of channels which is specified in subscribe section(s).
|
193
|
+
|
194
|
+
e.g) The previous configuration can handle `read_existing_events` but this parameter only specifies `read_existing_events` or not for channels which are specified in `channels`.
|
195
|
+
|
196
|
+
```aconf
|
197
|
+
channels ["Application", "Security", "HardwareEvents"]
|
198
|
+
read_existing_events true
|
199
|
+
```
|
200
|
+
|
201
|
+
is interpreted as "Application", "Security", and "HardwareEvents" should be read existing events.
|
202
|
+
|
203
|
+
But some users want to configure to:
|
204
|
+
|
205
|
+
* "Application" and "Security" channels just tailing
|
206
|
+
* "HardwareEvent" channel read existing events before launching Fluentd
|
207
|
+
|
208
|
+
With `<subscribe>` directive, this requirements can be represendted as:
|
209
|
+
|
210
|
+
```aconf
|
211
|
+
<subscribe>
|
212
|
+
channles ["Application", "Security"]
|
213
|
+
# read_existing_events false
|
214
|
+
</subscribe>
|
215
|
+
<subscribe>
|
216
|
+
channles ["HardwareEvent"]
|
217
|
+
read_existing_events true
|
218
|
+
</subscribe>
|
219
|
+
```
|
220
|
+
|
221
|
+
This configuration can be handled as:
|
222
|
+
|
223
|
+
* "Application" and "Security" channels just tailing
|
224
|
+
* "HardwareEvent" channel read existing events before launching Fluentd
|
173
225
|
|
174
226
|
##### Available keys
|
175
227
|
|
@@ -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.
|
7
|
+
spec.version = "0.5.1"
|
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.}
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "test-unit", "~> 3.2.0"
|
23
23
|
spec.add_runtime_dependency "fluentd", [">= 0.14.12", "< 2"]
|
24
24
|
spec.add_runtime_dependency "win32-eventlog"
|
25
|
-
spec.add_runtime_dependency "winevt_c", ">= 0.
|
25
|
+
spec.add_runtime_dependency "winevt_c", ">= 0.7.0"
|
26
26
|
spec.add_runtime_dependency "nokogiri", "~> 1.10"
|
27
27
|
spec.add_runtime_dependency "fluent-plugin-parser-winevt_xml", ">= 0.1.2"
|
28
28
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
class WinevtBookmarkDocument < Nokogiri::XML::SAX::Document
|
4
|
+
attr_reader :result
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@result = {}
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_document
|
12
|
+
end
|
13
|
+
|
14
|
+
def start_element(name, attributes = [])
|
15
|
+
if name == "Bookmark"
|
16
|
+
@result[:channel] = attributes[0][1] rescue nil
|
17
|
+
@result[:record_id] = attributes[1][1].to_i rescue nil
|
18
|
+
@result[:is_current] = attributes[2][1].downcase == "true" rescue nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def characters(string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def end_element(name, attributes = [])
|
26
|
+
end
|
27
|
+
|
28
|
+
def end_document
|
29
|
+
end
|
30
|
+
end
|
@@ -151,7 +151,11 @@ module Fluent::Plugin
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def on_notify(ch)
|
154
|
-
|
154
|
+
begin
|
155
|
+
el = Win32::EventLog.open(ch)
|
156
|
+
rescue => e
|
157
|
+
log.error "Failed to open Windows Event log.", error: e
|
158
|
+
end
|
155
159
|
|
156
160
|
current_oldest_record_number = el.oldest_record_number
|
157
161
|
current_total_records = el.total_records
|
@@ -186,7 +190,9 @@ module Fluent::Plugin
|
|
186
190
|
receive_lines(ch, winlogs)
|
187
191
|
@pos_storage.put(ch, [read_start, read_num + winlogs.size])
|
188
192
|
ensure
|
189
|
-
el
|
193
|
+
if el
|
194
|
+
el.close
|
195
|
+
end
|
190
196
|
end
|
191
197
|
|
192
198
|
GROUP_DELIMITER = "\r\n\r\n".freeze
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'winevt'
|
2
2
|
require 'fluent/plugin/input'
|
3
3
|
require 'fluent/plugin'
|
4
|
+
require_relative 'bookmark_sax_parser'
|
4
5
|
|
5
6
|
module Fluent::Plugin
|
6
7
|
class WindowsEventLog2Input < Input
|
@@ -32,13 +33,19 @@ module Fluent::Plugin
|
|
32
33
|
|
33
34
|
config_param :tag, :string
|
34
35
|
config_param :read_interval, :time, default: 2
|
35
|
-
config_param :channels, :array, default: [
|
36
|
+
config_param :channels, :array, default: []
|
36
37
|
config_param :keys, :array, default: []
|
37
|
-
config_param :read_from_head, :bool, default: false
|
38
|
+
config_param :read_from_head, :bool, default: false, deprecated: "Use `read_existing_events' instead."
|
39
|
+
config_param :read_existing_events, :bool, default: false
|
38
40
|
config_param :parse_description, :bool, default: false
|
39
41
|
config_param :render_as_xml, :bool, default: true
|
40
42
|
config_param :rate_limit, :integer, default: Winevt::EventLog::Subscribe::RATE_INFINITE
|
41
43
|
|
44
|
+
config_section :subscribe, param_name: :subscribe_configs, required: false, multi: true do
|
45
|
+
config_param :channels, :array
|
46
|
+
config_param :read_existing_events, :bool, default: false
|
47
|
+
end
|
48
|
+
|
42
49
|
config_section :storage do
|
43
50
|
config_set_default :usage, "bookmarks"
|
44
51
|
config_set_default :@type, DEFAULT_STORAGE_TYPE
|
@@ -58,7 +65,22 @@ module Fluent::Plugin
|
|
58
65
|
|
59
66
|
def configure(conf)
|
60
67
|
super
|
61
|
-
@chs =
|
68
|
+
@chs = []
|
69
|
+
|
70
|
+
@read_existing_events = @read_from_head || @read_existing_events
|
71
|
+
if @channels.empty? && @subscribe_configs.empty?
|
72
|
+
@chs.push(['application', @read_existing_events])
|
73
|
+
else
|
74
|
+
@channels.map {|ch| ch.strip.downcase }.uniq.each do |uch|
|
75
|
+
@chs.push([uch, @read_existing_events])
|
76
|
+
end
|
77
|
+
@subscribe_configs.each do |subscribe|
|
78
|
+
subscribe.channels.map {|ch| ch.strip.downcase }.uniq.each do |uch|
|
79
|
+
@chs.push([uch, subscribe.read_existing_events])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
@chs.uniq!
|
62
84
|
@keynames = @keys.map {|k| k.strip }.uniq
|
63
85
|
if @keynames.empty?
|
64
86
|
@keynames = KEY_MAP.keys
|
@@ -67,7 +89,6 @@ module Fluent::Plugin
|
|
67
89
|
@keynames.delete('EventData') if @parse_description
|
68
90
|
|
69
91
|
@tag = tag
|
70
|
-
@tailing = @read_from_head ? false : true
|
71
92
|
@bookmarks_storage = storage_create(usage: "bookmarks")
|
72
93
|
@winevt_xml = false
|
73
94
|
if @render_as_xml
|
@@ -86,30 +107,48 @@ module Fluent::Plugin
|
|
86
107
|
def start
|
87
108
|
super
|
88
109
|
|
89
|
-
@chs.each do |ch|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
subscribe.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
110
|
+
@chs.each do |ch, read_existing_events|
|
111
|
+
subscribe_channel(ch, read_existing_events)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def subscribe_channel(ch, read_existing_events)
|
116
|
+
bookmarkXml = @bookmarks_storage.get(ch) || ""
|
117
|
+
bookmark = nil
|
118
|
+
if bookmark_validator(bookmarkXml, ch)
|
119
|
+
bookmark = Winevt::EventLog::Bookmark.new(bookmarkXml)
|
120
|
+
end
|
121
|
+
subscribe = Winevt::EventLog::Subscribe.new
|
122
|
+
subscribe.read_existing_events = read_existing_events
|
123
|
+
begin
|
124
|
+
subscribe.subscribe(ch, "*", bookmark)
|
125
|
+
rescue Winevt::EventLog::Query::Error => e
|
126
|
+
raise Fluent::ConfigError, "Invalid Bookmark XML is loaded. #{e}"
|
127
|
+
end
|
128
|
+
subscribe.render_as_xml = @render_as_xml
|
129
|
+
subscribe.rate_limit = @rate_limit
|
130
|
+
timer_execute("in_windows_eventlog_#{escape_channel(ch)}".to_sym, @read_interval) do
|
131
|
+
on_notify(ch, subscribe)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def bookmark_validator(bookmarkXml, channel)
|
136
|
+
return false if bookmarkXml.empty?
|
137
|
+
|
138
|
+
evtxml = WinevtBookmarkDocument.new
|
139
|
+
parser = Nokogiri::XML::SAX::Parser.new(evtxml)
|
140
|
+
parser.parse(bookmarkXml)
|
141
|
+
result = evtxml.result
|
142
|
+
if !result.empty? && (result[:channel].downcase == channel.downcase) && result[:is_current]
|
143
|
+
true
|
144
|
+
else
|
145
|
+
log.warn "This stored bookmark is incomplete for using. Referring `read_existing_events` parameter to subscribe: #{bookmarkXml}, channel: #{channel}"
|
146
|
+
false
|
108
147
|
end
|
109
148
|
end
|
110
149
|
|
111
150
|
def escape_channel(ch)
|
112
|
-
ch.gsub(/[^a-zA-Z0-9]/, '_')
|
151
|
+
ch.gsub(/[^a-zA-Z0-9\s]/, '_')
|
113
152
|
end
|
114
153
|
|
115
154
|
def on_notify(ch, subscribe)
|
@@ -209,6 +248,7 @@ module Fluent::Plugin
|
|
209
248
|
else
|
210
249
|
r.split(NONE_FIELD_DELIMITER)
|
211
250
|
end
|
251
|
+
key = "" if key.nil?
|
212
252
|
key.chop! # remove ':' from key
|
213
253
|
if value.nil?
|
214
254
|
parent_key = to_key(key)
|
@@ -217,7 +257,7 @@ module Fluent::Plugin
|
|
217
257
|
value.strip!
|
218
258
|
# merge empty key values into the previous non-empty key record.
|
219
259
|
if key.empty?
|
220
|
-
record[previous_key] = [record[previous_key], value].flatten
|
260
|
+
record[previous_key] = [record[previous_key], value].flatten.reject {|e| e.nil?}
|
221
261
|
elsif parent_key.nil?
|
222
262
|
record[to_key(key)] = value
|
223
263
|
else
|
@@ -0,0 +1,27 @@
|
|
1
|
+
A new external device was recognized by the system.
|
2
|
+
|
3
|
+
Subject:
|
4
|
+
Security ID: SYSTEM
|
5
|
+
Account Name: IIZHU2016$
|
6
|
+
Account Domain: ITSS
|
7
|
+
Logon ID: 0x3E7
|
8
|
+
|
9
|
+
Device ID: SWD\PRINTENUM\{60FA1C6A-1AB2-440A-AEE1-62ABFB9A4650}
|
10
|
+
|
11
|
+
Device Name: Microsoft Print to PDF
|
12
|
+
|
13
|
+
Class ID: {1ed2bbf9-11f0-4084-b21f-ad83a8e6dcdc}
|
14
|
+
|
15
|
+
Class Name: PrintQueue
|
16
|
+
|
17
|
+
Vendor IDs:
|
18
|
+
PRINTENUM\{084f01fa-e634-4d77-83ee-074817c03581}
|
19
|
+
PRINTENUM\LocalPrintQueue
|
20
|
+
{084f01fa-e634-4d77-83ee-074817c03581}
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
Compatible IDs:
|
25
|
+
GenPrintQueue
|
26
|
+
SWD\GenericRaw
|
27
|
+
SWD\Generic
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
|
3
|
+
class BookmarkSAXParserTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@evtxml = WinevtBookmarkDocument.new
|
7
|
+
@parser = Nokogiri::XML::SAX::Parser.new(@evtxml)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_parse
|
11
|
+
bookmark_str = <<EOS
|
12
|
+
<BookmarkList>
|
13
|
+
<Bookmark Channel='Application' RecordId='161332' IsCurrent='true'/>
|
14
|
+
</BookmarkList>
|
15
|
+
EOS
|
16
|
+
@parser.parse(bookmark_str)
|
17
|
+
expected = {channel: "Application", record_id: 161332, is_current: true}
|
18
|
+
assert_equal expected, @evtxml.result
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_parse_2
|
22
|
+
bookmark_str = <<EOS
|
23
|
+
<BookmarkList>
|
24
|
+
<Bookmark Channel='Security' RecordId='25464' IsCurrent='true'/>
|
25
|
+
</BookmarkList>
|
26
|
+
EOS
|
27
|
+
@parser.parse(bookmark_str)
|
28
|
+
expected = {channel: "Security", record_id: 25464, is_current: true}
|
29
|
+
assert_equal expected, @evtxml.result
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_parse_empty_bookmark_list
|
33
|
+
bookmark_str = <<EOS
|
34
|
+
<BookmarkList>
|
35
|
+
</BookmarkList>
|
36
|
+
EOS
|
37
|
+
@parser.parse(bookmark_str)
|
38
|
+
expected = {}
|
39
|
+
assert_equal expected, @evtxml.result
|
40
|
+
end
|
41
|
+
end
|
@@ -23,11 +23,84 @@ class WindowsEventLog2InputTest < Test::Unit::TestCase
|
|
23
23
|
d = create_driver CONFIG
|
24
24
|
assert_equal 'fluent.eventlog', d.instance.tag
|
25
25
|
assert_equal 2, d.instance.read_interval
|
26
|
-
assert_equal [
|
27
|
-
assert_false d.instance.
|
26
|
+
assert_equal [], d.instance.channels
|
27
|
+
assert_false d.instance.read_existing_events
|
28
28
|
assert_true d.instance.render_as_xml
|
29
29
|
end
|
30
30
|
|
31
|
+
sub_test_case "configure" do
|
32
|
+
test "subscribe directive" do
|
33
|
+
d = create_driver config_element("ROOT", "", {"tag" => "fluent.eventlog"}, [
|
34
|
+
config_element("storage", "", {
|
35
|
+
'@type' => 'local',
|
36
|
+
'persistent' => false
|
37
|
+
}),
|
38
|
+
config_element("subscribe", "", {
|
39
|
+
'channels' => ['System', 'Windows PowerShell'],
|
40
|
+
}),
|
41
|
+
config_element("subscribe", "", {
|
42
|
+
'channels' => ['Security'],
|
43
|
+
'read_existing_events' => true
|
44
|
+
}),
|
45
|
+
])
|
46
|
+
expected = [["system", false], ["windows powershell", false], ["security", true]]
|
47
|
+
assert_equal expected, d.instance.instance_variable_get(:@chs)
|
48
|
+
end
|
49
|
+
|
50
|
+
test "duplicated subscribe" do
|
51
|
+
d = create_driver config_element("ROOT", "", {"tag" => "fluent.eventlog",
|
52
|
+
"channels" => ["System", "Windows PowerShell"]
|
53
|
+
}, [
|
54
|
+
config_element("storage", "", {
|
55
|
+
'@type' => 'local',
|
56
|
+
'persistent' => false
|
57
|
+
}),
|
58
|
+
config_element("subscribe", "", {
|
59
|
+
'channels' => ['System', 'Windows PowerShell'],
|
60
|
+
}),
|
61
|
+
config_element("subscribe", "", {
|
62
|
+
'channels' => ['Security'],
|
63
|
+
'read_existing_events' => true
|
64
|
+
}),
|
65
|
+
])
|
66
|
+
expected = [["system", false], ["windows powershell", false], ["security", true]]
|
67
|
+
assert_equal 1, d.instance.instance_variable_get(:@chs).select {|ch, flag| ch == "system"}.size
|
68
|
+
assert_equal expected, d.instance.instance_variable_get(:@chs)
|
69
|
+
end
|
70
|
+
|
71
|
+
test "non duplicated subscribe" do
|
72
|
+
d = create_driver config_element("ROOT", "", {"tag" => "fluent.eventlog",
|
73
|
+
"channels" => ["System", "Windows PowerShell"]
|
74
|
+
}, [
|
75
|
+
config_element("storage", "", {
|
76
|
+
'@type' => 'local',
|
77
|
+
'persistent' => false
|
78
|
+
}),
|
79
|
+
config_element("subscribe", "", {
|
80
|
+
'channels' => ['System', 'Windows PowerShell'],
|
81
|
+
'read_existing_events' => true
|
82
|
+
}),
|
83
|
+
config_element("subscribe", "", {
|
84
|
+
'channels' => ['Security'],
|
85
|
+
'read_existing_events' => true
|
86
|
+
}),
|
87
|
+
])
|
88
|
+
expected = [["system", false], ["windows powershell", false], ["system", true], ["windows powershell", true], ["security", true]]
|
89
|
+
assert_equal 2, d.instance.instance_variable_get(:@chs).select {|ch, flag| ch == "system"}.size
|
90
|
+
assert_equal expected, d.instance.instance_variable_get(:@chs)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
data("application" => ["Application", "Application"],
|
95
|
+
"windows powershell" => ["Windows PowerShell", "Windows PowerShell"],
|
96
|
+
"escaped" => ["Should_Be_Escaped_", "Should+Be;Escaped/"]
|
97
|
+
)
|
98
|
+
def test_escape_channel(data)
|
99
|
+
expected, actual = data
|
100
|
+
d = create_driver CONFIG
|
101
|
+
assert_equal expected, d.instance.escape_channel(actual)
|
102
|
+
end
|
103
|
+
|
31
104
|
def test_parse_desc
|
32
105
|
d = create_driver
|
33
106
|
desc =<<-DESC
|
@@ -80,6 +153,31 @@ DESC
|
|
80
153
|
assert_equal(expected, h)
|
81
154
|
end
|
82
155
|
|
156
|
+
test "A new external device was recognized by the system." do
|
157
|
+
# using the event log example: eventopedia.cloudapp.net/EventDetails.aspx?id=17ef124e-eb89-4c01-9ba2-d761e06b2b68
|
158
|
+
d = create_driver
|
159
|
+
desc = nil
|
160
|
+
File.open('./test/data/eventid_6416', 'r') do |f|
|
161
|
+
desc = f.read.gsub(/\R/, "\r\n")
|
162
|
+
end
|
163
|
+
h = {"Description" => desc}
|
164
|
+
expected = {"DescriptionTitle" => "A new external device was recognized by the system.",
|
165
|
+
"class_id" => "{1ed2bbf9-11f0-4084-b21f-ad83a8e6dcdc}",
|
166
|
+
"class_name" => "PrintQueue",
|
167
|
+
"compatible_ids" => ["GenPrintQueue", "SWD\\GenericRaw", "SWD\\Generic"],
|
168
|
+
"device_id" => "SWD\\PRINTENUM\\{60FA1C6A-1AB2-440A-AEE1-62ABFB9A4650}",
|
169
|
+
"device_name" => "Microsoft Print to PDF",
|
170
|
+
"subject.account_domain" => "ITSS",
|
171
|
+
"subject.account_name" => "IIZHU2016$",
|
172
|
+
"subject.logon_id" => "0x3E7",
|
173
|
+
"subject.security_id" => "SYSTEM",
|
174
|
+
"vendor_ids" => ["PRINTENUM\\{084f01fa-e634-4d77-83ee-074817c03581}",
|
175
|
+
"PRINTENUM\\LocalPrintQueue",
|
176
|
+
"{084f01fa-e634-4d77-83ee-074817c03581}"]}
|
177
|
+
d.instance.parse_desc(h)
|
178
|
+
assert_equal(expected, h)
|
179
|
+
end
|
180
|
+
|
83
181
|
def test_write
|
84
182
|
d = create_driver
|
85
183
|
|
@@ -163,6 +261,7 @@ DESC
|
|
163
261
|
config_element("storage", "", {
|
164
262
|
'@type' => 'local',
|
165
263
|
'@id' => 'test-02',
|
264
|
+
'@log_level' => "info",
|
166
265
|
'path' => File.join(TEST_PLUGIN_STORAGE_PATH,
|
167
266
|
'json', 'test-02.json'),
|
168
267
|
'persistent' => true,
|
@@ -226,6 +325,21 @@ EOS
|
|
226
325
|
assert_raise(Fluent::ConfigError) do
|
227
326
|
d2.instance.start
|
228
327
|
end
|
328
|
+
assert_equal 0, d2.logs.grep(/This stored bookmark is incomplete for using. Referring `read_existing_events` parameter to subscribe:/).length
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_start_with_empty_bookmark
|
332
|
+
invalid_storage_contents = <<-EOS
|
333
|
+
<BookmarkList>\r\n</BookmarkList>
|
334
|
+
EOS
|
335
|
+
d = create_driver(CONFIG2)
|
336
|
+
storage = d.instance.instance_variable_get(:@bookmarks_storage)
|
337
|
+
storage.put('application', invalid_storage_contents)
|
338
|
+
assert File.exist?(File.join(TEST_PLUGIN_STORAGE_PATH, 'json', 'test-02.json'))
|
339
|
+
|
340
|
+
d2 = create_driver(CONFIG2)
|
341
|
+
d2.instance.start
|
342
|
+
assert_equal 1, d2.logs.grep(/This stored bookmark is incomplete for using. Referring `read_existing_events` parameter to subscribe:/).length
|
229
343
|
end
|
230
344
|
end
|
231
345
|
|
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.
|
4
|
+
version: 0.5.1
|
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:
|
13
|
+
date: 2020-02-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -94,14 +94,14 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.7.0
|
98
98
|
type: :runtime
|
99
99
|
prerelease: false
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
104
|
+
version: 0.7.0
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: nokogiri
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,10 +147,13 @@ files:
|
|
147
147
|
- Rakefile
|
148
148
|
- appveyor.yml
|
149
149
|
- fluent-plugin-winevtlog.gemspec
|
150
|
+
- lib/fluent/plugin/bookmark_sax_parser.rb
|
150
151
|
- lib/fluent/plugin/in_windows_eventlog.rb
|
151
152
|
- lib/fluent/plugin/in_windows_eventlog2.rb
|
153
|
+
- test/data/eventid_6416
|
152
154
|
- test/generate-windows-event.rb
|
153
155
|
- test/helper.rb
|
156
|
+
- test/plugin/test_bookmark_sax_parser.rb
|
154
157
|
- test/plugin/test_in_windows_eventlog2.rb
|
155
158
|
- test/plugin/test_in_winevtlog.rb
|
156
159
|
homepage: https://github.com/fluent/fluent-plugin-windows-eventlog
|
@@ -173,12 +176,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
176
|
version: '0'
|
174
177
|
requirements: []
|
175
178
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.7.
|
179
|
+
rubygems_version: 2.7.6.2
|
177
180
|
signing_key:
|
178
181
|
specification_version: 4
|
179
182
|
summary: Fluentd Input plugin to read windows event log.
|
180
183
|
test_files:
|
184
|
+
- test/data/eventid_6416
|
181
185
|
- test/generate-windows-event.rb
|
182
186
|
- test/helper.rb
|
187
|
+
- test/plugin/test_bookmark_sax_parser.rb
|
183
188
|
- test/plugin/test_in_windows_eventlog2.rb
|
184
189
|
- test/plugin/test_in_winevtlog.rb
|