Merge pull request #652 from JakubOnderka/fix-json

chg: [server] Cache module list JSON
pull/653/head v2.4.184
Jakub Onderka 2024-01-09 13:19:42 +01:00 committed by GitHub
commit b5b9d8d408
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 9 deletions

View File

@ -174,17 +174,22 @@ class ListModules(tornado.web.RequestHandler):
global loaded_modules
global mhandlers
_cached_json = None
def get(self):
ret = []
for module_name in loaded_modules:
ret.append({
'name': module_name,
'type': mhandlers['type:' + module_name],
'mispattributes': mhandlers[module_name].introspection(),
'meta': mhandlers[module_name].version()
})
if not self._cached_json:
ret = []
for module_name in loaded_modules:
ret.append({
'name': module_name,
'type': mhandlers['type:' + module_name],
'mispattributes': mhandlers[module_name].introspection(),
'meta': mhandlers[module_name].version()
})
self._cached_json = json.dumps(ret)
log.debug('MISP ListModules request')
self.write(json.dumps(ret))
self.write(self._cached_json)
class QueryModule(tornado.web.RequestHandler):