fix: Properly set the distribution at event level

fix #120
pull/141/head
Raphaël Vinot 2017-10-28 17:09:11 -04:00
parent ea327ceffb
commit 7ece6b7fbc
2 changed files with 4 additions and 3 deletions

View File

@ -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,

View File

@ -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))