From 63fecc779b01b6ef6ace9ff494f64c2358c5235233a3c93c99244c491931d2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Tue, 19 Mar 2024 10:22:23 +0000 Subject: [PATCH] Accepting request 1158231 from home:ygutierrez:branches:systemsmanagement:saltstack-oscap - Ignore non-ascii chars in oscap output (bsc#1219001) - Added: * decode-oscap-byte-stream-to-string-bsc-1219001.patch OBS-URL: https://build.opensuse.org/request/show/1158231 OBS-URL: https://build.opensuse.org/package/show/systemsmanagement:saltstack/salt?expand=0&rev=239 --- _lastrevision | 2 +- ...ap-byte-stream-to-string-bsc-1219001.patch | 80 +++++++++++++++++++ salt.changes | 8 ++ salt.spec | 2 + 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 decode-oscap-byte-stream-to-string-bsc-1219001.patch diff --git a/_lastrevision b/_lastrevision index 990cdc7..08aac20 100644 --- a/_lastrevision +++ b/_lastrevision @@ -1 +1 @@ -37c3c283a5a6c4d2f7eadf672d34d01159c8db09 \ No newline at end of file +e5cb245008cb6c5c2e6da334bc30ceaa7c428bdf \ No newline at end of file diff --git a/decode-oscap-byte-stream-to-string-bsc-1219001.patch b/decode-oscap-byte-stream-to-string-bsc-1219001.patch new file mode 100644 index 0000000..3cca99d --- /dev/null +++ b/decode-oscap-byte-stream-to-string-bsc-1219001.patch @@ -0,0 +1,80 @@ +From 45b97042766e15a4336b141b40a03d68156771bc Mon Sep 17 00:00:00 2001 +From: Marek Czernek +Date: Thu, 14 Mar 2024 16:16:02 +0100 +Subject: [PATCH] Decode oscap byte stream to string (bsc#1219001) + +--- + salt/modules/openscap.py | 5 +++-- + tests/unit/modules/test_openscap.py | 10 +++++----- + 2 files changed, 8 insertions(+), 7 deletions(-) + +diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py +index 216fd89eef..89712ae722 100644 +--- a/salt/modules/openscap.py ++++ b/salt/modules/openscap.py +@@ -152,10 +152,11 @@ def xccdf_eval(xccdffile, ovalfiles=None, **kwargs): + if success: + tempdir = tempfile.mkdtemp() + proc = Popen(cmd_opts, stdout=PIPE, stderr=PIPE, cwd=tempdir) +- (stdoutdata, error) = proc.communicate() ++ (_, error) = proc.communicate() ++ error = error.decode('ascii', errors='ignore') + success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False) + if proc.returncode < 0: +- error += "\nKilled by signal {}\n".format(proc.returncode).encode('ascii') ++ error += "\nKilled by signal {}\n".format(proc.returncode) + returncode = proc.returncode + if success: + __salt__["cp.push_dir"](tempdir) +diff --git a/tests/unit/modules/test_openscap.py b/tests/unit/modules/test_openscap.py +index 301c1869ec..6fbdfed7cf 100644 +--- a/tests/unit/modules/test_openscap.py ++++ b/tests/unit/modules/test_openscap.py +@@ -218,7 +218,7 @@ class OpenscapTestCase(TestCase): + "salt.modules.openscap.Popen", + MagicMock( + return_value=Mock( +- **{"returncode": 0, "communicate.return_value": ("", "")} ++ **{"returncode": 0, "communicate.return_value": (bytes(0), bytes(0))} + ) + ), + ): +@@ -269,7 +269,7 @@ class OpenscapTestCase(TestCase): + "salt.modules.openscap.Popen", + MagicMock( + return_value=Mock( +- **{"returncode": 0, "communicate.return_value": ("", "")} ++ **{"returncode": 0, "communicate.return_value": (bytes(0), bytes(0))} + ) + ), + ): +@@ -323,7 +323,7 @@ class OpenscapTestCase(TestCase): + "salt.modules.openscap.Popen", + MagicMock( + return_value=Mock( +- **{"returncode": 2, "communicate.return_value": ("", "some error")} ++ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))} + ) + ), + ): +@@ -374,7 +374,7 @@ class OpenscapTestCase(TestCase): + "salt.modules.openscap.Popen", + MagicMock( + return_value=Mock( +- **{"returncode": 2, "communicate.return_value": ("", "some error")} ++ **{"returncode": 2, "communicate.return_value": (bytes(0), bytes("some error", "UTF-8"))} + ) + ), + ): +@@ -423,7 +423,7 @@ class OpenscapTestCase(TestCase): + return_value=Mock( + **{ + "returncode": 1, +- "communicate.return_value": ("", "evaluation error"), ++ "communicate.return_value": (bytes(0), bytes("evaluation error", "UTF-8")), + } + ) + ), +-- +2.43.0 + diff --git a/salt.changes b/salt.changes index 67ac797..9f03147 100644 --- a/salt.changes +++ b/salt.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Mar 15 10:00:35 UTC 2024 - Yeray Gutiérrez Cedrés + +- Ignore non-ascii chars in oscap output (bsc#1219001) + +- Added: + * decode-oscap-byte-stream-to-string-bsc-1219001.patch + ------------------------------------------------------------------- Thu Mar 14 13:11:21 UTC 2024 - Pablo Suárez Hernández diff --git a/salt.spec b/salt.spec index ac2d43c..8f716dc 100644 --- a/salt.spec +++ b/salt.spec @@ -357,6 +357,8 @@ Patch101: fix-problematic-tests-and-allow-smooth-tests-executi.patch Patch102: make-importing-seco.range-thread-safe-bsc-1211649.patch # PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66130 PAtch103: fix-tests-failures-and-errors-when-detected-on-vm-ex.patch +# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/pull/66234 +Patch104: decode-oscap-byte-stream-to-string-bsc-1219001.patch ### IMPORTANT: The line below is used as a snippet marker. Do not touch it. ### SALT PATCHES LIST END