mirror of https://github.com/CIRCL/lookyloo
chg: use cache instead of get_info everywhere.
parent
94b3b487f3
commit
3e7f1c3de9
|
@ -427,7 +427,12 @@ class Lookyloo():
|
||||||
def capture_cache(self, capture_uuid: str, /) -> Optional[CaptureCache]:
|
def capture_cache(self, capture_uuid: str, /) -> Optional[CaptureCache]:
|
||||||
"""Get the cache from redis, rebuild the tree if the internal UUID changed => slow"""
|
"""Get the cache from redis, rebuild the tree if the internal UUID changed => slow"""
|
||||||
try:
|
try:
|
||||||
return self._captures_index[capture_uuid]
|
cache = self._captures_index[capture_uuid]
|
||||||
|
# 2022-12-07: New cache format, store the user agent and referers. Re-cache if needed
|
||||||
|
if cache and not cache.user_agent:
|
||||||
|
self._captures_index.reload_cache(capture_uuid)
|
||||||
|
cache = self._captures_index[capture_uuid]
|
||||||
|
return cache
|
||||||
except NoValidHarFile:
|
except NoValidHarFile:
|
||||||
self.logger.debug('No HAR files, {capture_uuid} is a broken capture.')
|
self.logger.debug('No HAR files, {capture_uuid} is a broken capture.')
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -662,7 +662,6 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
ct = lookyloo.get_crawled_tree(tree_uuid)
|
ct = lookyloo.get_crawled_tree(tree_uuid)
|
||||||
b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True)
|
b64_thumbnail = lookyloo.get_screenshot_thumbnail(tree_uuid, for_datauri=True)
|
||||||
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
|
screenshot_size = lookyloo.get_screenshot(tree_uuid).getbuffer().nbytes
|
||||||
info = lookyloo.get_info(tree_uuid)
|
|
||||||
meta = lookyloo.get_meta(tree_uuid)
|
meta = lookyloo.get_meta(tree_uuid)
|
||||||
hostnode_to_highlight = None
|
hostnode_to_highlight = None
|
||||||
if node_uuid:
|
if node_uuid:
|
||||||
|
@ -682,7 +681,7 @@ def tree(tree_uuid: str, node_uuid: Optional[str]=None):
|
||||||
if cache.error:
|
if cache.error:
|
||||||
flash(cache.error, 'warning')
|
flash(cache.error, 'warning')
|
||||||
return render_template('tree.html', tree_json=ct.to_json(),
|
return render_template('tree.html', tree_json=ct.to_json(),
|
||||||
info=info,
|
info=cache,
|
||||||
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
tree_uuid=tree_uuid, public_domain=lookyloo.public_domain,
|
||||||
screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
|
screenshot_thumbnail=b64_thumbnail, page_title=cache.title,
|
||||||
screenshot_size=screenshot_size,
|
screenshot_size=screenshot_size,
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
{% from 'bootstrap5/utils.html' import render_messages %}
|
{% from 'bootstrap5/utils.html' import render_messages %}
|
||||||
{% from "macros.html" import shorten_string %}
|
{% from "macros.html" import shorten_string %}
|
||||||
|
|
||||||
{% block title %}Capture of {{info['url']}}{% endblock %}
|
{% block title %}Capture of {{info.url}}{% endblock %}
|
||||||
|
|
||||||
{% block card %}
|
{% block card %}
|
||||||
<meta property="og:title" content="Lookyloo capture" />
|
<meta property="og:title" content="Lookyloo capture" />
|
||||||
<meta property="og:type" content="website"/>
|
<meta property="og:type" content="website"/>
|
||||||
<meta
|
<meta
|
||||||
property="og:description"
|
property="og:description"
|
||||||
content="URL captured: {{info['url']}}"
|
content="URL captured: {{info.url}}"
|
||||||
/>
|
/>
|
||||||
<meta
|
<meta
|
||||||
property="og:image"
|
property="og:image"
|
||||||
|
@ -148,7 +148,7 @@
|
||||||
var enable_bookmark = {{ enable_bookmark|tojson }};
|
var enable_bookmark = {{ enable_bookmark|tojson }};
|
||||||
var treeData = {{ tree_json | safe }};
|
var treeData = {{ tree_json | safe }};
|
||||||
var parent_uuid = {{ parent_uuid|tojson }};
|
var parent_uuid = {{ parent_uuid|tojson }};
|
||||||
var capture_starttime = new Date(Date.parse("{{ info['capture_time'] }}"));
|
var capture_starttime = new Date(Date.parse("{{ info.timestamp.isoformat() }}"));
|
||||||
window.addEventListener('DOMContentLoaded', (event) => {
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
document.getElementById("start_time").innerHTML =
|
document.getElementById("start_time").innerHTML =
|
||||||
`${capture_starttime.getFullYear()}-${("0" + (capture_starttime.getMonth() + 1)).slice(-2)}-${("0" + capture_starttime.getDate()).slice(-2)} ${capture_starttime.toLocaleTimeString()}`;
|
`${capture_starttime.getFullYear()}-${("0" + (capture_starttime.getMonth() + 1)).slice(-2)}-${("0" + capture_starttime.getDate()).slice(-2)} ${capture_starttime.toLocaleTimeString()}`;
|
||||||
|
@ -413,20 +413,20 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<dl class="row">
|
<dl class="row">
|
||||||
<dt class="col-sm-2">URL captured</dt>
|
<dt class="col-sm-2">URL captured</dt>
|
||||||
<dd class="col-sm-10">{{ shorten_string(info['url'], 1000) }}</dd>
|
<dd class="col-sm-10">{{ shorten_string(info.url, 1000) }}</dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">Page title</dt>
|
<dt class="col-sm-2">Page title</dt>
|
||||||
<dd class="col-sm-10">{{ info['title'] }}</dd>
|
<dd class="col-sm-10">{{ info.title }}</dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">Capture time</dt>
|
<dt class="col-sm-2">Capture time</dt>
|
||||||
<dd class="col-sm-10" id="start_time"></dd>
|
<dd class="col-sm-10" id="start_time"></dd>
|
||||||
|
|
||||||
<dt class="col-sm-2">User Agent</dt>
|
<dt class="col-sm-2">User Agent</dt>
|
||||||
<dd class="col-sm-10">{{ info['user_agent'] }}</dd>
|
<dd class="col-sm-10">{{ info.user_agent }}</dd>
|
||||||
|
|
||||||
{% if 'referer' in info and info['referer'] %}
|
{% if info.referer %}
|
||||||
<dt class="col-sm-2">Referer</dt>
|
<dt class="col-sm-2">Referer</dt>
|
||||||
<dd class="col-sm-10">{{ info['referer'] }}</dd>
|
<dd class="col-sm-10">{{ info.referer }}</dd>
|
||||||
{%endif%}
|
{%endif%}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue