From 7ece6b7fbcc2be9e645f52acd804abd63689410f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Sat, 28 Oct 2017 17:09:11 -0400 Subject: [PATCH] fix: Properly set the distribution at event level fix #120 --- pymisp/api.py | 2 +- pymisp/mispevent.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index fde42d8..0069153 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -265,7 +265,7 @@ class PyMISP(object): misp_event.publish() return misp_event - def _prepare_full_attribute(self, category, type_value, value, to_ids, comment=None, distribution=5, **kwargs): + def _prepare_full_attribute(self, category, type_value, value, to_ids, comment=None, distribution=None, **kwargs): """Initialize a new MISPAttribute from scratch""" misp_attribute = MISPAttribute(self.describe_types) misp_attribute.set_all_values(type=type_value, value=value, category=category, diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 3f99d7a..130d905 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -428,8 +428,9 @@ class MISPEvent(AbstractMISP): raise NewAttributeError('The info field of the new event is required.') # Default values for a valid event to send to a MISP instance - if kwargs.get('distribution') is not None: - self.distribution = int(kwargs.pop('distribution')) + self.distribution = kwargs.pop('distribution', None) + if self.distribution is not None: + self.distribution = int(self.distribution) if self.distribution not in [0, 1, 2, 3, 4]: raise NewAttributeError('{} is invalid, the distribution has to be in 0, 1, 2, 3, 4'.format(self.distribution))