mirror of https://github.com/MISP/PyMISP
fix: [add_attribute] Only create a proposal when needed
parent
f5cbb417c8
commit
1ae058acde
|
@ -307,6 +307,10 @@ class ExpandedPyMISP(PyMISP):
|
||||||
event_id = self.__get_uuid_or_id_from_abstract_misp(event)
|
event_id = self.__get_uuid_or_id_from_abstract_misp(event)
|
||||||
new_attribute = self._prepare_request('POST', f'attributes/add/{event_id}', data=attribute)
|
new_attribute = self._prepare_request('POST', f'attributes/add/{event_id}', data=attribute)
|
||||||
if new_attribute.status_code == 403:
|
if new_attribute.status_code == 403:
|
||||||
|
if new_attribute['message'] == 'Could not add Attribute':
|
||||||
|
# In that case, we have a duplicate (uuid or value), and need to return the error to the user
|
||||||
|
return new_attribute
|
||||||
|
# At this point, we assume the user tried to add an attribute on an event they don't own
|
||||||
# Re-try with a proposal
|
# Re-try with a proposal
|
||||||
return self.add_attribute_proposal(event_id, attribute, pythonify)
|
return self.add_attribute_proposal(event_id, attribute, pythonify)
|
||||||
new_attribute = self._check_response(new_attribute, expect_json=True)
|
new_attribute = self._check_response(new_attribute, expect_json=True)
|
||||||
|
|
Loading…
Reference in New Issue