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

This commit is contained in:
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) obj_correlations[correl_type] = get_nb_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type)
return obj_correlations return obj_correlations
def get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type): def get_correlation_by_correl_type(obj_type, subtype, obj_id, correl_type, unpack=False):
return r_metadata.smembers(f'correlation:obj:{obj_type}:{subtype}:{correl_type}:{obj_id}') 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: if subtype is None:
subtype = '' subtype = ''
obj_correlations = {} obj_correlations = {}
filter_types = sanityze_obj_correl_types(obj_type, filter_types) filter_types = sanityze_obj_correl_types(obj_type, filter_types)
for correl_type in 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 return obj_correlations
def exists_obj_correlation(obj_type, subtype, obj_id, obj2_type): 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]) 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 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): 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) 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(): def crawlers_dashboard():
is_manager_connected = crawlers.get_lacus_connection_metadata() is_manager_connected = crawlers.get_lacus_connection_metadata()
crawlers_status = crawlers.get_captures_status() crawlers_status = crawlers.get_captures_status()
# print(crawlers_status)
crawlers_latest_stats = crawlers.get_crawlers_stats() crawlers_latest_stats = crawlers.get_crawlers_stats()
# print(crawlers_status)
# print(crawlers_latest_stats) # print(crawlers_latest_stats)
date = crawlers.get_current_date() date = crawlers.get_current_date()
return render_template("dashboard_crawler.html", date=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.get_meta(options=['last_origin', 'languages'])
dict_domain['domain'] = domain.id dict_domain['domain'] = domain.id
if domain.was_up(): 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['correlation_nb'] = len(dict_domain['decoded']) + len(dict_domain['username']) + len(
dict_domain['pgp']) + len(dict_domain['cryptocurrency']) + len(dict_domain['screenshot']) dict_domain['pgp']) + len(dict_domain['cryptocurrency']) + len(dict_domain['screenshot'])
dict_domain['tags_safe'] = Tag.is_tags_safe(dict_domain['tags']) 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 // On click, get html content from url and update the corresponding modal
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) { $("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
var modal=$(this); 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'); last_clicked_paste = $(this).attr('data-num');
$.get(url, function (data) { $.get(url, function (data) {

View file

@ -191,7 +191,7 @@
<tbody> <tbody>
{% for decoded in dict_domain['decoded']%} {% for decoded in dict_domain['decoded']%}
<tr> <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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@ -230,26 +230,21 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for dict_key in dict_domain['pgp']%} {% for row in dict_domain['pgp']%}
{% if dict_key != "nb" %} {% if row[0] != "mail" %}
{% if dict_key=="mail" %}
{% set var_icon = "fas fa-at" %} {% set var_icon = "fas fa-at" %}
{% elif dict_key=="name" %} {% elif row[0]=="name" %}
{% set var_icon = "fas fa-user-tag" %} {% set var_icon = "fas fa-user-tag" %}
{% else %} {% else %}
{% set var_icon = "fas fa-key" %} {% 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 %} {% 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> </tbody>
</table> </table>
</div> </div>
@ -258,8 +253,6 @@
</div> </div>
{% endif %} {% endif %}
{{dict_domain['cryptocurrency']}}
{% if dict_domain['cryptocurrency']%} {% if dict_domain['cryptocurrency']%}
<div id="accordioncurrency" class="mt-3"> <div id="accordioncurrency" class="mt-3">
<div class="card"> <div class="card">
@ -288,27 +281,23 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for dict_key in dict_domain['cryptocurrency']%} {% for row in dict_domain['cryptocurrency']%}
{% if dict_key=="bitcoin" %}
{% if dict_key != "nb" %}
{% if dict_key=="bitcoin" %}
{% set var_icon = "fab fa-bitcoin" %} {% set var_icon = "fab fa-bitcoin" %}
{% elif dict_key=="monero" %} {% elif dict_key=="monero" %}
{% set var_icon = "fab fa-monero" %} {% set var_icon = "fab fa-monero" %}
{% else %} {% else %}
{% set var_icon = "fas fa-coins" %} {% 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 %} {% 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> </tbody>
</table> </table>
</div> </div>
@ -345,9 +334,9 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for screenshot in dict_domain['screenshot']%} {% for row in dict_domain['screenshot']%}
<tr> <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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View file

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