fix: [misp keys import] fix #471

pull/486/head
Terrtia 2020-02-21 11:03:28 +01:00
parent fd4b3e04b6
commit e3f76c52fa
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 16 additions and 2 deletions

View File

@ -20,7 +20,12 @@ import Correlate_object
# # TODO: # FIXME: REFRACTOR ME => use UI/Global config
sys.path.append('../../configs/keys')
from mispKEYS import misp_url, misp_key, misp_verifycert
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

View File

@ -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),