Skip to content

Commit

Permalink
Improved normalization of EventLog paths #4890 (#4894)
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Jul 17, 2024
1 parent f24124b commit d3c314d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plaso/helpers/windows/eventlog_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def _GetNormalizedPath(self, path):
path_segments = ['%SystemRoot%', 'System32']

elif path_segments_lower[0] in ('system32', '$(runtime.system32)'):
# Note that the path can be relative so if it starts with "System32"
# asume this represents "%SystemRoot%\System32".
# Note that the path can be relative so if it starts with "System32"
# asume this represents "%SystemRoot%\System32".
path_segments = ['%SystemRoot%', 'System32'] + path_segments[1:]

elif path_segments_lower[0] in (
Expand All @@ -43,8 +43,8 @@ def _GetNormalizedPath(self, path):

# Check if path starts with "\SystemRoot\", "\Windows\" or "\WinNT\" for
# example: "\SystemRoot\system32\drivers\SerCx.sys"
elif not path_segments_lower[0] and path_segments_lower[1] in (
'systemroot', 'windows', 'winnt'):
elif (len(path_segments_lower) > 1 and not path_segments_lower[0] and
path_segments_lower[1] in ('systemroot', 'windows', 'winnt')):
path_segments = ['%SystemRoot%'] + path_segments[2:]

path_segments.append(filename)
Expand Down
3 changes: 3 additions & 0 deletions tests/helpers/windows/eventlog_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def testGetNormalizedPath(self):
self.assertEqual(normalized_path, (
'%SystemRoot%\\immersivecontrolpanel\\systemsettings.exe'))

normalized_path = test_helper._GetNormalizedPath('\\eventlogmessages.dll')
self.assertEqual(normalized_path, '\\eventlogmessages.dll')

# TODO: add tests for Merge
# TODO: add tests for NormalizeMessageFiles

Expand Down

0 comments on commit d3c314d

Please sign in to comment.