mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
chg: [correlation graph] select correlation depth
This commit is contained in:
parent
b4f1a43208
commit
5d4b718174
2 changed files with 36 additions and 11 deletions
|
@ -52,6 +52,15 @@ def sanitise_nb_max_nodes(nb_max_nodes):
|
||||||
nb_max_nodes = 300
|
nb_max_nodes = 300
|
||||||
return nb_max_nodes
|
return nb_max_nodes
|
||||||
|
|
||||||
|
def sanitise_level(level):
|
||||||
|
try:
|
||||||
|
level = int(level)
|
||||||
|
if level < 0:
|
||||||
|
level = 2
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
level = 2
|
||||||
|
return level
|
||||||
|
|
||||||
# ============= ROUTES ==============
|
# ============= ROUTES ==============
|
||||||
@correlation.route('/correlation/show', methods=['GET', 'POST'])
|
@correlation.route('/correlation/show', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -67,6 +76,7 @@ def show_correlation():
|
||||||
mode = 'inter'
|
mode = 'inter'
|
||||||
else:
|
else:
|
||||||
mode = 'union'
|
mode = 'union'
|
||||||
|
level = sanitise_level(request.form.get('level'))
|
||||||
|
|
||||||
## get all selected correlations
|
## get all selected correlations
|
||||||
filter_types = []
|
filter_types = []
|
||||||
|
@ -104,7 +114,7 @@ def show_correlation():
|
||||||
|
|
||||||
# redirect to keep history and bookmark
|
# redirect to keep history and bookmark
|
||||||
return redirect(url_for('correlation.show_correlation', type=object_type, subtype=subtype, id=obj_id, mode=mode,
|
return redirect(url_for('correlation.show_correlation', type=object_type, subtype=subtype, id=obj_id, mode=mode,
|
||||||
max_nodes=max_nodes, filter=filter_types))
|
max_nodes=max_nodes, level=level, filter=filter_types))
|
||||||
|
|
||||||
# request.method == 'GET'
|
# request.method == 'GET'
|
||||||
else:
|
else:
|
||||||
|
@ -113,6 +123,7 @@ def show_correlation():
|
||||||
obj_id = request.args.get('id')
|
obj_id = request.args.get('id')
|
||||||
max_nodes = sanitise_nb_max_nodes(request.args.get('max_nodes'))
|
max_nodes = sanitise_nb_max_nodes(request.args.get('max_nodes'))
|
||||||
mode = sanitise_graph_mode(request.args.get('mode'))
|
mode = sanitise_graph_mode(request.args.get('mode'))
|
||||||
|
level = sanitise_level(request.args.get('level'))
|
||||||
|
|
||||||
related_btc = bool(request.args.get('related_btc', False))
|
related_btc = bool(request.args.get('related_btc', False))
|
||||||
|
|
||||||
|
@ -125,7 +136,7 @@ def show_correlation():
|
||||||
else:
|
else:
|
||||||
dict_object = {"object_type": obj_type,
|
dict_object = {"object_type": obj_type,
|
||||||
"correlation_id": obj_id,
|
"correlation_id": obj_id,
|
||||||
"max_nodes": max_nodes, "mode": mode,
|
"max_nodes": max_nodes, "mode": mode, "level": level,
|
||||||
"filter": filter_types, "filter_str": ",".join(filter_types),
|
"filter": filter_types, "filter_str": ",".join(filter_types),
|
||||||
"metadata": ail_objects.get_object_meta(obj_type, subtype, obj_id,
|
"metadata": ail_objects.get_object_meta(obj_type, subtype, obj_id,
|
||||||
options={'tags'}, flask_context=True),
|
options={'tags'}, flask_context=True),
|
||||||
|
@ -175,10 +186,11 @@ def graph_node_json():
|
||||||
subtype = request.args.get('subtype')
|
subtype = request.args.get('subtype')
|
||||||
obj_type = request.args.get('type')
|
obj_type = request.args.get('type')
|
||||||
max_nodes = sanitise_nb_max_nodes(request.args.get('max_nodes'))
|
max_nodes = sanitise_nb_max_nodes(request.args.get('max_nodes'))
|
||||||
|
level = sanitise_level(request.args.get('level'))
|
||||||
|
|
||||||
filter_types = ail_objects.sanitize_objs_types(request.args.get('filter', '').split(','))
|
filter_types = ail_objects.sanitize_objs_types(request.args.get('filter', '').split(','))
|
||||||
|
|
||||||
json_graph = ail_objects.get_correlations_graph_node(obj_type, subtype, obj_id, filter_types=filter_types, max_nodes=max_nodes, level=2, flask_context=True)
|
json_graph = ail_objects.get_correlations_graph_node(obj_type, subtype, obj_id, filter_types=filter_types, max_nodes=max_nodes, level=level, flask_context=True)
|
||||||
#json_graph = Correlate_object.get_graph_node_object_correlation(obj_type, obj_id, 'union', correlation_names, correlation_objects, requested_correl_type=subtype, max_nodes=max_nodes)
|
#json_graph = Correlate_object.get_graph_node_object_correlation(obj_type, obj_id, 'union', correlation_names, correlation_objects, requested_correl_type=subtype, max_nodes=max_nodes)
|
||||||
return jsonify(json_graph)
|
return jsonify(json_graph)
|
||||||
|
|
||||||
|
@ -204,6 +216,7 @@ def correlation_tags_add():
|
||||||
subtype = request.form.get('tag_subtype', '')
|
subtype = request.form.get('tag_subtype', '')
|
||||||
obj_type = request.form.get('tag_obj_type')
|
obj_type = request.form.get('tag_obj_type')
|
||||||
nb_max = sanitise_nb_max_nodes(request.form.get('tag_nb_max'))
|
nb_max = sanitise_nb_max_nodes(request.form.get('tag_nb_max'))
|
||||||
|
level = sanitise_level(request.form.get('tag_level'))
|
||||||
filter_types = ail_objects.sanitize_objs_types(request.form.get('tag_filter', '').split(','))
|
filter_types = ail_objects.sanitize_objs_types(request.form.get('tag_filter', '').split(','))
|
||||||
|
|
||||||
if not ail_objects.exists_obj(obj_type, subtype, obj_id):
|
if not ail_objects.exists_obj(obj_type, subtype, obj_id):
|
||||||
|
@ -232,8 +245,10 @@ def correlation_tags_add():
|
||||||
tags = []
|
tags = []
|
||||||
|
|
||||||
if tags:
|
if tags:
|
||||||
ail_objects.obj_correlations_objs_add_tags(obj_type, subtype, obj_id, tags, filter_types=filter_types, lvl=2, nb_max=nb_max)
|
ail_objects.obj_correlations_objs_add_tags(obj_type, subtype, obj_id, tags, filter_types=filter_types,
|
||||||
|
lvl=level + 1, nb_max=nb_max)
|
||||||
|
|
||||||
return redirect(url_for('correlation.show_correlation',
|
return redirect(url_for('correlation.show_correlation',
|
||||||
type=obj_type, subtype=subtype, id=obj_id,
|
type=obj_type, subtype=subtype, id=obj_id,
|
||||||
|
level=level,
|
||||||
filter=",".join(filter_types)))
|
filter=",".join(filter_types)))
|
||||||
|
|
|
@ -228,14 +228,23 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
{# <li class="list-group-item text-left">#}
|
||||||
|
{# <div class="d-flex mt-1">#}
|
||||||
|
{# Union #}
|
||||||
|
{# <div class="custom-control custom-switch">#}
|
||||||
|
{# <input class="custom-control-input" type="checkbox" name="mode" value="True" id="mode" {%if dict_object["mode"]=="inter"%}checked{%endif%}>#}
|
||||||
|
{# <label class="custom-control-label" for="mode">Intersection</label>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# </div>#}
|
||||||
|
{# </li>#}
|
||||||
<li class="list-group-item text-left">
|
<li class="list-group-item text-left">
|
||||||
<div class="d-flex mt-1">
|
|
||||||
Union
|
<div class="form-group">
|
||||||
<div class="custom-control custom-switch">
|
<label for="max_nb_nodes_in">Correlation Depth:</label>
|
||||||
<input class="custom-control-input" type="checkbox" name="mode" value="True" id="mode" {%if dict_object["mode"]=="inter"%}checked{%endif%}>
|
<input class="form-control" type="number" value="{{dict_object["level"]}}" min="0" id="level" name="level">
|
||||||
<label class="custom-control-label" for="mode">Intersection</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item text-left">
|
<li class="list-group-item text-left">
|
||||||
|
|
||||||
|
@ -316,6 +325,7 @@
|
||||||
<input type="hidden" id="tag_obj_type" name="tag_obj_type" value="{{ dict_object["object_type"] }}">
|
<input type="hidden" id="tag_obj_type" name="tag_obj_type" value="{{ dict_object["object_type"] }}">
|
||||||
<input type="hidden" id="tag_subtype" name="tag_subtype" value="{{ dict_object["metadata"]["type_id"] }}">
|
<input type="hidden" id="tag_subtype" name="tag_subtype" value="{{ dict_object["metadata"]["type_id"] }}">
|
||||||
<input type="hidden" id="tag_obj_id" name="tag_obj_id" value="{{ dict_object["correlation_id"] }}">
|
<input type="hidden" id="tag_obj_id" name="tag_obj_id" value="{{ dict_object["correlation_id"] }}">
|
||||||
|
<input type="hidden" id="tag_level" name="tag_level" value="{{dict_object["level"]}}">
|
||||||
<input type="hidden" id="tag_nb_max" name="tag_nb_max" value="{{dict_object["max_nodes"]}}">
|
<input type="hidden" id="tag_nb_max" name="tag_nb_max" value="{{dict_object["max_nodes"]}}">
|
||||||
<input type="hidden" id="filter" name="tag_filter" value="{{dict_object["filter_str"]}}">
|
<input type="hidden" id="filter" name="tag_filter" value="{{dict_object["filter_str"]}}">
|
||||||
{% include 'tags/block_tags_selector.html' %}
|
{% include 'tags/block_tags_selector.html' %}
|
||||||
|
@ -336,7 +346,7 @@ var all_graph = {};
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#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"] }}&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 %}");
|
||||||
{% if dict_object["object_type"] in ["cryptocurrency", "pgp", "username"] %}
|
{% if dict_object["object_type"] in ["cryptocurrency", "pgp", "username"] %}
|
||||||
all_graph.line_chart = create_line_chart('graph_line', "{{ url_for('objects_subtypes.objects_cve_graphline_json') }}?type={{ dict_object["object_type"] }}&subtype={{dict_object["metadata"]["type_id"]}}&id={{dict_object["correlation_id"]}}");
|
all_graph.line_chart = create_line_chart('graph_line', "{{ url_for('objects_subtypes.objects_cve_graphline_json') }}?type={{ dict_object["object_type"] }}&subtype={{dict_object["metadata"]["type_id"]}}&id={{dict_object["correlation_id"]}}");
|
||||||
{% elif dict_object["object_type"] == "decoded" %}
|
{% elif dict_object["object_type"] == "decoded" %}
|
||||||
|
|
Loading…
Reference in a new issue