diff --git a/stages/org.osbuild.oscap.autotailor b/stages/org.osbuild.oscap.autotailor index 3c33eecb..2b8daedc 100755 --- a/stages/org.osbuild.oscap.autotailor +++ b/stages/org.osbuild.oscap.autotailor @@ -14,10 +14,15 @@ def main(tree, options): profile = config.get("profile_id") new_profile = config.get("new_profile") tailoring_file = config.get("tailoring_file") + # use `new_profile` as a fallback for backwards compatibility + tailored_profile_id = config.get("tailored_profile_id", new_profile) + + if new_profile is not None: + print("WARNING: use the `tailored_profile_id` option instead") # make sure either profile & new_profile are set # or tailoring_filepath is set - if not ((profile and new_profile) or tailoring_file): + if not ((profile and tailored_profile_id) or tailoring_file): raise ValueError("Either profile & new profile must be set or provide filepath to json tailoring file") if tailoring_file: @@ -39,7 +44,7 @@ def main(tree, options): cmd = [ "/usr/bin/autotailor", "--output", f"{tree}/{filepath.lstrip('/')}", - "--new-profile-id", new_profile + "--new-profile-id", tailored_profile_id, ] for s in selected: diff --git a/stages/org.osbuild.oscap.autotailor.meta.json b/stages/org.osbuild.oscap.autotailor.meta.json index 77f28c10..3c346044 100644 --- a/stages/org.osbuild.oscap.autotailor.meta.json +++ b/stages/org.osbuild.oscap.autotailor.meta.json @@ -33,8 +33,7 @@ "additionalProperties": false, "required": [ "profile_id", - "datastream", - "new_profile" + "datastream" ], "type": "object", "description": "OpenSCAP configuration variables", @@ -49,7 +48,11 @@ }, "new_profile": { "type": "string", - "description": "The name of the new customized OpenSCAP profile" + "description": "The id of the new customized (tailored) OpenSCAP profile" + }, + "tailored_profile_id": { + "type": "string", + "description": "The id of the new customized (tailored) OpenSCAP profile" }, "selected": { "type": "array", diff --git a/stages/test/test_autotailor.py b/stages/test/test_autotailor.py index b9e90fd0..ac08d6ba 100644 --- a/stages/test/test_autotailor.py +++ b/stages/test/test_autotailor.py @@ -45,7 +45,7 @@ def fake_input_fixture(): "config": { "profile_id": "some-profile-id", "datastream": "some-datastream", - "new_profile": "some-new-profile", + "tailoring_profile_id": "some-new-profile", } }, } @@ -90,7 +90,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage "value": 50, }, ] - }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile'," + }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile'," + " 'overrides': [{'no': 'var', 'value': 50}]} is not valid under any of the given schemas"), ({ "overrides": [ @@ -99,7 +99,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage "var": "some", }, ] - }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile'," + }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile'," + " 'overrides': [{'no': 'value', 'var': 'some'}]} is not valid under any of the given schemas"), ({ "overrides": [ @@ -108,7 +108,7 @@ def test_oscap_autotailor_overrides_smoke(mock_subprocess_run, fake_input, stage "value": {"some": "object"}, }, ] - }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'new_profile': 'some-new-profile'," + }, "{'profile_id': 'some-profile-id', 'datastream': 'some-datastream', 'tailoring_profile_id': 'some-new-profile'," + " 'overrides': [{'var': 'ssh_idle_timeout_value', 'value': {'some': 'object'}}]} is not valid under any of the given schemas"), ], ) diff --git a/test/data/stages/oscap.autotailor/b.json b/test/data/stages/oscap.autotailor/b.json index b8cebf04..c5714cc4 100644 --- a/test/data/stages/oscap.autotailor/b.json +++ b/test/data/stages/oscap.autotailor/b.json @@ -464,7 +464,7 @@ "config": { "datastream": "/usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml", "profile_id": "xccdf_org.ssgproject.content_profile_ospp", - "new_profile": "xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring", + "tailored_profile_id": "xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring", "selected": [ "partition_for_var_log" ], diff --git a/test/data/stages/oscap.autotailor/b.mpp.yaml b/test/data/stages/oscap.autotailor/b.mpp.yaml index 5360f50c..f2564f55 100644 --- a/test/data/stages/oscap.autotailor/b.mpp.yaml +++ b/test/data/stages/oscap.autotailor/b.mpp.yaml @@ -21,7 +21,7 @@ pipelines: config: datastream: /usr/share/xml/scap/ssg/content/ssg-fedora-ds.xml profile_id: xccdf_org.ssgproject.content_profile_ospp - new_profile: xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring + tailored_profile_id: xccdf_org.ssgproject.content_profile_ospp_osbuild_tailoring selected: - partition_for_var_log unselected: