diff --git a/docs/manual/developer/05_tools_and_utilities.md b/docs/manual/developer/05_tools_and_utilities.md index 633a986608fc..e87e2ed51103 100644 --- a/docs/manual/developer/05_tools_and_utilities.md +++ b/docs/manual/developer/05_tools_and_utilities.md @@ -543,7 +543,7 @@ $ python utils/generate_profile.py -i benchmark.xlsx list To generate a rule for a specific control: ``` -$ python utils/generate_profile.py -i benchmark.xlsx generate --product-type ocp -c 1.1.2 +$ python utils/generate_profile.py -i benchmark.xlsx generate -c 1.1.2 documentation_complete: false title: |- Ensure that the API server pod specification file ownership is set to root:root @@ -575,7 +575,7 @@ template: PLACEHOLDER To generate an entire section: ``` -$ python utils/generate_profile.py -i benchmark.xlsx generate --product-type ocp -s 1 +$ python utils/generate_profile.py -i benchmark.xlsx generate -s 1 ``` The `PLACEHOLDER` values must be filled in later, ideally when the rules are diff --git a/tests/unit/ssg-module/test_rule_dir_stats.py b/tests/unit/ssg-module/test_rule_dir_stats.py index 25235af8e316..7b937d81d092 100644 --- a/tests/unit/ssg-module/test_rule_dir_stats.py +++ b/tests/unit/ssg-module/test_rule_dir_stats.py @@ -115,74 +115,3 @@ def test_two_plus_remediation(): assert not rds.two_plus_remediation(one_rule, 'bash') assert not rds.two_plus_remediation(empty_rule, 'bash') assert not rds.two_plus_remediation(empty_rule, 'anaconda') - - -def test_prodtypes_oval(): - bad_rule = { - "id": "bad_rule", - "products": ["rhel8"], - "ovals": { - "rhel7.xml": { - "products": ["rhel7"] - } - } - } - good_rule = { - "id": "good_rule", - "products": ["rhel7"], - "ovals": { - "rhel7.xml": { - "products": ["rhel7"] - } - } - } - empty_rule = { - "id": "empty_rule" - } - no_oval_rule = { - "id": "empty_rule", - "products": ["rhel7"] - } - - assert rds.prodtypes_oval(bad_rule) - assert not rds.prodtypes_oval(good_rule) - assert not rds.prodtypes_oval(empty_rule) - assert not rds.prodtypes_oval(no_oval_rule) - - -def test_prodtypes_remediation(): - bad_rule = { - "id": "bad_rule", - "products": ["rhel8"], - "remediations": { - "bash": { - "rhel7.sh": { - "products": ["rhel7"] - } - } - } - } - good_rule = { - "id": "good_rule", - "products": ["rhel7"], - "remediations": { - "bash": { - "rhel7.sh": { - "products": ["rhel7"] - } - } - } - } - empty_rule = { - "id": "empty_rule" - } - no_remediation_rule = { - "id": "empty_rule", - "products": ["rhel7"] - } - - assert rds.prodtypes_remediation(bad_rule, 'bash') - assert not rds.prodtypes_remediation(good_rule, 'bash') - assert not rds.prodtypes_remediation(empty_rule, 'bash') - assert not rds.prodtypes_remediation(no_remediation_rule, 'bash') - assert not rds.prodtypes_remediation(no_remediation_rule, 'ansible') diff --git a/utils/generate_profile.py b/utils/generate_profile.py index 272a090d5758..b02b12b839ea 100755 --- a/utils/generate_profile.py +++ b/utils/generate_profile.py @@ -48,8 +48,6 @@ def setup_argument_parser() -> argparse.ArgumentParser: list_parser = subparsers.add_parser('list', help='List controls within a benchmark') list_parser.set_defaults(func=list_controls) generate_parser = subparsers.add_parser('generate', help='Generate a control from benchmark') - generate_parser.add_argument('-p', '--product-type', required=True, - help='Product name to generate in output') generate_parser.add_argument('-c', '--control', help='Control ID to generate') generate_parser.add_argument('-s', '--section', help='Section ID to generate, including containing controls') @@ -203,9 +201,8 @@ def _generate(self, node: pycompliance.Node) -> dict: class RuleGenerator(Generator): - def __init__(self, benchmark: pycompliance.Benchmark, product_type: str): + def __init__(self, benchmark: pycompliance.Benchmark): super().__init__(benchmark) - self.product_type = product_type def generate(self, control: pycompliance.Control): if not isinstance(control, pycompliance.Control): @@ -274,7 +271,7 @@ def generate_control(args): control = b.find(args.control) section = b.find(args.section) if control: - r = RuleGenerator(b, args.product_type) + r = RuleGenerator(b) r.generate(control) elif section: r = SectionGenerator(b)