fix: Avoid exceptions when the submission is a file

pull/588/head
Raphaël Vinot 2023-01-24 15:23:59 +01:00
parent b020184b1f
commit eab4b17070
4 changed files with 17 additions and 5 deletions

View File

@ -60,6 +60,8 @@ class FOX():
'''
if not self.available:
raise ConfigError('FOX not available, probably no API key')
if url.startswith('file'):
return {'error': 'FOX does not support files.'}
if self.autosubmit:
# submit is allowed and we either force it, or it's just allowed

View File

@ -166,15 +166,19 @@ class MISP():
directly to a MISP instance and it will create an event.'''
public_domain = get_config('generic', 'public_domain')
event = MISPEvent()
event.info = f'Lookyloo Capture ({cache.url})'
if cache.url.startswith('file'):
filename = cache.url.rsplit('/', 1)[-1]
event.info = f'Lookyloo Capture ({filename})'
else:
event.info = f'Lookyloo Capture ({cache.url})'
initial_url = URLObject(cache.url)
initial_url.comment = 'Submitted URL'
self.__misp_add_ips_to_URLObject(initial_url, cache.tree.root_hartree.hostname_tree)
lookyloo_link: MISPAttribute = event.add_attribute('link', f'https://{public_domain}/tree/{cache.uuid}') # type: ignore
if not is_public_instance:
lookyloo_link.distribution = 0
initial_url = URLObject(cache.url)
initial_url.comment = 'Submitted URL'
self.__misp_add_ips_to_URLObject(initial_url, cache.tree.root_hartree.hostname_tree)
redirects: List[URLObject] = []
for nb, url in enumerate(cache.redirects):
if url == cache.url:
@ -183,6 +187,7 @@ class MISP():
obj.comment = f'Redirect {nb}'
self.__misp_add_ips_to_URLObject(obj, cache.tree.root_hartree.hostname_tree)
redirects.append(obj)
if redirects:
redirects[-1].comment = f'Last redirect ({nb})'

View File

@ -83,6 +83,8 @@ class RiskIQ():
return {'error': 'Module not available'}
if auto_trigger and not self.allow_auto_trigger:
return {'error': 'Auto trigger not allowed on module'}
if cache.url.startswith('file'):
return {'error': 'RiskIQ does not support files.'}
if cache.redirects:
hostname = urlparse(cache.redirects[-1]).hostname

View File

@ -118,6 +118,9 @@ class UrlScan():
if not self.available:
raise ConfigError('UrlScan not available, probably no API key')
if capture_info.url.startswith('file'):
return {'error': 'URLScan does not support files.'}
url_storage_dir = get_cache_directory(
self.storage_dir_urlscan,
f'{capture_info.url}{capture_info.user_agent}{capture_info.referer}',