mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
chg: [correlation graph] show message if max_nodes reached + fix cookie-name sparkline
This commit is contained in:
parent
501d10bbbd
commit
4567c9d400
5 changed files with 33 additions and 16 deletions
|
@ -167,20 +167,22 @@ def delete_obj_correlations(obj_type, subtype, obj_id):
|
||||||
def get_obj_str_id(obj_type, subtype, obj_id):
|
def get_obj_str_id(obj_type, subtype, obj_id):
|
||||||
if subtype is None:
|
if subtype is None:
|
||||||
subtype = ''
|
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):
|
def get_correlations_graph_nodes_links(obj_type, subtype, obj_id, filter_types=[], max_nodes=300, level=1, flask_context=False):
|
||||||
links = set()
|
links = set()
|
||||||
nodes = set()
|
nodes = set()
|
||||||
|
meta = {'complete': True, 'objs': set()}
|
||||||
|
|
||||||
obj_str_id = get_obj_str_id(obj_type, subtype, obj_id)
|
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='')
|
_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
|
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)
|
obj_str_id = get_obj_str_id(obj_type, subtype, obj_id)
|
||||||
|
meta['objs'].add(obj_str_id)
|
||||||
nodes.add(obj_str_id)
|
nodes.add(obj_str_id)
|
||||||
|
|
||||||
obj_correlations = get_correlations(obj_type, subtype, obj_id, filter_types=filter_types)
|
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]:
|
for str_obj in obj_correlations[correl_type]:
|
||||||
subtype2, obj2_id = str_obj.split(':', 1)
|
subtype2, obj2_id = str_obj.split(':', 1)
|
||||||
obj2_str_id = get_obj_str_id(correl_type, subtype2, obj2_id)
|
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:
|
if obj2_str_id == previous_str_obj:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if len(nodes) > max_nodes != 0:
|
if len(nodes) > max_nodes != 0:
|
||||||
|
meta['complete'] = False
|
||||||
break
|
break
|
||||||
nodes.add(obj2_str_id)
|
nodes.add(obj2_str_id)
|
||||||
links.add((obj_str_id, obj2_str_id))
|
links.add((obj_str_id, obj2_str_id))
|
||||||
|
|
||||||
if level > 0:
|
if level > 0:
|
||||||
next_level = level - 1
|
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)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*-coding:UTF-8 -*
|
# -*-coding:UTF-8 -*
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
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)
|
obj = get_object(obj_type, subtype, id)
|
||||||
meta = obj.get_meta()
|
meta = obj.get_meta()
|
||||||
meta['icon'] = obj.get_svg_icon()
|
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()
|
meta['sparkline'] = obj.get_sparkline()
|
||||||
if obj_type == 'cve':
|
if obj_type == 'cve':
|
||||||
meta['cve_search'] = obj.get_cve_search()
|
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):
|
def create_correlation_graph_nodes(nodes_set, obj_str_id, flask_context=True):
|
||||||
graph_nodes_list = []
|
graph_nodes_list = []
|
||||||
for node_id in nodes_set:
|
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 = {'id': node_id}
|
||||||
dict_node['style'] = get_object_svg(obj_type, subtype, obj_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,
|
def get_correlations_graph_node(obj_type, subtype, obj_id, filter_types=[], max_nodes=300, level=1,
|
||||||
flask_context=False):
|
flask_context=False):
|
||||||
obj_str_id, nodes, links = correlations_engine.get_correlations_graph_nodes_links(obj_type, subtype, obj_id,
|
obj_str_id, nodes, links, meta = correlations_engine.get_correlations_graph_nodes_links(obj_type, subtype, obj_id,
|
||||||
filter_types=filter_types,
|
filter_types=filter_types,
|
||||||
max_nodes=max_nodes, level=level,
|
max_nodes=max_nodes, level=level,
|
||||||
flask_context=flask_context)
|
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),
|
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 --- #
|
# --- CORRELATION --- #
|
||||||
|
|
|
@ -156,7 +156,7 @@ def show_correlation():
|
||||||
@login_read_only
|
@login_read_only
|
||||||
def get_description():
|
def get_description():
|
||||||
object_id = request.args.get('object_id')
|
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
|
# unpack object_id # # TODO: put me in lib
|
||||||
if len(object_id) == 3:
|
if len(object_id) == 3:
|
||||||
object_type = object_id[0]
|
object_type = object_id[0]
|
||||||
|
|
|
@ -162,6 +162,9 @@
|
||||||
<i class="fas fa-sync"></i> Resize Graph
|
<i class="fas fa-sync"></i> Resize Graph
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
<div id="incomplete_graph" class="text-danger mt-3">
|
||||||
|
<i class="fas fa-exclamation-triangle"></i> Graph Incomplete, Max Nodes Reached.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body graph_panel">
|
<div class="card-body graph_panel">
|
||||||
<div id="graph_loading" class="ml-3 mt-3">
|
<div id="graph_loading" class="ml-3 mt-3">
|
||||||
|
@ -350,6 +353,7 @@
|
||||||
|
|
||||||
var all_graph = {};
|
var all_graph = {};
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$("#incomplete_graph").hide();
|
||||||
$("#page-Decoded").addClass("active");
|
$("#page-Decoded").addClass("active");
|
||||||
|
|
||||||
all_graph.node_graph = create_graph("{{ url_for('correlation.graph_node_json') }}?id={{ dict_object["correlation_id"] }}&type={{ dict_object["object_type"] }}&mode={{ dict_object["mode"] }}&level={{ dict_object["level"] }}&filter={{ dict_object["filter_str"] }}&max_nodes={{dict_object["max_nodes"]}}{% if 'type_id' in dict_object["metadata"] %}&subtype={{ dict_object["metadata"]["type_id"] }}{% endif %}");
|
all_graph.node_graph = create_graph("{{ url_for('correlation.graph_node_json') }}?id={{ dict_object["correlation_id"] }}&type={{ dict_object["object_type"] }}&mode={{ dict_object["mode"] }}&level={{ dict_object["level"] }}&filter={{ dict_object["filter_str"] }}&max_nodes={{dict_object["max_nodes"]}}{% if 'type_id' in dict_object["metadata"] %}&subtype={{ dict_object["metadata"]["type_id"] }}{% endif %}");
|
||||||
|
@ -526,6 +530,12 @@ d3.json(url)
|
||||||
// Loading ...
|
// Loading ...
|
||||||
$("#graph_loading").remove();
|
$("#graph_loading").remove();
|
||||||
|
|
||||||
|
if (!data.meta.complete){
|
||||||
|
$("#incomplete_graph").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
$("#graph_loading").remove()
|
$("#graph_loading").remove()
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
||||||
|
|
||||||
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
|
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
|
||||||
|
|
Loading…
Reference in a new issue