chg: Better logging and error handling

pull/180/head
Raphaël Vinot 2021-03-08 13:57:55 +01:00
parent e467f1d1eb
commit e35ceab3dd
2 changed files with 4 additions and 1 deletions

View File

@ -711,6 +711,7 @@ class Lookyloo():
if int(depth) > int(get_config('generic', 'max_depth')): if int(depth) > int(get_config('generic', 'max_depth')):
self.logger.warning(f'Not allowed to capture on a depth higher than {get_config("generic", "max_depth")}: {depth}') self.logger.warning(f'Not allowed to capture on a depth higher than {get_config("generic", "max_depth")}: {depth}')
depth = int(get_config('generic', 'max_depth')) depth = int(get_config('generic', 'max_depth'))
self.logger.info(f'Capturing {url}')
try: try:
items = crawl(self.splash_url, url, cookies=cookies, depth=depth, user_agent=ua, items = crawl(self.splash_url, url, cookies=cookies, depth=depth, user_agent=ua,
referer=referer, log_enabled=True, log_level=get_config('generic', 'splash_loglevel')) referer=referer, log_enabled=True, log_level=get_config('generic', 'splash_loglevel'))
@ -719,6 +720,7 @@ class Lookyloo():
raise e raise e
if not items: if not items:
# broken # broken
self.logger.critical(f'Something went terribly wrong when capturing {url}.')
return False return False
if not perma_uuid: if not perma_uuid:
perma_uuid = str(uuid4()) perma_uuid = str(uuid4())

View File

@ -14,6 +14,7 @@ from .helpers import get_homedir, get_config
from .exceptions import ConfigError from .exceptions import ConfigError
import vt # type: ignore import vt # type: ignore
from vt.error import APIError
from pysanejs import SaneJS from pysanejs import SaneJS
from pyeupi import PyEUPI from pyeupi import PyEUPI
from pymisp import PyMISP, MISPEvent from pymisp import PyMISP, MISPEvent
@ -271,7 +272,7 @@ class VirusTotal():
with vt_file.open('w') as _f: with vt_file.open('w') as _f:
json.dump(url_information.to_dict(), _f) json.dump(url_information.to_dict(), _f)
break break
except vt.APIError as e: except APIError as e:
if not self.autosubmit: if not self.autosubmit:
break break
if not scan_requested and e.code == 'NotFoundError': if not scan_requested and e.code == 'NotFoundError':