fix: Properly initialize pandora, more cleanup

pull/1015/head
Raphaël Vinot 2024-12-11 19:46:53 +01:00
parent a8b0464afa
commit 7df7ef7d1d
No known key found for this signature in database
GPG Key ID: 32E4E1C133B3792F
4 changed files with 15 additions and 11 deletions

View File

@ -19,6 +19,7 @@ class Pandora():
self.logger = logging.getLogger(f'{self.__class__.__name__}')
self.logger.setLevel(get_config('generic', 'loglevel'))
self.config = get_config('modules', 'Pandora')
self.available = True
if not self.config.get('url'):
self.logger.info('No URL in config.')
self.available = False
@ -28,8 +29,6 @@ class Pandora():
self.logger.warning('Not up.')
self.available = False
self.available = False
def submit_file(self, file_in_memory: BytesIO, filename: str) -> dict[str, Any]:
'''Submit a file to Pandora'''
if not self.available:

View File

@ -633,7 +633,6 @@ def hostnode_popup(tree_uuid: str, node_uuid: str) -> str | WerkzeugResponse | R
hostnode, urls = get_hostnode_investigator(tree_uuid, node_uuid)
except IndexError:
return render_template('error.html', error_message='Sorry, this one is on us. The tree was rebuild, please reload the tree and try again.')
return render_template('hostname_popup.html',
tree_uuid=tree_uuid,
hostnode_uuid=node_uuid,

View File

@ -244,9 +244,9 @@
{% else %}
{{ hash_info(tree_uuid, url['url_object'].uuid, url['url_object'].mimetype,
url['url_object'].body_hash, url['url_object'].body.getbuffer().nbytes,
url.get('body_hash_freq', 0), has_pandora) }}
{{ ressource_legitimacy_details(url.get('legitimacy')) }}
{{ known_content_details(url.get('known_content')) }}
url.get('body_hash_freq', 0), has_pandora,
url.get('legitimacy'),
url.get('known_content')) }}
{% if enable_context_by_users %}
{{ context_form(tree_uuid, url['url_object'].uuid,
@ -288,9 +288,11 @@
<div class="card card-body">
{% for hash, details in url['embedded_ressources'].items() %}
<div>
{{hash_info(tree_uuid, url['url_object'].uuid, details['type'], hash, details['body_size'], details['hash_freq'] ) }}<br>
{{ ressource_legitimacy_details(details.get('legitimacy')) }}
{{ known_content_details(details.get('known_content')) }}
{{hash_info(tree_uuid, url['url_object'].uuid, details['type'], hash,
details['body_size'], details['hash_freq'],
has_pandora,
details.get('legitimacy'),
details.get('known_content')) }}<br>
{% if enable_context_by_users %}
{{ context_form(tree_uuid, url['url_object'].uuid, hash, 'hostnode_popup') }}
{% endif %}

View File

@ -84,7 +84,7 @@
{% if details %}
<div>
{% if details is string %}
<b>{{ details }} </b>
This ressource is known as a generic file: <b>{{ details }}</b>
{% else %}
This file is known as part of <b>{{ details[0] }}</b>
version <b>{{ details[1] }}</b>: <b>{{ details[2] }}</b>.
@ -230,12 +230,15 @@
{% endmacro %}
{% macro hash_info(tree_uuid, urlnode_uuid, mimetype, hash, ressource_size,
nb_occurrences, has_pandora)%}
nb_occurrences, has_pandora, legitimacy, known_content)%}
{{ hash_icon(tree_uuid, urlnode_uuid, mimetype, hash) }}
<b>Body size</b> (in the HTTP response): {{ sizeof_fmt(ressource_size) }}
{{ ressource_legitimacy_details(legitimacy) }}
{{ known_content_details(known_content) }}
{% if nb_occurrences > 0 %}
<div>
This file can be found <b>{{ nb_occurrences }}</b> times across all the captures on this lookyloo instance.
@ -249,6 +252,7 @@
{% if has_pandora %}
{{ pandora_submit(tree_uuid, urlnode_uuid, hash) }}
<br>
{% endif %}
{% endmacro %}