From 6aff0186959d4836afb19f1f81bb5c9d7bc142dc Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Thu, 27 Jun 2019 17:19:05 +0200 Subject: [PATCH] fix: Avoid issues with custom objects - Custom objects type is dict, which makes it fail when the attribute 'id' is called --- stix2/v20/bundle.py | 2 +- stix2/v21/bundle.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stix2/v20/bundle.py b/stix2/v20/bundle.py index be419da..eff862a 100644 --- a/stix2/v20/bundle.py +++ b/stix2/v20/bundle.py @@ -38,7 +38,7 @@ class Bundle(_STIXBase): def get_obj(self, obj_uuid): 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 == []: raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid) return found_objs diff --git a/stix2/v21/bundle.py b/stix2/v21/bundle.py index 3ed6024..5e782e2 100644 --- a/stix2/v21/bundle.py +++ b/stix2/v21/bundle.py @@ -36,7 +36,7 @@ class Bundle(_STIXBase): def get_obj(self, obj_uuid): 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 == []: raise KeyError("'%s' does not match the id property of any of the bundle's objects" % obj_uuid) return found_objs