From 4c60ed7e95557cc2c82bdcf0d6a064a72e42e413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 22 Jan 2019 11:07:06 +0100 Subject: [PATCH] fix: Don't modify event passed to the add_attribute methods fix #321 --- pymisp/api.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index a0fe15b..7fc6292 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -307,7 +307,7 @@ class PyMISP(object): :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) 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))): event_id = event else: - e = MISPEvent(describe_types=self.describe_types) - e.load(event) - if hasattr(e, 'id'): - event_id = e.id - elif hasattr(e, 'uuid'): - event_id = e.uuid + if 'Event' in event: + e = event['Event'] + if 'id' in e: + event_id = e['id'] + elif 'uuid' in e: + event_id = e['uuid'] return event_id def add_named_attribute(self, event, type_value, value, category=None, to_ids=False, comment=None, distribution=None, proposal=False, **kwargs):