fix: [main] Disable duplicate JSON decoding

pull/435/head
Jakub Onderka 2020-10-22 18:03:29 +02:00
parent 095fbfd75f
commit d0115e8b36
1 changed files with 3 additions and 4 deletions

View File

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