fix: Avoid exception when there are no historical data.

pull/847/head
Raphaël Vinot 2023-12-13 12:40:33 +01:00
parent 2e666423c8
commit db26633ebb
3 changed files with 11 additions and 7 deletions

View File

@ -434,7 +434,8 @@ class Lookyloo():
else:
hostname = urlparse(cache.url).hostname
if hostname:
to_return['riskiq'] = self.riskiq.get_passivedns(hostname)
if entries := self.riskiq.get_passivedns(hostname):
to_return['riskiq'] = entries
except RiskIQError as e:
self.logger.warning(e.response.content)
if self.circl_pdns.available:
@ -444,8 +445,8 @@ class Lookyloo():
else:
hostname = urlparse(cache.url).hostname
if hostname:
to_return['circl_pdns'][hostname] = self.circl_pdns.get_passivedns(hostname)
if entries := self.circl_pdns.get_passivedns(hostname):
to_return['circl_pdns'][hostname] = entries
return to_return
def hide_capture(self, capture_uuid: str, /) -> None:

View File

@ -108,7 +108,7 @@ class RiskIQ(AbstractModule):
return
pdns_info = self.client_dns.get_passive_dns(query=hostname, start=first_seen.isoformat())
if not pdns_info:
if not pdns_info or not pdns_info.get('results'):
try:
url_storage_dir.rmdir()
except OSError:

View File

@ -1,6 +1,9 @@
{% from "macros.html" import shorten_string %}
<div>
{% if not circl_pdns and not riskiq %}
No historical data available
{%else%}
{% if circl_pdns %}
<center>
<h1 class="display-4">CIRCL Passive DNS
@ -9,7 +12,7 @@
style="cursor: pointer;">
</div>
</h1>
{% for query, responses in circl_pdns.items() %}
{% for query, responses in circl_pdns.items() if responses %}
<div>
<h3>{{query}}</h3>
<table class="table">
@ -35,9 +38,8 @@
</div>
{%endfor%}
</center>
{% endif%}
{% if riskiq and current_user.is_authenticated %}
{% if riskiq %}
<hr>
<center>
<h1 class="display-4">RiskIQ</h1>
@ -65,4 +67,5 @@
</div>
</center>
{% endif%}
{% endif%}
</div>