Skip to content

Commit 8261dec

Browse files
committed
in_windows_eventlog2: fix parser to handle both tab and space delimiters
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent 0603846 commit 8261dec

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/fluent/plugin/in_windows_eventlog2.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def parse_desc(record)
417417
r.split(NONE_FIELD_DELIMITER)
418418
end
419419
key = "" if key.nil?
420+
key.strip! # parsed key sometimes contain unexpected " ". So remove it.
420421
key.chop! # remove ':' from key
421422
if value.nil?
422423
parent_key = to_key(key)

test/data/eventid_4697

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
A service was installed in the system.
2+
3+
Subject:
4+
Security ID: SYSTEM
5+
Account Name: 824ZWL3$
6+
Account Domain: WORKGROUP
7+
Logon ID: 0x3E7
8+
9+
Service Information:
10+
Service Name: WpnUserService_a46b7
11+
Service File Name: C:\WINDOWS\system32\svchost.exe -k UnistackSvcGroup
12+
Service Type: 0xE0
13+
Service Start Type: 2
14+
Service Account: LocalSystem

test/plugin/test_in_windows_eventlog2.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,27 @@ def test_parse_privileges_description
325325
assert_equal(expected, h)
326326
end
327327

328+
test "A service was installed in the system." do
329+
d = create_driver
330+
desc = nil
331+
File.open('./test/data/eventid_4697', 'r') do |f|
332+
desc = f.read.gsub(/\R/, "\r\n")
333+
end
334+
h = {"Description" => desc}
335+
expected = {"DescriptionTitle" => "A service was installed in the system.",
336+
"service_information.service_account" => "LocalSystem",
337+
"service_information.service_file_name" => "C:\\WINDOWS\\system32\\svchost.exe -k UnistackSvcGroup",
338+
"service_information.service_name" => "WpnUserService_a46b7",
339+
"service_information.service_start_type" => "2",
340+
"service_information.service_type" => "0xE0",
341+
"subject.account_domain" => "WORKGROUP",
342+
"subject.account_name" => "824ZWL3$",
343+
"subject.logon_id" => "0x3E7",
344+
"subject.security_id" => "SYSTEM"}
345+
d.instance.parse_desc(h)
346+
assert_equal(expected, h)
347+
end
348+
328349
def test_write
329350
d = create_driver XML_RENDERING_CONFIG
330351

0 commit comments

Comments
 (0)