mirror of https://github.com/CIRCL/lookyloo
fix: Copy bodies before sending them over.
send_file in flask close the BytesIO, causing issue if we need to re-access it.pull/268/head
parent
deb9a0e341
commit
1a0fe677ab
|
@ -607,7 +607,7 @@ class Lookyloo():
|
||||||
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
|
||||||
return url.filename if url.filename else 'file.bin', url.body, url.mimetype
|
return url.filename if url.filename else 'file.bin', BytesIO(url.body.getvalue()), url.mimetype
|
||||||
|
|
||||||
# We want an embedded ressource
|
# We want an embedded ressource
|
||||||
if h not in url.resources_hashes:
|
if h not in url.resources_hashes:
|
||||||
|
@ -615,7 +615,7 @@ class Lookyloo():
|
||||||
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', blob, mimetype
|
return 'embedded_ressource.bin', BytesIO(blob.getvalue()), mimetype
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __misp_add_vt_to_URLObject(self, obj: MISPObject) -> Optional[MISPObject]:
|
def __misp_add_vt_to_URLObject(self, obj: MISPObject) -> Optional[MISPObject]:
|
||||||
|
|
|
@ -1000,7 +1000,6 @@ def get_ressource(tree_uuid: str, node_uuid: str):
|
||||||
to_return = BytesIO(b'Unknown Hash')
|
to_return = BytesIO(b'Unknown Hash')
|
||||||
filename = 'file.txt'
|
filename = 'file.txt'
|
||||||
mimetype = 'text/text'
|
mimetype = 'text/text'
|
||||||
to_return.seek(0)
|
|
||||||
return send_file(to_return, mimetype=mimetype, as_attachment=True, attachment_filename=filename)
|
return send_file(to_return, mimetype=mimetype, as_attachment=True, attachment_filename=filename)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue