From 0e123af546b7de00f65ee65a4b72402c3d10dd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 2 Nov 2017 09:57:53 -0700 Subject: [PATCH] fix: Let load unknown object relations in known templates This isn't recommended, but happens very often. --- pymisp/mispevent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 098dd4f..20eeb49 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -721,7 +721,11 @@ class MISPObject(AbstractMISP): if value.get('value') is None: return None if self.__known_template: - attribute = MISPObjectAttribute(self.__definition['attributes'][object_relation]) + if self.__definition['attributes'].get(object_relation): + attribute = MISPObjectAttribute(self.__definition['attributes'][object_relation]) + else: + # Woopsie, this object_relation is unknown, no sane defaults for you. + attribute = MISPObjectAttribute({}) else: attribute = MISPObjectAttribute({}) attribute.from_dict(object_relation, **value)