From 9446fd2ac643659d4c4681a544c95f836158e091 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 9 Jan 2024 12:19:23 +0100 Subject: [PATCH 1/3] chg: [server] Fail if server could not be started --- misp_modules/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misp_modules/__init__.py b/misp_modules/__init__.py index bdbd601f..cf9f00b6 100644 --- a/misp_modules/__init__.py +++ b/misp_modules/__init__.py @@ -303,6 +303,9 @@ def main(): return 1 print(e) print("misp-modules might still be running.") + else: + log.exception(f"Could not listen on {args.listen}:{args.port}") + return 1 log.info(f'MISP modules server started on {args.listen} port {args.port}') if args.test: From 5b57b8b29603ecf78504b4c73881f2ecc3002a37 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 9 Jan 2024 12:19:48 +0100 Subject: [PATCH 2/3] fix: [server] Serializing PyMISP objects --- misp_modules/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misp_modules/__init__.py b/misp_modules/__init__.py index cf9f00b6..bd76f3ad 100644 --- a/misp_modules/__init__.py +++ b/misp_modules/__init__.py @@ -39,6 +39,7 @@ from tornado.ioloop import IOLoop from tornado.concurrent import run_on_executor from concurrent.futures import ThreadPoolExecutor +from pymisp import pymisp_json_default try: from .modules import * # noqa @@ -202,7 +203,7 @@ def run_request(self, module_name, json_payload, dict_payload): response = module.dict_handler(request=dict_payload) else: response = module.handler(q=json_payload) - return json.dumps(response) + return json.dumps(response, default=pymisp_json_default) @tornado.gen.coroutine def post(self): From c6d5e19010e7281042ec69476b04d29a6aae686b Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 9 Jan 2024 12:20:29 +0100 Subject: [PATCH 3/3] chg: [test] Reduce time for waiting until server is ready --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a414fc84..63e1a564 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -41,7 +41,7 @@ jobs: - name: Run server in background run: | misp-modules -l 127.0.0.1 -s 2>error.log & - sleep 5 + sleep 3 - name: Check if server is running run: | curl -sS localhost:6666/healthcheck