From 134ccf1acfdb16fa5942b6dd465b7e6495211375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 26 Apr 2023 15:40:36 +0200 Subject: [PATCH] new: Submit any file to Pandora (if available) Fix proposal for #670 --- website/web/__init__.py | 19 +++++++++++++++++-- website/web/templates/hostname_popup.html | 22 ++++++++++++++++++---- website/web/templates/macros.html | 16 ++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/website/web/__init__.py b/website/web/__init__.py index 088bf4c..31b950e 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -792,9 +792,24 @@ def tree_body_hashes(tree_uuid: str): return render_template('tree_body_hashes.html', tree_uuid=tree_uuid, body_hashes=body_hashes) -@app.route('/tree//pandora', methods=['GET']) +@app.route('/tree//pandora', methods=['GET', 'POST']) def pandora_submit(tree_uuid: str): - filename, content = lookyloo.get_data(tree_uuid) + node_uuid = None + if request.method == 'POST': + input_json = request.get_json(force=True) + node_uuid = input_json.get('node_uuid') + h_request = input_json.get('ressource_hash') + if node_uuid: + ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_request) + if ressource: + filename, content, mimetype = ressource + elif h_request: + return {'error': 'Unable to find resource {h_request} in node {node_uuid} of tree {tree_uuid}'} + else: + return {'error': 'Unable to find resource in node {node_uuid} of tree {tree_uuid}'} + else: + filename, content = lookyloo.get_data(tree_uuid) + response = lookyloo.pandora.submit_file(content, filename) return jsonify(response) diff --git a/website/web/templates/hostname_popup.html b/website/web/templates/hostname_popup.html index c864903..73a8285 100644 --- a/website/web/templates/hostname_popup.html +++ b/website/web/templates/hostname_popup.html @@ -9,6 +9,7 @@ {% from "macros.html" import other_captures_table %} {% from "macros.html" import get_ressource_button %} {% from "macros.html" import context_form %} +{% from "macros.html" import pandora_submit %} {% block title %}Details for {{ hostnode.name }} {% endblock %} @@ -63,9 +64,17 @@ });