From 2b02834ecf53e50d58bbf384fffdf9f78169cbe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 26 Mar 2024 17:10:10 +0100 Subject: [PATCH] chg: Make typing happy --- lookyloo/lookyloo.py | 7 ++++--- website/web/genericapi.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index 162373d..40c97c3 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -371,15 +371,16 @@ class Lookyloo(): to_return['URLhaus'] = self.urlhaus.capture_default_trigger(cache, auto_trigger=auto_trigger) return to_return - def get_modules_responses(self, capture_uuid: str, /) -> dict[str, Any] | None: + def get_modules_responses(self, capture_uuid: str, /) -> dict[str, Any]: '''Get the responses of the modules from the cached responses on the disk''' cache = self.capture_cache(capture_uuid) + # TODO: return a message when we cannot get the modules responses, update the code checking if it is falsy accordingly. if not cache: self.logger.warning(f'Unable to get the modules responses unless the capture {capture_uuid} is cached') - return None + return {} if not hasattr(cache, 'url'): self.logger.warning(f'The capture {capture_uuid} does not have a URL in the cache, it is broken.') - return None + return {} to_return: dict[str, Any] = {} if self.vt.available: diff --git a/website/web/genericapi.py b/website/web/genericapi.py index c1fa998..0e1a29f 100644 --- a/website/web/genericapi.py +++ b/website/web/genericapi.py @@ -281,6 +281,7 @@ class TriggerModules(Resource): # type: ignore[misc] force = True if parameters.get('force') else False return lookyloo.trigger_modules(capture_uuid, force=force) + @api.route('/json//modules') @api.doc(description='Get responses from the 3rd party modules', params={'tree_uuid': 'The UUID of the capture'})