fix: [modules] Gracefully accept no hashlookup fixes #916

pull/917/head
Christophe Vandeplas 2024-05-20 10:41:15 +02:00
parent 2baa2cd73a
commit 992dc84e00
No known key found for this signature in database
GPG Key ID: BDC48619FFDC5A5B
5 changed files with 21 additions and 7 deletions

4
cache/run_redis.sh vendored
View File

@ -5,6 +5,8 @@ set -x
if [ -f ../../valkey/src/valkey-server ]; then
../../valkey/src/valkey-server ./cache.conf
else
elif [ -f ../../redis/src/redis-server ]; then
../../redis/src/redis-server ./cache.conf
else
/usr/bin/redis-server ./cache.conf
fi

View File

@ -5,6 +5,9 @@ set -x
if [ -f ../../valkey/src/valkey-server ]; then
../../valkey/src/valkey-server ./indexing.conf
else
elif [ -f ../../redis/src/redis-server ]; then
../../redis/src/redis-server ./indexing.conf
else
/usr/bin/redis-server ./indexing.conf
fi

View File

@ -962,10 +962,14 @@ def urls_rendered_page(tree_uuid: str) -> WerkzeugResponse | str | Response:
@app.route('/tree/<string:tree_uuid>/hashlookup', methods=['GET'])
def hashlookup(tree_uuid: str) -> str | WerkzeugResponse | Response:
merged, total_ressources = lookyloo.merge_hashlookup_tree(tree_uuid)
# We only want unique URLs for the template
for sha1, entries in merged.items():
entries['nodes'] = {node.name for node in entries['nodes']}
try:
merged, total_ressources = lookyloo.merge_hashlookup_tree(tree_uuid)
# We only want unique URLs for the template
for sha1, entries in merged.items():
entries['nodes'] = {node.name for node in entries['nodes']}
except Exception: # error or module not enabled
merged = False
total_ressources = False
return render_template('hashlookup.html', base_tree_uuid=tree_uuid, merged=merged, total_ressources=total_ressources)

View File

@ -1,4 +1,8 @@
<div>
{% if not merged %}
No result data available or hashlookup module not enabled.
{%else%}
<b>Total Hits</b>: {{ merged|length }}</br>
<b>Total ressources</b>: {{total_ressources}}</br></br>
{% for sha1, entries in merged.items() %}
@ -25,4 +29,5 @@
</dd>
</dl>
{% endfor %}
{%endif%}
</div>

View File

@ -434,7 +434,7 @@
</div>
{% endif %}
<a id="help" href="https://www.lookyloo.eu/docs/main/usage.html#_investigate_a_capture" role="button" title="Lookyloo Manual">?</a>
<a id="help" href="https://www.lookyloo.eu/docs/main/usage.html#_investigate_a_capture" role="button" title="Lookyloo Manual" target="_blank">?</a>
</div>
</div>