diff --git a/src/DS/rds.c b/src/DS/rds.c index d2553b2dbe..346d3f7728 100644 --- a/src/DS/rds.c +++ b/src/DS/rds.c @@ -757,12 +757,7 @@ static int _ds_rds_create_from_dom(xmlDocPtr *ret, xmlDocPtr sds_doc, free(tailoring_component_ref_id); xmlNsPtr xlink_ns = xmlSearchNsByHref(doc, sds_res_node, BAD_CAST xlink_ns_uri); if (!xlink_ns) { - oscap_seterr(OSCAP_EFAMILY_XML, - "Unable to find namespace '%s' in the XML DOM tree. " - "This is most likely an internal error!.", - xlink_ns_uri); - free(tailoring_component_id); - return -1; + xlink_ns = xmlNewNs(tailoring_component_ref, BAD_CAST xlink_ns_uri, BAD_CAST "xlink"); } char *tailoring_cref_href = oscap_sprintf("#%s", tailoring_component_id); free(tailoring_component_id); diff --git a/tests/API/XCCDF/tailoring/all.sh b/tests/API/XCCDF/tailoring/all.sh index fc2ccd7436..de6cc043e8 100755 --- a/tests/API/XCCDF/tailoring/all.sh +++ b/tests/API/XCCDF/tailoring/all.sh @@ -98,6 +98,26 @@ function test_api_xccdf_tailoring_simple_include_in_arf { rm -f $result } +function test_api_xccdf_tailoring_simple_include_in_arf_xlink_namespace { + # This test case is a regression test for RHEL-34104 + + local INPUT=$srcdir/$1 + local TAILORING=$srcdir/$2 + + result=`mktemp` + stderr=`mktemp` + $OSCAP xccdf eval --tailoring-file $TAILORING --results-arf $result $INPUT 2>"$stderr" + if [ "$?" != "0" ]; then + return 1 + fi + + [ ! -s "$stderr" ] + assert_exists 1 '/arf:asset-report-collection/arf:report-requests/arf:report-request/arf:content/ds:data-stream-collection/ds:component/Tailoring' + + rm -f "$result" + rm -f "$stderr" +} + function test_api_xccdf_tailoring_profile_include_in_arf { local INPUT=$srcdir/$1 local TAILORING=$srcdir/$2 @@ -167,6 +187,7 @@ test_run "test_api_xccdf_tailoring_oscap_info_11" test_api_xccdf_tailoring_oscap test_run "test_api_xccdf_tailoring_oscap_info_12" test_api_xccdf_tailoring_oscap_info simple-tailoring.xml 1 test_run "test_api_xccdf_tailoring_autonegotiation" test_api_xccdf_tailoring_autonegotiation simple-tailoring-autonegotiation.xml xccdf_org.open-scap_profile_default 1 test_run "test_api_xccdf_tailoring_simple_include_in_arf" test_api_xccdf_tailoring_simple_include_in_arf simple-xccdf.xml simple-tailoring.xml +test_run "test_api_xccdf_tailoring_simple_include_in_arf_xlink_namespace" test_api_xccdf_tailoring_simple_include_in_arf_xlink_namespace xlink-test-simple-ds.xml simple-tailoring.xml test_run "test_api_xccdf_tailoring_profile_include_in_arf" test_api_xccdf_tailoring_profile_include_in_arf baseline.xccdf.xml baseline.tailoring.xml test_run "test_api_xccdf_tailoring_profile_generate_fix" test_api_xccdf_tailoring_profile_generate_fix baseline.xccdf.xml baseline.tailoring.xml test_run "test_api_xccdf_tailoring_profile_generate_guide" test_api_xccdf_tailoring_profile_generate_guide baseline.xccdf.xml baseline.tailoring.xml diff --git a/tests/API/XCCDF/tailoring/xlink-test-simple-ds.xml b/tests/API/XCCDF/tailoring/xlink-test-simple-ds.xml new file mode 100644 index 0000000000..a8d5701e0f --- /dev/null +++ b/tests/API/XCCDF/tailoring/xlink-test-simple-ds.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + 5.10 + 0001-01-01T00:00:00+00:00 + + + + + x + x + + x + + + + + + + + + + x + x + + x + + + + + + + + + + + + + + + + + + + oval:x:var:1 + + + + + x + + + + + + + incomplete + 1.0 + + Override +