@@ -195,7 +195,8 @@ def create_parser():
195
195
parser .add_argument ("--prepare-scan" , type = str , const = '' , nargs = '?' ,
196
196
help = "Path to the configuration file used to do the pre-analysis stage" )
197
197
parser .add_argument ("--run-scan" , type = str , const = '' , nargs = "?" ,
198
- help = "Flag for whether a security scan should be run. Target will be the results folder." )
198
+ help = "Flag for whether a security scan should be run. If left empty, will run on all folders in results-dir."
199
+ "If passed a path to a command_line.json file, it will only run on that folder." )
199
200
parser .add_argument ("--skip-di-generation" , action = 'store_true' ,
200
201
help = "Turns off DI overlay generation. This overrides the automatic detection of DI usage." )
201
202
@@ -282,9 +283,13 @@ def load_config_and_run_scan(config_path):
282
283
283
284
# We save the json with '-' as seperators to mimic the arguments coming in
284
285
# but the parser replaces those with '_' and here we want to mimic that.
285
- with open (config_path ) as config_file :
286
- json_output = { key .replace ("-" , "_" ): val for key , val in json .load (config_file ).items ()}
287
- cmdline = SimpleNamespace (** json_output )
286
+ try :
287
+ with open (config_path ) as config_file :
288
+ json_output = { key .replace ("-" , "_" ): val for key , val in json .load (config_file ).items ()}
289
+ cmdline = SimpleNamespace (** json_output )
290
+ except json .JSONDecodeError as ex :
291
+ print ("ERROR: Command line configuration at " + config_path + " is invalid json. " + ex .msg )
292
+ return
288
293
289
294
run_scan (cmdline )
290
295
@@ -512,6 +517,10 @@ def extract_wildcard_paths(path):
512
517
" and the default file can't be found at {0}." .format (default_config_path ))
513
518
return
514
519
520
+ if not os .path .isfile (cmdline .prepare_scan ):
521
+ print ("ERROR: The path passed in via cmdline.prepare_scan, " + cmdline .prepare_scan + ", dosen't exist." )
522
+ return
523
+
515
524
if cmdline .name is None :
516
525
cmdline .name = os .path .basename (cmdline .install_dir )
517
526
0 commit comments