Fix add_named_attribute regression, update add_named_attribute.py example

pull/212/head
user 2018-03-26 17:37:02 +02:00
parent 2963303404
commit 1503508c16
2 changed files with 4 additions and 5 deletions

View File

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

View File

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