[2.8][PATCH 0/4] Pull request
Passed a-full on autobuilder:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/29/builds/3933
The following changes since commit 82abbfcdbda949851a03bb2cb2049ea689564ad6:
tests/fetch: Avoid using git protocol in tests (2026-05-13 22:22:20 +0200)
are available in the Git repository at:
https://git.openembedded.org/bitbake-contrib stable/2.8-next
https://git.openembedded.org/bitbake-contrib/log/?h=stable/2.8-next
for you to fetch changes up to 37beb06ba9329cd16976273efbb341f781d4e749:
fetch2: Unpack RPMs with --no-absolute-filenames (2026-06-05 12:50:29 +0200)
----------------------------------------------------------------
Anders Heimer (4):
fetch2: validate deb/ipk data member names
fetch2: validate striplevel parameter fetch2/git: quote shallow extra ref arguments
fetch2: Unpack RPMs with --no-absolute-filenames
lib/bb/fetch2/__init__.py | 19 +++++--- lib/bb/fetch2/git.py | 2 +- lib/bb/tests/fetch.py | 94 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 7 deletions(-)
[bitbake][scarthgap][2.8][PATCH 4/4] fetch2: Unpack RPMs with --no-absolute-filenames
From: Anders Heimer <[email protected]>
Use cpio --no-absolute-filenames when unpacking RPM and SRPM archives so absolute paths and parent-directory components in cpio member names are extracted relative to the intended unpack directory.
--- lib/bb/fetch2/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/bb/fetch2/__init__.py +2 -2
@@ -1563,11 +1563,11 @@ class FetchMethod(object): elif file.endswith('.rpm') or file.endswith('.srpm'): if 'extract' in urldata.parm: unpack_file = urldata.parm.get('extract') - cmd = 'rpm2cpio.sh %s | cpio -id %s' % (file, unpack_file) + cmd = 'rpm2cpio.sh %s | cpio --no-absolute-filenames -id %s' % (file, unpack_file) iterate = True iterate_file = unpack_file else: - cmd = 'rpm2cpio.sh %s | cpio -id' % (file) + cmd = 'rpm2cpio.sh %s | cpio --no-absolute-filenames -id' % (file) elif file.endswith('.deb') or file.endswith('.ipk'): output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup) datafile = None
[bitbake][scarthgap][2.8][PATCH 2/4] fetch2: validate striplevel parameter
In reply to Yoann CongalFrom: Anders Heimer <[email protected]>
The striplevel URL parameter is appended to tar_cmd, which is later run through the shell. Validate it as a decimal count before using it in the tar arguments.
[YC: Removed the striplevel="1\n" subtest case. The URL-decoding regex in decodeurl uses .* without re.DOTALL, causing literal newlines in parameters to be silently truncated during parsing.]
--- lib/bb/fetch2/__init__.py | 5 ++++- lib/bb/tests/fetch.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +4 -1
@@ -1520,7 +1520,10 @@ class FetchMethod(object): if unpack: tar_cmd = 'tar --extract --no-same-owner' if 'striplevel' in urldata.parm: - tar_cmd += ' --strip-components=%s' % urldata.parm['striplevel'] + striplevel = urldata.parm['striplevel'] + if not striplevel.isdigit(): + raise UnpackError("Invalid striplevel parameter: %s" % striplevel, urldata.url) + tar_cmd += ' --strip-components=%s' % striplevel if file.endswith('.tar'): cmd = '%s -f %s' % (tar_cmd, file) elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
lib/bb/tests/fetch.py +11 -0
@@ -7,6 +7,7 @@ # import contextlib +import shutil import unittest import hashlib import tempfile
@@ -853,6 +854,16 @@ class FetcherLocalTest(FetcherTest): self.assertIn("does not contain supported data.tar* file", str(context.exception)) + def assertInvalidStriplevel(self, value): + with self.assertRaises(bb.fetch2.UnpackError) as context: + self.fetchUnpack(['file://archive.tar;subdir=bar;striplevel=%s' % value]) + self.assertIn("Invalid striplevel parameter", str(context.exception)) + + def test_local_striplevel_rejects_invalid_values(self): + for value in ("abc", "", "-1", "1 2"): + with self.subTest(striplevel=repr(value)): + self.assertInvalidStriplevel(value) + def dummyGitTest(self, suffix): # Create dummy local Git repo src_dir = tempfile.mkdtemp(dir=self.tempdir,
[bitbake][scarthgap][2.8][PATCH 3/4] fetch2/git: quote shallow extra ref arguments
In reply to Yoann CongalFrom: Anders Heimer <[email protected]>
BB_GIT_SHALLOW_EXTRA_REFS can include wildcard entries. Matching refs advertised by the remote are later passed to git fetch and update-ref while creating shallow tarballs.
Quote the generated command arguments and pass the fetched ref after -- so shell metacharacters and option-like ref names are not interpreted as command syntax or git fetch options.
[YC: Only the quote part of the master patch applies.
The "--" part does not. This part is handled by bin/git-make-shallow which only pass arguments to git rev-list and rev-parse through arrays]
--- lib/bb/fetch2/git.py | 2 +- lib/bb/tests/fetch.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-)
lib/bb/fetch2/git.py +1 -1
@@ -602,7 +602,7 @@ class Git(FetchMethod): shallow_cmd = [self.make_shallow_path, '-s'] for b in shallow_branches: shallow_cmd.append('-r') - shallow_cmd.append(b) + shallow_cmd.append(shlex.quote(b)) shallow_cmd.extend(shallow_revisions) runfetchcmd(subprocess.list2cmdline(shallow_cmd), d, workdir=dest)
lib/bb/tests/fetch.py +30 -0
@@ -2206,6 +2206,36 @@ class GitShallowTest(FetcherTest): self.assertRefs(['master', 'origin/master', 'v1.0']) self.assertRevCount(1) + def test_shallow_extra_refs_wildcard_shell_quoted(self): + self.add_empty_file('a') + marker = os.path.join(self.tempdir, 'ref-command-marker') + ref = 'refs/tags/poc;touch${IFS}%s' % marker + self.git(['update-ref', ref, 'HEAD'], cwd=self.srcdir) + + self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*') + self.fetch_shallow() + + self.assertFalse(os.path.exists(marker)) + self.assertRefs(['master', 'origin/master', ref]) + + def test_shallow_extra_refs_wildcard_fetch_options(self): + self.add_empty_file('a') + marker = os.path.join(self.tempdir, 'ref-option-marker') + helper = os.path.join(self.tempdir, 'upload-pack-helper') + with open(helper, 'w') as f: + f.write('#!/bin/sh\n') + f.write('touch "%s"\n' % marker) + f.write('exec git-upload-pack "$@"\n') + os.chmod(helper, 0o755) + ref = 'refs/tags/--upload-pack=%s' % helper + self.git(['update-ref', ref, 'HEAD'], cwd=self.srcdir) + + self.d.setVar('BB_GIT_SHALLOW_EXTRA_REFS', 'refs/tags/*') + self.fetch_shallow() + + self.assertFalse(os.path.exists(marker)) + self.assertRefs(['master', 'origin/master', ref]) + def test_shallow_missing_extra_refs(self): self.add_empty_file('a') self.add_empty_file('b')
[bitbake][scarthgap][2.8][PATCH 1/4] fetch2: validate deb/ipk data member names
In reply to Yoann CongalFrom: Anders Heimer <[email protected]>
The deb/ipk unpack path selects a data archive member from 'ar -t' output and then passes that member name to a shell command. Previously, any member beginning with data.tar. was selected.
Only select known deb/ipk data archive member names when datafile is created. Quote the package path used in the shell command as it can come from the local fetch path.
Add local fetcher regression coverage for quoted package filenames, valid compressed data members, and unsupported or unsafe data member names.
--- lib/bb/fetch2/__init__.py | 10 +++++--- lib/bb/tests/fetch.py | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-)
lib/bb/fetch2/__init__.py +7 -3
@@ -23,6 +23,7 @@ import collections import subprocess import pickle import errno +import shlex import bb.persist_data, bb.utils import bb.checksum import bb.process
@@ -1567,16 +1568,19 @@ class FetchMethod(object): elif file.endswith('.deb') or file.endswith('.ipk'): output = subprocess.check_output(['ar', '-t', file], preexec_fn=subprocess_setup) datafile = None + valid_datafiles = ('data.tar', 'data.tar.gz', 'data.tar.xz', + 'data.tar.zst', 'data.tar.bz2', 'data.tar.lzma') if output: for line in output.decode().splitlines(): - if line.startswith('data.tar.'): + if line in valid_datafiles: datafile = line break else: - raise UnpackError("Unable to unpack deb/ipk package - does not contain data.tar.* file", urldata.url) + raise UnpackError("Unable to unpack deb/ipk package - does not contain supported data.tar* file", urldata.url) else: raise UnpackError("Unable to unpack deb/ipk package - could not list contents", urldata.url) - cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (file, datafile, tar_cmd, datafile, datafile) + quoted_datafile = shlex.quote(datafile) + cmd = 'ar x %s %s && %s -p -f %s && rm %s' % (shlex.quote(file), quoted_datafile, tar_cmd, quoted_datafile, quoted_datafile) # If 'subdir' param exists, create a dir and use it as destination for unpack cmd if 'subdir' in urldata.parm:
lib/bb/tests/fetch.py +53 -0
71 lines not on this page · raw message