mirror of https://github.com/CIRCL/lookyloo
chg: Add logging to debug why some files are not downloadable
parent
d1ca709ed9
commit
12e9430443
|
@ -1118,12 +1118,15 @@ class Lookyloo():
|
||||||
url = self.get_urlnode_from_tree(tree_uuid, urlnode_uuid)
|
url = self.get_urlnode_from_tree(tree_uuid, urlnode_uuid)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# unable to find the uuid, the cache is probably in a weird state.
|
# unable to find the uuid, the cache is probably in a weird state.
|
||||||
|
self.logger.info(f'Unable to find node "{urlnode_uuid}" in "{tree_uuid}"')
|
||||||
return None
|
return None
|
||||||
except NoValidHarFile as e:
|
except NoValidHarFile as e:
|
||||||
# something went poorly when rebuilding the tree (probably a recursive error)
|
# something went poorly when rebuilding the tree (probably a recursive error)
|
||||||
self.logger.warning(e)
|
self.logger.warning(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if url.empty_response:
|
if url.empty_response:
|
||||||
|
self.logger.info(f'The response for node "{urlnode_uuid}" in "{tree_uuid}" is empty.')
|
||||||
return None
|
return None
|
||||||
if not h or h == url.body_hash:
|
if not h or h == url.body_hash:
|
||||||
# we want the body
|
# we want the body
|
||||||
|
@ -1131,11 +1134,13 @@ class Lookyloo():
|
||||||
|
|
||||||
# We want an embedded ressource
|
# We want an embedded ressource
|
||||||
if h not in url.resources_hashes:
|
if h not in url.resources_hashes:
|
||||||
|
self.logger.info(f'Unable to find "{h}" in capture "{tree_uuid}" - node "{urlnode_uuid}".')
|
||||||
return None
|
return None
|
||||||
for mimetype, blobs in url.embedded_ressources.items():
|
for mimetype, blobs in url.embedded_ressources.items():
|
||||||
for ressource_h, blob in blobs:
|
for ressource_h, blob in blobs:
|
||||||
if ressource_h == h:
|
if ressource_h == h:
|
||||||
return 'embedded_ressource.bin', BytesIO(blob.getvalue()), mimetype
|
return 'embedded_ressource.bin', BytesIO(blob.getvalue()), mimetype
|
||||||
|
self.logger.info(f'Unable to find "{h}" in capture "{tree_uuid}" - node "{urlnode_uuid}", but in a weird way.')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __misp_add_vt_to_URLObject(self, obj: MISPObject) -> MISPObject | None:
|
def __misp_add_vt_to_URLObject(self, obj: MISPObject) -> MISPObject | None:
|
||||||
|
|
|
@ -1542,14 +1542,16 @@ def recapture(tree_uuid: str) -> str | Response | WerkzeugResponse:
|
||||||
@app.route('/ressource_by_hash/<string:sha512>', methods=['GET'])
|
@app.route('/ressource_by_hash/<string:sha512>', methods=['GET'])
|
||||||
@file_response # type: ignore[misc]
|
@file_response # type: ignore[misc]
|
||||||
def ressource_by_hash(sha512: str) -> Response:
|
def ressource_by_hash(sha512: str) -> Response:
|
||||||
|
content_fallback = f'Unable to find "{sha512}"'
|
||||||
if uuids := get_indexing(flask_login.current_user).get_hash_uuids(sha512):
|
if uuids := get_indexing(flask_login.current_user).get_hash_uuids(sha512):
|
||||||
# got UUIDs for this hash
|
# got UUIDs for this hash
|
||||||
capture_uuid, urlnode_uuid = uuids
|
capture_uuid, urlnode_uuid = uuids
|
||||||
|
content_fallback += f' in capture "{capture_uuid}" and node "{urlnode_uuid}"'
|
||||||
if ressource := lookyloo.get_ressource(capture_uuid, urlnode_uuid, sha512):
|
if ressource := lookyloo.get_ressource(capture_uuid, urlnode_uuid, sha512):
|
||||||
filename, body, mimetype = ressource
|
filename, body, mimetype = ressource
|
||||||
return send_file(body, as_attachment=True, download_name=filename)
|
return send_file(body, as_attachment=True, download_name=filename)
|
||||||
|
|
||||||
return send_file(BytesIO(f'Unable to find {sha512}'.encode()), as_attachment=True, download_name='Unknown_Hash.txt')
|
return send_file(BytesIO(content_fallback.encode()), as_attachment=True, download_name='Unknown_Hash.txt')
|
||||||
|
|
||||||
|
|
||||||
# ################## Submit existing capture ##################
|
# ################## Submit existing capture ##################
|
||||||
|
|
Loading…
Reference in New Issue