public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Sandro Bonazzola <sbonazzo@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/sos] f43: Rebased on upstream 4.12.1
Date: Tue, 20 Oct 2026 13:25:43 GMT [thread overview]
Message-ID: <179250274362.1.6136033182449861203.rpms-sos-d2a2828fc0fc@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/sos
Branch : f43
Commit : d2a2828fc0fc8f1c6f5b74db87f6be3809c4c5e5
Author : Sandro Bonazzola <sbonazzo@redhat.com>
Date : 2026-10-20T09:48:03+02:00
Stats : +7/-338 in 5 file(s)
URL : https://src.fedoraproject.org/rpms/sos/c/d2a2828fc0fc8f1c6f5b74db87f6be3809c4c5e5?branch=f43
Log:
Rebased on upstream 4.12.1
- Resolves: fedora#2555570
Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
---
diff --git a/.gitignore b/.gitignore
index 99aa5a3..3ac3d87 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,4 @@ sos-2.2.tar.gz
/4.11.1.tar.gz
/4.11.2.tar.gz
/4.12.0.tar.gz
+/4.12.1.tar.gz
diff --git a/0001-cleaner-refuse-out-of-tree-tar-members-on-extract.patch b/0001-cleaner-refuse-out-of-tree-tar-members-on-extract.patch
deleted file mode 100644
index c4e6738..0000000
--- a/0001-cleaner-refuse-out-of-tree-tar-members-on-extract.patch
+++ /dev/null
@@ -1,289 +0,0 @@
-From 7837ba43e4473b9b71a86135b2ddeb3a5cf1cfbc Mon Sep 17 00:00:00 2001
-From: Sandipan Roy <saroy@redhat.com>
-Date: Fri, 25 Sep 2026 16:20:54 +0200
-Subject: [PATCH 1/2] [cleaner] refuse out-of-tree tar members on extract
-
-sos clean used fully_trusted_filter plus a member-name-only path
-guard. That does not stop a symlink whose target is an absolute
-host path followed by a regular file with the same relative name,
-so extraction can write outside the dest directory.
-
-Use PEP-706 data_filter when available and skip FilterError
-members. Keep in-tree relative symlinks. Pre-filter the member
-list as well: Python 3.11.2 (Debian 12) ignores extraction_filter.
-Log skipped members. Non-root skips device nodes that mknod cannot
-create.
-
-Relevant: #4461
-
-Signed-off-by: Sandipan Roy <saroy@redhat.com>
-Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
----
- sos/cleaner/archives/__init__.py | 100 +++++++++++++++++++-----
- tests/unittests/cleaner_tests.py | 130 +++++++++++++++++++++++++++++++
- 2 files changed, 212 insertions(+), 18 deletions(-)
-
-diff --git a/sos/cleaner/archives/__init__.py b/sos/cleaner/archives/__init__.py
-index 32c2957d..2e908f00 100644
---- a/sos/cleaner/archives/__init__.py
-+++ b/sos/cleaner/archives/__init__.py
-@@ -22,36 +22,100 @@ from sos.utilities import (file_is_binary, sos_get_command_output,
- file_is_certificate)
-
-
-+def _path_is_within(directory, target):
-+ """Return True if *target* is inside (or equal to) *directory*.
-+
-+ Both arguments must already be absolute paths.
-+ """
-+ try:
-+ return os.path.commonpath([directory, target]) == directory
-+ except ValueError:
-+ return False
-+
-+
-+def _member_path_ok(abs_dest, member):
-+ """Return True when the member resolves inside *abs_dest*."""
-+ member_path = os.path.abspath(os.path.join(abs_dest, member.name))
-+ if not _path_is_within(abs_dest, member_path):
-+ return False
-+ if member.issym() or member.islnk():
-+ if os.path.isabs(member.linkname):
-+ link_target = member.linkname
-+ else:
-+ link_target = os.path.abspath(
-+ os.path.join(os.path.dirname(member_path), member.linkname)
-+ )
-+ if not _path_is_within(abs_dest, link_target):
-+ return False
-+ return True
-+
-+
-+def _warn_skip_member(member, reason):
-+ logging.getLogger('sos').warning(
-+ "[cleaner] skipping tar member %r: %s", member.name, reason)
-+
-+
-+def _make_safer_extract_filter(dest_path):
-+ """Build a per-archive extraction filter (closure).
-+
-+ PEP-706 ``data_filter`` is the primary check. It rejects special files
-+ (block devices, FIFOs) that are legitimate sosreport members, so those
-+ are rescued when their path stays inside the destination tree.
-+ Out-of-tree symlinks and absolute links are skipped rather than aborting
-+ the whole extraction. ``fully_trusted`` is not used: a member-name-only
-+ ``abspath``/``commonprefix`` guard does not stop a symlink-to-absolute-
-+ path followed by a regular file of the same relative name.
-+ """
-+ abs_dest = os.path.abspath(dest_path)
-+ data_filter = getattr(tarfile, 'data_filter', None)
-+
-+ def _filter(member, dest_path):
-+ if data_filter is not None:
-+ try:
-+ return data_filter(member, dest_path)
-+ except tarfile.FilterError as err:
-+ if (member.isdev() or member.isfifo()) \
-+ and _member_path_ok(abs_dest, member):
-+ return member
-+ _warn_skip_member(member, err)
-+ return None
-+
-+ if not _member_path_ok(abs_dest, member):
-+ _warn_skip_member(member, "path outside destination")
-+ return None
-+ return member
-+
-+ return _filter
-+
-+
- # python older than 3.8 will hit a pickling error when we go to spawn a new
- # process for extraction if this method is a part of the SoSObfuscationArchive
- # class. So, the simplest solution is to remove it from the class.
- def extract_archive(archive_path, tmpdir):
- with tarfile.open(archive_path) as archive:
- path = os.path.join(tmpdir, 'cleaner')
-- # set extract filter since python 3.12 (see PEP-706 for more)
-- # Because python 3.10 and 3.11 raises false alarms as exceptions
-- # (see #3330 for examples), we can't use data filter but must
-- # fully trust the archive (legacy behaviour)
-- archive.extraction_filter = getattr(tarfile, 'fully_trusted_filter',
-- (lambda member, path: member))
--
-- # Guard against "Arbitrary file write during tarfile extraction"
-- # Checks the extracted files don't stray out of the target directory.
-+ filt = _make_safer_extract_filter(path)
-+ # Honored on 3.12+ (and 3.11.4+). Debian 12 ships 3.11.2, where
-+ # this attribute is ignored; members must still be pre-filtered.
-+ archive.extraction_filter = filt
-+
- not_root = os.getuid() != 0
-- members = archive.getmembers()
-- for member in members:
-- member_path = os.path.join(path, member.name)
-- abs_directory = os.path.abspath(path)
-- abs_target = os.path.abspath(member_path)
-- prefix = os.path.commonprefix([abs_directory, abs_target])
-- if prefix != abs_directory:
-- raise Exception(f"Attempted path traversal in tarfle"
-- f"{prefix} != {abs_directory}")
-+ members = []
-+ for member in archive.getmembers():
-+ member = filt(member, path)
-+ if member is None:
-+ continue
- # Directories collected from the host may lack u+w or u+x
- # permissions, preventing child members from being created during
- # extract
- if not_root and member.isdir():
- member.mode |= stat.S_IWUSR | stat.S_IXUSR
-+ # tarfile.makedev() -> os.mknod() needs CAP_MKNOD. Drop device
-+ # nodes for non-root rather than aborting the whole extract.
-+ if not_root and member.isdev():
-+ _warn_skip_member(member, "device node requires root")
-+ continue
-+ members.append(member)
- archive.extractall(path, members=members)
- return os.path.join(path, archive.name.split('/')[-1].split('.tar')[0])
-
-diff --git a/tests/unittests/cleaner_tests.py b/tests/unittests/cleaner_tests.py
-index 12f41c7a..0ad10ba1 100644
---- a/tests/unittests/cleaner_tests.py
-+++ b/tests/unittests/cleaner_tests.py
-@@ -723,3 +723,133 @@ class PackedDirTarballTests(unittest.TestCase):
- with mock.patch.object(self.archive, 'get_file_content',
- return_value='{"components": {"report": {}}}'):
- self.assertEqual(self.archive._load_packed_dirs(), [])
-+
-+
-+class ExtractArchiveSafetyTests(unittest.TestCase):
-+ """Out-of-tree symlink members must not write outside dest."""
-+
-+ def _write_tar(self, members):
-+ import io
-+ import tarfile
-+ import tempfile
-+ with tempfile.NamedTemporaryFile(
-+ suffix='.tar', delete=False) as handle:
-+ tar_path = handle.name
-+ with tarfile.open(tar_path, 'w') as tf:
-+ for name, kind, extra in members:
-+ info = tarfile.TarInfo(name=name)
-+ if kind == 'symlink':
-+ info.type = tarfile.SYMTYPE
-+ info.linkname = extra
-+ tf.addfile(info)
-+ elif kind == 'chrdev':
-+ info.type = tarfile.CHRTYPE
-+ info.devmajor, info.devminor = extra
-+ tf.addfile(info)
-+ else:
-+ payload = extra
-+ info.size = len(payload)
-+ tf.addfile(info, io.BytesIO(payload))
-+ return tar_path
-+
-+ def test_absolute_symlink_does_not_write_outside_dest(self):
-+ import os
-+ import tempfile
-+ from sos.cleaner.archives import extract_archive
-+
-+ victim_dir = tempfile.mkdtemp()
-+ victim = os.path.join(victim_dir, 'pwned')
-+ tar_path = self._write_tar([
-+ ('sosreport-host/var/log/link', 'symlink', victim_dir),
-+ ('sosreport-host/var/log/link/pwned', 'file', b'PWNED\n'),
-+ ])
-+ dest = tempfile.mkdtemp()
-+ with self.assertLogs('sos', level='WARNING') as logcm:
-+ extract_archive(tar_path, dest)
-+ self.assertFalse(
-+ os.path.exists(victim),
-+ 'extraction followed an out-of-tree symlink',
-+ )
-+ self.assertTrue(
-+ any('skipping tar member' in rec for rec in logcm.output),
-+ logcm.output,
-+ )
-+ os.remove(tar_path)
-+
-+ def test_absolute_symlink_when_extractall_ignores_filter(self):
-+ """Debian 12 / Python 3.11.2 ignores TarFile.extraction_filter."""
-+ import os
-+ import tarfile
-+ import tempfile
-+ from sos.cleaner.archives import extract_archive
-+
-+ orig_extractall = tarfile.TarFile.extractall
-+
-+ def extractall_ignore_filter(self, *args, **kwargs):
-+ self.extraction_filter = (lambda member, path: member)
-+ return orig_extractall(self, *args, **kwargs)
-+
-+ victim_dir = tempfile.mkdtemp()
-+ victim = os.path.join(victim_dir, 'pwned')
-+ tar_path = self._write_tar([
-+ ('sosreport-host/var/log/link', 'symlink', victim_dir),
-+ ('sosreport-host/var/log/link/pwned', 'file', b'PWNED\n'),
-+ ])
-+ dest = tempfile.mkdtemp()
-+ with mock.patch.object(tarfile.TarFile, 'extractall',
-+ extractall_ignore_filter):
-+ with self.assertLogs('sos', level='WARNING'):
-+ extract_archive(tar_path, dest)
-+ self.assertFalse(
-+ os.path.exists(victim),
-+ 'extraction followed an out-of-tree symlink',
-+ )
-+ os.remove(tar_path)
-+
-+ def test_in_tree_relative_symlink_is_kept(self):
-+ import os
-+ import tempfile
-+ from sos.cleaner.archives import extract_archive
-+
-+ tar_path = self._write_tar([
-+ ('sosreport-host/etc/motd', 'file', b'hello\n'),
-+ ('sosreport-host/etc/motd.link', 'symlink', 'motd'),
-+ ])
-+ dest = tempfile.mkdtemp()
-+ extract_archive(tar_path, dest)
-+ found_link = None
-+ for root, _, files in os.walk(dest):
-+ if 'motd.link' in files:
-+ found_link = os.path.join(root, 'motd.link')
-+ break
-+ self.assertTrue(found_link and os.path.islink(found_link))
-+ self.assertEqual(os.readlink(found_link), 'motd')
-+ os.remove(tar_path)
-+
-+ def test_non_root_skips_device_and_keeps_later_files(self):
-+ import os
-+ import tempfile
-+ from sos.cleaner.archives import extract_archive
-+
-+ tar_path = self._write_tar([
-+ ('sosreport-host/etc/hostname', 'file', b'testhost\n'),
-+ ('sosreport-host/dev/null', 'chrdev', (1, 3)),
-+ ('sosreport-host/etc/hosts', 'file', b'127.0.0.1 localhost\n'),
-+ ])
-+ dest = tempfile.mkdtemp()
-+ with mock.patch('sos.cleaner.archives.os.getuid', return_value=1000):
-+ with self.assertLogs('sos', level='WARNING'):
-+ extract_archive(tar_path, dest)
-+
-+ found_hostname = found_hosts = found_null = None
-+ for root, _, files in os.walk(dest):
-+ if 'hostname' in files:
-+ found_hostname = os.path.join(root, 'hostname')
-+ if 'hosts' in files:
-+ found_hosts = os.path.join(root, 'hosts')
-+ if 'null' in files and os.path.basename(root) == 'dev':
-+ found_null = os.path.join(root, 'null')
-+ self.assertTrue(found_hostname)
-+ self.assertTrue(found_hosts)
-+ self.assertIsNone(found_null)
-+ os.remove(tar_path)
---
-2.55.0
-
diff --git a/0002-cleaner-refuse-out-of-tree-tar-members-for-hardlinks.patch b/0002-cleaner-refuse-out-of-tree-tar-members-for-hardlinks.patch
deleted file mode 100644
index 1429778..0000000
--- a/0002-cleaner-refuse-out-of-tree-tar-members-for-hardlinks.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-From 417e25897181d3099bd39f85f0a68c1df4a11860 Mon Sep 17 00:00:00 2001
-From: Pavel Moravec <pmoravec@redhat.com>
-Date: Fri, 25 Sep 2026 16:23:12 +0200
-Subject: [PATCH 2/2] [cleaner] refuse out-of-tree tar members for hardlinks
-
-Followup of previous commit to fix a scenario with hardlinks pointing out
-of the tree.
-
-Closes: #4461
-
-Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
----
- sos/cleaner/archives/__init__.py | 11 ++++++++++-
- 1 file changed, 10 insertions(+), 1 deletion(-)
-
-diff --git a/sos/cleaner/archives/__init__.py b/sos/cleaner/archives/__init__.py
-index 2e908f00..24c3d9b4 100644
---- a/sos/cleaner/archives/__init__.py
-+++ b/sos/cleaner/archives/__init__.py
-@@ -40,11 +40,20 @@ def _member_path_ok(abs_dest, member):
- return False
- if member.issym() or member.islnk():
- if os.path.isabs(member.linkname):
-+ # Absolute linkname is the same for both types: check it directly.
- link_target = member.linkname
-- else:
-+ elif member.issym():
-+ # Symlink: target is relative to the directory that will contain
-+ # the symlink on disk, i.e. dirname(member_path).
- link_target = os.path.abspath(
- os.path.join(os.path.dirname(member_path), member.linkname)
- )
-+ else:
-+ # Hardlink: tarfile resolves linkname relative to abs_dest (the
-+ # archive root), not relative to the member's directory.
-+ link_target = os.path.abspath(
-+ os.path.join(abs_dest, member.linkname)
-+ )
- if not _path_is_within(abs_dest, link_target):
- return False
- return True
---
-2.55.0
-
diff --git a/sos.spec b/sos.spec
index e44c250..81fdd63 100644
--- a/sos.spec
+++ b/sos.spec
@@ -1,6 +1,9 @@
+# bash_completions_dir is not defined by redhat-rpm-config on RHEL 9
+%{!?bash_completions_dir: %global bash_completions_dir %{_datadir}/bash-completion/completions}
+
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
-Version: 4.12.0
+Version: 4.12.1
Release: %autorelease
Source0: https://github.com/sosreport/sos/archive/%{version}.tar.gz
License: GPL-2.0-only
@@ -27,8 +30,6 @@ Recommends: python3-boto3
# Address duplicate man pages
BuildRequires: fdupes
%endif
-Patch1: 0001-cleaner-refuse-out-of-tree-tar-members-on-extract.patch
-Patch2: 0002-cleaner-refuse-out-of-tree-tar-members-for-hardlinks.patch
%description
Sos is a set of tools that gathers information about system
@@ -98,6 +99,7 @@ rm -rf %{buildroot}/usr/config/
%{python3_sitelib}/sos-*info/
%{_mandir}/man1/*
%{_mandir}/man5/*
+%{bash_completions_dir}/sos
%doc AUTHORS README.md
%license LICENSE
%config(noreplace) %{_sysconfdir}/sos/sos.conf
diff --git a/sources b/sources
index 16872b7..7868d7e 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (4.12.0.tar.gz) = d47776c686b01dcc5a96828138ce9bbd9b18ff9c2517e3a1dfd305a2e02b69ad6d4b96a09e376296744f6c9d51a873cccfabe3f33e06d3ebd7c8f45f36bb5c19
+SHA512 (4.12.1.tar.gz) = 74dc6e3d4f53db0f2e910ce419b7a06754d0bc30b3d0cf724e960c43583e2c965039f3a7d603c89be1d8b7592bbb83835128d855c59f14e58e618253c87c6401
reply other threads:[~2026-10-20 13:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179250274362.1.6136033182449861203.rpms-sos-d2a2828fc0fc@fedoraproject.org \
--to=sbonazzo@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox