Skip to content

Commit

Permalink
fix: [investigation misp export] fix JSON export
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Feb 18, 2025
1 parent 85f7f8d commit aaec6cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 3 additions & 9 deletions bin/exporter/MISPExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,9 @@ def get_daily_event_id(self):
misp_event = self.create_event([], info=event_info, threat_level=3, export=True)
return misp_event['Event']['id']


# TODO EVENT REPORT ???????
def create_event(self, objs, export=False, event_uuid=None, date=None, publish=False, info=None, tags=None,
analysis=0, distribution=0, threat_level=4):
# Test Connection
if export and self.url:
self.get_misp()
if tags is None:
tags = []
event = MISPEvent()
Expand All @@ -219,7 +215,7 @@ def create_event(self, objs, export=False, event_uuid=None, date=None, publish=F
event.add_object(obj)
# print(event.to_json())

if export:
if export and self.url:
misp = self.get_misp()
misp_event = misp.add_event(event)
# TODO: handle error
Expand Down Expand Up @@ -291,10 +287,8 @@ def export(self, investigation):
info=investigation.get_info(),
tags=investigation.get_tags(),
export=True)
url = event['url']
# if url:
# investigation.add_misp_events(url)
return url
return event


class MISPExporterTrackerMatch(MISPExporter):
"""MISPExporter Tracker match
Expand Down
3 changes: 2 additions & 1 deletion var/www/blueprints/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ def export_investigation():

misp = MISPExporter.MISPExporterInvestigation(url=misp_meta['url'], key=misp_meta['key'], ssl=misp_meta['ssl'])
try:
event_url = misp.export(investigation)
event = misp.export(investigation)
except MISPConnectionError as e:
return create_json_response({"error": e.message}, 400)
event_url = event['url']
return redirect(url_for('investigations_b.show_investigation', uuid=investigation_uuid, misp_url=event_url))


Expand Down

0 comments on commit aaec6cf

Please sign in to comment.