feat(provenance): enforce trusted Ed25519 package signatures in publish, lockfile, and locked builds
This commit is contained in:
1 parent
21babb8c31
commit
85f2ae274f
21 files changed
+519
-15
No files matched your search
@@ -113,6 +113,8 @@ serialize_contexts_body(const std::map<std::string, LockContextRecord, std::less
|
||||
",\"sha256\":" + json_quote(e.sha256) + ",\"builder\":" + json_quote(e.builder) +
|
||||
",\"features\":" + json_array(e.features, json_quote) +
|
||||
",\"build_dependency\":" + std::string{e.build_dependency ? "true" : "false"} +
|
||||
(e.signature ? ",\"signature\":" + json_quote(*e.signature) : std::string{}) +
|
||||
(e.public_key ? ",\"public_key\":" + json_quote(*e.public_key) : std::string{}) +
|
||||
'}';
|
||||
});
|
||||
out += '}';
|
||||
@@ -252,6 +254,12 @@ parse_lockfile(std::string_view json_text) {
|
||||
e.builder = get_str(*eo, "builder");
|
||||
e.features = get_str_array(*eo, "features");
|
||||
e.build_dependency = get_bool(*eo, "build_dependency", false);
|
||||
if (const auto sig = get_str(*eo, "signature"); !sig.empty()) {
|
||||
e.signature = sig;
|
||||
}
|
||||
if (const auto key = get_str(*eo, "public_key"); !key.empty()) {
|
||||
e.public_key = key;
|
||||
}
|
||||
rec.entries.push_back(std::move(e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Void/Build/Package/Fetch.hpp>
|
||||
#include <Void/Build/Platform/FileOps.hpp>
|
||||
#include <Void/Build/Platform/ProcessSupervisor.hpp>
|
||||
#include <Void/Build/Provenance/Signing.hpp>
|
||||
#include <Void/Build/Util/Sha256.hpp>
|
||||
#include <Void/Core/Scope.hpp>
|
||||
#include <Void/Data/StrictJson.hpp>
|
||||
@@ -323,6 +324,12 @@ fetch_package_releases(std::string_view registry_url, std::string_view package_n
|
||||
rec.version = *ver;
|
||||
rec.yanked = get_bool(*ro, "yanked", false);
|
||||
rec.source_sha256 = get_str(*ro, "sha256");
|
||||
if (const auto sig = get_str(*ro, "signature"); !sig.empty()) {
|
||||
rec.signature = sig;
|
||||
}
|
||||
if (const auto key = get_str(*ro, "public_key"); !key.empty()) {
|
||||
rec.public_key = key;
|
||||
}
|
||||
rec.source_url = std::string{registry_url} + "/api/v1/packages/" +
|
||||
Void::Encoding::Url::encode(package_name) + "/" +
|
||||
Void::Encoding::Url::encode(ver_str) + "/download";
|
||||
@@ -390,6 +397,19 @@ publish_package_archive(const PublishOptions &options) {
|
||||
|
||||
std::map<std::string, std::string, std::less<>> headers;
|
||||
headers["X-Content-SHA256"] = sha;
|
||||
if (options.signing_seed_path) {
|
||||
auto signature = Provenance::sign_package(options.package_name, options.version, sha,
|
||||
*options.signing_seed_path);
|
||||
if (!signature) {
|
||||
return std::unexpected{signature.error()};
|
||||
}
|
||||
auto public_key = Provenance::public_key_from_seed(*options.signing_seed_path);
|
||||
if (!public_key) {
|
||||
return std::unexpected{public_key.error()};
|
||||
}
|
||||
headers["X-Package-Signature"] = *signature;
|
||||
headers["X-Package-Public-Key"] = *public_key;
|
||||
}
|
||||
if (!options.auth.bearer_token.empty()) {
|
||||
headers["Authorization"] = "Bearer " + options.auth.bearer_token;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ class PubGrubSolver {
|
||||
sp.version = rel.version;
|
||||
sp.source_sha256 = rel.source_sha256;
|
||||
sp.source_url = rel.source_url;
|
||||
sp.signature = rel.signature;
|
||||
sp.public_key = rel.public_key;
|
||||
sp.binaries = rel.binaries;
|
||||
if (const auto cit = constraints.find(id); cit != constraints.end()) {
|
||||
for (const auto &ac : cit->second) {
|
||||
|
||||
Reference in new issue
Block a user