Merge branch 'adrima01-3rd_party'

pull/899/head
Raphaël Vinot 2024-03-26 17:10:31 +01:00
commit 4b6cf752bc
2 changed files with 12 additions and 3 deletions

View File

@ -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:

View File

@ -282,6 +282,14 @@ class TriggerModules(Resource): # type: ignore[misc]
return lookyloo.trigger_modules(capture_uuid, force=force)
@api.route('/json/<string:tree_uuid>/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/<h>')
@api.doc(description='Search for a ressource with a specific hash (sha512)',
params={'h': 'The hash (sha512)'})