Allow to mark an attribute as deleted in a MISPEvent

Related to #33
pull/36/head
Raphaël Vinot 2017-01-02 16:53:23 +01:00
parent 0511bd4486
commit 585ca9cd08
1 changed files with 10 additions and 0 deletions

View File

@ -534,6 +534,16 @@ class MISPEvent(object):
def unpublish(self):
self.published = False
def delete_attribute(self, attribute_id):
found = False
for a in self.attributes:
if a.id == attribute_id or a.uuid == attribute_id:
a.deleted = True
found = True
break
if not found:
raise Exception('No attribute with UUID/ID {} found.'.format(attribute_id))
def add_attribute(self, type, value, **kwargs):
attribute = MISPAttribute(self.describe_types)
attribute.set_all_values(type=type, value=value, **kwargs)