Skip to content

Commit d3c314d

Browse files
authored
Improved normalization of EventLog paths #4890 (#4894)
1 parent f24124b commit d3c314d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

plaso/helpers/windows/eventlog_providers.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def _GetNormalizedPath(self, path):
3333
path_segments = ['%SystemRoot%', 'System32']
3434

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

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

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

5050
path_segments.append(filename)

tests/helpers/windows/eventlog_providers.py

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def testGetNormalizedPath(self):
6767
self.assertEqual(normalized_path, (
6868
'%SystemRoot%\\immersivecontrolpanel\\systemsettings.exe'))
6969

70+
normalized_path = test_helper._GetNormalizedPath('\\eventlogmessages.dll')
71+
self.assertEqual(normalized_path, '\\eventlogmessages.dll')
72+
7073
# TODO: add tests for Merge
7174
# TODO: add tests for NormalizeMessageFiles
7275

0 commit comments

Comments
 (0)