feat(graph): validate Windows path case and reserved names
This commit is contained in:
1 parent
b55aca328a
commit
7772697a48
6 files changed
+115
-9
No files matched your search
+63
-8
@@ -18,9 +18,9 @@
|
||||
#include <Void/Build/Provider/Provider.hpp>
|
||||
#include <Void/Build/Provider/Translator.hpp>
|
||||
#include <Void/Build/Snapshot/Snapshot.hpp>
|
||||
#include <Void/Build/Util/Sha256.hpp>
|
||||
#include <Void/Build/State/StateStore.hpp>
|
||||
#include <Void/Build/Toolchain/Driver.hpp>
|
||||
#include <Void/Build/Util/Sha256.hpp>
|
||||
#include <Void/Build/Watch/Watcher.hpp>
|
||||
#include <Void/Core/Scope.hpp>
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
@@ -1007,8 +1007,7 @@ void build(Void::Build::Project &p) {
|
||||
if (data_member) {
|
||||
const auto data_tar_path = tmp / "data.tar";
|
||||
write_file(data_tar_path, *data_member);
|
||||
Void::Testing::expect(
|
||||
Package::extract_safe_tar(data_tar_path, data_out).has_value());
|
||||
Void::Testing::expect(Package::extract_safe_tar(data_tar_path, data_out).has_value());
|
||||
Void::Testing::expect(std::filesystem::exists(data_out / "bin" / "cli_hi"));
|
||||
}
|
||||
|
||||
@@ -1025,8 +1024,7 @@ void build(Void::Build::Project &p) {
|
||||
sign_req.arguments.push_back(signing_seed.string());
|
||||
const bool signing_ready = Provenance::signing_available();
|
||||
if (signing_ready) {
|
||||
Void::Testing::require(
|
||||
Provenance::generate_signing_seed(signing_seed).has_value());
|
||||
Void::Testing::require(Provenance::generate_signing_seed(signing_seed).has_value());
|
||||
}
|
||||
auto sign_res = Platform::run_supervised(sign_req);
|
||||
if (signing_ready) {
|
||||
@@ -1044,8 +1042,7 @@ void build(Void::Build::Project &p) {
|
||||
Void::Testing::expect_eq(public_key_text->size(), std::size_t{65});
|
||||
Void::Testing::expect(checksum_text->starts_with(Util::sha256_hex(*archive_bytes)));
|
||||
auto verified = Provenance::verify_message(
|
||||
std::as_bytes(
|
||||
std::span<const char>{archive_bytes->data(), archive_bytes->size()}),
|
||||
std::as_bytes(std::span<const char>{archive_bytes->data(), archive_bytes->size()}),
|
||||
std::string_view{*signature_text}.substr(0, 128),
|
||||
std::string_view{*public_key_text}.substr(0, 64));
|
||||
Void::Testing::require(verified.has_value());
|
||||
@@ -1086,7 +1083,19 @@ void build(Void::Build::Project &p) {
|
||||
}
|
||||
)cpp");
|
||||
write_file(proj / "main.cpp", "#include <cstdio>\nint main() { return 0; }\n");
|
||||
write_file(proj / "test.cpp", "#include <cstdio>\nint main() { return 0; }\n");
|
||||
// Under Wine the Windows filesystem semantics apply: an upper-case open must find the file
|
||||
// created in lower case, proving PE path handling rather than Linux semantics.
|
||||
write_file(proj / "test.cpp", R"cpp(#include <cstdio>
|
||||
int main() {
|
||||
std::FILE *f = std::fopen("case_a.txt", "wb");
|
||||
if (!f) return 2;
|
||||
std::fclose(f);
|
||||
std::FILE *g = std::fopen("CASE_A.TXT", "rb");
|
||||
if (!g) { std::printf("case-insensitive open failed\n"); return 1; }
|
||||
std::fclose(g);
|
||||
return 0;
|
||||
}
|
||||
)cpp");
|
||||
|
||||
Platform::ProcessRequest req;
|
||||
req.executable = vbs_bin;
|
||||
@@ -1113,6 +1122,52 @@ void build(Void::Build::Project &p) {
|
||||
}
|
||||
Void::Testing::expect(std::filesystem::exists(tmp / "build" / "profiles" / "debug" / "out" /
|
||||
"bin" / "winapp.exe"));
|
||||
|
||||
// Case-insensitive output collisions and reserved device names are rejected for Windows.
|
||||
const auto collision_proj = tmp / "collision_proj";
|
||||
write_file(collision_proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
void build(Void::Build::Project &p) {
|
||||
p.executable("Tool").sources({"main.cpp"});
|
||||
p.executable("tool").sources({"main.cpp"});
|
||||
}
|
||||
)cpp");
|
||||
write_file(collision_proj / "main.cpp", "int main() { return 0; }\n");
|
||||
Platform::ProcessRequest collision_req = req;
|
||||
collision_req.arguments = {"build",
|
||||
"--project",
|
||||
collision_proj.string(),
|
||||
"--build-dir",
|
||||
(tmp / "collision_build").string(),
|
||||
"--target-os",
|
||||
"windows"};
|
||||
auto collision_res = Platform::run_supervised(collision_req);
|
||||
Void::Testing::expect(collision_res.has_value() && !collision_res->succeeded());
|
||||
if (collision_res) {
|
||||
Void::Testing::expect(collision_res->stderr_data.find("differ only by case") !=
|
||||
std::string::npos);
|
||||
}
|
||||
|
||||
const auto reserved_proj = tmp / "reserved_proj";
|
||||
write_file(reserved_proj / "build.cpp", R"cpp(#include <Void/Build.hpp>
|
||||
void build(Void::Build::Project &p) {
|
||||
p.executable("CON").sources({"main.cpp"});
|
||||
}
|
||||
)cpp");
|
||||
write_file(reserved_proj / "main.cpp", "int main() { return 0; }\n");
|
||||
Platform::ProcessRequest reserved_req = req;
|
||||
reserved_req.arguments = {"build",
|
||||
"--project",
|
||||
reserved_proj.string(),
|
||||
"--build-dir",
|
||||
(tmp / "reserved_build").string(),
|
||||
"--target-os",
|
||||
"windows"};
|
||||
auto reserved_res = Platform::run_supervised(reserved_req);
|
||||
Void::Testing::expect(reserved_res.has_value() && !reserved_res->succeeded());
|
||||
if (reserved_res) {
|
||||
Void::Testing::expect(reserved_res->stderr_data.find("reserved Windows device name") !=
|
||||
std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
// === Plan 08: Modern C++ (GCC16 P1689 named modules + partitions, cycle/dup checks, unity, PCH)
|
||||
|
||||
Reference in new issue
Block a user