diff --git a/SOURCES/openscap-1.3.6-PR-1756-yaml-nulls.patch b/SOURCES/openscap-1.3.6-PR-1756-yaml-nulls.patch new file mode 100644 index 0000000..9489211 --- /dev/null +++ b/SOURCES/openscap-1.3.6-PR-1756-yaml-nulls.patch @@ -0,0 +1,150 @@ +From 89f99834ba183284a7d75835932a0c0ea4eb9007 Mon Sep 17 00:00:00 2001 +From: Evgeny Kolesnikov +Date: Mon, 17 May 2021 08:40:17 +0200 +Subject: [PATCH] oval/yamlfilecontent: Add 'null' values handling + +For now null values would be represented as string '(null)' as +record's field could not be attributed as nil="true" yet. +--- + .../independent/yamlfilecontent_probe.c | 9 ++++ + .../test_probes_yamlfilecontent_types.sh | 5 ++ + .../test_probes_yamlfilecontent_types.xml | 52 +++++++++++++++++++ + tests/probes/yamlfilecontent/types.yaml | 4 ++ + 4 files changed, 70 insertions(+) + +diff --git a/src/OVAL/probes/independent/yamlfilecontent_probe.c b/src/OVAL/probes/independent/yamlfilecontent_probe.c +index 62a8f4ff29..2d0cac6991 100644 +--- a/src/OVAL/probes/independent/yamlfilecontent_probe.c ++++ b/src/OVAL/probes/independent/yamlfilecontent_probe.c +@@ -41,6 +41,7 @@ + #define OSCAP_YAML_BOOL_TAG "tag:yaml.org,2002:bool" + #define OSCAP_YAML_FLOAT_TAG "tag:yaml.org,2002:float" + #define OSCAP_YAML_INT_TAG "tag:yaml.org,2002:int" ++#define OSCAP_YAML_NULL_TAG "tag:yaml.org,2002:null" + + #define OVECCOUNT 30 /* should be a multiple of 3 */ + +@@ -135,6 +136,14 @@ static SEXP_t *yaml_scalar_event_to_sexp(yaml_event_t *event) + return NULL; + } + } ++ if (question || !strcmp(tag, OSCAP_YAML_NULL_TAG)) { ++ if (match_regex("^(null|Null|NULL|~|)$", value)) { ++ // TODO: Return real NULL when record's field will support nil="true" ++ return SEXP_string_new("(null)", strlen("(null)")); ++ } else if (!question) { ++ return NULL; ++ } ++ } + + return SEXP_string_new(value, strlen(value)); + } +diff --git a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh +index 4f110f6eb7..e445771d03 100755 +--- a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh ++++ b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.sh +@@ -60,6 +60,11 @@ function test_probes_yamlfilecontent_types { + assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and @datatype!="boolean" and text()="true"]' + # string_number + assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and @datatype!="int" and text()="81"]' ++ # string_null ++ assert_exists 1 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and text()="null"]' ++ ++ # null_1_2_3 ++ assert_exists 3 $sd'/ind-sys:yamlfilecontent_item/ind-sys:value/field[@name="#" and text()="(null)"]' + + # bool_error_cast, int_error_cast, float_error_cast + co='/oval_results/results/system/oval_system_characteristics/collected_objects' +diff --git a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml +index adf96571b8..503ec2d4a4 100644 +--- a/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml ++++ b/tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml +@@ -262,6 +262,19 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +@@ -364,6 +377,21 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +@@ -517,6 +545,30 @@ + types.yaml + .float_error_cast + ++ ++ ++ /tmp ++ types.yaml ++ .null_1 ++ ++ ++ ++ /tmp ++ types.yaml ++ .null_2 ++ ++ ++ ++ /tmp ++ types.yaml ++ .null_3 ++ ++ ++ ++ /tmp ++ types.yaml ++ .string_null ++ + + + +diff --git a/tests/probes/yamlfilecontent/types.yaml b/tests/probes/yamlfilecontent/types.yaml +index f05fa3a967..fb26eab5f0 100644 +--- a/tests/probes/yamlfilecontent/types.yaml ++++ b/tests/probes/yamlfilecontent/types.yaml +@@ -19,7 +19,11 @@ bool_false_cast: !!bool "false" + int_cast: !!int "369" + float_cast: !!float "978.65" + string_true: "true" ++string_null: "null" + string_number: "81" + bool_error_cast: !!bool "falsee" + int_error_cast: !!int "50%" + float_error_cast: !!float "58.41$" ++null_1: null ++null_2: ++null_3: !!null "null" diff --git a/SPECS/openscap.spec b/SPECS/openscap.spec index a0b284f..d415d82 100644 --- a/SPECS/openscap.spec +++ b/SPECS/openscap.spec @@ -1,6 +1,6 @@ Name: openscap Version: 1.3.5 -Release: 4%{?dist} +Release: 5%{?dist} Summary: Set of open source libraries enabling integration of the SCAP line of standards Group: System Environment/Libraries License: LGPLv2+ @@ -10,6 +10,7 @@ Patch1: openscap-1.3.6-PR-1745-waive-hugepages.patch Patch2: openscap-1.3.6-PR-1748-covscan.patch Patch3: openscap-1.3.6-PR-1749-blueprint-fix.patch Patch4: openscap-1.3.6-PR-1753-getlogin.patch +Patch5: openscap-1.3.6-PR-1756-yaml-nulls.patch BuildRequires: cmake >= 2.6 BuildRequires: swig libxml2-devel libxslt-devel perl-generators perl-XML-Parser BuildRequires: rpm-devel @@ -218,6 +219,9 @@ rm -rf $RPM_BUILD_ROOT %{_bindir}/oscap-run-sce-script %changelog +* Wed Jul 14 2021 Evgenii Kolesnikov - 1.3.5-5 +- Add 'null' values handling to the yamlfilecontent probe (RHBZ#1981691) + * Tue Jun 01 2021 Jan Černý - 1.3.5-4 - Replace getlogin by cuserid