fix: Don't modify event passed to the add_attribute methods

fix #321
pull/325/head
Raphaël Vinot 2019-01-22 11:07:06 +01:00
parent d4934cdf5f
commit 4c60ed7e95
1 changed files with 7 additions and 7 deletions

View File

@ -307,7 +307,7 @@ class PyMISP(object):
:param uuid: an uuid :param uuid: an uuid
""" """
regex = re.compile('^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I) regex = re.compile(r'^[a-f0-9]{8}-?[a-f0-9]{4}-?4[a-f0-9]{3}-?[89ab][a-f0-9]{3}-?[a-f0-9]{12}\Z', re.I)
match = regex.match(uuid) match = regex.match(uuid)
return bool(match) return bool(match)
@ -596,12 +596,12 @@ class PyMISP(object):
elif isinstance(event, int) or (isinstance(event, str) and (event.isdigit() or self._valid_uuid(event))): elif isinstance(event, int) or (isinstance(event, str) and (event.isdigit() or self._valid_uuid(event))):
event_id = event event_id = event
else: else:
e = MISPEvent(describe_types=self.describe_types) if 'Event' in event:
e.load(event) e = event['Event']
if hasattr(e, 'id'): if 'id' in e:
event_id = e.id event_id = e['id']
elif hasattr(e, 'uuid'): elif 'uuid' in e:
event_id = e.uuid event_id = e['uuid']
return event_id return event_id
def add_named_attribute(self, event, type_value, value, category=None, to_ids=False, comment=None, distribution=None, proposal=False, **kwargs): def add_named_attribute(self, event, type_value, value, category=None, to_ids=False, comment=None, distribution=None, proposal=False, **kwargs):