This repository was archived by the owner on Oct 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -110,17 +110,16 @@ def get_additional_args():
110110 scan_type = self .get_scan_type ()
111111
112112 # Load the atomic config file and check scanner settings
113- yaml_error = "The image name or scanner arguments for '{}' is not " \
114- "defined in /etc/atomic.conf" .format (self .scanner )
115-
116113 scanner_image_name , scanner_args , custom_args = get_scan_info (self .scanner , scan_type )
117114
118115 if not isinstance (scanner_args , list ):
119116 raise ValueError ("The scanner arguments for {} must be in list"
120117 " ([]) form." .format (self .scanner ))
121118
122119 if None in [scanner_image_name , scanner_args ]:
123- raise ValueError (yaml_error )
120+ sconf_file = util .get_scanner_conf_path_by_name (self .scanner )
121+ raise ValueError ("The scanner configuration for '{}' in '{}' is missing its image name "
122+ "or scanner arguments" .format (self .scanner , sconf_file ))
124123
125124 self .results_dir = os .path .join (self .results , self .scanner , self .cur_time )
126125
Original file line number Diff line number Diff line change @@ -486,6 +486,22 @@ def _recursive_get(atomic_config, items):
486486 else :
487487 return default
488488
489+ def get_scanner_conf_path_by_name (scanner_name ):
490+ if not os .path .exists (ATOMIC_CONFD ):
491+ raise ValueError ("{} does not exist" .format (ATOMIC_CONFD ))
492+ files = [os .path .join (ATOMIC_CONFD , x ) for x in os .listdir (ATOMIC_CONFD ) if os .path .isfile (os .path .join (ATOMIC_CONFD , x ))]
493+ for f in files :
494+ with open (f , 'r' ) as conf_file :
495+ try :
496+ temp_conf = yaml_load (conf_file )
497+ if temp_conf .get ('type' ) == "scanner" and temp_conf .get ("scanner_name" ) == scanner_name :
498+ return conf_file .name
499+ except YAMLError :
500+ pass
501+ except AttributeError :
502+ pass
503+ raise ValueError ("Unable to correlate {} to its configuration file" .format (scanner_name ))
504+
489505def get_scanners ():
490506 scanners = []
491507 if not os .path .exists (ATOMIC_CONFD ):
You can’t perform that action at this time.
0 commit comments