mirror of https://github.com/MISP/PyMISP
fix: Properly set Tag to attributes within objects
parent
0ff2120511
commit
6b81e5ddba
|
@ -169,11 +169,8 @@ class MISPAttribute(AbstractMISP):
|
||||||
if kwargs.get('sharing_group_id'):
|
if kwargs.get('sharing_group_id'):
|
||||||
self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
|
self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
|
||||||
if kwargs.get('Tag'):
|
if kwargs.get('Tag'):
|
||||||
self.Tag = []
|
|
||||||
for tag in kwargs.pop('Tag'):
|
for tag in kwargs.pop('Tag'):
|
||||||
t = MISPTag()
|
self.add_tag(**tag)
|
||||||
t.from_dict(**tag)
|
|
||||||
self.Tag.append(t)
|
|
||||||
|
|
||||||
# If the user wants to disable correlation, let them. Defaults to False.
|
# If the user wants to disable correlation, let them. Defaults to False.
|
||||||
self.disable_correlation = kwargs.pop("disable_correlation", False)
|
self.disable_correlation = kwargs.pop("disable_correlation", False)
|
||||||
|
@ -419,11 +416,7 @@ class MISPEvent(AbstractMISP):
|
||||||
self.set_date(kwargs.pop('date'))
|
self.set_date(kwargs.pop('date'))
|
||||||
if kwargs.get('Attribute'):
|
if kwargs.get('Attribute'):
|
||||||
for a in kwargs.pop('Attribute'):
|
for a in kwargs.pop('Attribute'):
|
||||||
attribute = MISPAttribute()
|
self.add_attribute(**a)
|
||||||
attribute.from_dict(**a)
|
|
||||||
if not hasattr(self, 'Attribute'):
|
|
||||||
self.Attribute = []
|
|
||||||
self.Attribute.append(attribute)
|
|
||||||
|
|
||||||
# All other keys
|
# All other keys
|
||||||
if kwargs.get('id'):
|
if kwargs.get('id'):
|
||||||
|
@ -439,23 +432,16 @@ class MISPEvent(AbstractMISP):
|
||||||
if kwargs.get('sharing_group_id'):
|
if kwargs.get('sharing_group_id'):
|
||||||
self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
|
self.sharing_group_id = int(kwargs.pop('sharing_group_id'))
|
||||||
if kwargs.get('RelatedEvent'):
|
if kwargs.get('RelatedEvent'):
|
||||||
self.RelatedEvent = []
|
|
||||||
for rel_event in kwargs.pop('RelatedEvent'):
|
for rel_event in kwargs.pop('RelatedEvent'):
|
||||||
sub_event = MISPEvent()
|
sub_event = MISPEvent()
|
||||||
sub_event.load(rel_event)
|
sub_event.load(rel_event)
|
||||||
self.RelatedEvent.append(sub_event)
|
self.RelatedEvent.append(sub_event)
|
||||||
if kwargs.get('Tag'):
|
if kwargs.get('Tag'):
|
||||||
self.Tag = []
|
|
||||||
for tag in kwargs.pop('Tag'):
|
for tag in kwargs.pop('Tag'):
|
||||||
t = MISPTag()
|
self.add_tag(**tag)
|
||||||
t.from_dict(**tag)
|
|
||||||
self.Tag.append(t)
|
|
||||||
if kwargs.get('Object'):
|
if kwargs.get('Object'):
|
||||||
self.Object = []
|
|
||||||
for obj in kwargs.pop('Object'):
|
for obj in kwargs.pop('Object'):
|
||||||
tmp_object = MISPObject(obj['name'])
|
self.add_object(**obj)
|
||||||
tmp_object.from_dict(**obj)
|
|
||||||
self.Object.append(tmp_object)
|
|
||||||
|
|
||||||
super(MISPEvent, self).from_dict(**kwargs)
|
super(MISPEvent, self).from_dict(**kwargs)
|
||||||
|
|
||||||
|
@ -543,8 +529,6 @@ class MISPEvent(AbstractMISP):
|
||||||
else:
|
else:
|
||||||
attribute = MISPAttribute()
|
attribute = MISPAttribute()
|
||||||
attribute.from_dict(type=type, value=value, **kwargs)
|
attribute.from_dict(type=type, value=value, **kwargs)
|
||||||
if not hasattr(self, 'attributes'):
|
|
||||||
self.attributes = []
|
|
||||||
self.attributes.append(attribute)
|
self.attributes.append(attribute)
|
||||||
self.edited = True
|
self.edited = True
|
||||||
|
|
||||||
|
@ -784,6 +768,7 @@ class MISPObject(AbstractMISP):
|
||||||
pass
|
pass
|
||||||
self.uuid = str(uuid.uuid4())
|
self.uuid = str(uuid.uuid4())
|
||||||
self.__fast_attribute_access = {} # Hashtable object_relation: [attributes]
|
self.__fast_attribute_access = {} # Hashtable object_relation: [attributes]
|
||||||
|
self.ObjectReference = []
|
||||||
self.Attribute = []
|
self.Attribute = []
|
||||||
self.Tag = []
|
self.Tag = []
|
||||||
self._default_attributes_parameters = default_attributes_parameters
|
self._default_attributes_parameters = default_attributes_parameters
|
||||||
|
@ -805,7 +790,6 @@ class MISPObject(AbstractMISP):
|
||||||
else:
|
else:
|
||||||
self.distribution = 5 # Default to inherit
|
self.distribution = 5 # Default to inherit
|
||||||
self.sharing_group_id = None
|
self.sharing_group_id = None
|
||||||
self.ObjectReference = []
|
|
||||||
self._standalone = standalone
|
self._standalone = standalone
|
||||||
if self._standalone:
|
if self._standalone:
|
||||||
# Mark as non_jsonable because we need to add the references manually after the object(s) have been created
|
# Mark as non_jsonable because we need to add the references manually after the object(s) have been created
|
||||||
|
|
Loading…
Reference in New Issue