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 c3ec35d..0e1a29f 100644 --- a/website/web/genericapi.py +++ b/website/web/genericapi.py @@ -282,6 +282,14 @@ class TriggerModules(Resource): # type: ignore[misc] 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'}) +class ModulesResponse(Resource): # type: ignore[misc] + def get(self, tree_uuid: str) -> dict[str, Any]: + return lookyloo.get_modules_responses(tree_uuid) + + @api.route('/json/hash_info/') @api.doc(description='Search for a ressource with a specific hash (sha512)', params={'h': 'The hash (sha512)'})