From 18dcdfe9b4d43f4bb54fc51f80acea780ae09400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 4 Dec 2024 16:17:59 +0100 Subject: [PATCH] chg: Remove hash lookup from rendering in the hostnode popup. --- website/web/__init__.py | 36 +--------- website/web/templates/hostname_popup.html | 10 --- website/web/templates/macros.html | 86 ----------------------- 3 files changed, 1 insertion(+), 131 deletions(-) diff --git a/website/web/__init__.py b/website/web/__init__.py index 2fc5c127..9942d5c0 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -462,35 +462,6 @@ def get_hhh_investigator(hhh: str, offset: int | None=None, limit: int | None=No return total, captures -def hash_lookup(blob_hash: str, url: str, current_capture_uuid: str) -> tuple[int, dict[str, list[tuple[str, str, str, str, str]]]]: - '''Search all the captures a specific hash was seen. - If a URL is given, it splits the results if the hash is seen on the same URL or an other one. - Capture UUID avoids duplicates on the same capture''' - captures_list: dict[str, list[tuple[str, str, str, str, str]]] = {'same_url': [], 'different_url': []} - _, entries = get_indexing(flask_login.current_user).get_captures_body_hash(blob_hash, oldest_capture=datetime.now() - timedelta(**time_delta_on_index)) - cached_captures = lookyloo.sorted_capture_cache( - [uuid for uuid, _ in entries], - cached_captures_only=True) - for cache in cached_captures: - if cache.uuid == current_capture_uuid: - continue - urlnodes = get_indexing(flask_login.current_user).get_capture_body_hash_nodes(cache.uuid, blob_hash) - for urlnode_uuid in urlnodes: - try: - urlnode = cache.tree.root_hartree.get_url_node_by_uuid(urlnode_uuid) - except IndexError: - continue - if url == urlnode.name: - captures_list['same_url'].append((cache.uuid, urlnode_uuid, cache.title, cache.timestamp.isoformat(), urlnode.hostname)) - else: - captures_list['different_url'].append((cache.uuid, urlnode_uuid, cache.title, cache.timestamp.isoformat(), urlnode.hostname)) - # Sort by timestamp by default - captures_list['same_url'].sort(key=lambda y: y[3]) - captures_list['different_url'].sort(key=lambda y: y[3]) - total_captures = get_indexing(flask_login.current_user).get_captures_body_hash_count(blob_hash) - return total_captures, captures_list - - def get_hostnode_investigator(capture_uuid: str, /, node_uuid: str) -> tuple[HostNode, list[dict[str, Any]]]: '''Gather all the informations needed to display the Hostnode investigator popup.''' @@ -535,9 +506,7 @@ def get_hostnode_investigator(capture_uuid: str, /, node_uuid: str) -> tuple[Hos # Index lookup # %%% Full body %%% if freq := get_indexing(flask_login.current_user).get_captures_body_hash_count(url.body_hash): - to_append['body_hash_details'] = {'hash_freq': freq, 'other_captures': (freq, {'same_url': [], 'different_url': []})} - if freq > 1: - to_append['body_hash_details']['other_captures'] = hash_lookup(url.body_hash, url.name, capture_uuid) + to_append['body_hash_details'] = {'hash_freq': freq} # %%% Embedded ressources %%% if hasattr(url, 'embedded_ressources') and url.embedded_ressources: @@ -551,9 +520,6 @@ def get_hostnode_investigator(capture_uuid: str, /, node_uuid: str) -> tuple[Hos 'type': mimetype} if freq := get_indexing(flask_login.current_user).get_captures_body_hash_count(h): to_append['embedded_ressources'][h]['hash_freq'] = freq - to_append['embedded_ressources'][h]['other_captures'] = (freq, {'same_url': [], 'different_url': []}) - if freq > 1: - to_append['embedded_ressources'][h]['other_captures'] = hash_lookup(h, url.name, capture_uuid) for h in to_append['embedded_ressources'].keys(): known, legitimate = normalize_known_content(h, known_content, url) if known: diff --git a/website/web/templates/hostname_popup.html b/website/web/templates/hostname_popup.html index eb9a1b53..a0790d77 100644 --- a/website/web/templates/hostname_popup.html +++ b/website/web/templates/hostname_popup.html @@ -1,7 +1,6 @@ {% extends "main.html" %} {% from "macros.html" import known_content_details %} {% from "macros.html" import ressource_legitimacy_details %} -{% from "macros.html" import indexed_hash %} {% from "macros.html" import indexed_cookies %} {% from "macros.html" import popup_icons_request %} {% from "macros.html" import popup_icons_response %} @@ -258,12 +257,6 @@ This file can be found {{ url['body_hash_details']['hash_freq'] }} times across all the captures on this lookyloo instance. - {# other captures related with the same content #} - {% if 'other_captures' in url['body_hash_details'] %} -
- {{ indexed_hash(url['body_hash_details']['other_captures'], url['url_object'].uuid) }} - {% endif %} - {# Link to list of captures with the same hash #}

Show more information about this response body. @@ -316,9 +309,6 @@ {{ context_form(tree_uuid, url['url_object'].uuid, hash, 'hostnode_popup') }} {% endif %} - {% if 'other_captures' in details %} - {{ indexed_hash(details['other_captures'], url['url_object'].uuid + '_' + loop.index|string) }} - {% endif %}

Show more information about this embedded content.

diff --git a/website/web/templates/macros.html b/website/web/templates/macros.html index 6d8f69cb..e3fc63a0 100644 --- a/website/web/templates/macros.html +++ b/website/web/templates/macros.html @@ -188,92 +188,6 @@ {%endif%} {% endmacro %} -{% macro indexed_hash(details, identifier_for_toggle) %} -{% set total_captures = details[0] %} -{% set other_captures = details[1] %} -{# Only show details if the hits are in an other capture #} -{% if total_captures > 1 %} -

- The same file was seen in {{ total_captures - 1 }} other captures. -
- -

-{# Lists of other captures loading the same content... #} -
-
- Note that only the most recent cached captures are displayed here, click on the link below to see more. - {% if other_captures['different_url']|length > 0 %} - {# ... on other URLs #} -
-

The following captures get the same file from a different URL

- {{ other_captures_table(other_captures['different_url'], 20, identifier_for_toggle + '_same') }} -
- {% endif %} -
- {% if other_captures['same_url']|length > 0 %} - {# ... on the same URL #} -
-

The following captures get the same file from the same URL

- {{ other_captures_table(other_captures['same_url'], 20, identifier_for_toggle + '_different') }} -
- {% endif %} -
-
-{% endif %} -{% endmacro %} - -{% macro other_captures_table(entries, max_entries, identifier) %} - - -
- - - - - - - - - - {% for capture_uuid, urlnode_uuid, title, timestamp, hostname in entries[:max_entries] %} - - - - - - {% endfor %} - -
TitleTimestampDomain
- - {{ timestamp }}{{ hostname }}
-
-{% endmacro %} - {% macro indexed_cookies(header_text, button_text, cookies) %} {% if cookies %}
{{ header_text }}