4141 "output" : "" ,
4242}
4343
44+
4445def export_to_sentinel (request , event_uuid ):
4546 params = request ["params" ]
4647 misp2_venv = params ["misp2_venv" ]
47- misp2_script = params ["misp2_script" ]
48-
48+ misp2_script = params ["misp2_script" ]
49+
4950 script_dir = os .path .dirname (misp2_script )
5051 python_executable = os .path .join (misp2_venv , "bin" , "python" )
51-
52+
5253 if not os .path .exists (python_executable ):
5354 print (f"Error: Python executable not found at { python_executable } " )
5455 return False
55-
56+
5657 if not os .path .exists (misp2_script ):
5758 print (f"Error: Script not found at { misp2_script } " )
5859 return False
59-
60+
6061 print (f"Exporting event { event_uuid } to Sentinel or Defender..." )
6162 print (f"Using Python: { python_executable } " )
6263 print (f"Running script: { misp2_script } " )
6364 print (f"Working directory: { script_dir } " )
64-
65+
6566 try :
6667 result = subprocess .run (
6768 [python_executable , misp2_script , event_uuid ],
@@ -70,7 +71,7 @@ def export_to_sentinel(request, event_uuid):
7071 text = True ,
7172 timeout = 300
7273 )
73-
74+
7475 if result .returncode == 0 :
7576 print (f"Successfully exported event { event_uuid } " )
7677 if result .stdout :
@@ -83,18 +84,19 @@ def export_to_sentinel(request, event_uuid):
8384 if result .stdout :
8485 print (f"Output: { result .stdout } " )
8586 return False
86-
87+
8788 except subprocess .TimeoutExpired :
88- print (f "Export timed out after 300 seconds " )
89+ print ("Export timed out" )
8990 return False
9091 except Exception as e :
9192 print (f"Error executing script: { str (e )} " )
9293 return False
9394
95+
9496def handler (q = False ):
9597 if q is False :
9698 return False
97-
99+
98100 request = json .loads (q )
99101 success = False
100102
0 commit comments