From fbbfa3082dd8309188b6888e6b441ede5eb07151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 7 Dec 2020 20:54:33 +0100 Subject: [PATCH] chg: Fix typing --- lookyloo/lookyloo.py | 6 +++--- website/web/__init__.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index 188ecf9a..59219ccc 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -880,7 +880,7 @@ class Lookyloo(): return 'embedded_ressource.bin', blob return None - def misp_export(self, capture_uuid: str) -> MISPEvent: + def misp_export(self, capture_uuid: str) -> Union[MISPEvent, Dict[str, str]]: cache = self.capture_cache(capture_uuid) if not cache: return {'error': 'UUID missing in cache, try again later.'} @@ -891,8 +891,8 @@ class Lookyloo(): event = MISPEvent() event.info = f'Lookyloo Capture ({cache["url"]})' event.add_attribute('link', f'https://{self.public_domain}/tree/{capture_uuid}') - initial_url = URLObject(cache["url"]) - redirects = [URLObject(url) for url in cache['redirects']] + initial_url = URLObject(cache["url"]) # type: ignore + redirects = [URLObject(url) for url in cache['redirects']] # type: ignore initial_url.add_reference(redirects[0], 'redirects-to') prec_object = redirects[0] for u_object in redirects[1:]: diff --git a/website/web/__init__.py b/website/web/__init__.py index fc3a3de2..66dd5cc4 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -673,6 +673,8 @@ def json_redirects(tree_uuid: str): @app.route('/json//misp_export', methods=['GET']) def misp_export(tree_uuid: str): event = lookyloo.misp_export(tree_uuid) + if isinstance(event, dict): + return jsonify(event) return Response(event.to_json(indent=2), mimetype='application/json')