39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
#include "echoion/standalone/ReleaseManifest.hpp"
|
|
|
|
#include <Void/System/Path.hpp>
|
|
#include <Void/System/TempDir.hpp>
|
|
|
|
#include <iostream>
|
|
|
|
int main()
|
|
{
|
|
auto directory = Void::FileSystem::TempDir::open("echoion-manifest-test");
|
|
if (!directory) {
|
|
std::cerr << directory.error().message() << '\n';
|
|
return 1;
|
|
}
|
|
const auto manifestPath = directory->path() / "pending.json";
|
|
const std::string traversal = R"({
|
|
"version":"bad",
|
|
"executable":"../echoiond",
|
|
"core":"release/Echoion.ts",
|
|
"sha256":{"executable":"x","core":"y"}
|
|
})";
|
|
if (auto written = Void::FileSystem::atomic_write(manifestPath, traversal);
|
|
!written) {
|
|
std::cerr << written.error().message() << '\n';
|
|
return 1;
|
|
}
|
|
if (Echoion::Standalone::ReleaseManifest::load(manifestPath)) {
|
|
std::cerr << "path traversal manifest was accepted\n";
|
|
return 1;
|
|
}
|
|
if (auto written = Void::FileSystem::atomic_write(manifestPath, "{}");
|
|
!written) return 1;
|
|
if (Echoion::Standalone::ReleaseManifest::load(manifestPath)) {
|
|
std::cerr << "incomplete manifest was accepted\n";
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|