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)
|
new_object = self._check_json_response(r)
|
||||||
if not (self.global_pythonify or pythonify) or 'errors' in new_object:
|
if not (self.global_pythonify or pythonify) or 'errors' in new_object:
|
||||||
return new_object
|
return new_object
|
||||||
o = MISPObject(new_object['Object']['name'])
|
o = MISPObject(new_object['Object']['name'], standalone=False)
|
||||||
o.from_dict(**new_object)
|
o.from_dict(**new_object)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ class PyMISP:
|
||||||
updated_object = self._check_json_response(r)
|
updated_object = self._check_json_response(r)
|
||||||
if not (self.global_pythonify or pythonify) or 'errors' in updated_object:
|
if not (self.global_pythonify or pythonify) or 'errors' in updated_object:
|
||||||
return updated_object
|
return updated_object
|
||||||
o = MISPObject(updated_object['Object']['name'])
|
o = MISPObject(updated_object['Object']['name'], standalone=False)
|
||||||
o.from_dict(**updated_object)
|
o.from_dict(**updated_object)
|
||||||
return o
|
return o
|
||||||
|
|
||||||
|
|
|
@ -603,7 +603,7 @@ class MISPObject(AbstractMISP):
|
||||||
'sharing_group_id', 'comment', 'first_seen', 'last_seen',
|
'sharing_group_id', 'comment', 'first_seen', 'last_seen',
|
||||||
'deleted'}
|
'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
|
''' Master class representing a generic MISP object
|
||||||
:name: Name of the object
|
:name: Name of the object
|
||||||
|
|
||||||
|
@ -1398,6 +1398,7 @@ class MISPEvent(AbstractMISP):
|
||||||
misp_obj.from_dict(**kwargs)
|
misp_obj.from_dict(**kwargs)
|
||||||
else:
|
else:
|
||||||
raise InvalidMISPObject("An object to add to an existing Event needs to be either a MISPObject, or a plain python dictionary")
|
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.Object.append(misp_obj)
|
||||||
self.edited = True
|
self.edited = True
|
||||||
return misp_obj
|
return misp_obj
|
||||||
|
|
Loading…
Reference in New Issue