Skip to content

Commit 94970af

Browse files
tests: add test for hex64 value and issue 38
closes #38
1 parent 8d33711 commit 94970af

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

tests/data/issue_38.evtx

68 KB
Binary file not shown.

tests/data/readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ The source for security.evtx with md5 8fa20a376cb6745453bc51f906e0fcd0
77
The source for ae831beda7dfda43f4de0e18a1035f64/dns_log_malformed.evtx
88
was @stephensheridan, via Github issue #37 (https://github.com/williballenthin/python-evtx/issues/37).
99

10+
The source for d75c90e629f38c7b9e612905e02e2255 issue_38.evtx
11+
was @nbareil, via Github issue #38 (https://github.com/williballenthin/python-evtx/issues/38).
12+

tests/test_issue_38.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import os
2+
import pytest
3+
4+
import Evtx.Evtx as evtx
5+
6+
from fixtures import *
7+
8+
9+
10+
def one(iterable):
11+
'''
12+
fetch a single element from the given iterable.
13+
14+
Args:
15+
iterable (iterable): a sequence of things.
16+
17+
Returns:
18+
object: the first thing in the sequence.
19+
'''
20+
for i in iterable:
21+
return i
22+
23+
24+
def get_child(node, tag, ns="{http://schemas.microsoft.com/win/2004/08/events/event}"):
25+
return node.find("%s%s" % (ns, tag))
26+
27+
28+
def test_hex64_value(data_path):
29+
'''
30+
regression test demonstrating issue 38.
31+
32+
Args:
33+
data_path (str): the file system path of the test directory.
34+
'''
35+
with evtx.Evtx(os.path.join(data_path, 'issue_38.evtx')) as log:
36+
for chunk in log.chunks():
37+
record = one(chunk.records())
38+
event_data = get_child(record.lxml(), 'EventData')
39+
for data in event_data:
40+
if data.get('Name') != 'SubjectLogonId':
41+
continue
42+
43+
assert data.text == '0x000000000019d3af'
44+
45+
46+

0 commit comments

Comments
 (0)