@@ -70,6 +70,8 @@ def _init_menu():
7070 'scores are calculated in the same way as with the option: '
7171 '-y, --yaml' , action = 'store_true' )
7272 parser_data_sources .add_argument ('-of' , '--output-filename' , help = 'set the output filename' )
73+ parser_data_sources .add_argument ('--force-overwrite' , help = 'force overwriting the output file if it already exists' ,
74+ action = 'store_true' )
7375 parser_data_sources .add_argument ('-ln' , '--layer-name' , help = 'set the name of the Navigator layer' )
7476 parser_data_sources .add_argument ('--health' , help = 'check the YAML file(s) for errors' , action = 'store_true' )
7577 parser_data_sources .add_argument ('--local-stix-path' , help = 'path to a local STIX repository to use DeTT&CT offline '
@@ -109,6 +111,8 @@ def _init_menu():
109111 parser_visibility .add_argument ('-g' , '--graph' , help = 'generate a graph with visibility added through time' ,
110112 action = 'store_true' )
111113 parser_visibility .add_argument ('-of' , '--output-filename' , help = 'set the output filename' )
114+ parser_visibility .add_argument ('--force-overwrite' , help = 'force overwriting the output file if it already exists' ,
115+ action = 'store_true' )
112116 parser_visibility .add_argument ('-ln' , '--layer-name' , help = 'set the name of the Navigator layer' )
113117 parser_visibility .add_argument ('-cd' , '--count-detections' , help = 'Show the number of detections instead of listing '
114118 'all detection locations in Layer metadata (when using '
@@ -155,6 +159,8 @@ def _init_menu():
155159 parser_detection .add_argument ('-g' , '--graph' , help = 'generate a graph with detections added through time' ,
156160 action = 'store_true' )
157161 parser_detection .add_argument ('-of' , '--output-filename' , help = 'set the output filename' )
162+ parser_detection .add_argument ('--force-overwrite' , help = 'force overwriting the output file if it already exists' ,
163+ action = 'store_true' )
158164 parser_detection .add_argument ('-ln' , '--layer-name' , help = 'set the name of the Navigator layer' )
159165 parser_detection .add_argument ('-cd' , '--count-detections' , help = 'Show the number of detections instead of listing '
160166 'all detection locations in Layer metadata. Location '
@@ -224,6 +230,8 @@ def _init_menu():
224230 'most recent \' score\' objects' ,
225231 action = 'store_true' , default = False )
226232 parser_group .add_argument ('-of' , '--output-filename' , help = 'set the output filename' )
233+ parser_group .add_argument ('--force-overwrite' , help = 'force overwriting the output file if it already exists' ,
234+ action = 'store_true' )
227235 parser_group .add_argument ('-ln' , '--layer-name' , help = 'set the name of the Navigator layer' )
228236 parser_group .add_argument ('-cd' , '--count-detections' , help = 'Show the number of detections instead of listing '
229237 'all detection locations in Layer metadata (when using an overlay with detection). Location '
@@ -301,13 +309,13 @@ def _menu(menu_parser):
301309 if args .update and check_file (args .file_tech , FILE_TYPE_TECHNIQUE_ADMINISTRATION , args .health ):
302310 update_technique_administration_file (file_ds , args .file_tech )
303311 if args .layer :
304- generate_data_sources_layer (file_ds , args .output_filename , args .layer_name , layer_settings )
312+ generate_data_sources_layer (file_ds , args .output_filename , args .force_overwrite , args . layer_name , layer_settings )
305313 if args .excel :
306- export_data_source_list_to_excel (file_ds , args .output_filename , eql_search = args .search )
314+ export_data_source_list_to_excel (file_ds , args .output_filename , args . force_overwrite , eql_search = args .search )
307315 if args .graph :
308- plot_data_sources_graph (file_ds , args .output_filename )
316+ plot_data_sources_graph (file_ds , args .output_filename , args . force_overwrite )
309317 if args .yaml :
310- generate_technique_administration_file (file_ds , args .output_filename , all_techniques = args .yaml_all_techniques )
318+ generate_technique_administration_file (file_ds , args .output_filename , args . force_overwrite , all_techniques = args .yaml_all_techniques )
311319
312320 elif args .subparser in ['visibility' , 'v' ]:
313321 if check_file (args .file_tech , FILE_TYPE_TECHNIQUE_ADMINISTRATION , args .health ):
@@ -323,22 +331,22 @@ def _menu(menu_parser):
323331 if not file_tech :
324332 quit () # something went wrong in executing the search or 0 results where returned
325333 if args .layer :
326- generate_visibility_layer (file_tech , False , args .output_filename , args .layer_name ,
334+ generate_visibility_layer (file_tech , False , args .output_filename , args .force_overwrite , args . layer_name ,
327335 layer_settings , args .platform , args .count_detections )
328336 if args .overlay :
329- generate_visibility_layer (file_tech , True , args .output_filename , args .layer_name ,
337+ generate_visibility_layer (file_tech , True , args .output_filename , args .force_overwrite , args . layer_name ,
330338 layer_settings , args .platform , args .count_detections )
331339 if args .graph :
332- plot_graph (file_tech , 'visibility' , args .output_filename )
340+ plot_graph (file_tech , 'visibility' , args .output_filename , args . force_overwrite )
333341 if args .excel :
334- export_techniques_list_to_excel (file_tech , args .output_filename )
342+ export_techniques_list_to_excel (file_tech , args .output_filename , args . force_overwrite )
335343
336344 # TODO add Group EQL search capabilities
337345 elif args .subparser in ['group' , 'g' ]:
338346 layer_settings = _parse_layer_settings (args .layer_settings )
339347 generate_group_heat_map (args .groups , args .campaigns , args .overlay , args .overlay_type , args .platform ,
340348 args .software , args .include_software , args .search_visibility , args .search_detection , args .health ,
341- args .output_filename , args .layer_name , args .domain , layer_settings ,
349+ args .output_filename , args .force_overwrite , args . layer_name , args .domain , layer_settings ,
342350 args .all_scores , args .count_detections )
343351
344352 elif args .subparser in ['detection' , 'd' ]:
@@ -355,14 +363,15 @@ def _menu(menu_parser):
355363 if not file_tech :
356364 quit () # something went wrong in executing the search or 0 results where returned
357365 if args .layer :
358- generate_detection_layer (file_tech , False , args .output_filename , args .layer_name ,
366+ generate_detection_layer (file_tech , False , args .output_filename , args .force_overwrite , args . layer_name ,
359367 layer_settings , args .platform , args .count_detections )
360368 if args .overlay :
361- generate_detection_layer (file_tech , True , args .output_filename , args .layer_name , layer_settings , args .platform , args .count_detections )
369+ generate_detection_layer (file_tech , True , args .output_filename , args .force_overwrite , args .layer_name ,
370+ layer_settings , args .platform , args .count_detections )
362371 if args .graph :
363- plot_graph (file_tech , 'detection' , args .output_filename )
372+ plot_graph (file_tech , 'detection' , args .output_filename , args . force_overwrite )
364373 if args .excel :
365- export_techniques_list_to_excel (file_tech , args .output_filename )
374+ export_techniques_list_to_excel (file_tech , args .output_filename , args . force_overwrite )
366375
367376 elif args .subparser in ['generic' , 'ge' ]:
368377 if args .datasources :
0 commit comments