From ccad142dd04c0aca750ef82e0e7f0877a19a92c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 27 May 2020 12:38:25 +0200 Subject: [PATCH] chg: Improve hostname popup --- website/web/__init__.py | 12 +++-- website/web/templates/hostname_popup.html | 61 +++++++++++++++++++++-- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/website/web/__init__.py b/website/web/__init__.py index 7b0011f..99a7acc 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -17,7 +17,7 @@ from lookyloo.lookyloo import Lookyloo from lookyloo.exceptions import NoValidHarFile from .proxied import ReverseProxied -from typing import Optional, Dict, Any, List +from typing import Optional, Dict, Any, List, Tuple import logging @@ -164,11 +164,12 @@ def hostnode_popup(tree_uuid: str, node_uuid: str): 'request_cookie': "/static/cookie_read.png", } - urls = [] sanejs_lookups: Dict[str, List[str]] = {} if hasattr(lookyloo, 'sanejs') and lookyloo.sanejs.available: to_lookup = [url.body_hash for url in hostnode.urls if hasattr(url, 'body_hash')] sanejs_lookups = lookyloo.sanejs.hashes_lookup(to_lookup) + + urls: List[Tuple[bool, str, str]] = [] for url in hostnode.urls: if hasattr(url, 'body_hash') and url.body_hash in sanejs_lookups: url.add_feature('sane_js_details', sanejs_lookups[url.body_hash]) @@ -180,7 +181,12 @@ def hostnode_popup(tree_uuid: str, node_uuid: str): else: # Predefined generic file url.add_feature('sane_js_details_to_print', sanejs_lookups[url.body_hash]) - urls.append(url) + + # For the popup, we need: + # * https vs http + # * everything after the domain + # * the full URL + urls.append((url.name.startswith('https'), url.name.split('/', 3)[-1], url)) return render_template('hostname_popup.html', tree_uuid=tree_uuid, hostname_uuid=node_uuid, diff --git a/website/web/templates/hostname_popup.html b/website/web/templates/hostname_popup.html index eaa5336..2458b93 100644 --- a/website/web/templates/hostname_popup.html +++ b/website/web/templates/hostname_popup.html @@ -3,11 +3,42 @@ {% block title %}Details for {{ hostname }} {% endblock %} {% block scripts %} + {{ super() }} + + {% endblock %} {% block content %} @@ -18,9 +49,27 @@

Click on the URL to get the content of the response