fix: Avoid None in urlscan.io result.

pull/263/head
Raphaël Vinot 2021-09-17 12:58:05 +02:00
parent 404f9a3112
commit 275b4aee93
1 changed files with 3 additions and 3 deletions

View File

@ -59,15 +59,15 @@ class UrlScan():
m.update(to_hash.encode())
return self.storage_dir_urlscan / m.hexdigest()
def get_url_submission(self, capture_info: Dict[str, Any]) -> Optional[Dict[str, Any]]:
def get_url_submission(self, capture_info: Dict[str, Any]) -> Dict[str, Any]:
url_storage_dir = self.__get_cache_directory(capture_info['url'],
capture_info['user_agent'],
capture_info['referer']) / 'submit'
if not url_storage_dir.exists():
return None
return {}
cached_entries = sorted(url_storage_dir.glob('*'), reverse=True)
if not cached_entries:
return None
return {}
with cached_entries[0].open() as f:
return json.load(f)