Skip to content

Commit

Permalink
Changes to handling message file resource paths log2timeline#4259
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Dec 31, 2023
1 parent 122f47c commit 13f7a99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions plaso/formatters/winevt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,23 @@ def FormatEventValues(self, output_mediator, event_values):
message_string_template = self._winevt_resources_helper.GetMessageString(
provider_identifier, source_name, message_identifier, event_version)
if message_string_template:
string_values = [
string or '' for string in event_values.get('strings', [])]
string_values = []
for string_value in event_values.get('strings', []):
if string_value is None:
string_value = ''

string_values.append(string_value)

try:
message_string = message_string_template.format(*string_values)
except (IndexError, TypeError) as exception:
provider_identifier = provider_identifier or ''
strings = ', '.join(string_values)
logger.error((
'Unable to format message: 0x{0:08x} of provider: {1:s} '
'template: "{2:s}" and strings: "{3:s}" with error: '
'{4!s}').format(
message_identifier, provider_identifier or '',
message_string_template, ', '.join(string_values), exception))
f'Unable to format message: 0x{message_identifier:08x} of '
f'provider: {provider_identifier:s} template: '
f'"{message_string_template:s}" and strings: "{strings:s}" '
f'with error: {exception!s}'))
# Unable to create the message string.
# TODO: consider returning the unformatted message string.

Expand Down
4 changes: 2 additions & 2 deletions plaso/output/winevt_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def _ReadWindowsEventLogMessageString(
if not message_file_identifiers:
logger.warning((
f'No message file for message: 0x{message_identifier:08x} '
f'(0x{original_message_identifier:08x}) '
f'(original: 0x{original_message_identifier:08x}) '
f'of provider: {lookup_key:s}'))
return None

Expand All @@ -615,7 +615,7 @@ def _ReadWindowsEventLogMessageString(
if not message_strings:
logger.warning((
f'No message string for message: 0x{message_identifier:08x} '
f'(0x{original_message_identifier:08x}) '
f'(original: 0x{original_message_identifier:08x}) '
f'of provider: {lookup_key:s}'))
return None

Expand Down

0 comments on commit 13f7a99

Please sign in to comment.