mirror of https://github.com/CIRCL/lookyloo
fix: Avoid exception in case the DNS files are broken
parent
1a0fe677ab
commit
9215522563
|
|
@ -321,13 +321,21 @@ class CapturesIndex(Mapping):
|
||||||
ips_path = ct.root_hartree.har.path.parent / 'ips.json'
|
ips_path = ct.root_hartree.har.path.parent / 'ips.json'
|
||||||
host_cnames: Dict[str, Optional[str]] = {}
|
host_cnames: Dict[str, Optional[str]] = {}
|
||||||
if cnames_path.exists():
|
if cnames_path.exists():
|
||||||
|
try:
|
||||||
with cnames_path.open() as f:
|
with cnames_path.open() as f:
|
||||||
host_cnames = json.load(f)
|
host_cnames = json.load(f)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
# The json is broken, delete and re-trigger the requests
|
||||||
|
host_cnames = {}
|
||||||
|
|
||||||
host_ips: Dict[str, List[str]] = {}
|
host_ips: Dict[str, List[str]] = {}
|
||||||
if ips_path.exists():
|
if ips_path.exists():
|
||||||
|
try:
|
||||||
with ips_path.open() as f:
|
with ips_path.open() as f:
|
||||||
host_ips = json.load(f)
|
host_ips = json.load(f)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
# The json is broken, delete and re-trigger the requests
|
||||||
|
host_ips = {}
|
||||||
|
|
||||||
for node in ct.root_hartree.hostname_tree.traverse():
|
for node in ct.root_hartree.hostname_tree.traverse():
|
||||||
if node.name not in host_cnames or node.name not in host_ips:
|
if node.name not in host_cnames or node.name not in host_ips:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue