Add get_obj function to bundle.py to make accessing bundles easier
parent
67f6663e5e
commit
a61344a8aa
|
@ -183,6 +183,8 @@ def test_parse_bundle(version):
|
|||
assert bundle.objects[0].type == 'indicator'
|
||||
assert bundle.objects[1].type == 'malware'
|
||||
assert bundle.objects[2].type == 'relationship'
|
||||
assert bundle.get_obj('malware--00000000-0000-4000-8000-000000000003').type == 'malware'
|
||||
assert bundle.get_obj('blah blah') is None
|
||||
|
||||
|
||||
def test_parse_unknown_type():
|
||||
|
|
|
@ -33,3 +33,6 @@ class Bundle(_STIXBase):
|
|||
self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False)
|
||||
|
||||
super(Bundle, self).__init__(**kwargs)
|
||||
|
||||
def get_obj(self, obj_uuid):
|
||||
return next((elem for elem in self.objects if elem['id'] == obj_uuid), None)
|
||||
|
|
Loading…
Reference in New Issue