Skip to content

utils: relax the error when tar extraction filters are unavailable - #745

Merged
jkloetzke merged 1 commit into
BobBuildTool:masterfrom
rhubert:fix-744
Nov 21, 2026
Merged

jkloetzke merged 1 commit into
BobBuildTool:masterfrom
rhubert:fix-744

Conversation

@rhubert

@rhubert rhubert commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Python of Debians 12 did not support PEP 706 (Filter for tarfile.extractall) raising the Refusing to extract tar file: Python version is too old to do this safely error. As this is still a supported version of debian relax the error to warning level and continue without the extraction filter.

Fixes #744.

@rhubert

rhubert commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Implementing this as a policy would require a lot of work. The extraction might run when building, updating layers, on jenkins jobs, bob archive,... and the policy is only part of the recipeset and not passed to all the workers / intermediates, ...
By making this a warning we can avoid passing the unsafetar policy..

@rhubert

rhubert commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

For the unittests I do not see the error in the logs? 🤔

@jkloetzke

Copy link
Copy Markdown
Member

You need to view the raw logs and then search for "finished: FAIL". But yeah, all the tests logging makes it rather hard to follow.

2026-11-17T12:49:54.3906410Z test_utils_tarfilter     | ======================================================================
2026-11-17T12:49:54.3936493Z test_utils_tarfilter     | ERROR: testMissingExtractionFilter (test_utils_tarfilter.TestTarExtractFilter)
2026-11-17T12:49:54.3966246Z test_utils_tarfilter     | Warn once and leave extraction unfiltered without PEP 706.
2026-11-17T12:49:54.3967450Z test_utils_tarfilter     | ----------------------------------------------------------------------
2026-11-17T12:49:54.3996274Z test_utils_tarfilter     | Traceback (most recent call last):
2026-11-17T12:49:54.4026621Z test_utils_tarfilter     |   File "/home/runner/work/bob/bob/test/unit/test_utils_tarfilter.py", line 262, in testMissingExtractionFilter
2026-11-17T12:49:54.4086425Z test_utils_tarfilter     |     with tarfileOpen(fileobj=archive) as tar:
2026-11-17T12:49:54.4087703Z test_utils_tarfilter     |   File "/home/runner/work/bob/bob/pym/bob/utils.py", line 1044, in tarfileOpen
2026-11-17T12:49:54.4146605Z test_utils_tarfilter     |     ret = tarfile.open(name, mode, *args, **kwargs)
2026-11-17T12:49:54.4206952Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/tarfile.py", line 1889, in open
2026-11-17T12:49:54.4236794Z test_utils_tarfilter     |     return func(name, "r", fileobj, **kwargs)
2026-11-17T12:49:54.4266792Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/tarfile.py", line 1950, in gzopen
2026-11-17T12:49:54.4297799Z test_utils_tarfilter     |     from gzip import GzipFile
2026-11-17T12:49:54.4322068Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/coverage/control.py", line 452, in _should_trace
2026-11-17T12:49:54.4326305Z test_utils_tarfilter     |     disp = self._inorout.should_trace(filename, frame)
2026-11-17T12:49:54.4327605Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/coverage/inorout.py", line 401, in should_trace
2026-11-17T12:49:54.4328801Z test_utils_tarfilter     |     canonical = canonical_filename(filename)
2026-11-17T12:49:54.4329972Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/coverage/files.py", line 85, in canonical_filename
2026-11-17T12:49:54.4331025Z test_utils_tarfilter     |     cf = abs_file(cf)
2026-11-17T12:49:54.4332067Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/site-packages/coverage/files.py", line 158, in abs_file
2026-11-17T12:49:54.4333278Z test_utils_tarfilter     |     return actual_path(os.path.abspath(os.path.realpath(path)))
2026-11-17T12:49:54.4334396Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/posixpath.py", line 393, in realpath
2026-11-17T12:49:54.4335954Z test_utils_tarfilter     |     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2026-11-17T12:49:54.4337103Z test_utils_tarfilter     |   File "/opt/hostedtoolcache/Python/3.10.22/x64/lib/python3.10/posixpath.py", line 408, in _joinrealpath
2026-11-17T12:49:54.4338088Z test_utils_tarfilter     |     if strict is ALLOW_MISSING:
2026-11-17T12:49:54.4338785Z test_utils_tarfilter     | NameError: name 'ALLOW_MISSING' is not defined

Python of Debians 12 did not support PEP 706 (Filter for tarfile.extractall)
raising the `Refusing to extract tar file: Python version is too old to do this
safely` error. As this is still a supported version of debian relax the
error to warning level and continue without the extraction filter.

Also change the order of the PEP 706 + CVE-2025-4517 test. First check
if the `data_filter` is available before checking for it's fix.

Fixes BobBuildTool#744.
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.44%. Comparing base (423b76e) to head (6dc537e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #745   +/-   ##
=======================================
  Coverage   90.43%   90.44%           
=======================================
  Files          60       60           
  Lines       17587    17590    +3     
=======================================
+ Hits        15905    15909    +4     
+ Misses       1682     1681    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rhubert

rhubert commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

:/ WarnOnce doesn't play well with the parallel gui

@jkloetzke
jkloetzke merged commit be64e43 into BobBuildTool:master Nov 21, 2026
11 checks passed
@jkloetzke

Copy link
Copy Markdown
Member

:/ WarnOnce doesn't play well with the parallel gui

Thanks. I'll put some fix for that on top. This has been a problem since a long time.

@jkloetzke

Copy link
Copy Markdown
Member

Just because I noticed this... Tests should go into a separate commit. That makes cherry-picks for stable branches easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debian 12: Refusing to extract tar file: Python version is too old to do this safely.

2 participants