mirror of https://github.com/CIRCL/lookyloo
chg: Simplify modules activation
parent
cebdbefccd
commit
d353463548
|
@ -17,7 +17,7 @@ from .modules import SaneJavaScript
|
|||
|
||||
class Context():
|
||||
|
||||
def __init__(self, sanejs: Optional[SaneJavaScript] = None):
|
||||
def __init__(self, sanejs: SaneJavaScript):
|
||||
self.logger = logging.getLogger(f'{self.__class__.__name__}')
|
||||
self.logger.setLevel(get_config('generic', 'loglevel'))
|
||||
self.redis: Redis = Redis(unix_socket_path=get_socket_path('indexing'), db=1, decode_responses=True)
|
||||
|
@ -102,7 +102,7 @@ class Context():
|
|||
if not to_lookup:
|
||||
return known_content_table
|
||||
|
||||
if to_lookup and self.sanejs and self.sanejs.available:
|
||||
if to_lookup and self.sanejs.available:
|
||||
# Query sanejs on the remaining ones
|
||||
try:
|
||||
for h, entry in self.sanejs.hashes_lookup(to_lookup).items():
|
||||
|
|
|
@ -70,10 +70,7 @@ class Lookyloo():
|
|||
if not self.sanejs.available:
|
||||
self.logger.warning('Unable to setup the SaneJS module')
|
||||
|
||||
if hasattr(self, 'sanejs') and self.sanejs.available:
|
||||
self.context = Context(self.sanejs)
|
||||
else:
|
||||
self.context = Context()
|
||||
self.context = Context(self.sanejs)
|
||||
|
||||
if not self.redis.exists('cache_loaded'):
|
||||
self._init_existing_dumps()
|
||||
|
@ -329,14 +326,14 @@ class Lookyloo():
|
|||
self.logger.warning(f'Unable to trigger the modules unless the tree ({capture_dir}) is cached.')
|
||||
return
|
||||
|
||||
if hasattr(self, 'pi') and self.pi.available:
|
||||
if self.pi.available:
|
||||
if ct.redirects:
|
||||
for redirect in ct.redirects:
|
||||
self.pi.url_lookup(redirect, force)
|
||||
else:
|
||||
self.pi.url_lookup(ct.root_hartree.har.root_url, force)
|
||||
|
||||
if hasattr(self, 'vt') and self.vt.available:
|
||||
if self.vt.available:
|
||||
if ct.redirects:
|
||||
for redirect in ct.redirects:
|
||||
self.vt.url_lookup(redirect, force)
|
||||
|
@ -352,14 +349,14 @@ class Lookyloo():
|
|||
self.logger.warning(f'Unable to get the modules responses unless the tree ({capture_dir}) is cached.')
|
||||
return None
|
||||
to_return: Dict[str, Any] = {}
|
||||
if hasattr(self, 'vt') and self.vt.available:
|
||||
if self.vt.available:
|
||||
to_return['vt'] = {}
|
||||
if ct.redirects:
|
||||
for redirect in ct.redirects:
|
||||
to_return['vt'][redirect] = self.vt.get_url_lookup(redirect)
|
||||
else:
|
||||
to_return['vt'][ct.root_hartree.har.root_url] = self.vt.get_url_lookup(ct.root_hartree.har.root_url)
|
||||
if hasattr(self, 'pi') and self.pi.available:
|
||||
if self.pi.available:
|
||||
to_return['pi'] = {}
|
||||
if ct.redirects:
|
||||
for redirect in ct.redirects:
|
||||
|
|
|
@ -20,7 +20,7 @@ from pyeupi import PyEUPI
|
|||
class SaneJavaScript():
|
||||
|
||||
def __init__(self, config: Dict[str, Any]):
|
||||
if not ('enabled' in config or config['enabled']):
|
||||
if not config.get('enabled'):
|
||||
self.available = False
|
||||
return
|
||||
self.client = SaneJS()
|
||||
|
@ -85,7 +85,7 @@ class SaneJavaScript():
|
|||
class PhishingInitiative():
|
||||
|
||||
def __init__(self, config: Dict[str, Any]):
|
||||
if 'apikey' not in config or config['apikey'] is None:
|
||||
if not config.get('apikey'):
|
||||
self.available = False
|
||||
return
|
||||
|
||||
|
@ -158,7 +158,7 @@ class PhishingInitiative():
|
|||
class VirusTotal():
|
||||
|
||||
def __init__(self, config: Dict[str, Any]):
|
||||
if 'apikey' not in config or config['apikey'] is None:
|
||||
if not config.get('apikey'):
|
||||
self.available = False
|
||||
return
|
||||
|
||||
|
|
|
@ -237,6 +237,8 @@ def modules(tree_uuid: str):
|
|||
vt = modules_responses.pop('vt')
|
||||
# Get malicious entries
|
||||
for url, full_report in vt.items():
|
||||
if not full_report:
|
||||
continue
|
||||
vt_short_result[url] = {
|
||||
'permaurl': f'https://www.virustotal.com/gui/url/{full_report["id"]}/detection',
|
||||
'malicious': []
|
||||
|
|
Loading…
Reference in New Issue