mirror of https://github.com/MISP/PyMISP
chg: Some more code cleanup
parent
5286462361
commit
89a24d4923
|
@ -363,22 +363,22 @@ class ExpandedPyMISP(PyMISP):
|
||||||
if 'errors' in new_attribute:
|
if 'errors' in new_attribute:
|
||||||
to_return['errors'] = new_attribute['errors']
|
to_return['errors'] = new_attribute['errors']
|
||||||
|
|
||||||
for attribute in new_attribute['Attribute']:
|
for new_attr in new_attribute['Attribute']:
|
||||||
a = MISPAttribute()
|
a = MISPAttribute()
|
||||||
a.from_dict(**attribute)
|
a.from_dict(**attribute)
|
||||||
to_return['attributes'].append(a)
|
to_return['attributes'].append(a)
|
||||||
return to_return
|
return to_return
|
||||||
else:
|
|
||||||
if ('errors' in new_attribute and new_attribute['errors'][0] == 403
|
if ('errors' in new_attribute and new_attribute['errors'][0] == 403
|
||||||
and new_attribute['errors'][1]['message'] == 'You do not have permission to do that.'):
|
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
|
# 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)
|
||||||
if not (self.global_pythonify or pythonify) or 'errors' in new_attribute:
|
if not (self.global_pythonify or pythonify) or 'errors' in new_attribute:
|
||||||
return new_attribute
|
return new_attribute
|
||||||
a = MISPAttribute()
|
a = MISPAttribute()
|
||||||
a.from_dict(**new_attribute)
|
a.from_dict(**new_attribute)
|
||||||
return a
|
return a
|
||||||
|
|
||||||
def update_attribute(self, attribute: MISPAttribute, attribute_id: int=None, pythonify: bool=False):
|
def update_attribute(self, attribute: MISPAttribute, attribute_id: int=None, pythonify: bool=False):
|
||||||
'''Update an attribute on a MISP instance'''
|
'''Update an attribute on a MISP instance'''
|
||||||
|
|
Loading…
Reference in New Issue