mirror of https://github.com/MISP/PyMISP
parent
8013e90e40
commit
0ff2120511
|
|
@ -785,6 +785,7 @@ class MISPObject(AbstractMISP):
|
||||||
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.Attribute = []
|
self.Attribute = []
|
||||||
|
self.Tag = []
|
||||||
self._default_attributes_parameters = default_attributes_parameters
|
self._default_attributes_parameters = default_attributes_parameters
|
||||||
if self._default_attributes_parameters:
|
if self._default_attributes_parameters:
|
||||||
# Let's clean that up
|
# Let's clean that up
|
||||||
|
|
@ -837,6 +838,9 @@ class MISPObject(AbstractMISP):
|
||||||
if kwargs.get('ObjectReference'):
|
if kwargs.get('ObjectReference'):
|
||||||
for r in kwargs.pop('ObjectReference'):
|
for r in kwargs.pop('ObjectReference'):
|
||||||
self.add_reference(**r)
|
self.add_reference(**r)
|
||||||
|
if kwargs.get('Tag'):
|
||||||
|
for tag in kwargs.pop('Tag'):
|
||||||
|
self.add_tag(**tag)
|
||||||
|
|
||||||
super(MISPObject, self).from_dict(**kwargs)
|
super(MISPObject, self).from_dict(**kwargs)
|
||||||
|
|
||||||
|
|
@ -854,6 +858,12 @@ class MISPObject(AbstractMISP):
|
||||||
self.ObjectReference.append(reference)
|
self.ObjectReference.append(reference)
|
||||||
self.edited = True
|
self.edited = True
|
||||||
|
|
||||||
|
def add_tag(self, name, **kwargs):
|
||||||
|
tag = MISPTag()
|
||||||
|
tag.from_dict(name=name, **kwargs)
|
||||||
|
self.Tag.append(tag)
|
||||||
|
self.edited = True
|
||||||
|
|
||||||
def get_attributes_by_relation(self, object_relation):
|
def get_attributes_by_relation(self, object_relation):
|
||||||
'''Returns the list of attributes with the given object relation in the object'''
|
'''Returns the list of attributes with the given object relation in the object'''
|
||||||
return self.__fast_attribute_access.get(object_relation, [])
|
return self.__fast_attribute_access.get(object_relation, [])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue