mirror of https://github.com/CIRCL/AIL-framework
chg: [UI MISP export] add error output
parent
4d0e9a94d0
commit
1b861f55ee
|
@ -383,6 +383,13 @@ def get_obj_global_id(obj_type, obj_id, obj_sub_type=None):
|
||||||
|
|
||||||
return '{}:{}'.format(obj_type, obj_id)
|
return '{}:{}'.format(obj_type, obj_id)
|
||||||
|
|
||||||
|
# used by UI
|
||||||
|
def get_obj_str_type_subtype(obj_type, obj_subtype):
|
||||||
|
if obj_subtype:
|
||||||
|
return '{};{}'.format(obj_type, obj_subtype)
|
||||||
|
else:
|
||||||
|
return obj_type
|
||||||
|
|
||||||
######## API EXPOSED ########
|
######## API EXPOSED ########
|
||||||
def sanitize_object_type(object_type):
|
def sanitize_object_type(object_type):
|
||||||
if not is_valid_object_type(object_type):
|
if not is_valid_object_type(object_type):
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import uuid
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
|
||||||
|
@ -102,16 +103,22 @@ def export_object_file():
|
||||||
if MispExport.is_valid_obj_to_export(obj_type, obj_subtype, obj_id):
|
if MispExport.is_valid_obj_to_export(obj_type, obj_subtype, obj_id):
|
||||||
l_obj_to_export.append(obj_dict)
|
l_obj_to_export.append(obj_dict)
|
||||||
else:
|
else:
|
||||||
l_obj_invalid.append(obj_dict)
|
if obj_id:
|
||||||
print(l_obj_to_export)
|
l_obj_invalid.append(obj_dict)
|
||||||
print(l_obj_invalid)
|
|
||||||
|
|
||||||
if l_obj_to_export:
|
if l_obj_invalid:
|
||||||
|
for obj_dict in l_obj_to_export:
|
||||||
|
obj_dict['uuid'] = str(uuid.uuid4())
|
||||||
|
obj_dict['type'] = Correlate_object.get_obj_str_type_subtype(obj_dict['type'], obj_dict.get('subtype', None))
|
||||||
|
for obj_dict in l_obj_invalid:
|
||||||
|
obj_dict['uuid'] = str(uuid.uuid4())
|
||||||
|
obj_dict['type'] = Correlate_object.get_obj_str_type_subtype(obj_dict['type'], obj_dict.get('subtype', None))
|
||||||
|
|
||||||
|
return render_template("export_object.html", l_obj_to_export=l_obj_to_export,
|
||||||
|
l_obj_invalid=l_obj_invalid)
|
||||||
|
else:
|
||||||
|
|
||||||
json_export = MispExport.create_list_of_objs_to_export(l_obj_to_export)
|
json_export = MispExport.create_list_of_objs_to_export(l_obj_to_export)
|
||||||
export_filename = MispExport.get_export_filename(json_export)
|
export_filename = MispExport.get_export_filename(json_export)
|
||||||
json_export = MispExport.create_in_memory_file(json_export)
|
json_export = MispExport.create_in_memory_file(json_export)
|
||||||
return send_file(json_export, as_attachment=True, attachment_filename=export_filename)
|
return send_file(json_export, as_attachment=True, attachment_filename=export_filename)
|
||||||
|
|
||||||
else:
|
|
||||||
return render_template("export_object.html", bootstrap_label=bootstrap_label)
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<div class="input-group mb-1">
|
||||||
|
<select class="custom-select col-2" name="{{input_uuid}}" value="{{obj_type}}">
|
||||||
|
{% if not obj_type %}
|
||||||
|
<option selected="">Object type...</option>
|
||||||
|
{% else %}
|
||||||
|
<option>Object type...</option>
|
||||||
|
{% endif %}
|
||||||
|
<option value="item" {%if obj_type=="item"%}selected{%endif%}>Item</option>
|
||||||
|
<option value="domain" {%if obj_type=="domain"%}selected{%endif%}>Domain</option>
|
||||||
|
<option value="image" {%if obj_type=="image"%}selected{%endif%}>Image</option>
|
||||||
|
<option value="decoded" {%if obj_type=="decoded"%}selected{%endif%}>Decoded</option>
|
||||||
|
<option value="pgp;key" {%if obj_type=="pgp;key"%}selected{%endif%}>PGP - Key</option>
|
||||||
|
<option value="pgp;name" {%if obj_type=="pgp;name"%}selected{%endif%}>PGP - Name</option>
|
||||||
|
<option value="pgp;mail" {%if obj_type=="pgp;mail"%}selected{%endif%}>PGP - Mail</option>
|
||||||
|
<option value="cryptocurrency;bitcoin" {%if obj_type=="cryptocurrency;bitcoin"%}selected{%endif%}>Cryptocurrency - Bitcoin</option>
|
||||||
|
<option value="cryptocurrency;bitcoin-cash" {%if obj_type=="cryptocurrency;bitcoin-cash"%}selected{%endif%}>Cryptocurrency - Bitcoin Cash</option>
|
||||||
|
<option value="cryptocurrency;dash" {%if obj_type=="cryptocurrency;dash"%}selected{%endif%}>Cryptocurrency - Dash</option>
|
||||||
|
<option value="cryptocurrency;etherum" {%if obj_type=="cryptocurrency;etherum"%}selected{%endif%}>Cryptocurrency - Etherum</option>
|
||||||
|
<option value="cryptocurrency;litecoin" {%if obj_type=="cryptocurrency;litecoin"%}selected{%endif%}>Cryptocurrency - Litecoin</option>
|
||||||
|
<option value="cryptocurrency;monero" {%if obj_type=="cryptocurrency;monero"%}selected{%endif%}>Cryptocurrency - Monero</option>
|
||||||
|
<option value="cryptocurrency;zcash" {%if obj_type=="cryptocurrency;zcash"%}selected{%endif%}>Cryptocurrency - Zcash</option>
|
||||||
|
</select>
|
||||||
|
<input type="text" class="form-control col-8 {%if obj_error%}is-invalid{%endif%}" name="{{input_uuid}}" value="{{obj_id}}">
|
||||||
|
<input class="form-control col-1" type="number" min="0" name="{{input_uuid}}" {%if obj_lvl%}value="{{obj_lvl}}"{%else%}value="0"{%endif%}>
|
||||||
|
<span class="btn btn-danger input-group-addon delete-field col-1"><i class="fas fa-trash-alt"></i></span>
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{%if obj_type=="Object type..."%}
|
||||||
|
Please select an object type.
|
||||||
|
{%endif%}
|
||||||
|
Unknow or Invalid ID.
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -70,6 +70,19 @@
|
||||||
<input class="form-control col-1" type="number" min="0" value="0" name="first_obj_to_export" id="obj_input_lvl">
|
<input class="form-control col-1" type="number" min="0" value="0" name="first_obj_to_export" id="obj_input_lvl">
|
||||||
<span class="btn btn-info input-group-addon add-field col-1"><i class="fas fa-plus"></i></span>
|
<span class="btn btn-info input-group-addon add-field col-1"><i class="fas fa-plus"></i></span>
|
||||||
</div>
|
</div>
|
||||||
|
{% for obj_dict in l_obj_to_export %}
|
||||||
|
{% with obj_type=obj_dict['type'], obj_id=obj_dict['id'], obj_lvl=obj_dict['lvl'], input_uuid=obj_dict['uuid'], obj_error=False%}
|
||||||
|
{% include 'import_export/block_to_export_input.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
{% for obj_dict in l_obj_invalid %}
|
||||||
|
{% with obj_type=obj_dict['type'], obj_id=obj_dict['id'], obj_lvl=obj_dict['lvl'], input_uuid=obj_dict['uuid'], obj_error=True%}
|
||||||
|
{% include 'import_export/block_to_export_input.html' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
<span class="help-block" hidden>Export Objects</span>
|
<span class="help-block" hidden>Export Objects</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue