fix: Add attribute dict as proposal

pull/665/head
Raphaël Vinot 2020-11-24 20:03:01 +01:00
parent 7b08cfcade
commit ded44278af
2 changed files with 2 additions and 2 deletions

View File

@ -600,7 +600,7 @@ class PyMISP:
and new_attribute['errors'][1]['message'] == 'You do not have permission to do that.'):
# At this point, we assume the user tried to add an attribute on an event they don't own
# Re-try with a proposal
if isinstance(attribute, MISPAttribute):
if isinstance(attribute, (MISPAttribute, dict)):
return self.add_attribute_proposal(event_id, attribute, pythonify)
if not (self.global_pythonify or pythonify) or 'errors' in new_attribute:
return new_attribute

View File

@ -1740,7 +1740,7 @@ class TestComprehensive(unittest.TestCase):
self.assertTrue(isinstance(attribute, MISPShadowAttribute), attribute)
# Test if add proposal without category works - https://github.com/MISP/MISP/issues/4868
attribute = self.user_misp_connector.add_attribute(second.id, {'type': 'ip-dst', 'value': '123.43.32.22'})
self.assertTrue(isinstance(attribute, MISPShadowAttribute))
self.assertTrue(isinstance(attribute, MISPShadowAttribute), attribute)
# Add attribute with the same value as an existing proposal
prop_attr.uuid = str(uuid4())
attribute = self.admin_misp_connector.add_attribute(second, prop_attr, pythonify=True)