Graceful handling of tagging when name attribute is missing

pull/877/head
Sura De Silva 2022-11-17 20:31:50 +11:00
parent 6748ad8a62
commit 0f79e760c6
1 changed files with 5 additions and 4 deletions

View File

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