mirror of https://github.com/CIRCL/AIL-framework
fix: [misp keys import] fix #471
parent
fd4b3e04b6
commit
e3f76c52fa
|
@ -20,7 +20,12 @@ import Correlate_object
|
|||
|
||||
# # TODO: # FIXME: REFRACTOR ME => use UI/Global config
|
||||
sys.path.append('../../configs/keys')
|
||||
try:
|
||||
from mispKEYS import misp_url, misp_key, misp_verifycert
|
||||
except:
|
||||
misp_url = ''
|
||||
misp_key = ''
|
||||
misp_verifycert = False
|
||||
|
||||
# MISP
|
||||
from pymisp import MISPEvent, MISPObject, PyMISP
|
||||
|
@ -355,6 +360,15 @@ def sanitize_event_analysis(analysis):
|
|||
except:
|
||||
return 0
|
||||
|
||||
# # TODO: return error
|
||||
def ping_misp():
|
||||
try:
|
||||
PyMISP(misp_url, misp_key, misp_verifycert)
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
def create_misp_event(event, distribution=0, threat_level_id=4, publish=False, analysis=0, event_info=None):
|
||||
if event_info:
|
||||
event.info = event_info
|
||||
|
|
|
@ -151,7 +151,7 @@ def export_object_file():
|
|||
return render_template("export_object.html", l_obj_to_export=l_obj_to_export,
|
||||
l_obj_invalid=l_obj_invalid, dict_misp_event_export=dict_misp_event_export)
|
||||
else:
|
||||
if export_to_misp:
|
||||
if export_to_misp and MispExport.ping_misp():
|
||||
event = MispExport.create_list_of_objs_to_export(l_obj_to_export, r_type='event')
|
||||
event_metadata = MispExport.create_misp_event(event, distribution=dict_misp_event_export.get('export_to_misp', None),
|
||||
threat_level_id=dict_misp_event_export.get('misp_threat_level_id', None),
|
||||
|
|
Loading…
Reference in New Issue