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
|
||||
if not h or h == url.body_hash:
|
||||
# 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
|
||||
if h not in url.resources_hashes:
|
||||
|
@ -615,7 +615,7 @@ class Lookyloo():
|
|||
for mimetype, blobs in url.embedded_ressources.items():
|
||||
for ressource_h, blob in blobs:
|
||||
if ressource_h == h:
|
||||
return 'embedded_ressource.bin', blob, mimetype
|
||||
return 'embedded_ressource.bin', BytesIO(blob.getvalue()), mimetype
|
||||
return None
|
||||
|
||||
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')
|
||||
filename = 'file.txt'
|
||||
mimetype = 'text/text'
|
||||
to_return.seek(0)
|
||||
return send_file(to_return, mimetype=mimetype, as_attachment=True, attachment_filename=filename)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue