mirror of https://github.com/CIRCL/lookyloo
fix: Make mypy happy.
parent
acfb0d1c26
commit
c358c08640
|
@ -25,7 +25,7 @@ import dns.resolver
|
||||||
import dns.rdatatype
|
import dns.rdatatype
|
||||||
from har2tree import CrawledTree, Har2TreeError, HarFile, HostNode, URLNode
|
from har2tree import CrawledTree, Har2TreeError, HarFile, HostNode, URLNode
|
||||||
from PIL import Image # type: ignore
|
from PIL import Image # type: ignore
|
||||||
from pymisp import MISPEvent
|
from pymisp import MISPEvent, MISPAttribute
|
||||||
from pymisp.tools import URLObject, FileObject
|
from pymisp.tools import URLObject, FileObject
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
from scrapysplashwrapper import crawl
|
from scrapysplashwrapper import crawl
|
||||||
|
@ -916,7 +916,7 @@ class Lookyloo():
|
||||||
|
|
||||||
event = MISPEvent()
|
event = MISPEvent()
|
||||||
event.info = f'Lookyloo Capture ({cache.url})'
|
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)
|
initial_url = URLObject(cache.url)
|
||||||
redirects = [URLObject(url) for url in cache.redirects if url != 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:
|
for u_object in redirects:
|
||||||
event.add_object(u_object)
|
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:
|
try:
|
||||||
fo = FileObject(pseudofile=ct.root_hartree.rendered_node.body, filename='body_response.html')
|
fo = FileObject(pseudofile=ct.root_hartree.rendered_node.body, filename='body_response.html')
|
||||||
fo.comment = 'Content received for the final redirect (before rendering)'
|
fo.comment = 'Content received for the final redirect (before rendering)'
|
||||||
|
|
|
@ -781,7 +781,7 @@ def misp_export(tree_uuid: str):
|
||||||
@app.route('/json/<string:tree_uuid>/misp_push', methods=['GET'])
|
@app.route('/json/<string:tree_uuid>/misp_push', methods=['GET'])
|
||||||
@auth.login_required
|
@auth.login_required
|
||||||
def misp_push(tree_uuid: str):
|
def misp_push(tree_uuid: str):
|
||||||
to_return = {}
|
to_return: Dict = {}
|
||||||
if not lookyloo.misp.available:
|
if not lookyloo.misp.available:
|
||||||
to_return['error'] = 'MISP module not available.'
|
to_return['error'] = 'MISP module not available.'
|
||||||
elif not lookyloo.misp.enable_push:
|
elif not lookyloo.misp.enable_push:
|
||||||
|
@ -793,13 +793,11 @@ def misp_push(tree_uuid: str):
|
||||||
else:
|
else:
|
||||||
event = lookyloo.misp.push(event)
|
event = lookyloo.misp.push(event)
|
||||||
if isinstance(event, MISPEvent):
|
if isinstance(event, MISPEvent):
|
||||||
to_return = event.to_json(indent=2)
|
return Response(event.to_json(indent=2), mimetype='application/json')
|
||||||
else:
|
else:
|
||||||
to_return['error'] = event
|
to_return['error'] = event
|
||||||
|
|
||||||
if isinstance(to_return, dict):
|
return jsonify(to_return)
|
||||||
to_return = json.dumps(to_return, indent=2)
|
|
||||||
return Response(to_return, mimetype='application/json')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/json/hash_info/<h>', methods=['GET'])
|
@app.route('/json/hash_info/<h>', methods=['GET'])
|
||||||
|
|
Loading…
Reference in New Issue