From 89fd79f4d4f0b820c769af483d3eaa48bc3dc476 Mon Sep 17 00:00:00 2001 From: Arden97 Date: Thu, 2 Jul 2026 11:22:33 +0200 Subject: [PATCH] fix rewriting 'extends' attribute by an empty base profile --- tests/utils/autotailor_integration_test.sh | 9 +++++++++ utils/autotailor | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/utils/autotailor_integration_test.sh b/tests/utils/autotailor_integration_test.sh index 56b436db59..e8e73d4444 100755 --- a/tests/utils/autotailor_integration_test.sh +++ b/tests/utils/autotailor_integration_test.sh @@ -150,6 +150,15 @@ python3 $autotailor --id-namespace "com.example.www" --json-tailoring $json_tail $OSCAP xccdf eval --profile CMDL_P --progress --tailoring-file $tailoring --results $result $ds assert_exists 1 '/Benchmark/TestResult/rule-result[@idref="xccdf_com.example.www_rule_R3"]/result[text()="pass"]' +# JSON tailoring with base_profile_id must set 'extends' attribute +python3 $autotailor $ds --id-namespace "com.example.www" --json-tailoring $json_tailoring > $tailoring +saved_result=$result +result=$tailoring +assert_exists 1 '/*[local-name()="Tailoring"]/*[local-name()="Profile"][@id="xccdf_com.example.www_profile_JSON_P1"][@extends="xccdf_com.example.www_profile_P1"]' +assert_exists 1 '/*[local-name()="Tailoring"]/*[local-name()="Profile"][@id="xccdf_com.example.www_profile_JSON_P11"][@extends="xccdf_com.example.www_profile_P1"]' +assert_exists 0 '/*[local-name()="Tailoring"]/*[local-name()="Profile"][@id="xccdf_com.example.www_profile_JSON_P12"][@extends]' +result=$saved_result + # test --local-path option with absolute path (should use basename) python3 $autotailor --id-namespace "com.example.www" --local-path --select R3 $ds $original_profile > $tailoring saved_result=$result diff --git a/utils/autotailor b/utils/autotailor index bccd5bbc37..541f7ecbaa 100755 --- a/utils/autotailor +++ b/utils/autotailor @@ -670,7 +670,8 @@ if __name__ == "__main__": if args.profile or (args.json_tailoring and args.tailored_profile_id): p = t.get_or_create_tailored_profile_with_id(args.tailored_profile_id) - p.extends = args.profile + if args.profile: + p.extends = args.profile # Validate base profile try: