summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api
diff options
context:
space:
mode:
Diffstat (limited to 'src/buildtool/execution_api')
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_blob.hpp2
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp11
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp36
3 files changed, 19 insertions, 30 deletions
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp b/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp
index ed82d92d..944bb2d8 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_blob.hpp
@@ -39,7 +39,7 @@ struct BazelBlob {
/// given path.
[[nodiscard]] static inline auto CreateBlobFromPath(
std::filesystem::path const& fpath) noexcept -> std::optional<BazelBlob> {
- auto const type = FileSystemManager::Type(fpath);
+ auto const type = FileSystemManager::Type(fpath, /*allow_upwards=*/true);
if (not type) {
return std::nullopt;
}
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index 9104b94d..145b51cd 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -600,8 +600,7 @@ auto BazelMsgFactory::CreateDirectoryDigestFromLocalTree(
if (IsSymlinkObject(type)) {
// create and store symlink
auto content = FileSystemManager::ReadSymlink(full_name);
- if (content and PathIsNonUpwards(*content) and
- store_symlink(*content)) {
+ if (content and store_symlink(*content)) {
symlinks.emplace_back(
CreateSymlinkNode(name.string(), *content, {}));
return true;
@@ -628,7 +627,8 @@ auto BazelMsgFactory::CreateDirectoryDigestFromLocalTree(
return false;
};
- if (FileSystemManager::ReadDirectory(root, dir_reader)) {
+ if (FileSystemManager::ReadDirectory(
+ root, dir_reader, /*allow_upwards=*/true)) {
auto dir = CreateDirectory(files, dirs, symlinks, {});
if (auto bytes = SerializeMessage(dir)) {
try {
@@ -678,7 +678,7 @@ auto BazelMsgFactory::CreateGitTreeDigestFromLocalTree(
try {
if (IsSymlinkObject(type)) {
auto content = FileSystemManager::ReadSymlink(full_name);
- if (content and PathIsNonUpwards(*content)) {
+ if (content) {
if (auto digest = store_symlink(*content)) {
if (auto raw_id = FromHexString(
NativeSupport::Unprefix(digest->hash()))) {
@@ -716,7 +716,8 @@ auto BazelMsgFactory::CreateGitTreeDigestFromLocalTree(
return false;
};
- if (FileSystemManager::ReadDirectory(root, dir_reader)) {
+ if (FileSystemManager::ReadDirectory(
+ root, dir_reader, /*allow_upwards=*/true)) {
if (auto tree = GitRepo::CreateShallowTree(entries)) {
try {
if (auto digest = store_tree(tree->second, entries)) {
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index d3ad7fd9..3fcd8fe7 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -268,15 +268,14 @@ auto LocalAction::CollectOutputFileOrSymlink(
std::string const& local_path) const noexcept
-> std::optional<OutputFileOrSymlink> {
auto file_path = exec_path / local_path;
- auto type = FileSystemManager::Type(file_path);
+ auto type = FileSystemManager::Type(file_path, /*allow_upwards=*/true);
if (not type) {
Logger::Log(LogLevel::Error, "expected known type at {}", local_path);
return std::nullopt;
}
if (IsSymlinkObject(*type)) {
auto content = FileSystemManager::ReadSymlink(file_path);
- if (content and PathIsNonUpwards(*content) and
- storage_->CAS().StoreBlob(*content)) {
+ if (content and storage_->CAS().StoreBlob(*content)) {
auto out_symlink = bazel_re::OutputSymlink{};
out_symlink.set_path(local_path);
out_symlink.set_target(*content);
@@ -308,15 +307,14 @@ auto LocalAction::CollectOutputDirOrSymlink(
std::string const& local_path) const noexcept
-> std::optional<OutputDirOrSymlink> {
auto dir_path = exec_path / local_path;
- auto type = FileSystemManager::Type(dir_path);
+ auto type = FileSystemManager::Type(dir_path, /*allow_upwards=*/true);
if (not type) {
Logger::Log(LogLevel::Error, "expected known type at {}", local_path);
return std::nullopt;
}
if (IsSymlinkObject(*type)) {
auto content = FileSystemManager::ReadSymlink(dir_path);
- if (content and PathIsNonUpwards(*content) and
- storage_->CAS().StoreBlob(*content)) {
+ if (content and storage_->CAS().StoreBlob(*content)) {
auto out_symlink = bazel_re::OutputSymlink{};
out_symlink.set_path(local_path);
out_symlink.set_target(*content);
@@ -354,15 +352,10 @@ auto LocalAction::CollectAndStoreOutputs(
}
if (std::holds_alternative<bazel_re::OutputSymlink>(*out)) {
auto out_symlink = std::get<bazel_re::OutputSymlink>(*out);
- auto const& target = out_symlink.target();
- if (not PathIsNonUpwards(target)) {
- logger_.Emit(LogLevel::Error,
- "collected upwards output symlink {}",
- path);
- return false;
- }
- logger_.Emit(
- LogLevel::Trace, " - symlink {}: {}", path, target);
+ logger_.Emit(LogLevel::Trace,
+ " - symlink {}: {}",
+ path,
+ out_symlink.target());
result->mutable_output_file_symlinks()->Add(
std::move(out_symlink));
}
@@ -383,15 +376,10 @@ auto LocalAction::CollectAndStoreOutputs(
}
if (std::holds_alternative<bazel_re::OutputSymlink>(*out)) {
auto out_symlink = std::get<bazel_re::OutputSymlink>(*out);
- auto const& target = out_symlink.target();
- if (not PathIsNonUpwards(target)) {
- logger_.Emit(LogLevel::Error,
- "collected upwards output symlink {}",
- path);
- return false;
- }
- logger_.Emit(
- LogLevel::Trace, " - symlink {}: {}", path, target);
+ logger_.Emit(LogLevel::Trace,
+ " - symlink {}: {}",
+ path,
+ out_symlink.target());
result->mutable_output_file_symlinks()->Add(
std::move(out_symlink));
}