fix: [domain UI] fix correlation card + language search

pull/594/head
Terrtia 2023-04-21 10:26:14 +02:00
parent 79fa5dc30b
commit 6338268e8c
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
6 changed files with 45 additions and 48 deletions

View File

@ -74,16 +74,24 @@ def get_nb_correlations(obj_type, subtype, obj_id, filter_types=[]):
obj_correlations[correl_type] = get_nb_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type)
return obj_correlations
def get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type):
return r_metadata.smembers(f'correlation:obj:{obj_type}:{subtype}:{correl_type}:{obj_id}')
def get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type, unpack=False):
correl = r_metadata.smembers(f'correlation:obj:{obj_type}:{subtype}:{correl_type}:{obj_id}')
if unpack:
unpacked = []
for str_correl in correl:
unpacked.append(str_correl.split(':', 1))
return unpacked
else:
return correl
def get_correlations(obj_type, subtype, obj_id, filter_types=[]):
def get_correlations(obj_type, subtype, obj_id, filter_types=[], unpack=False):
if subtype is None:
subtype = ''
obj_correlations = {}
filter_types = sanityze_obj_correl_types(obj_type, filter_types)
for correl_type in filter_types:
obj_correlations[correl_type] = get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type)
obj_correlations[correl_type] = get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type,
unpack=unpack)
return obj_correlations
def exists_obj_correlation(obj_type, subtype, obj_id, obj2_type):

View File

@ -213,11 +213,11 @@ class AbstractObject(ABC):
"""
return get_correlations(self.type, self.subtype, self.id, filter_types=[obj_type])
def get_correlations(self, filter_types=[]):
def get_correlations(self, filter_types=[], unpack=False):
"""
Get object correlations
"""
return get_correlations(self.type, self.subtype, self.id, filter_types=filter_types)
return get_correlations(self.type, self.subtype, self.id, filter_types=filter_types, unpack=unpack)
def get_nb_correlation(self, correl_type):
return get_nb_correlation_by_correl_type(self.type, self.get_subtype(r_str=True), self.id, correl_type)

View File

@ -61,8 +61,8 @@ def create_json_response(data, status_code):
def crawlers_dashboard():
is_manager_connected = crawlers.get_lacus_connection_metadata()
crawlers_status = crawlers.get_captures_status()
# print(crawlers_status)
crawlers_latest_stats = crawlers.get_crawlers_stats()
# print(crawlers_status)
# print(crawlers_latest_stats)
date = crawlers.get_current_date()
return render_template("dashboard_crawler.html", date=date,
@ -290,7 +290,7 @@ def showDomain():
dict_domain = domain.get_meta(options=['last_origin', 'languages'])
dict_domain['domain'] = domain.id
if domain.was_up():
dict_domain = {**dict_domain, **domain.get_correlations()}
dict_domain = {**dict_domain, **domain.get_correlations(unpack=True)}
dict_domain['correlation_nb'] = len(dict_domain['decoded']) + len(dict_domain['username']) + len(
dict_domain['pgp']) + len(dict_domain['cryptocurrency']) + len(dict_domain['screenshot'])
dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags'])

View File

@ -284,7 +284,7 @@
// On click, get html content from url and update the corresponding modal
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
var modal=$(this);
var url = " {{ url_for('showsavedpastes.showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
var url = " {{ url_for('objects_item.item_preview') }}?id=" + $(this).attr('data-path');
last_clicked_paste = $(this).attr('data-num');
$.get(url, function (data) {

View File

@ -191,7 +191,7 @@
<tbody>
{% for decoded in dict_domain['decoded']%}
<tr>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=decoded&id={{ decoded }}">{{ decoded }}</a></td>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=decoded&id={{ decoded[1] }}">{{ decoded[1] }}</a></td>
</tr>
{% endfor %}
</tbody>
@ -230,26 +230,21 @@
</tr>
</thead>
<tbody>
{% for dict_key in dict_domain['pgp']%}
{% if dict_key != "nb" %}
{% if dict_key=="mail" %}
{% for row in dict_domain['pgp']%}
{% if row[0] != "mail" %}
{% set var_icon = "fas fa-at" %}
{% elif dict_key=="name" %}
{% elif row[0]=="name" %}
{% set var_icon = "fas fa-user-tag" %}
{% else %}
{% else %}
{% set var_icon = "fas fa-key" %}
{% endif %}
{% for key_id in dict_domain['pgp'][dict_key]%}
<tr>
<td>
<i class="{{ var_icon }}"></i>
&nbsp;&nbsp;{{ dict_key }}
</td>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=pgp&subtype={{ dict_key }}&id={{ key_id }}">{{ key_id }}</a></td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
<tr>
<td>
<i class="{{ var_icon }}"></i>&nbsp;&nbsp;{{ row[0] }}
</td>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=pgp&subtype={{ row[0] }}&id={{ row[1] }}">{{ row[1] }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
@ -258,8 +253,6 @@
</div>
{% endif %}
{{dict_domain['cryptocurrency']}}
{% if dict_domain['cryptocurrency']%}
<div id="accordioncurrency" class="mt-3">
<div class="card">
@ -288,27 +281,23 @@
</tr>
</thead>
<tbody>
{% for dict_key in dict_domain['cryptocurrency']%}
{% if dict_key != "nb" %}
{% if dict_key=="bitcoin" %}
{% for row in dict_domain['cryptocurrency']%}
{% if dict_key=="bitcoin" %}
{% set var_icon = "fab fa-bitcoin" %}
{% elif dict_key=="monero" %}
{% elif dict_key=="monero" %}
{% set var_icon = "fab fa-monero" %}
{% else %}
{% else %}
{% set var_icon = "fas fa-coins" %}
{% endif %}
{% for key_id in dict_domain['cryptocurrency'][dict_key]%}
<tr>
<td>
<i class="{{ var_icon }}"></i>
&nbsp;&nbsp;{{ dict_key }}
</td>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=cryptocurrency&subtype={{ dict_key }}&id={{ key_id }}">{{ key_id }}</a></td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
<tr>
<td>
<i class="{{ var_icon }}"></i>&nbsp;&nbsp;{{ row[0] }}
</td>
<td>
<a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=cryptocurrency&subtype={{ row[0] }}&id={{ row[1] }}">{{ row[1] }}</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
@ -345,9 +334,9 @@
</tr>
</thead>
<tbody>
{% for screenshot in dict_domain['screenshot']%}
{% for row in dict_domain['screenshot']%}
<tr>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=screenshot&id={{ screenshot }}">{{ screenshot }}</a></td>
<td><a target="_blank" href="{{ url_for('correlation.show_correlation') }}?type=screenshot&id={{ row[1] }}">{{ row[1] }}</a></td>
</tr>
{% endfor %}
</tbody>

View File

@ -179,7 +179,7 @@ blocks.addEventListener('change', pixelate_all, false);
{% for dict_domain in l_dict_domains['list_elem'] %}
{% if 'screenshot' in dict_domain %}
{% if dict_domain['is_tags_safe'] %}
var screenshot_url = "{{ url_for('showsavedpastes.screenshot', filename="") }}{{dict_domain['screenshot']}}";
var screenshot_url = "{{ url_for('objects_item.screenshot', filename="") }}{{dict_domain['screenshot']}}";
{% else %}
var screenshot_url = "{{ url_for('static', filename='image/AIL.png') }}";
{% endif %}