fix: [UI showDomain] fix down domain history

This commit is contained in:
Terrtia 2019-12-16 15:55:50 +01:00
parent fffb4464c6
commit b4f49f9e81
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
4 changed files with 69 additions and 64 deletions

View file

@ -283,6 +283,7 @@ def get_domain_items_crawled(domain, domain_type, port, epoch=None, items_link=F
item_crawled['epoch'] = item_root['epoch'] item_crawled['epoch'] = item_root['epoch']
item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch'])) item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch']))
item_crawled['items'] = [] item_crawled['items'] = []
if item_root['root_item'] != str(item_root['epoch']):
for item in get_domain_items(domain, item_root['root_item']): for item in get_domain_items(domain, item_root['root_item']):
dict_item = {"id": item} dict_item = {"id": item}
if items_link: if items_link:
@ -540,7 +541,7 @@ class Domain(object):
def __init__(self, domain, port=None): def __init__(self, domain, port=None):
self.domain = str(domain) self.domain = str(domain)
self.type = get_domain_type(domain) self.type = get_domain_type(domain)
if self.is_domain_up(): if self.domain_was_up():
self.current_port = sanathyse_port(port, self.domain, self.type) self.current_port = sanathyse_port(port, self.domain, self.type)
def get_domain_name(self): def get_domain_name(self):

View file

@ -61,7 +61,7 @@ def showDomain():
dict_domain = domain.get_domain_metadata() dict_domain = domain.get_domain_metadata()
dict_domain['domain'] = domain_name dict_domain['domain'] = domain_name
if domain.is_domain_up(): if domain.domain_was_up():
dict_domain = {**dict_domain, **domain.get_domain_correlation()} dict_domain = {**dict_domain, **domain.get_domain_correlation()}
dict_domain['correlation_nb'] = Domain.get_domain_total_nb_correlation(dict_domain) dict_domain['correlation_nb'] = Domain.get_domain_total_nb_correlation(dict_domain)
dict_domain['origin_item'] = domain.get_domain_last_origin() dict_domain['origin_item'] = domain.get_domain_last_origin()
@ -69,6 +69,7 @@ def showDomain():
dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags']) dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags'])
dict_domain['history'] = domain.get_domain_history_with_status() dict_domain['history'] = domain.get_domain_history_with_status()
dict_domain['crawler_history'] = domain.get_domain_items_crawled(items_link=True, epoch=epoch, item_screenshot=True, item_tag=True) # # TODO: handle multiple port dict_domain['crawler_history'] = domain.get_domain_items_crawled(items_link=True, epoch=epoch, item_screenshot=True, item_tag=True) # # TODO: handle multiple port
if dict_domain['crawler_history']['items']:
dict_domain['crawler_history']['random_item'] = random.choice(dict_domain['crawler_history']['items']) dict_domain['crawler_history']['random_item'] = random.choice(dict_domain['crawler_history']['items'])
return render_template("showDomain.html", dict_domain=dict_domain, bootstrap_label=bootstrap_label, return render_template("showDomain.html", dict_domain=dict_domain, bootstrap_label=bootstrap_label,

View file

@ -287,11 +287,12 @@
{{dict_domain["crawler_history"]["port"]}} {{dict_domain["crawler_history"]["port"]}}
</span> </span>
</div> </div>
<h5>Crawled Items</h5> <h5>Crawled Items {% if not dict_domain["crawler_history"]["items"] %}: DOWN{% endif %}</h5>
</div> </div>
</div> </div>
{% if dict_domain["crawler_history"]["items"] %}
<table class="table table-striped table-bordered table-hover" id="myTable_1"> <table class="table table-striped table-bordered table-hover" id="myTable_1">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
@ -334,6 +335,7 @@
</a> </a>
</div> </div>
{%endif%} {%endif%}
{%endif%}
{% if dict_domain["history"] %} {% if dict_domain["history"] %}
<table class="table table-hover mt-2" id="myTable_2"> <table class="table table-hover mt-2" id="myTable_2">
@ -456,18 +458,19 @@ img.addEventListener("error", img_error);
var draw_img = false; var draw_img = false;
{%if "crawler_history" in dict_domain%} {%if "crawler_history" in dict_domain%}
{%if "random_item" in dict_domain['crawler_history']%}
{%if dict_domain['crawler_history']['random_item']['screenshot']%} {%if dict_domain['crawler_history']['random_item']['screenshot']%}
var screenshot = "{{dict_domain['crawler_history']['random_item']['screenshot']}}"; var screenshot = "{{dict_domain['crawler_history']['random_item']['screenshot']}}";
var selected_icon = $("#"+screenshot.replace(/\//g, "")); var selected_icon = $("#"+screenshot.replace(/\//g, ""));
selected_icon.addClass("icon_selected"); selected_icon.addClass("icon_selected");
selected_icon.removeClass("icon_img"); selected_icon.removeClass("icon_img");
$("#screenshot_link").attr("href", screenshot_href + "{{dict_domain['crawler_history']['random_item']['id']}}"); $("#screenshot_link").attr("href", screenshot_href + "{{dict_domain['crawler_history']['random_item']['id']}}");
$("#screenshot_link").text("{{dict_domain['crawler_history']['random_item']['link']}}"); $("#screenshot_link").text("{{dict_domain['crawler_history']['random_item']['link']}}");
{%else%} {%else%}
var screenshot = ""; var screenshot = "";
{%endif%} {%endif%}
{%endif%}
{%else%} {%else%}
var screenshot = ""; var screenshot = "";
{%endif%} {%endif%}