SHA256
1
0
forked from pool/salt

Accepting request 1161691 from systemsmanagement:saltstack

OBS-URL: https://build.opensuse.org/request/show/1161691
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/salt?expand=0&rev=147
This commit is contained in:
Ana Guerrero 2024-03-26 18:25:12 +00:00 committed by Git OBS Bridge
commit 8486f4dbd9
6 changed files with 4058 additions and 1 deletions

View File

@ -1 +1 @@
37c3c283a5a6c4d2f7eadf672d34d01159c8db09
6f191fc01de41fe2c1c4b659d5738e80aeb89b4c

View File

@ -0,0 +1,80 @@
From 45b97042766e15a4336b141b40a03d68156771bc Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
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

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Tue Mar 26 08:44:29 UTC 2024 - Marek Czernek <marek.czernek@suse.com>
- Convert oscap output to UTF-8
- Added:
* switch-oscap-encoding-to-utf-8-639.patch
-------------------------------------------------------------------
Thu Mar 21 13:14:03 UTC 2024 - Marek Czernek <marek.czernek@suse.com>
- Make Salt compatible with Python 3.11
- Added:
* fix-salt-warnings-and-testuite-for-python-3.11-635.patch
-------------------------------------------------------------------
Fri Mar 15 10:00:35 UTC 2024 - Yeray Gutiérrez Cedrés <yeray.gutierrez@suse.com>
- 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 <pablo.suarezhernandez@suse.com>

View File

@ -357,6 +357,19 @@ 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 (modified at Patch106)
Patch104: decode-oscap-byte-stream-to-string-bsc-1219001.patch
### Commits to make Salt compatible with Python 3.11 (and 3.6)
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/d92b5423464f93da6e3feb47d05a9acef8da75f9
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/60b36489225f958772b6a2f99d8fe6ae33ee9d73
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/eee0eca5e48922e5e404f812ced08ca7484bb568
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/991f7cf0a7baf08a31194ce52f4ec08290db8e52
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/2688c86f45eea9f8a6b916fcdf8eb94b3f5e185b
# PATCH-FIX_UPSTREAM https://github.com/saltstack/salt/commit/a1873a1d6d50d1769ddef528d7442e38aba9de23
# PATCH-FIX_OPENSUSE https://github.com/openSUSE/salt/commit/c7ecccb0a080ca9cca097f760ef0992ab34f82df
Patch105: fix-salt-warnings-and-testuite-for-python-3.11-635.patch
# PATCH-FIX_OPENSUSE: https://github.com/openSUSE/salt/pull/639
Patch106: switch-oscap-encoding-to-utf-8-639.patch
### IMPORTANT: The line below is used as a snippet marker. Do not touch it.
### SALT PATCHES LIST END

View File

@ -0,0 +1,80 @@
From 4ec5c8bdb8aecac6752c639f494b86c7f8f57ba2 Mon Sep 17 00:00:00 2001
From: Marek Czernek <marek.czernek@suse.com>
Date: Tue, 26 Mar 2024 09:20:30 +0100
Subject: [PATCH] Switch oscap encoding to utf-8 (#639)
---
salt/modules/openscap.py | 7 ++++---
tests/unit/modules/test_openscap.py | 8 ++++----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/salt/modules/openscap.py b/salt/modules/openscap.py
index 89712ae722b..7322c667dcc 100644
--- a/salt/modules/openscap.py
+++ b/salt/modules/openscap.py
@@ -153,7 +153,7 @@ def xccdf_eval(xccdffile, ovalfiles=None, **kwargs):
tempdir = tempfile.mkdtemp()
proc = Popen(cmd_opts, stdout=PIPE, stderr=PIPE, cwd=tempdir)
(_, error) = proc.communicate()
- error = error.decode('ascii', errors='ignore')
+ error = error.decode('utf-8', errors='surogateescape')
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
error += "\nKilled by signal {}\n".format(proc.returncode)
@@ -204,10 +204,11 @@ def xccdf(params):
cmd = _XCCDF_MAP[action]["cmd_pattern"].format(args.profile, policy)
tempdir = tempfile.mkdtemp()
proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE, cwd=tempdir)
- (stdoutdata, error) = proc.communicate()
+ (_, error) = proc.communicate()
+ error = error.decode('utf-8', errors='surogateescape')
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 6fbdfed7cf9..c20220ea977 100644
--- a/tests/unit/modules/test_openscap.py
+++ b/tests/unit/modules/test_openscap.py
@@ -35,7 +35,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))}
)
),
):
@@ -82,7 +82,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"))}
)
),
):
@@ -137,7 +137,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"))}
)
),
):
@@ -180,7 +180,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.44.0