def normalize_passed_arguments(options): if 'ALL' in options.target: options.target = ['ALL'] try: bench_id = xml_operations.infer_benchmark_id_from_component_ref_id( options.datastream, options.xccdf_id) options.benchmark_id = bench_id except RuntimeError as exc: msg = "Error inferring benchmark ID from component refId: {}".format(str(exc)) raise RuntimeError(msg) if options.docker: options.test_env = ssg_test_suite.test_env.DockerTestEnv( options.scanning_mode, options.docker) logging.info( "The base image option has been specified, " "choosing Docker-based test environment.") else: hypervisor, domain_name = options.libvirt options.test_env = ssg_test_suite.test_env.VMTestEnv( options.scanning_mode, hypervisor, domain_name) logging.info( "The base image option has not been specified, " "choosing libvirt-based test environment.") try: benchmark_cpes = xml_operations.benchmark_get_applicable_platforms( options.datastream, options.benchmark_id ) options.benchmark_cpes = benchmark_cpes except RuntimeError as exc: msg = "Error inferring platform from benchmark: {}".format(str(exc)) raise RuntimeError(msg)
def normalize_passed_arguments(options): if 'ALL' in options.target: options.target = ['ALL'] if not options.datastream: options.datastream = get_unique_datastream() if options.xccdf_id is None: options.xccdf_id = auto_select_xccdf_id(options.datastream, options.xccdf_id_number) try: bench_id = xml_operations.infer_benchmark_id_from_component_ref_id( options.datastream, options.xccdf_id) options.benchmark_id = bench_id except RuntimeError as exc: msg = "Error inferring benchmark ID from component refId: {}".format(str(exc)) raise RuntimeError(msg) if options.docker: options.test_env = ssg_test_suite.test_env.DockerTestEnv( options.scanning_mode, options.docker) logging.info( "The base image option has been specified, " "choosing Docker-based test environment.") elif options.container: options.test_env = ssg_test_suite.test_env.PodmanTestEnv( options.scanning_mode, options.container) logging.info( "The base image option has been specified, " "choosing Podman-based test environment.") else: hypervisor, domain_name = options.libvirt # Possible hypervisor spec we have to catch: qemu+unix:///session if not re.match(r"[\w\+]+:///", hypervisor): hypervisor = "qemu:///" + hypervisor options.test_env = ssg_test_suite.test_env.VMTestEnv( options.scanning_mode, hypervisor, domain_name) logging.info( "The base image option has not been specified, " "choosing libvirt-based test environment.") try: benchmark_cpes = xml_operations.benchmark_get_applicable_platforms( options.datastream, options.benchmark_id ) options.benchmark_cpes = benchmark_cpes except RuntimeError as exc: msg = "Error inferring platform from benchmark: {}".format(str(exc)) raise RuntimeError(msg)
def normalize_passed_arguments(options): if 'ALL' in options.target: options.target = ['ALL'] if options.xccdf_id is None: options.xccdf_id = auto_select_xccdf_id(options.datastream, options.xccdf_id_number) try: bench_id = xml_operations.infer_benchmark_id_from_component_ref_id( options.datastream, options.xccdf_id) options.benchmark_id = bench_id except RuntimeError as exc: msg = "Error inferring benchmark ID from component refId: {}".format(str(exc)) raise RuntimeError(msg) if options.docker: options.test_env = ssg_test_suite.test_env.DockerTestEnv( options.scanning_mode, options.docker) logging.info( "The base image option has been specified, " "choosing Docker-based test environment.") elif options.container: options.test_env = ssg_test_suite.test_env.PodmanTestEnv( options.scanning_mode, options.container) logging.info( "The base image option has been specified, " "choosing Podman-based test environment.") else: hypervisor, domain_name = options.libvirt options.test_env = ssg_test_suite.test_env.VMTestEnv( options.scanning_mode, hypervisor, domain_name) logging.info( "The base image option has not been specified, " "choosing libvirt-based test environment.") try: benchmark_cpes = xml_operations.benchmark_get_applicable_platforms( options.datastream, options.benchmark_id ) options.benchmark_cpes = benchmark_cpes except RuntimeError as exc: msg = "Error inferring platform from benchmark: {}".format(str(exc)) raise RuntimeError(msg)
def normalize_passed_arguments(options): targets = [] for target in options.target: if ',' in target: targets.extend(target.split(",")) else: targets.append(target) options.target = targets if 'ALL' in options.target: options.target = ['ALL'] if not options.datastream: options.datastream = get_unique_datastream() if not options.product and options.datastream: product_regex = re.compile(r'^.*ssg-([a-zA-Z0-9]*)-(ds|ds-1\.2)\.xml$') match = product_regex.match(options.datastream) if not match: msg = "Unable to detect product without explicit --product: " msg += "datastream {0} lacks product name".format(options.datastream) raise RuntimeError(msg) options.product = match.group(1) if options.xccdf_id is None: options.xccdf_id = auto_select_xccdf_id(options.datastream, options.xccdf_id_number) try: bench_id = xml_operations.infer_benchmark_id_from_component_ref_id( options.datastream, options.xccdf_id) options.benchmark_id = bench_id except RuntimeError as exc: msg = "Error inferring benchmark ID from component refId: {}".format(str(exc)) raise RuntimeError(msg) if options.docker: options.test_env = ssg_test_suite.test_env.DockerTestEnv( options.scanning_mode, options.docker) logging.info( "The base image option has been specified, " "choosing Docker-based test environment.") elif options.container: options.test_env = ssg_test_suite.test_env.PodmanTestEnv( options.scanning_mode, options.container) logging.info( "The base image option has been specified, " "choosing Podman-based test environment.") else: hypervisor, domain_name = options.libvirt # Possible hypervisor spec we have to catch: qemu+unix:///session if not re.match(r"[\w\+]+:///", hypervisor): hypervisor = "qemu:///" + hypervisor options.test_env = ssg_test_suite.test_env.VMTestEnv( options.scanning_mode, hypervisor, domain_name) logging.info( "The base image option has not been specified, " "choosing libvirt-based test environment.") # Add in product to the test environment. This is independent of actual # test environment type so we do it after creation. options.test_env.product = options.product options.test_env.duplicate_templates = options.duplicate_templates try: benchmark_cpes = xml_operations.benchmark_get_applicable_platforms( options.datastream, options.benchmark_id ) options.benchmark_cpes = benchmark_cpes except RuntimeError as exc: msg = "Error inferring platform from benchmark: {}".format(str(exc)) raise RuntimeError(msg)