From 443acd9a47f24b0b4322b29f3dedd5060a7886ca Mon Sep 17 00:00:00 2001 From: Tobias Mainka Date: Fri, 16 Feb 2018 18:35:45 +0100 Subject: [PATCH] add attributes within objects as well, for tagging via value/id/uuid --- pymisp/mispevent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 5d96719..ca48814 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -569,13 +569,14 @@ class MISPEvent(AbstractMISP): :attribute_identifier: can be an ID, UUID, or the value. ''' attributes = [] - for a in self.attributes: + for a in self.attributes + [attribute for o in self.objects for attribute in o.attributes]: if ((hasattr(a, 'id') and a.id == attribute_identifier) or (hasattr(a, 'uuid') and a.uuid == attribute_identifier) or (hasattr(a, 'value') and attribute_identifier == a.value or attribute_identifier in a.value.split('|'))): a.add_tag(tag) attributes.append(a) + if not attributes: raise Exception('No attribute with identifier {} found.'.format(attribute_identifier)) self.edited = True