chg: Fix typing

pull/135/head
Raphaël Vinot 2020-12-07 20:54:33 +01:00
parent 8eab287721
commit fbbfa3082d
2 changed files with 5 additions and 3 deletions

View File

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

View File

@ -673,6 +673,8 @@ def json_redirects(tree_uuid: str):
@app.route('/json/<string:tree_uuid>/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')