feat(update): fix schema-3 verify-before-parse and add replay floor, TrustStore, pin pruning, and InstallCoordinator
This commit is contained in:
1 parent
00d7478335
commit
47736cb6ce
13 files changed
+2663
-23
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <Void/Functional/Error.hpp>
|
||||
#include <Void/Functional/Result.hpp>
|
||||
#include <Void/Text/Semver.hpp>
|
||||
#include <Void/Update/Types.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
@@ -68,6 +69,8 @@ namespace Void::Update
|
||||
std::chrono::system_clock::time_point now{
|
||||
std::chrono::system_clock::now()};
|
||||
bool requireUnexpired{true};
|
||||
SchemaParsePolicy parsePolicy{SchemaParsePolicy::LegacyGeneralJson};
|
||||
std::size_t maxJsonDepth{64};
|
||||
};
|
||||
|
||||
struct VerifiedFeed {
|
||||
@@ -193,4 +196,108 @@ namespace Void::Update
|
||||
/// Select the greatest compatible version, independent of feed order.
|
||||
[[nodiscard]] std::optional<Release>
|
||||
selectRelease(const Feed& feed, const SelectionRequest& request);
|
||||
|
||||
/// Non-forgeable signature-verified release selection retaining the exact
|
||||
/// verified envelope bytes, signer key ID, policy decision, and selected
|
||||
/// release/component metadata. Can only be constructed by verified factory
|
||||
/// functions.
|
||||
class VerifiedSelection
|
||||
{
|
||||
public:
|
||||
|
||||
VerifiedSelection(const VerifiedSelection&) = default;
|
||||
VerifiedSelection(VerifiedSelection&&) noexcept = default;
|
||||
VerifiedSelection& operator=(const VerifiedSelection&) = default;
|
||||
VerifiedSelection& operator=(VerifiedSelection&&) noexcept = default;
|
||||
|
||||
[[nodiscard]] const std::string&
|
||||
signed_envelope_bytes() const noexcept
|
||||
{
|
||||
return m_signed_envelope;
|
||||
}
|
||||
[[nodiscard]] const std::string&
|
||||
signed_payload_bytes() const noexcept
|
||||
{
|
||||
return m_signed_payload;
|
||||
}
|
||||
[[nodiscard]] const std::string& signer_key_id() const noexcept
|
||||
{
|
||||
return m_signer_key_id;
|
||||
}
|
||||
[[nodiscard]] const std::string& feed_id() const noexcept
|
||||
{
|
||||
return m_feed_id;
|
||||
}
|
||||
[[nodiscard]] std::uint64_t sequence() const noexcept
|
||||
{
|
||||
return m_sequence;
|
||||
}
|
||||
[[nodiscard]] std::chrono::system_clock::time_point
|
||||
expires_at() const noexcept
|
||||
{
|
||||
return m_expires_at;
|
||||
}
|
||||
[[nodiscard]] SchemaParsePolicy parse_policy() const noexcept
|
||||
{
|
||||
return m_parse_policy;
|
||||
}
|
||||
[[nodiscard]] const ReleaseIdentity& release() const noexcept
|
||||
{
|
||||
return m_release;
|
||||
}
|
||||
[[nodiscard]] const std::map<std::string, ComponentRelease>&
|
||||
component_releases() const noexcept
|
||||
{
|
||||
return m_components;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
VerifiedSelection() = default;
|
||||
|
||||
std::string m_signed_envelope{};
|
||||
std::string m_signed_payload{};
|
||||
std::string m_signer_key_id{};
|
||||
std::string m_feed_id{};
|
||||
std::uint64_t m_sequence{0};
|
||||
std::chrono::system_clock::time_point m_expires_at{};
|
||||
SchemaParsePolicy m_parse_policy{
|
||||
SchemaParsePolicy::LegacyGeneralJson};
|
||||
ReleaseIdentity m_release{};
|
||||
std::map<std::string, ComponentRelease> m_components{};
|
||||
|
||||
friend Void::Result::Result<VerifiedSelection>
|
||||
verify_and_select_release(std::string_view envelopeJson,
|
||||
const Keyring& keys,
|
||||
const SelectionRequest& request,
|
||||
const VerificationPolicy& policy);
|
||||
|
||||
friend Void::Result::Result<VerifiedSelection>
|
||||
verify_and_select_component_set(
|
||||
std::string_view catalogEnvelopeJson,
|
||||
const std::map<std::string, std::string>&
|
||||
releaseEnvelopeJsons,
|
||||
const Keyring& keys, std::string_view primaryComponentId,
|
||||
const VerificationPolicy& policy);
|
||||
};
|
||||
|
||||
/// Verify an aggregate feed envelope (verify-before-parse), validate
|
||||
/// policy, and produce a non-forgeable VerifiedSelection for the best
|
||||
/// compatible release.
|
||||
[[nodiscard]] Void::Result::Result<VerifiedSelection>
|
||||
verify_and_select_release(std::string_view envelopeJson,
|
||||
const Keyring& keys,
|
||||
const SelectionRequest& request,
|
||||
const VerificationPolicy& policy = {});
|
||||
|
||||
/// Verify a signed component catalog envelope and signed per-component
|
||||
/// release envelopes, validate dependency closure and transaction limits
|
||||
/// (<= 32 components, <= 256 dependency edges), and return a non-forgeable
|
||||
/// VerifiedSelection.
|
||||
[[nodiscard]] Void::Result::Result<VerifiedSelection>
|
||||
verify_and_select_component_set(
|
||||
std::string_view catalogEnvelopeJson,
|
||||
const std::map<std::string, std::string>& releaseEnvelopeJsons,
|
||||
const Keyring& keys, std::string_view primaryComponentId,
|
||||
const VerificationPolicy& policy = {});
|
||||
} // namespace Void::Update
|
||||
Reference in new issue
Block a user