fix: Avoid issues with custom objects

- Custom objects type is dict, which makes it fail
  when the attribute 'id' is called
master
chrisr3d 2019-06-27 17:19:05 +02:00
parent a6fa3ff1d7
commit 6aff018695
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
2 changed files with 2 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class Bundle(_STIXBase):
def get_obj(self, obj_uuid): def get_obj(self, obj_uuid):
if "objects" in self._inner: if "objects" in self._inner:
found_objs = [elem for elem in self.objects if elem.id == obj_uuid] found_objs = [elem for elem in self.objects if elem['id'] == obj_uuid]
if found_objs == []: if found_objs == []:
raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid) raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid)
return found_objs return found_objs

View File

@ -36,7 +36,7 @@ class Bundle(_STIXBase):
def get_obj(self, obj_uuid): def get_obj(self, obj_uuid):
if "objects" in self._inner: if "objects" in self._inner:
found_objs = [elem for elem in self.objects if elem.id == obj_uuid] found_objs = [elem for elem in self.objects if elem['id'] == obj_uuid]
if found_objs == []: if found_objs == []:
raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid) raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid)
return found_objs return found_objs