From 8b34993480f32530324388a5ada8b52592468bd2 Mon Sep 17 00:00:00 2001 From: Christophe Vandeplas Date: Wed, 15 Jun 2022 07:18:18 +0200 Subject: [PATCH 1/2] fix: [feed] fixes bug when template_uuid does not exist --- pymisp/mispevent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 549a926..6964e0f 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -793,6 +793,9 @@ class MISPObject(AbstractMISP): def _to_feed(self, with_distribution=False) -> Dict: if with_distribution: self._fields_for_feed.add('distribution') + if not hasattr(self, 'template_uuid'): + # workaround for old events where the template_uuid was not yet mandatory + self.template_uuid = '11111111-1111-1111-aaaa-111111111111' to_return = super(MISPObject, self)._to_feed() if self.references: to_return['ObjectReference'] = [reference._to_feed() for reference in self.references] From 4ddabe75b5846df7d11b7e133dc40bf8bda7820d Mon Sep 17 00:00:00 2001 From: Christophe Vandeplas Date: Mon, 20 Jun 2022 14:18:49 +0200 Subject: [PATCH 2/2] fig: [feed] fixes bugs during export with old data --- pymisp/mispevent.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 6964e0f..bc073d0 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -793,9 +793,12 @@ class MISPObject(AbstractMISP): def _to_feed(self, with_distribution=False) -> Dict: if with_distribution: self._fields_for_feed.add('distribution') - if not hasattr(self, 'template_uuid'): - # workaround for old events where the template_uuid was not yet mandatory - self.template_uuid = '11111111-1111-1111-aaaa-111111111111' + if not hasattr(self, 'template_uuid'): # workaround for old events where the template_uuid was not yet mandatory + self.template_uuid = str(uuid.uuid5(uuid.UUID("9319371e-2504-4128-8410-3741cebbcfd3"), self.name)) + if not hasattr(self, 'description'): # workaround for old events where description is not always set + self.description='' + if not hasattr(self, 'meta-category'): # workaround for old events where meta-category is not always set + setattr(self, 'meta-category', 'misc') to_return = super(MISPObject, self)._to_feed() if self.references: to_return['ObjectReference'] = [reference._to_feed() for reference in self.references]