From 85643da9ae78e7f2cca057880db5c58988e67fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 16 Aug 2019 11:44:32 +0200 Subject: [PATCH] fix: Fallback to propose attribute update. --- pymisp/aping.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pymisp/aping.py b/pymisp/aping.py index 3e882db..a101e19 100644 --- a/pymisp/aping.py +++ b/pymisp/aping.py @@ -403,12 +403,12 @@ class ExpandedPyMISP(PyMISP): attribute_id = self.__get_uuid_or_id_from_abstract_misp(attribute_id) updated_attribute = self._prepare_request('POST', f'attributes/edit/{attribute_id}', data=attribute) updated_attribute = self._check_response(updated_attribute, expect_json=True) - if ('errors' in updated_attribute and updated_attribute['errors'][0] == 403 - and updated_attribute['errors'][1]['message'] == 'Invalid attribute.'): - # FIXME: https://github.com/MISP/MISP/issues/4913 - # At this point, we assume the user tried to update an attribute on an event they don't own - # Re-try with a proposal - return self.update_attribute_proposal(attribute_id, attribute, pythonify) + if 'errors' in updated_attribute: + if (updated_attribute['errors'][0] == 403 + and updated_attribute['errors'][1]['message'] == 'You do not have permission to do that.'): + # At this point, we assume the user tried to update an attribute on an event they don't own + # Re-try with a proposal + return self.update_attribute_proposal(attribute_id, attribute, pythonify) if not (self.global_pythonify or pythonify) or 'errors' in updated_attribute: return updated_attribute a = MISPAttribute()