From af8f9a663d69e7bce01be200d556909b90ec1873 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 26 May 2025 13:19:48 +0200 Subject: FileRoot: Ensure all read blobs and trees contain valid entries In particular, ensure that Git roots check for, e.g., upwards symlinks, before returning blobs and trees. To ensure that only the bear minimum extra work is performed for this purpose, Git roots now keep also the root's GitTreeEntry as a field, allowing the validity check of root source trees to take place only once and only if required. --- src/buildtool/execution_engine/executor/executor.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/buildtool/execution_engine/executor/executor.hpp') diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp index e38a656f..018a1536 100644 --- a/src/buildtool/execution_engine/executor/executor.hpp +++ b/src/buildtool/execution_engine/executor/executor.hpp @@ -457,7 +457,8 @@ class ExecutorImpl { } else { // if known blob is not available, read and upload it - content = ReadGitBlob(repo, repo_config, hash); + content = ReadGitBlob( + repo, repo_config, hash, IsSymlinkObject(info.type)); } if (not content) { logger.Emit(LogLevel::Error, "failed to get content"); @@ -478,15 +479,16 @@ class ExecutorImpl { [[nodiscard]] static auto ReadGitBlob( std::string const& repo, gsl::not_null const& repo_config, - std::string const& hash) noexcept -> std::optional { + std::string const& hash, + bool is_symlink) noexcept -> std::optional { std::optional blob{}; if (auto const* ws_root = repo_config->WorkspaceRoot(repo)) { // try to obtain blob from local workspace's Git CAS, if any - blob = ws_root->ReadBlob(hash); + blob = ws_root->ReadBlob(hash, is_symlink); } if (not blob) { // try to obtain blob from global Git CAS, if any - blob = repo_config->ReadBlobFromGitCAS(hash, /*is_symlink=*/false); + blob = repo_config->ReadBlobFromGitCAS(hash, is_symlink); } return blob; } -- cgit v1.2.3