diff --git a/shared/macros/10-oval.jinja b/shared/macros/10-oval.jinja index a3ef9910a090..63eb602caa54 100644 --- a/shared/macros/10-oval.jinja +++ b/shared/macros/10-oval.jinja @@ -7,7 +7,7 @@ Generates the :code:`` tag for OVAL check using correct product platfo #}} {{%- macro oval_affected(products) %}} -{{{ prodtype_to_platform(products)|indent(2) }}} +{{{ product_to_platform(products)|indent(2) }}} {{%- endmacro %}} @@ -132,7 +132,7 @@ Generates the :code:`` tag for OVAL check using correct product platfo {{{ oval_metadata("Ensure '" + parameter + "' is configured with value '" + value | replace("(?i)", "") | replace("(?-i)", "") + (" in section '" + section if section else "") + "' in " + path) }}} - {{% set dir_path = path + ".d" %}} + {{% set dir_path = path + ".d" %}} {{{- oval_line_in_file_criterion(path, parameter) }}} @@ -1057,9 +1057,9 @@ Generates the :code:`` tag for OVAL check using correct product platfo {{% if product in ['opensuse', 'sle12','sle15'] %}} - - {{% else %}} + {{% else %}} {{% endif %}} diff --git a/shared/schemas/rule.json b/shared/schemas/rule.json index 7214e728a6d9..e5b1a9305322 100644 --- a/shared/schemas/rule.json +++ b/shared/schemas/rule.json @@ -84,7 +84,6 @@ "required": [ "documentation_complete", "title", - "prodtype", "description", "rationale", "severity" diff --git a/ssg/build_yaml.py b/ssg/build_yaml.py index 78b7e61a21b9..2eee61b69591 100644 --- a/ssg/build_yaml.py +++ b/ssg/build_yaml.py @@ -741,8 +741,7 @@ def __deepcopy__(self, memo): def _has_platforms_to_convert(rule, product_cpes): # Convert the platform names to CPE names # But only do it if an env_yaml was specified (otherwise there would - # be no product CPEs to lookup), and the rule's prodtype matches the - # product being built also if the rule already has cpe_platform_names + # be no product CPEs to lookup) and if the rule already has cpe_platform_names # specified (compiled rule) do not evaluate platforms again return product_cpes and not rule.cpe_platform_names diff --git a/ssg/entities/profile.py b/ssg/entities/profile.py index 852d8bdaa660..38ea4cdbf10d 100644 --- a/ssg/entities/profile.py +++ b/ssg/entities/profile.py @@ -58,7 +58,6 @@ def resolve(self, all_profiles, rules_by_id, controls_manager=None): if rid not in rules_by_id: msg = ( "Rule {rid} is selected by {profile}, but the rule is not available. " - "This may be caused by a discrepancy of prodtypes." .format(rid=rid, profile=self.id_)) raise ValueError(msg) diff --git a/ssg/jinja.py b/ssg/jinja.py index b4641f87befa..e8446b477960 100644 --- a/ssg/jinja.py +++ b/ssg/jinja.py @@ -16,9 +16,9 @@ from .constants import JINJA_MACROS_DIRECTORY from .utils import (required_key, - prodtype_to_name, + product_to_name, name_to_platform, - prodtype_to_platform, + product_to_platform, banner_regexify, banner_anchor_wrap, escape_id, @@ -135,9 +135,9 @@ def process_file(filepath, substitutions_dict): def add_python_functions(substitutions_dict): - substitutions_dict['prodtype_to_name'] = prodtype_to_name + substitutions_dict['product_to_name'] = product_to_name substitutions_dict['name_to_platform'] = name_to_platform - substitutions_dict['prodtype_to_platform'] = prodtype_to_platform + substitutions_dict['product_to_platform'] = product_to_platform substitutions_dict['url_encode'] = url_encode substitutions_dict['raise'] = raise_exception substitutions_dict['expand_yaml_path'] = expand_yaml_path diff --git a/ssg/utils.py b/ssg/utils.py index 010b0b39e3de..f728a26489cf 100644 --- a/ssg/utils.py +++ b/ssg/utils.py @@ -128,9 +128,9 @@ def map_name(version): % (version)) -def prodtype_to_name(prod): +def product_to_name(prod): """ - Converts a vaguely-prodtype-like thing into one or more full product names. + Converts a vaguely-product-id-like thing into one or more full product names. """ for name, prod_type in FULL_NAME_TO_PRODUCT_MAPPING.items(): if prod == prod_type: @@ -150,14 +150,14 @@ def name_to_platform(names): return "\n".join(map(name_to_platform, names)) -def prodtype_to_platform(prods): +def product_to_platform(prods): """ - Converts one or more prodtypes into a string with one or more + Converts one or more product ids into a string with one or more elements. """ if isinstance(prods, str): - return name_to_platform(prodtype_to_name(prods)) - return "\n".join(map(prodtype_to_platform, prods)) + return name_to_platform(product_to_name(prods)) + return "\n".join(map(product_to_platform, prods)) def parse_name(product): @@ -181,7 +181,7 @@ def parse_name(product): def get_fixed_product_version(product, product_version): # Some product versions have a dot in between the numbers - # While the prodtype doesn't have the dot, the full product name does + # While the product id doesn't have the dot, the full product name does if product == "ubuntu" or product == "macos": product_version = product_version[:2] + "." + product_version[2:] return product_version @@ -230,8 +230,7 @@ def is_applicable_for_product(platform, product): def is_applicable(platform, product): """ Function to check if a platform is applicable for the product. - Handles when a platform is really a list of products, i.e., a - prodtype field from a rule.yml. + Handles when a platform is really a list of products. Returns true iff product is applicable for the platform or list of products diff --git a/tests/ssg_test_suite/rule.py b/tests/ssg_test_suite/rule.py index 4650e6bfdd0e..583e7ae20455 100644 --- a/tests/ssg_test_suite/rule.py +++ b/tests/ssg_test_suite/rule.py @@ -322,17 +322,6 @@ def _get_rules_to_test(self): rule, local_env_yaml = common.load_rule_and_env( dirpath, product_yaml, product) - # Before we get too far, we wish to search the rule YAML to see if - # it is applicable to the current product. If we have a product - # and the rule isn't applicable for the product, there's no point - # in continuing with the rest of the loading. This should speed up - # the loading of the templated tests. Note that we've already - # parsed the prodtype into local_env_yaml - if product and local_env_yaml['products']: - prodtypes = local_env_yaml['products'] - if "all" not in prodtypes and product not in prodtypes: - continue - tests_dir = os.path.join(dirpath, "tests") template_name = None if rule.template and rule.template['vars']: diff --git a/utils/fix_rules.py b/utils/fix_rules.py index 5e2b6b5285a6..3c43b49357ab 100755 --- a/utils/fix_rules.py +++ b/utils/fix_rules.py @@ -47,8 +47,6 @@ def has_empty_identifier(rule_path, rule, rule_lines): def has_no_cce(yaml_file, product_yaml=None): rule = yaml.open_and_macro_expand(yaml_file, product_yaml) product = product_yaml["product"] - if "prodtype" in rule and product not in rule["prodtype"]: - return False if 'identifiers' in rule and rule['identifiers'] is None: return True diff --git a/utils/gen_srg_table.py b/utils/gen_srg_table.py index ff5b7ed02616..1496ed45d0fd 100644 --- a/utils/gen_srg_table.py +++ b/utils/gen_srg_table.py @@ -50,6 +50,6 @@ def get_rules_by_srgid(build_dir, product): data = dict() data["srgs"] = ssg.build_stig.parse_srgs(args.srgs) data["rules_by_srgid"] = get_rules_by_srgid(args.build_dir, args.product) - data["full_name"] = ssg.utils.prodtype_to_name(args.product) + data["full_name"] = ssg.utils.product_to_name(args.product) render_template(data, SRGMAP_TEMPLATE, args.srgmap) render_template(data, SRGMAP_FLAT_TEMPLATE, args.srgmap_flat) diff --git a/utils/generate_profile.py b/utils/generate_profile.py index 4fd3f93e2544..272a090d5758 100755 --- a/utils/generate_profile.py +++ b/utils/generate_profile.py @@ -216,7 +216,6 @@ def generate(self, control: pycompliance.Control): ) output = { 'documentation_complete': False, - 'prodtype': self.product_type, 'title': LiteralUnicode(control.title), 'description': description, 'rationale': LiteralUnicode(control.rationale),