mirror of https://github.com/MISP/PyMISP
new: method to get the raw object template
parent
f8ebad547b
commit
db1ffe7be6
|
@ -640,6 +640,13 @@ class PyMISP:
|
||||||
t.from_dict(**object_template_r)
|
t.from_dict(**object_template_r)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
|
def get_raw_object_template(self, uuid_or_name: str) -> Dict:
|
||||||
|
"""Get a row template. It needs to be present on disk on the MISP instance you're connected to.
|
||||||
|
The response of this method can be passed to MISPObject(<name>, misp_objects_template_custom=<response>)
|
||||||
|
"""
|
||||||
|
r = self._prepare_request('GET', f'objectTemplates/getRaw/{uuid_or_name}')
|
||||||
|
return self._check_json_response(r)
|
||||||
|
|
||||||
def update_object_templates(self) -> Dict:
|
def update_object_templates(self) -> Dict:
|
||||||
"""Trigger an update of the object templates"""
|
"""Trigger an update of the object templates"""
|
||||||
response = self._prepare_request('POST', 'objectTemplates/update')
|
response = self._prepare_request('POST', 'objectTemplates/update')
|
||||||
|
|
|
@ -1371,6 +1371,13 @@ class TestComprehensive(unittest.TestCase):
|
||||||
template = self.admin_misp_connector.get_object_template(object_template.uuid, pythonify=True)
|
template = self.admin_misp_connector.get_object_template(object_template.uuid, pythonify=True)
|
||||||
self.assertEqual(template.name, 'file')
|
self.assertEqual(template.name, 'file')
|
||||||
|
|
||||||
|
raw_template = self.admin_misp_connector.get_raw_object_template('domain-ip')
|
||||||
|
raw_template['uuid'] = '4'
|
||||||
|
mo = MISPObject('domain-ip', misp_objects_template_custom=raw_template)
|
||||||
|
mo.add_attribute('ip', '8.8.8.8')
|
||||||
|
mo.add_attribute('domain', 'google.fr')
|
||||||
|
self.assertEqual(mo.template_uuid, '4')
|
||||||
|
|
||||||
def test_tags(self):
|
def test_tags(self):
|
||||||
# Get list
|
# Get list
|
||||||
tags = self.admin_misp_connector.tags(pythonify=True)
|
tags = self.admin_misp_connector.tags(pythonify=True)
|
||||||
|
|
Loading…
Reference in New Issue