mirror of https://github.com/MISP/PyMISP
chg: Make MISPObject standalone by default
standalone defaults to True in MISPObject.__init__, and is set to False when the object is added to an event.pull/595/head
parent
86f758e5b4
commit
67d2e47b3b
|
@ -342,7 +342,7 @@ class PyMISP:
|
|||
new_object = self._check_json_response(r)
|
||||
if not (self.global_pythonify or pythonify) or 'errors' in new_object:
|
||||
return new_object
|
||||
o = MISPObject(new_object['Object']['name'])
|
||||
o = MISPObject(new_object['Object']['name'], standalone=False)
|
||||
o.from_dict(**new_object)
|
||||
return o
|
||||
|
||||
|
@ -356,7 +356,7 @@ class PyMISP:
|
|||
updated_object = self._check_json_response(r)
|
||||
if not (self.global_pythonify or pythonify) or 'errors' in updated_object:
|
||||
return updated_object
|
||||
o = MISPObject(updated_object['Object']['name'])
|
||||
o = MISPObject(updated_object['Object']['name'], standalone=False)
|
||||
o.from_dict(**updated_object)
|
||||
return o
|
||||
|
||||
|
|
|
@ -603,7 +603,7 @@ class MISPObject(AbstractMISP):
|
|||
'sharing_group_id', 'comment', 'first_seen', 'last_seen',
|
||||
'deleted'}
|
||||
|
||||
def __init__(self, name: str, strict: bool=False, standalone: bool=False, default_attributes_parameters: dict={}, **kwargs):
|
||||
def __init__(self, name: str, strict: bool=False, standalone: bool=True, default_attributes_parameters: dict={}, **kwargs):
|
||||
''' Master class representing a generic MISP object
|
||||
:name: Name of the object
|
||||
|
||||
|
@ -1398,6 +1398,7 @@ class MISPEvent(AbstractMISP):
|
|||
misp_obj.from_dict(**kwargs)
|
||||
else:
|
||||
raise InvalidMISPObject("An object to add to an existing Event needs to be either a MISPObject, or a plain python dictionary")
|
||||
misp_obj.standalone = False
|
||||
self.Object.append(misp_obj)
|
||||
self.edited = True
|
||||
return misp_obj
|
||||
|
|
Loading…
Reference in New Issue