fix: Typing

pull/86/head
Raphaël Vinot 2020-09-01 17:54:54 +02:00
parent b16a5768ea
commit ecbbceb781
2 changed files with 6 additions and 6 deletions

View File

@ -423,7 +423,7 @@ class Context():
# Query DB # Query DB
def is_legitimate(self, urlnode: URLNode, known_hashes: Iterable[str]) -> Optional[bool]: def is_legitimate(self, urlnode: URLNode, known_hashes: Dict[str, Any]) -> Optional[bool]:
""" """
If legitimate if generic, marked as legitimate or known on sanejs, loaded from the right domain If legitimate if generic, marked as legitimate or known on sanejs, loaded from the right domain
3 cases: 3 cases:
@ -451,7 +451,7 @@ class Context():
return True # All the contents are known legitimate return True # All the contents are known legitimate
return None return None
def is_malicious(self, urlnode: URLNode, known_hashes: Iterable[str]) -> Optional[bool]: def is_malicious(self, urlnode: URLNode, known_hashes: Dict[str, Any]) -> Optional[bool]:
"""3 cases: """3 cases:
* True if *any* content is malicious * True if *any* content is malicious
* False if *all* the contents are known legitimate * False if *all* the contents are known legitimate
@ -1060,7 +1060,7 @@ class Lookyloo():
for domain, freq in self.indexing.get_cookie_domains(cookie_name)] for domain, freq in self.indexing.get_cookie_domains(cookie_name)]
return captures, domains return captures, domains
def hash_lookup(self, blob_hash: str, url: str, capture_uuid: str) -> Dict[str, List[Tuple[str, str, str, str, str]]]: def hash_lookup(self, blob_hash: str, url: str, capture_uuid: str) -> Tuple[int, Dict[str, List[Tuple[str, str, str, str, str]]]]:
captures_list: Dict[str, List[Tuple[str, str, str, str, str]]] = {'same_url': [], 'different_url': []} captures_list: Dict[str, List[Tuple[str, str, str, str, str]]] = {'same_url': [], 'different_url': []}
total_captures, details = self.indexing.get_body_hash_captures(blob_hash, url) total_captures, details = self.indexing.get_body_hash_captures(blob_hash, url)
for h_capture_uuid, url_uuid, url_hostname, same_url in details: for h_capture_uuid, url_uuid, url_hostname, same_url in details:

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from typing import Dict, Any, Optional, List, Union from typing import Dict, Any, Optional, List, Union, Iterable
from datetime import date from datetime import date
import hashlib import hashlib
import json import json
@ -31,9 +31,9 @@ class SaneJavaScript():
self.storage_dir = get_homedir() / 'sanejs' self.storage_dir = get_homedir() / 'sanejs'
self.storage_dir.mkdir(parents=True, exist_ok=True) self.storage_dir.mkdir(parents=True, exist_ok=True)
def hashes_lookup(self, sha512: Union[List[str], str], force: bool=False) -> Dict[str, List[str]]: def hashes_lookup(self, sha512: Union[Iterable[str], str], force: bool=False) -> Dict[str, List[str]]:
if isinstance(sha512, str): if isinstance(sha512, str):
hashes = [sha512] hashes: Iterable[str] = [sha512]
else: else:
hashes = sha512 hashes = sha512