Skip to content

Commit 3e41441

Browse files
author
Bryan Worrell
committed
Fixed lxml parser exception which occurs during from_dict() on openioc and maec extensions
1 parent 012f3a9 commit 3e41441

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stix/extensions/malware/maec_4_1_malware.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import stix.bindings.extensions.malware.maec_4_1 as ext_binding
55
from lxml import etree
66
from itertools import izip
7+
from StringIO import StringIO
78

89
# TODO: enable use of python-maec here
910

@@ -89,7 +90,7 @@ def from_dict(cls, d, return_obj=None):
8990
super(MAECInstance, cls).from_dict(d, return_obj)
9091
if 'maec' in d:
9192
parser = etree.ETCompatXMLParser(huge_tree=True)
92-
return_obj.maec = etree.parse(d['maec'], parser=parser)
93+
return_obj.maec = etree.parse(StringIO(d['maec']), parser=parser)
9394

9495
return return_obj
9596

stix/extensions/test_mechanism/open_ioc_2010_test_mechanism.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import stix.bindings.extensions.test_mechanism.open_ioc_2010 as open_ioc_tm_binding
99
from lxml import etree
1010
from itertools import izip
11+
from StringIO import StringIO
1112

1213
class OpenIOCTestMechanism(_BaseTestMechanism):
1314
_namespace = "http://stix.mitre.org/extensions/TestMechanism#OpenIOC2010-1"
@@ -92,7 +93,7 @@ def from_dict(cls, d, return_obj=None):
9293
super(OpenIOCTestMechanism, cls).from_dict(d, return_obj)
9394
if 'ioc' in d:
9495
parser = etree.ETCompatXMLParser(huge_tree=True)
95-
return_obj.ioc = etree.parse(d['ioc'], parser=parser)
96+
return_obj.ioc = etree.parse(StringIO(d['ioc']), parser=parser)
9697

9798
return return_obj
9899

0 commit comments

Comments
 (0)