Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package buildstream for openSUSE:Factory checked in at 2026-11-24 17:03:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/buildstream (Old) and /work/SRC/openSUSE:Factory/.buildstream.new.1340718 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "buildstream" Tue Nov 24 17:03:38 2026 rev:35 rq:1400298 version:2.8.2 Changes: -------- --- /work/SRC/openSUSE:Factory/buildstream/buildstream.changes 2026-09-23 14:37:28.974644249 +0200 +++ /work/SRC/openSUSE:Factory/.buildstream.new.1340718/buildstream.changes 2026-11-24 17:04:13.090027005 +0100 @@ -1,0 +2,11 @@ +Tue Nov 24 09:54:15 UTC 2026 - Bjørn Lie <[email protected]> + +- Update to version 2.8.2: + * Fixes CVE-2026-111600, CVE-2026-104813, boo#1291602, boo#1291603 + * Check that protobuf messages follow the REAPI spec + * Fixes for symlink handling + * Fix env export for `bst source checkout --include-build-scripts` + * Fix extra empty lines + * Fix reading of action result with latest buildbox-run + +------------------------------------------------------------------- Old: ---- buildstream-2.8.1.tar.xz New: ---- buildstream-2.8.2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ buildstream.spec ++++++ --- /var/tmp/diff_new_pack.Ygh3If/_old 2026-11-24 17:04:14.314078863 +0100 +++ /var/tmp/diff_new_pack.Ygh3If/_new 2026-11-24 17:04:14.317078990 +0100 @@ -17,7 +17,7 @@ Name: buildstream -Version: 2.8.1 +Version: 2.8.2 Release: 0 Summary: A framework for modelling build pipelines in YAML License: LGPL-2.1-or-later ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.Ygh3If/_old 2026-11-24 17:04:14.353080515 +0100 +++ /var/tmp/diff_new_pack.Ygh3If/_new 2026-11-24 17:04:14.358080727 +0100 @@ -1,7 +1,7 @@ -mtime: 1790104818 -commit: 810f32774cc2584dee9c5b3cc56229d23c00b275e31ca9598d0a83fff5080ffa +mtime: 1795526986 +commit: ed3706f8254117475233ea7f744348d24945311aa9921156a6f65b89f66900ce url: https://src.opensuse.org/GNOME/buildstream -revision: 810f32774cc2584dee9c5b3cc56229d23c00b275e31ca9598d0a83fff5080ffa +revision: ed3706f8254117475233ea7f744348d24945311aa9921156a6f65b89f66900ce trackingbranch: factory projectscmsync: https://src.opensuse.org/GNOME/_ObsPrj ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Ygh3If/_old 2026-11-24 17:04:14.380081659 +0100 +++ /var/tmp/diff_new_pack.Ygh3If/_new 2026-11-24 17:04:14.384081828 +0100 @@ -3,7 +3,7 @@ <service name="obs_scm" mode="manual"> <param name="scm">git</param> <param name="url">https://github.com/apache/buildstream.git</param> - <param name="revision">2.8.1</param> + <param name="revision">2.8.2</param> <param name="versionformat">@PARENT_TAG@+@TAG_OFFSET@</param> <param name="versionrewrite-pattern">v?(.*)\+0</param> <param name="versionrewrite-replacement">\1</param> ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2026-11-24 14:29:46.000000000 +0100 @@ -0,0 +1,5 @@ +*.obscpio +*.osc +_build.* +.pbuild +osc-collab.* ++++++ buildstream-2.8.1.tar.xz -> buildstream-2.8.2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/NEWS new/buildstream-2.8.2/NEWS --- old/buildstream-2.8.1/NEWS 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/NEWS 2026-11-13 10:07:49.000000000 +0100 @@ -1,4 +1,18 @@ ================= +buildstream 2.8.2 +================= + + o Check that protobuf messages follow the REAPI spec (#2201, #2203) + + o Fixes for symlink handling (#2204, #2205, #2206) + + o Fix env export for `bst source checkout --include-build-scripts` (#2207) + + o Fix extra empty lines (#2208) + + o Fix reading of action result with latest buildbox-run (#2222) + +================= buildstream 2.8.1 ================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/doc/source/format_declaring.rst new/buildstream-2.8.2/doc/source/format_declaring.rst --- old/buildstream-2.8.1/doc/source/format_declaring.rst 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/doc/source/format_declaring.rst 2026-11-13 10:07:49.000000000 +0100 @@ -260,10 +260,40 @@ ref: 9d4b1147f8cf244b0002ba74bfb0b8dfb3... Like Elements, Source types are plugins which are indicated by the ``kind`` attribute. -Asides from the common ``kind`` and ``directory`` attributes which may be applied to all -Sources, refer to the Source specific documentation for meaningful attributes for the -particular Source. +The ``kind``, ``directory`` and ``provenance`` attributes may be applied to all :ref:`Sources <core_source_builtins>`. +Another common attribute that a number of source plugins share is the ``url`` attribute. +These source plugins deal with downloading files from a url. +The ``url`` attribute can be a bare-url such as: + +.. code:: yaml + + sources: + + # Specify the source which should be built + - kind: git + url: https://my-upstream-forge.com/bananas/modulename.git + track: master + ref: d0b38561afb8122a3fc6bafc5a733ec502fcaed6 + +Alternatively the ``url`` attribute can make use of +:ref:`Source aliases declared in the project.conf <project_source_aliases>` +to abstract the download location, to enable the use of mirrors. +This is done by replacing the start of the url (e.g. ``https://my-upstream-forge.com/bananas/``) +with the name of the alias followed by a colon (e.g ``upstream:``), as complete example: + +.. code:: yaml + + sources: + + # Specify the source which should be built + - kind: git + url: upstream:bananas/modulename.git + track: master + ref: d0b38561afb8122a3fc6bafc5a733ec502fcaed6 + +For ``url`` support and all other attributes refer to the :ref:`Source specific documentation <plugins_sources>` for meaningful attributes for the +particular Source plugin. Variables ~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/doc/source/format_project.rst new/buildstream-2.8.2/doc/source/format_project.rst --- old/buildstream-2.8.1/doc/source/format_project.rst 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/doc/source/format_project.rst 2026-11-13 10:07:49.000000000 +0100 @@ -204,9 +204,14 @@ foo: git://git.foo.org/ bar: http://bar.com/downloads/ +If you want to use this project's alias definitions in source plugin ``url``\s, +see :ref:`Declaring Sources for elements <format_sources>`. + If you want this project's alias definitions to also be used for subprojects, see :ref:`Mapping source aliases of subprojects <project_junctions_source_aliases>`. +If you want to map this project's alias definitions to mirrors, +see :ref:`project_essentials_mirrors`. Sandbox options ~~~~~~~~~~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/doc/source/tutorial/running-commands.rst new/buildstream-2.8.2/doc/source/tutorial/running-commands.rst --- old/buildstream-2.8.1/doc/source/tutorial/running-commands.rst 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/doc/source/tutorial/running-commands.rst 2026-11-13 10:07:49.000000000 +0100 @@ -105,6 +105,11 @@ and some programs - this is what will be providing the programs we're going to run in this example. +.. tip:: + Note how we use the source alias ``alpine`` as part of the url + instead of the full url with the tar plugin. + For further information see see :ref:`Declaring Sources for elements <format_sources>` + ``elements/base.bst`` ~~~~~~~~~~~~~~~~~~~~~ @@ -170,7 +175,7 @@ and does not provide any default commands, so we have instructed it to use ``make`` to build and install our program. - + Using the project ----------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/_cas/cascache.py new/buildstream-2.8.2/src/buildstream/_cas/cascache.py --- old/buildstream-2.8.1/src/buildstream/_cas/cascache.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/_cas/cascache.py 2026-11-13 10:07:49.000000000 +0100 @@ -16,6 +16,7 @@ import itertools import os +import re import stat import contextlib import time @@ -41,6 +42,10 @@ _CACHE_USAGE_REFRESH = 5 +# Constant for SHA-256 validation (64 hexadecimal digits) +_HASH_REGEX = re.compile(r"[0-9a-f]{64}") + + class CASLogLevel(FastEnum): WARNING = "warning" INFO = "info" @@ -185,7 +190,11 @@ with open(self.objpath(tree), "rb") as f: directory.ParseFromString(f.read()) + names = set[str]() + for filenode in directory.files: + _validate_cas_node_name(filenode.name, names) + # regular file, create hardlink fullpath = os.path.join(dest, filenode.name) @@ -214,13 +223,27 @@ os.chmod(fullpath, mode) for dirnode in directory.directories: + _validate_cas_node_name(dirnode.name, names) fullpath = os.path.join(dest, dirnode.name) + # If the destination is a regular file, `os.makedirs()` will catch it. + # However, it will not raise an error if it's a valid directory symlink, + # so check here that we're not unexpectedly following a symlink. + if os.path.islink(fullpath): + raise CASCacheError(f"Destination already exists and is a symlink, not a directory: {fullpath}") self.checkout(fullpath, dirnode.digest, can_link=can_link, _fetch=False) for symlinknode in directory.symlinks: # symlink + _validate_cas_node_name(symlinknode.name, names) fullpath = os.path.join(dest, symlinknode.name) - os.symlink(symlinknode.target, fullpath) + try: + os.symlink(symlinknode.target, fullpath) + except FileExistsError: + try: + os.unlink(fullpath) + except OSError as e: + raise CASCacheError(f"Failed to remove destination file '{fullpath}': {e}") from e + os.symlink(symlinknode.target, fullpath) node_properties = directory.node_properties if node_properties.HasField("mtime"): @@ -323,6 +346,9 @@ # (str): The path of the object # def objpath(self, digest): + if not _HASH_REGEX.fullmatch(digest.hash): + raise ValueError(f"Invalid hash: `{digest.hash}`") + return os.path.join(self.casdir, "objects", digest.hash[:2], digest.hash[2:]) # open(): @@ -823,3 +849,22 @@ except StopIteration: return yield itertools.chain([current], itertools.islice(iterable, n - 1)) + + +# _validate_cas_node_name(): +# +# Validates that a CAS Directory entry name is a single path segment. +# +# Args: +# name (str): The name of a CAS Directory entry +# names (set): The set of names in the directory +# +def _validate_cas_node_name(name: str, names: set[str]): + if os.path.basename(name) != name or name in ("", ".", ".."): + raise CASCacheError( + f"Invalid name in a CAS Directory node: '{name}' (every child in the directory must have a path of exactly one segment)" + ) + + if name in names: + raise CASCacheError(f"Duplicate name in a CAS Directory node: '{name}'") + names.add(name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/_elementsources.py new/buildstream-2.8.2/src/buildstream/_elementsources.py --- old/buildstream-2.8.1/src/buildstream/_elementsources.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/_elementsources.py 2026-11-13 10:07:49.000000000 +0100 @@ -15,7 +15,7 @@ from contextlib import contextmanager from typing import TYPE_CHECKING, Iterator -from . import _cachekey +from . import _cachekey, utils from ._exceptions import SkipJob from ._context import Context from ._protos.buildstream.v2 import source_pb2 @@ -191,12 +191,12 @@ def init_workspace(self, directory: str): for source in self.sources(): if source._directory: - srcdir = os.path.join(directory, source._directory) + subdir = source._directory.lstrip(os.path.sep) + utils._ensure_real_directory(directory, subdir) + srcdir = os.path.join(directory, subdir) else: srcdir = directory - os.makedirs(srcdir, exist_ok=True) - source._init_workspace(srcdir) # fetch(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/_frontend/widget.py new/buildstream-2.8.2/src/buildstream/_frontend/widget.py --- old/buildstream-2.8.1/src/buildstream/_frontend/widget.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/_frontend/widget.py 2026-11-13 10:07:49.000000000 +0100 @@ -782,29 +782,31 @@ else: lines[n_lines - 1] = lines[n_lines - 1].rstrip("\n") - detail = self._indent + self._indent.join(lines) + # Nothing is left to print when message-lines is 0 + if lines: + detail = self._indent + self._indent.join(lines) + + text += "\n" + if message.message_type in ERROR_MESSAGES: + text += self._err_profile.fmt(detail, bold=True) + else: + text += self._detail_profile.fmt(detail) + + if abbrev: + text += self._indent + self.content_profile.fmt( + "Message contains {} additional lines".format(n_lines - self._message_lines), dim=True + ) + text += "\n" - text += "\n" - if message.message_type in ERROR_MESSAGES: - text += self._err_profile.fmt(detail, bold=True) - else: - text += self._detail_profile.fmt(detail) - - if abbrev: - text += self._indent + self.content_profile.fmt( - "Message contains {} additional lines".format(n_lines - self._message_lines), dim=True - ) - text += "\n" - - extra_nl = True + extra_nl = True if message.scheduler and message.message_type == MessageType.FAIL: - text += "\n" - if self.context is not None and not self.context.log_verbose: + text += "\n" text += self._indent + self._err_profile.fmt("Log file: ") text += self._indent + self._logfile_widget.render(message) + "\n" elif self._log_lines > 0: + text += "\n" text += ( self._indent + self._err_profile.fmt("Printing the last {} lines from log file:".format(self._log_lines)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/element.py new/buildstream-2.8.2/src/buildstream/element.py --- old/buildstream-2.8.1/src/buildstream/element.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/element.py 2026-11-13 10:07:49.000000000 +0100 @@ -64,6 +64,7 @@ import os import re +import shlex import stat import copy import warnings @@ -2165,7 +2166,7 @@ variable_string = "" for var, val in self.get_environment().items(): - variable_string += "{0}={1} ".format(var, val) + variable_string += "{0}={1} ".format(var, shlex.quote(val)) script = script_template.format( name=self.normal_name, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/plugins/sources/_tarfile.py new/buildstream-2.8.2/src/buildstream/plugins/sources/_tarfile.py --- old/buildstream-2.8.1/src/buildstream/plugins/sources/_tarfile.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/plugins/sources/_tarfile.py 2026-11-13 10:07:49.000000000 +0100 @@ -788,9 +788,22 @@ # For example, 'C:/foo' on Windows. raise AbsolutePathError(member) # Ensure we stay in the destination + if '..' in name.replace(os.sep, '/').split('/'): + # Directories are created from the name as given, so a name that + # leaves the destination part-way through would create them + # outside it even if the resolved path stays inside. + normalized = os.path.normpath(name) + if normalized != name: + name = new_attrs['name'] = normalized target_path = _realpath_allow_missing(os.path.join(dest_path, name)) if os.path.commonpath([target_path, dest_path]) != dest_path: raise OutsideDestinationError(member, target_path) + # A link member named after the destination directory itself + # would replace it with a (sym)link, redirecting the destination + # for all subsequent members. + if ((member.islnk() or member.issym()) + and os.path.normpath(name) == os.curdir): + raise OutsideDestinationError(member, target_path) # Limit permissions (no high bits, and go-w) mode = member.mode if mode is not None: @@ -826,11 +839,6 @@ if member.islnk() or member.issym(): if os.path.isabs(member.linkname): raise AbsoluteLinkError(member) - # A link member that resolves to the destination directory itself - # would replace it with a (sym)link, redirecting the destination - # for all subsequent members. - if target_path == dest_path: - raise OutsideDestinationError(member, target_path) normalized = os.path.normpath(member.linkname) if normalized != member.linkname: new_attrs['linkname'] = normalized @@ -2658,7 +2666,11 @@ return else: if os.path.exists(tarinfo._link_target): - os.link(tarinfo._link_target, targetpath) + # Resolve the target so the hard link points to the file + # itself. Otherwise os.link() may duplicate a symlink to a + # shallower location, where it's relative target escapes the + # destination directory. (CVE-2026-82049) + os.link(os.path.realpath(tarinfo._link_target), targetpath) return except symlink_exception: keyerror_to_extracterror = True @@ -2680,9 +2692,11 @@ "makelink_with_filter: if filter_function is not None, " + "extraction_root must also not be None") try: - filter_function( + filtered = filter_function( unfiltered.replace(name=tarinfo.name, deep=False), extraction_root) + if filtered is None: + return filtered = filter_function(unfiltered, extraction_root) except _FILTER_ERRORS as cause: raise LinkFallbackError(tarinfo, unfiltered.name) from cause diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/sandbox/_sandboxbuildboxrun.py new/buildstream-2.8.2/src/buildstream/sandbox/_sandboxbuildboxrun.py --- old/buildstream-2.8.1/src/buildstream/sandbox/_sandboxbuildboxrun.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/sandbox/_sandboxbuildboxrun.py 2026-11-13 10:07:49.000000000 +0100 @@ -16,6 +16,7 @@ import subprocess import sys from contextlib import ExitStack +from pathlib import Path import grpc import psutil @@ -174,7 +175,8 @@ interactive=(flags & _SandboxFlags.INTERACTIVE), ) - action_result = remote_execution_pb2.ActionResult().FromString(result_file.read()) + action_result_bytes = Path(result_file.name).read_bytes() + action_result = remote_execution_pb2.ActionResult().FromString(action_result_bytes) if self.re_remote and context.remote_execution_specs.storage_spec and context.remote_cache_spec: # This ensures that the outputs are uploaded to the cache storage-service diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/storage/_casbaseddirectory.py new/buildstream-2.8.2/src/buildstream/storage/_casbaseddirectory.py --- old/buildstream-2.8.1/src/buildstream/storage/_casbaseddirectory.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/storage/_casbaseddirectory.py 2026-11-13 10:07:49.000000000 +0100 @@ -653,11 +653,15 @@ if prop.name == "SubtreeReadOnly": self.__subtree_read_only = prop.value == "true" + names = set[str]() + for dentry in pb2_directory.directories: + _validate_cas_node_name(dentry.name, names) self.__index[dentry.name] = _IndexEntry( self.__cas_cache, dentry.name, FileType.DIRECTORY, digest=dentry.digest ) for entry in pb2_directory.files: + _validate_cas_node_name(entry.name, names) mtime: Optional[timestamp_pb2.Timestamp] if entry.node_properties.HasField("mtime"): mtime = entry.node_properties.mtime @@ -673,6 +677,7 @@ mtime=mtime, ) for lentry in pb2_directory.symlinks: + _validate_cas_node_name(lentry.name, names) self.__index[lentry.name] = _IndexEntry( self.__cas_cache, lentry.name, FileType.SYMLINK, target=lentry.target ) @@ -908,3 +913,22 @@ subdir.__add_files_to_result(path_prefix=relative_pathname, result=result) else: result.files_written.append(relative_pathname) + + +# _validate_cas_node_name(): +# +# Validates that a CAS Directory entry name is a single path segment. +# +# Args: +# name (str): The name of a CAS Directory entry +# names (set): The set of names in the directory +# +def _validate_cas_node_name(name: str, names: set[str]): + if os.path.basename(name) != name or name in ("", ".", ".."): + raise DirectoryError( + f"Invalid name in a CAS Directory node: '{name}' (every child in the directory must have a path of exactly one segment)" + ) + + if name in names: + raise DirectoryError(f"Duplicate name in a CAS Directory node: '{name}'") + names.add(name) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/storage/_filebaseddirectory.py new/buildstream-2.8.2/src/buildstream/storage/_filebaseddirectory.py --- old/buildstream-2.8.1/src/buildstream/storage/_filebaseddirectory.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/storage/_filebaseddirectory.py 2026-11-13 10:07:49.000000000 +0100 @@ -61,12 +61,19 @@ return self.__open_directory(paths, create=create, follow_symlinks=follow_symlinks) def import_single_file(self, external_pathspec: str) -> FileListResult: - dstpath = os.path.join(self.__external_directory, os.path.basename(external_pathspec)) + basename = os.path.basename(external_pathspec) + dstpath = os.path.join(self.__external_directory, basename) result = FileListResult() - if os.path.exists(dstpath): - result.ignored.append(dstpath) - else: - shutil.copyfile(external_pathspec, dstpath, follow_symlinks=False) + if os.path.lexists(dstpath): + # `os.path.isdir()` follows symlinks. The following condition is + # equivalent to `if not os.path.isdir(dstpath)` but without following symlinks. + if os.path.islink(dstpath) or not os.path.isdir(dstpath): + result.overwritten.append(basename) + if not utils.safe_remove(dstpath): + result.ignored.append(basename) + return result + shutil.copyfile(external_pathspec, dstpath, follow_symlinks=False) + result.files_written.append(basename) return result # Add a directory entry deterministically to a tar file @@ -137,6 +144,9 @@ subdir = self.__open_directory(paths[:-1]) newpath = os.path.join(subdir.__external_directory, paths[-1]) + if subdir.exists(paths[-1]) and not subdir.isfile(paths[-1]): + raise DirectoryError("{} in {} is not a file".format(paths[-1], str(subdir))) + if mode not in ["r", "rb", "w", "wb", "w+", "w+b", "x", "xb", "x+", "x+b"]: raise ValueError("Unsupported mode: `{}`".format(mode)) @@ -152,8 +162,8 @@ if "x" in mode: # This check is not atomic, however, we're operating with a # single thread in a private directory tree. - if subdir.exists(path[-1]): - raise DirectoryError("{} already exists in {}".format(path[-1], str(subdir))) + if subdir.exists(paths[-1]): + raise DirectoryError("{} already exists in {}".format(paths[-1], str(subdir))) mode = "w" + mode[1:] with utils.save_file_atomic(newpath, mode=mode, encoding=encoding) as f: @@ -261,7 +271,11 @@ ) if update_mtime: for f in import_result.files_written: - os.utime(os.path.join(self.__external_directory, f), times=(update_mtime, update_mtime)) + os.utime( + os.path.join(self.__external_directory, f), + times=(update_mtime, update_mtime), + follow_symlinks=False, + ) else: # # We're dealing with an abstract Directory object @@ -448,7 +462,10 @@ if not is_dir: if os.path.lexists(dest_path): # Collect overlaps - if not os.path.isdir(dest_path): + + # `os.path.isdir()` follows symlinks. The following condition is + # equivalent to `if not os.path.isdir(dest_path)` but without following symlinks. + if os.path.islink(dest_path) or not os.path.isdir(dest_path): result.overwritten.append(relative_pathname) if not utils.safe_remove(dest_path): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/src/buildstream/utils.py new/buildstream-2.8.2/src/buildstream/utils.py --- old/buildstream-2.8.1/src/buildstream/utils.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/src/buildstream/utils.py 2026-11-13 10:07:49.000000000 +0100 @@ -34,7 +34,7 @@ import threading import itertools from contextlib import contextmanager -from pathlib import Path +from pathlib import Path, PurePath from typing import Callable, IO, Iterable, Iterator, Optional, Tuple, Union, Pattern from google.protobuf import timestamp_pb2 @@ -1064,7 +1064,12 @@ # def _ensure_real_directory(root, path): destpath = root - for name in os.path.split(path): + purepath = PurePath(path) + if purepath.is_absolute(): + raise UtilError(f"Expected relative path, got absolute path: {path}") + for name in purepath.parts: + if name == "..": + raise UtilError(f"`..` not allowed in relative path: {path}") destpath = os.path.join(destpath, name) try: deststat = os.lstat(destpath) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/tests/frontend/logging.py new/buildstream-2.8.2/tests/frontend/logging.py --- old/buildstream-2.8.1/tests/frontend/logging.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/tests/frontend/logging.py 2026-11-13 10:07:49.000000000 +0100 @@ -15,17 +15,24 @@ # Pylint doesn't play well with fixtures and dependency injection from pytest # pylint: disable=redefined-outer-name +import datetime import os import re +import click import pytest from buildstream._testing import create_repo from buildstream import _yaml from buildstream.exceptions import ErrorDomain +from buildstream._frontend.profile import Profile +from buildstream._frontend.widget import LogLine +from buildstream._message import Message, MessageType from buildstream._testing import cli # pylint: disable=unused-import +from tests.testutils import dummy_context + # Project directory DATA_DIR = os.path.dirname(os.path.realpath(__file__)) @@ -225,3 +232,53 @@ assert log_name == staged_name assert log_key == staged_key assert log_key == keys[log_name] + + +# Render a message with LogLine the same way the frontend does, without colors +# +def render_log_line(context, message): + profile = Profile() + logger = LogLine(context, None, profile, profile, profile, profile, profile) + return click.unstyle(logger.render(message)) + + +# Test that message details are truncated to the configured message-lines, +# and that setting it to 0 does not leave empty lines behind. +# [email protected]( + "message_lines,expected", + [ + (0, "Running commands\n"), + (2, "Running commands\n\n line 1\n line 2\n Message contains 1 additional lines\n\n"), + ], + ids=["zero", "two"], +) +def test_message_lines(message_lines, expected): + with dummy_context() as context: + context.log_message_format = "%{message}" + context.log_message_lines = message_lines + + message = Message( + MessageType.INFO, "Running commands", element_name="test.bst", detail="line 1\nline 2\nline 3" + ) + assert render_log_line(context, message) == expected + + +# Test that a failure message is still followed by a single empty line, +# and not two, when error-lines is set to 0. +# +def test_error_lines_zero(): + with dummy_context() as context: + context.log_message_format = "%{message}" + context.log_verbose = True + context.log_error_lines = 0 + + message = Message( + MessageType.FAIL, + "Running commands", + element_name="test.bst", + elapsed=datetime.timedelta(), + logfile="test.log", + scheduler=True, + ) + assert render_log_line(context, message) == "Running commands\n\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/buildstream-2.8.1/tests/internals/cascache.py new/buildstream-2.8.2/tests/internals/cascache.py --- old/buildstream-2.8.1/tests/internals/cascache.py 2026-09-17 12:34:46.000000000 +0200 +++ new/buildstream-2.8.2/tests/internals/cascache.py 2026-11-13 10:07:49.000000000 +0100 @@ -15,8 +15,12 @@ import time from unittest.mock import MagicMock +import pytest + from buildstream._cas import casdprocessmanager +from buildstream._exceptions import CASCacheError from buildstream._messenger import Messenger +from buildstream._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 from tests.testutils import casd_cache # @@ -128,3 +132,87 @@ assert len(existing_log_files) == n_max_log_files assert evicted_file not in existing_log_files assert existing_log_files[-1].read_text() == "hello\n" + + +def add_directory(cas, *, files=None, directories=None, symlinks=None): + directory = remote_execution_pb2.Directory() + for name, digest in (files or {}).items(): + filenode = directory.files.add() + filenode.name = name + filenode.digest.CopyFrom(digest) + for name, digest in (directories or {}).items(): + dirnode = directory.directories.add() + dirnode.name = name + dirnode.digest.CopyFrom(digest) + for name, target in (symlinks or {}).items(): + symlinknode = directory.symlinks.add() + symlinknode.name = name + symlinknode.target = target + return cas.add_object(buffer=directory.SerializeToString()) + + +# Test that `checkout()` doesn't follow a symlink in the destination +# directory when checking out a subdirectory. +# [email protected]("can_link", [False, True], ids=["copy", "link"]) +def test_checkout_existing_directory_symlink(tmp_path, can_link): + dest = tmp_path.joinpath("dest") + outside = tmp_path.joinpath("outside") + dest.mkdir() + outside.mkdir() + dest.joinpath("subdir").symlink_to(outside) + + with casd_cache(tmp_path.joinpath("cas")) as cas: + subdir = add_directory(cas, files={"file": cas.add_object(buffer=b"content")}, symlinks={"link": "target"}) + tree = add_directory(cas, directories={"subdir": subdir}) + + with pytest.raises(CASCacheError, match="symlink"): + cas.checkout(str(dest), tree, can_link=can_link) + + assert os.listdir(outside) == [] + assert dest.joinpath("subdir").is_symlink() + + +# Test that `checkout()` replaces an existing symlink in the destination +# directory with a regular file instead of writing to the symlink target. +# [email protected]("can_link", [False, True], ids=["copy", "link"]) +def test_checkout_replace_symlink_with_file(tmp_path, can_link): + dest = tmp_path.joinpath("dest") + outside = tmp_path.joinpath("outside") + dest.mkdir() + outside.write_bytes(b"original") + dest.joinpath("file").symlink_to(outside) + + with casd_cache(tmp_path.joinpath("cas")) as cas: + tree = add_directory(cas, files={"file": cas.add_object(buffer=b"content")}) + cas.checkout(str(dest), tree, can_link=can_link) + + assert outside.read_bytes() == b"original" + assert not dest.joinpath("file").is_symlink() + assert dest.joinpath("file").read_bytes() == b"content" + + +# Test that `checkout()` replaces existing files in the destination +# directory with symlinks. +# [email protected]("existing", ["file", "symlink", "dangling-symlink"]) +def test_checkout_replace_with_symlink(tmp_path, existing): + dest = tmp_path.joinpath("dest") + outside = tmp_path.joinpath("outside") + dest.mkdir() + outside.write_bytes(b"original") + + if existing == "file": + dest.joinpath("link").write_bytes(b"existing") + elif existing == "symlink": + dest.joinpath("link").symlink_to(outside) + else: + dest.joinpath("link").symlink_to(tmp_path.joinpath("does-not-exist")) + + with casd_cache(tmp_path.joinpath("cas")) as cas: + tree = add_directory(cas, symlinks={"link": "new-target"}) + cas.checkout(str(dest), tree) + + assert os.readlink(dest.joinpath("link")) == "new-target" + assert outside.read_bytes() == b"original" ++++++ buildstream.obsinfo ++++++ --- /var/tmp/diff_new_pack.Ygh3If/_old 2026-11-24 17:04:15.126113265 +0100 +++ /var/tmp/diff_new_pack.Ygh3If/_new 2026-11-24 17:04:15.129113392 +0100 @@ -1,5 +1,5 @@ name: buildstream -version: 2.8.1 -mtime: 1789641286 -commit: 94f476e9fbb9a89094b6af59497fc5fcf73f6775 +version: 2.8.2 +mtime: 1794560869 +commit: 3aefb1a9633fdcf8156b34fba0c06e5e9357fe3d
