Skip to content

Commit be968bd

Browse files
committed
Created a draft of the test for this feature.
Signed-off-by: Blake Hensley <[email protected]>
1 parent 31bbaf0 commit be968bd

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ Fluentd Input plugin for the Windows Event Log using newer Windows Event Logging
8181
|`<storage>` | Setting for `storage` plugin for recording read position like `in_tail`'s `pos_file`.|
8282
|`<parse>` | Setting for `parser` plugin for parsing raw XML EventLog records. |
8383
|`parse_description`| (option) parse `description` field and set parsed result into the record. `Description` and `EventData` fields are removed|
84-
|`description_prefix_word_delimiter`| (option) Change the character placed between the parent_key and key. Set the value to "" for no delimiter. Defaults to `.` .|
85-
|`description_word_delimiter`| (option) Change the character placed between each word of the key. Set the value to "" for no delimiter. Defaults to `_` .|
86-
|`downcase_description_keys`| (option) Specify whether to downcase the keys that are parsed from the Description. Defaults to `true`.|
84+
|`description_key_delimiter`| (option) (Only applicable if parse_description is true) Change the character placed between the parent_key and key. Set the value to "" for no delimiter. Defaults to `.` .|
85+
|`description_word_delimiter`| (option) (Only applicable if parse_description is true) Change the character placed between each word of the key. Set the value to "" for no delimiter. Defaults to `_` .|
86+
|`downcase_description_keys`| (option) (Only applicable if parse_description is true) Specify whether to downcase the keys that are parsed from the Description. Defaults to `true`.|
8787
|`read_from_head` | **Deprecated** (option) Start to read the entries from the oldest, not from when fluentd is started. Defaults to `false`.|
8888
|`read_existing_events` | (option) Read the entries which already exist before fluentd is started. Defaults to `false`.|
8989
|`render_as_xml` | (option) Render Windows EventLog as XML or Ruby Hash object directly. Defaults to `false`.|

lib/fluent/plugin/in_windows_eventlog2.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def parse_desc(record)
392392
elsif parent_key.nil?
393393
record[to_key(key)] = value
394394
else
395-
k = "#{parent_key}#{@description_prefix_word_delimiter}#{to_key(key)}"
395+
k = "#{parent_key}#{@description_key_delimiter}#{to_key(key)}"
396396
record[k] = value
397397
end
398398
end

test/plugin/test_in_windows_eventlog2.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,36 @@ def test_parse_desc
226226
assert_equal(expected, h)
227227
end
228228

229+
def test_parse_desc_camelcase
230+
d = create_driver(config_element("ROOT", "", {"tag" => "fluent.eventlog",
231+
"parse_description" => true,
232+
"description_key_delimiter" => "",
233+
"description_word_delimiter" => "",
234+
"downcase_description_keys" => false
235+
}, [
236+
config_element("storage", "", {
237+
'@type' => 'local',
238+
'persistent' => false
239+
}),
240+
]))
241+
desc =<<-DESC
242+
A user's local group membership was enumerated.\r\n\r\nSubject:\r\n\tSecurity ID:\t\tS-X-Y-XX-WWWWWW-VVVV\r\n\tAccount Name:\t\tAdministrator\r\n\tAccount Domain:\t\tDESKTOP-FLUENTTEST\r\n\tLogon ID:\t\t0x3185B1\r\n\r\nUser:\r\n\tSecurity ID:\t\tS-X-Y-XX-WWWWWW-VVVV\r\n\tAccount Name:\t\tAdministrator\r\n\tAccount Domain:\t\tDESKTOP-FLUENTTEST\r\n\r\nProcess Information:\r\n\tProcess ID:\t\t0x50b8\r\n\tProcess Name:\t\tC:\\msys64\\usr\\bin\\make.exe
243+
DESC
244+
h = {"Description" => desc}
245+
expected = {"DescriptionTitle" => "A user's local group membership was enumerated.",
246+
"SubjectSecurityId" => "S-X-Y-XX-WWWWWW-VVVV",
247+
"SubjectAccountName" => "Administrator",
248+
"SubjectAccountDomain" => "DESKTOP-FLUENTTEST",
249+
"SubjectLogonId" => "0x3185B1",
250+
"UserSecurityId" => "S-X-Y-XX-WWWWWW-VVVV",
251+
"UserAccountName" => "Administrator",
252+
"UserAccountDomain" => "DESKTOP-FLUENTTEST",
253+
"ProcessInformationProcessId" => "0x50b8",
254+
"ProcessInformationProcessName" => "C:\\msys64\\usr\\bin\\make.exe"}
255+
d.instance.parse_desc(h)
256+
assert_equal(expected, h)
257+
end
258+
229259
def test_parse_privileges_description
230260
d = create_driver
231261
desc = ["Special privileges assigned to new logon.\r\n\r\nSubject:\r\n\tSecurity ID:\t\tS-X-Y-ZZ\r\n\t",

0 commit comments

Comments
 (0)