Merge pull request #877 from dragsu/feat/exception-when-tag-without-name

Graceful handling of tagging when name attribute is missing
pull/898/head
Raphaël Vinot 2022-12-22 11:03:16 +01:00 committed by GitHub
commit 8da684aad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -3492,8 +3492,10 @@ class PyMISP:
""" """
uuid = get_uuid_or_id_from_abstract_misp(misp_entity) uuid = get_uuid_or_id_from_abstract_misp(misp_entity)
if isinstance(tag, MISPTag): if isinstance(tag, MISPTag):
tag = tag.name tag_name = tag.name if 'name' in tag else ""
to_post = {'uuid': uuid, 'tag': tag, 'local': local} else:
tag_name = tag
to_post = {'uuid': uuid, 'tag': tag_name, 'local': local}
response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post) response = self._prepare_request('POST', 'tags/attachTagToObject', data=to_post)
return self._check_json_response(response) return self._check_json_response(response)
@ -3505,8 +3507,7 @@ class PyMISP:
""" """
uuid = get_uuid_or_id_from_abstract_misp(misp_entity) uuid = get_uuid_or_id_from_abstract_misp(misp_entity)
if isinstance(tag, MISPTag): if isinstance(tag, MISPTag):
if 'name' in tag: tag_name = tag.name if 'name' in tag else ""
tag_name = tag.name
else: else:
tag_name = tag tag_name = tag
to_post = {'uuid': uuid, 'tag': tag_name} to_post = {'uuid': uuid, 'tag': tag_name}