From 1503508c162d935cc18b7a3eef5172dac264c39d Mon Sep 17 00:00:00 2001 From: user Date: Mon, 26 Mar 2018 17:37:02 +0200 Subject: [PATCH] Fix add_named_attribute regression, update add_named_attribute.py example --- examples/add_named_attribute.py | 7 +++---- pymisp/api.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/add_named_attribute.py b/examples/add_named_attribute.py index 43bb5db..ea56214 100755 --- a/examples/add_named_attribute.py +++ b/examples/add_named_attribute.py @@ -16,14 +16,13 @@ def init(url, key): return PyMISP(url, key, True, 'json', debug=True) if __name__ == '__main__': - parser = argparse.ArgumentParser(description='Create an event on MISP.') - parser.add_argument("-e", "--event", type=int, help="The id of the event to update.") + parser = argparse.ArgumentParser(description='Add an attribute to an event') + parser.add_argument("-e", "--event", help="The id, uuid or json of the event to update.") parser.add_argument("-t", "--type", help="The type of the added attribute") parser.add_argument("-v", "--value", help="The value of the attribute") args = parser.parse_args() misp = init(misp_url, misp_key) - event = misp.get_event(args.event) - event = misp.add_named_attribute(event, args.type, args.value) + event = misp.add_named_attribute(args.event, args.type, args.value) print(event) diff --git a/pymisp/api.py b/pymisp/api.py index 1062290..d7569f9 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -507,7 +507,7 @@ class PyMISP(object): event_id = event.id elif hasattr(event, 'uuid'): event_id = event.uuid - elif isinstance(event, int): + 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)