diff --git a/bin/lib/correlations_engine.py b/bin/lib/correlations_engine.py index bf234c9c..8e29837d 100755 --- a/bin/lib/correlations_engine.py +++ b/bin/lib/correlations_engine.py @@ -167,20 +167,22 @@ def delete_obj_correlations(obj_type, subtype, obj_id): def get_obj_str_id(obj_type, subtype, obj_id): if subtype is None: subtype = '' - return f'{obj_type};{subtype};{obj_id}' + return f'{obj_type}:{subtype}:{obj_id}' def get_correlations_graph_nodes_links(obj_type, subtype, obj_id, filter_types=[], max_nodes=300, level=1, flask_context=False): links = set() nodes = set() + meta = {'complete': True, 'objs': set()} obj_str_id = get_obj_str_id(obj_type, subtype, obj_id) - _get_correlations_graph_node(links, nodes, obj_type, subtype, obj_id, level, max_nodes, filter_types=filter_types, previous_str_obj='') - return obj_str_id, nodes, links + _get_correlations_graph_node(links, nodes, meta, obj_type, subtype, obj_id, level, max_nodes, filter_types=filter_types, previous_str_obj='') + return obj_str_id, nodes, links, meta -def _get_correlations_graph_node(links, nodes, obj_type, subtype, obj_id, level, max_nodes, filter_types=[], previous_str_obj=''): +def _get_correlations_graph_node(links, nodes, meta, obj_type, subtype, obj_id, level, max_nodes, filter_types=[], previous_str_obj=''): obj_str_id = get_obj_str_id(obj_type, subtype, obj_id) + meta['objs'].add(obj_str_id) nodes.add(obj_str_id) obj_correlations = get_correlations(obj_type, subtype, obj_id, filter_types=filter_types) @@ -189,15 +191,18 @@ def _get_correlations_graph_node(links, nodes, obj_type, subtype, obj_id, level, for str_obj in obj_correlations[correl_type]: subtype2, obj2_id = str_obj.split(':', 1) obj2_str_id = get_obj_str_id(correl_type, subtype2, obj2_id) + meta['objs'].add(obj2_str_id) if obj2_str_id == previous_str_obj: continue if len(nodes) > max_nodes != 0: + meta['complete'] = False break nodes.add(obj2_str_id) links.add((obj_str_id, obj2_str_id)) if level > 0: next_level = level - 1 - _get_correlations_graph_node(links, nodes, correl_type, subtype2, obj2_id, next_level, max_nodes, filter_types=filter_types, previous_str_obj=obj_str_id) + _get_correlations_graph_node(links, nodes, meta, correl_type, subtype2, obj2_id, next_level, max_nodes, filter_types=filter_types, previous_str_obj=obj_str_id) + diff --git a/bin/lib/objects/ail_objects.py b/bin/lib/objects/ail_objects.py index b17ce3e6..df598a70 100755 --- a/bin/lib/objects/ail_objects.py +++ b/bin/lib/objects/ail_objects.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 # -*-coding:UTF-8 -* - import os import sys @@ -169,7 +168,7 @@ def get_object_card_meta(obj_type, subtype, id, related_btc=False): obj = get_object(obj_type, subtype, id) meta = obj.get_meta() meta['icon'] = obj.get_svg_icon() - if subtype or obj_type == 'cve' or obj_type == 'title' or obj_type == 'favicon': + if subtype or obj_type == 'cookie-name' or obj_type == 'cve' or obj_type == 'title' or obj_type == 'favicon': meta['sparkline'] = obj.get_sparkline() if obj_type == 'cve': meta['cve_search'] = obj.get_cve_search() @@ -396,7 +395,7 @@ def create_correlation_graph_links(links_set): def create_correlation_graph_nodes(nodes_set, obj_str_id, flask_context=True): graph_nodes_list = [] for node_id in nodes_set: - obj_type, subtype, obj_id = node_id.split(';', 2) + obj_type, subtype, obj_id = node_id.split(':', 2) dict_node = {'id': node_id} dict_node['style'] = get_object_svg(obj_type, subtype, obj_id) @@ -418,12 +417,15 @@ def create_correlation_graph_nodes(nodes_set, obj_str_id, flask_context=True): def get_correlations_graph_node(obj_type, subtype, obj_id, filter_types=[], max_nodes=300, level=1, flask_context=False): - obj_str_id, nodes, links = correlations_engine.get_correlations_graph_nodes_links(obj_type, subtype, obj_id, - filter_types=filter_types, - max_nodes=max_nodes, level=level, - flask_context=flask_context) + obj_str_id, nodes, links, meta = correlations_engine.get_correlations_graph_nodes_links(obj_type, subtype, obj_id, + filter_types=filter_types, + max_nodes=max_nodes, level=level, + flask_context=flask_context) + # print(meta) + meta['objs'] = list(meta['objs']) return {"nodes": create_correlation_graph_nodes(nodes, obj_str_id, flask_context=flask_context), - "links": create_correlation_graph_links(links)} + "links": create_correlation_graph_links(links), + "meta": meta} # --- CORRELATION --- # diff --git a/var/www/blueprints/correlation.py b/var/www/blueprints/correlation.py index bcf61729..f6e7feda 100644 --- a/var/www/blueprints/correlation.py +++ b/var/www/blueprints/correlation.py @@ -156,7 +156,7 @@ def show_correlation(): @login_read_only def get_description(): object_id = request.args.get('object_id') - object_id = object_id.split(';') + object_id = object_id.split(':') # unpack object_id # # TODO: put me in lib if len(object_id) == 3: object_type = object_id[0] diff --git a/var/www/templates/correlation/show_correlation.html b/var/www/templates/correlation/show_correlation.html index 93ca5c2b..95aa922c 100644 --- a/var/www/templates/correlation/show_correlation.html +++ b/var/www/templates/correlation/show_correlation.html @@ -162,6 +162,9 @@ Resize Graph +