Skip to content

Commit

Permalink
Merge pull request #652 from JakubOnderka/fix-json
Browse files Browse the repository at this point in the history
chg: [server] Cache module list JSON
  • Loading branch information
JakubOnderka authored Jan 9, 2024
2 parents 66c0cec + 8663db0 commit b5b9d8d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions misp_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit b5b9d8d

Please sign in to comment.