fix: Make mypy happy.

pull/165/head
Raphaël Vinot 2021-01-28 19:28:54 +01:00
parent acfb0d1c26
commit c358c08640
2 changed files with 6 additions and 8 deletions

View File

@ -25,7 +25,7 @@ import dns.resolver
import dns.rdatatype
from har2tree import CrawledTree, Har2TreeError, HarFile, HostNode, URLNode
from PIL import Image # type: ignore
from pymisp import MISPEvent
from pymisp import MISPEvent, MISPAttribute
from pymisp.tools import URLObject, FileObject
from redis import Redis
from scrapysplashwrapper import crawl
@ -916,7 +916,7 @@ class Lookyloo():
event = MISPEvent()
event.info = f'Lookyloo Capture ({cache.url})'
lookyloo_link = event.add_attribute('link', f'https://{self.public_domain}/tree/{capture_uuid}')
lookyloo_link: MISPAttribute = event.add_attribute('link', f'https://{self.public_domain}/tree/{capture_uuid}') # type: ignore
initial_url = URLObject(cache.url)
redirects = [URLObject(url) for url in cache.redirects if url != cache.url]
@ -933,7 +933,7 @@ class Lookyloo():
for u_object in redirects:
event.add_object(u_object)
screenshot = event.add_attribute('attachment', 'screenshot_landing_page.png', data=self.get_screenshot(capture_uuid), disable_correlation=True)
screenshot: MISPAttribute = event.add_attribute('attachment', 'screenshot_landing_page.png', data=self.get_screenshot(capture_uuid), disable_correlation=True) # type: ignore
try:
fo = FileObject(pseudofile=ct.root_hartree.rendered_node.body, filename='body_response.html')
fo.comment = 'Content received for the final redirect (before rendering)'

View File

@ -781,7 +781,7 @@ def misp_export(tree_uuid: str):
@app.route('/json/<string:tree_uuid>/misp_push', methods=['GET'])
@auth.login_required
def misp_push(tree_uuid: str):
to_return = {}
to_return: Dict = {}
if not lookyloo.misp.available:
to_return['error'] = 'MISP module not available.'
elif not lookyloo.misp.enable_push:
@ -793,13 +793,11 @@ def misp_push(tree_uuid: str):
else:
event = lookyloo.misp.push(event)
if isinstance(event, MISPEvent):
to_return = event.to_json(indent=2)
return Response(event.to_json(indent=2), mimetype='application/json')
else:
to_return['error'] = event
if isinstance(to_return, dict):
to_return = json.dumps(to_return, indent=2)
return Response(to_return, mimetype='application/json')
return jsonify(to_return)
@app.route('/json/hash_info/<h>', methods=['GET'])