Release 1.1.0 with transactional plugin validation

This commit is contained in:
faumaray committed 2026-08-01 17:59:57 +03:00
1 parent 4418374de7
commit cb58236538
6 files changed
+115 -4

No files matched your search

+14
View File
@@ -254,6 +254,13 @@ namespace Void::Plugin
return std::unexpected{inst.error()};
}
std::string name{(*inst)->plugin->name()};
if (m_options.candidate_validator &&
!m_options.candidate_validator(PluginHandle{*inst})) {
Void::Log::warn("Plugin.Manager",
"load '{}' aborted: binary validation failed",
name);
return std::unexpected{LoadError::ActivationFailed};
}
if (m_options.config_provider && (*inst)->configure != nullptr) {
const std::string config = m_options.config_provider(name);
(*inst)->configure((*inst)->plugin, config.c_str());
@@ -425,6 +432,13 @@ namespace Void::Plugin
name, (*next)->plugin->name());
return std::unexpected{LoadError::NameMismatch};
}
if (m_options.candidate_validator &&
!m_options.candidate_validator(PluginHandle{*next})) {
Void::Log::warn("Plugin.Manager",
"reload '{}' aborted: binary validation failed",
name);
return std::unexpected{LoadError::ActivationFailed};
}
if (m_options.config_provider && (*next)->configure != nullptr) {
const std::string config = m_options.config_provider(name);
+30 -3
View File
@@ -34,6 +34,10 @@ namespace Void::Update
{
return value.is_array();
}
[[nodiscard]] bool is_object(const Json::Value& value) noexcept
{
return value.is_object();
}
[[nodiscard]] bool is_string(const Json::Value& value) noexcept
{
return value.is_string();
@@ -639,10 +643,24 @@ namespace Void::Update
auto schema =
unsigned_number<std::uint32_t>(*envelope, "schemaVersion");
auto keyId = string_member(*envelope, "keyId");
auto payloadText = string_member(*envelope, "payload");
auto signatureText = string_member(*envelope, "signature");
if (!schema || !keyId || !payloadText || !signatureText ||
(*schema != 1 && *schema != 2) || !valid_token(*keyId, 256)) {
if (!schema || !keyId || !signatureText ||
(*schema != 1 && *schema != 2 && *schema != 3) ||
!valid_token(*keyId, 256)) {
return Void::Result::fail("Update feed: invalid envelope fields");
}
auto payloadText = string_member(
*envelope, *schema == 3 ? "signedPayload" : "payload");
const Json::Value* displayedDocument = nullptr;
if (*schema == 3) {
auto document =
member(*envelope, "document", is_object, "an object");
if (!document) {
return std::unexpected{document.error()};
}
displayedDocument = *document;
}
if (!payloadText) {
return Void::Result::fail("Update feed: invalid envelope fields");
}
const auto key = keys.find(*keyId);
@@ -657,6 +675,15 @@ namespace Void::Update
return Void::Result::fail(
"Update feed: invalid or oversized envelope encoding");
}
if (*schema == 3) {
auto signedDocument = Json::parse(*payload);
if (!signedDocument || !signedDocument->is_object() ||
displayedDocument == nullptr ||
*displayedDocument != *signedDocument) {
return Void::Result::fail("Update feed: readable document "
"differs from signed payload");
}
}
const auto signatureBytes =
std::as_bytes(std::span{signature->data(), signature->size()});
const auto payloadBytes =