From b169bcdce62ce2b23c2d05d059ffb21634447b25 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 15 2020 18:49:53 +0000 Subject: Apply patch openscap-1.3.4-export-profile-platform-PR_1609.patch patch_name: openscap-1.3.4-export-profile-platform-PR_1609.patch present_in_specfile: true --- diff --git a/src/XCCDF/profile.c b/src/XCCDF/profile.c index 776ef61..b8a3f47 100644 --- a/src/XCCDF/profile.c +++ b/src/XCCDF/profile.c @@ -319,7 +319,8 @@ void xccdf_profile_to_dom(struct xccdf_profile *profile, xmlNode *profile_node, struct oscap_string_iterator *platforms = xccdf_profile_get_platforms(profile); while (oscap_string_iterator_has_more(platforms)) { const char *platform = oscap_string_iterator_next(platforms); - xmlNewTextChild(profile_node, ns_xccdf, BAD_CAST "platform", BAD_CAST platform); + xmlNode *platform_node = xmlNewTextChild(profile_node, ns_xccdf, BAD_CAST "platform", NULL); + xmlNewProp(platform_node, BAD_CAST "idref", BAD_CAST platform); } oscap_string_iterator_free(platforms); diff --git a/tests/API/XCCDF/unittests/CMakeLists.txt b/tests/API/XCCDF/unittests/CMakeLists.txt index 05ddea2..153a1c3 100644 --- a/tests/API/XCCDF/unittests/CMakeLists.txt +++ b/tests/API/XCCDF/unittests/CMakeLists.txt @@ -62,6 +62,7 @@ add_oscap_test("test_default_selector.sh") add_oscap_test("test_inherit_selector.sh") add_oscap_test("test_xccdf_refine_value_bad.sh") add_oscap_test("test_xccdf_resolve.sh") +add_oscap_test("test_xccdf_resolve_profile_platform.sh") add_oscap_test("test_xccdf_results_arf_no_oval.sh") add_oscap_test("test_xccdf_sub_title.sh") add_oscap_test("test_xccdf_test_system.sh") diff --git a/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.sh b/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.sh new file mode 100755 index 0000000..95f8ce4 --- /dev/null +++ b/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +. $builddir/tests/test_common.sh + +######################################################################## +### Test "oscap xccdf resolve" command on a Profile with platform +######################################################################## + +set -e +set -o pipefail + +name=$(basename $0 .sh) + +result=$(mktemp -t ${name}.res.XXXXXX) +stderr=$(mktemp -t ${name}.out.XXXXXX) +stdout=$(mktemp -t ${name}.out.XXXXXX) + + +echo "Stderr file = $stderr" +echo "Result file = $result" + +$OSCAP xccdf resolve --output $result $srcdir/${name}.xccdf.xml > $stdout +$OSCAP xccdf validate $result >> $stdout + +assert_exists 1 '//Benchmark[@resolved="1"]' + +# Resolve Profile Platform +assert_exists 2 '//Profile[@id="xccdf_resolve_profile_platform"]/select' +assert_exists 1 '//Profile[@id="xccdf_resolve_profile_platform"]/platform[@idref="cpe:/a:open-scap:oscap"]' + +[ -f $stderr ]; [ ! -s $stderr ]; rm $stderr +rm $result diff --git a/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.xccdf.xml b/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.xccdf.xml new file mode 100644 index 0000000..f4773be --- /dev/null +++ b/tests/API/XCCDF/unittests/test_xccdf_resolve_profile_platform.xccdf.xml @@ -0,0 +1,13 @@ + + + incomplete + 1.0 + + + Profile with platform + + + + +