From b80dc1aab3cce3b87f8b7cd23b8372527ddd8c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 20 Dec 2021 16:50:29 +0100 Subject: [PATCH] chg: Make sure publishing the MISP event is done in the background --- lookyloo/modules/misp.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lookyloo/modules/misp.py b/lookyloo/modules/misp.py index e316153..185fc62 100644 --- a/lookyloo/modules/misp.py +++ b/lookyloo/modules/misp.py @@ -93,7 +93,14 @@ class MISP(): to_return = [] for event in events: try: + # NOTE: POST the event as published publishes inline, which can tak a long time. + # Here, we POST as not published, and trigger the publishing in a second call. + background_publish = event.published + if background_publish: + event.published = False new_event = self.client.add_event(event, pythonify=True) + if background_publish and isinstance(new_event, MISPEvent): + self.client.publish(new_event) except requests.exceptions.ReadTimeout: return {'error': 'The connection to MISP timed out, try increasing the timeout in the config.'} if isinstance(new_event, MISPEvent):