fix: Exception when none of the captures are cached.

pull/746/head
Raphaël Vinot 2023-07-24 22:41:11 +02:00
parent f7e5e3e867
commit 18b5a51c86
1 changed files with 10 additions and 9 deletions

View File

@ -989,15 +989,16 @@ class Lookyloo():
def get_hhh_investigator(self, hhh: str, /) -> Tuple[List[Tuple[str, str, str, str]], List[Tuple[str, str]]]:
'''Returns all the captures related to a cookie name entry, used in the web interface.'''
all_captures = dict(self.indexing.get_http_headers_hashes_captures(hhh))
cached_captures = self.sorted_capture_cache([entry for entry in all_captures])
captures = [(cache.uuid,
self.get_urlnode_from_tree(cache.uuid, all_captures[cache.uuid]).hostnode_uuid,
self.get_urlnode_from_tree(cache.uuid, all_captures[cache.uuid]).name,
cache.title) for cache in cached_captures]
# get the headers and format them as they were in the response
urlnode = self.get_urlnode_from_tree(cached_captures[0].uuid, all_captures[cached_captures[0].uuid])
headers = [(header["name"], header["value"]) for header in urlnode.response['headers']]
return captures, headers
if cached_captures := self.sorted_capture_cache([entry for entry in all_captures]):
captures = [(cache.uuid,
self.get_urlnode_from_tree(cache.uuid, all_captures[cache.uuid]).hostnode_uuid,
self.get_urlnode_from_tree(cache.uuid, all_captures[cache.uuid]).name,
cache.title) for cache in cached_captures]
# get the headers and format them as they were in the response
urlnode = self.get_urlnode_from_tree(cached_captures[0].uuid, all_captures[cached_captures[0].uuid])
headers = [(header["name"], header["value"]) for header in urlnode.response['headers']]
return captures, headers
return [], []
def hash_lookup(self, blob_hash: str, url: str, capture_uuid: str) -> Tuple[int, Dict[str, List[Tuple[str, str, str, str, str]]]]:
'''Search all the captures a specific hash was seen.