mirror of https://github.com/OWASP/Nettacker.git
bug fix in exporting results from webui
This commit is contained in:
parent
6679e30860
commit
4115a27e25
|
|
@ -345,7 +345,14 @@ def get_result_content():
|
|||
msg=messages("invalid_scan_id")
|
||||
)
|
||||
), 400
|
||||
return get_scan_result(scan_id)
|
||||
filename, file_content = get_scan_result(scan_id)
|
||||
return Response(
|
||||
file_content,
|
||||
mimetype=mime_types().get(filename.split('.')[-1]),
|
||||
headers={
|
||||
'Content-Disposition': 'attachment;filename=' + filename
|
||||
}
|
||||
) if file_content not in [404, 500] else filename, content
|
||||
|
||||
|
||||
@app.route("/results/get_json", methods=["GET"])
|
||||
|
|
|
|||
|
|
@ -282,11 +282,11 @@ def get_scan_result(id):
|
|||
try:
|
||||
filename = session.query(Report).filter_by(id=id).first().report_path_filename[1:-1]
|
||||
# for some reason filename saved like "filename" with double quotes in the beginning and end
|
||||
return open(str(filename), 'rb').read(), 200
|
||||
return filename, open(str(filename), 'rb').read()
|
||||
except Exception:
|
||||
return jsonify(structure(status="error", msg="cannot find the file!")), 400
|
||||
return jsonify(structure(status="error", msg="cannot find the file!")), 404
|
||||
except Exception:
|
||||
return jsonify(structure(status="error", msg="database error!")), 200
|
||||
return jsonify(structure(status="error", msg="database error!")), 500
|
||||
|
||||
|
||||
def last_host_logs(page):
|
||||
|
|
|
|||
Loading…
Reference in New Issue