From 8edda4238ef614dfd848ff0e05167ccf1e8892f3 Mon Sep 17 00:00:00 2001 From: Alfred Wingate Date: Mon, 27 Nov 2023 12:58:11 +0200 Subject: [PATCH] checks.git: Set tarfile filter * Not setting it triggers a DeprecationWarning in python3.12. * Despite tarballs by git-archive being trusted, there isn't benefit in trusting it as the tarballs don't use metadata that would require it. Signed-off-by: Alfred Wingate Closes: https://github.com/pkgcore/pkgcheck/pull/638 Signed-off-by: Arthur Zamarin --- src/pkgcheck/checks/git.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pkgcheck/checks/git.py b/src/pkgcheck/checks/git.py index 525bf6936..31f1dc69e 100644 --- a/src/pkgcheck/checks/git.py +++ b/src/pkgcheck/checks/git.py @@ -283,6 +283,10 @@ def _populate(self, pkgs): if old_files.poll(): error = old_files.stderr.read().decode().strip() raise PkgcheckUserException(f"failed populating archive repo: {error}") + # https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter + if hasattr(tarfile, "data_filter"): + # https://docs.python.org/3.12/library/tarfile.html#tarfile.TarFile.extraction_filter + tarfile.TarFile.extraction_filter = staticmethod(tarfile.data_filter) with tarfile.open(mode="r|", fileobj=old_files.stdout) as tar: tar.extractall(path=self.location)