Merge branch 'main' of github.com:MISP/misp-modules into main

pull/496/head
Alexandre Dulaunoy 2021-04-12 08:31:25 +02:00
commit f33f96c98a
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 3 additions and 4 deletions

View File

@ -183,10 +183,9 @@ class QueryModule(tornado.web.RequestHandler):
executor = ThreadPoolExecutor(nb_threads)
@run_on_executor
def run_request(self, jsonpayload):
x = json.loads(jsonpayload)
def run_request(self, module, jsonpayload):
log.debug('MISP QueryModule request {0}'.format(jsonpayload))
response = mhandlers[x['module']].handler(q=jsonpayload)
response = mhandlers[module].handler(q=jsonpayload)
return json.dumps(response)
@tornado.gen.coroutine
@ -198,7 +197,7 @@ class QueryModule(tornado.web.RequestHandler):
timeout = datetime.timedelta(seconds=int(dict_payload.get('timeout')))
else:
timeout = datetime.timedelta(seconds=300)
response = yield tornado.gen.with_timeout(timeout, self.run_request(jsonpayload))
response = yield tornado.gen.with_timeout(timeout, self.run_request(dict_payload['module'], jsonpayload))
self.write(response)
except tornado.gen.TimeoutError:
log.warning('Timeout on {} '.format(dict_payload['module']))