new: method to get the raw object template

pull/749/head
Raphaël Vinot 2021-05-11 12:30:00 -07:00
parent f8ebad547b
commit db1ffe7be6
2 changed files with 14 additions and 0 deletions

View File

@ -640,6 +640,13 @@ class PyMISP:
t.from_dict(**object_template_r)
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:
"""Trigger an update of the object templates"""
response = self._prepare_request('POST', 'objectTemplates/update')

View File

@ -1371,6 +1371,13 @@ class TestComprehensive(unittest.TestCase):
template = self.admin_misp_connector.get_object_template(object_template.uuid, pythonify=True)
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):
# Get list
tags = self.admin_misp_connector.tags(pythonify=True)