From d4ea1f34456f17bc953eef24fefbf1cd65515233 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:19:06 +0100 Subject: [PATCH] I2 own-put-needs-runs-as: a manifest invoking seat:mesh-vault.own-put without runs-as is refused, a get is not Builds: design 47 H2 H-A-576, H-A-584, H-A-670 --- modules/mesh-delivery-indexer/go.mod | 1 + modules/mesh-delivery-indexer/judge/rules.go | 19 +++++++++++++++++++ .../mesh-delivery-indexer/judge/rules_test.go | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/modules/mesh-delivery-indexer/go.mod b/modules/mesh-delivery-indexer/go.mod index dcf518af7..fb20e4d9a 100644 --- a/modules/mesh-delivery-indexer/go.mod +++ b/modules/mesh-delivery-indexer/go.mod @@ -49,6 +49,7 @@ require ( ) require git.novox.be/novox/mesh-contracts/go/seats/meshbroker v0.0.0-00010101000000-000000000000 +require git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault v0.0.0-00010101000000-000000000000 replace git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk => ../mesh-delivery-sdk diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index b43ab69b9..29601d23f 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -11,6 +11,7 @@ import ( errors "errors" fmt "fmt" "git.novox.be/novox/mesh-contracts/go/seats/meshbroker" + "git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault" catalogue "git.novox.be/novox/mesh-sdk/go/catalogue" math "math" net "net" @@ -2870,6 +2871,7 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M // facts about the catalogue and are checked at registration (CatalogueProblems). problems = append(problems, declaredSeatProblems(m)...) problems = append(problems, RunsAsProblems(m)...) + problems = append(problems, OwnPutProblems(m)...) problems = append(problems, ProcessBusProblems(m)...) problems = append(problems, seatEventProblems(m)...) problems = append(problems, ReadsHolderProblems(m)...) @@ -5284,6 +5286,23 @@ func RunsAsProblems(m catalogue.Manifest) []string { return problems } +// OwnPutProblems is what a manifest naming the vault's own-put is held to (design 47 H2, H-A-576, H-A-584, H-A-670): a +// module that invokes seat:mesh-vault.own-put declares runs-as, since the vault hands an own secret only to the account +// of the module's own. A get without runs-as is no problem here: the vault's refusal at the call is its one check. +func OwnPutProblems(m catalogue.Manifest) []string { + if m.RunsAs != "" { + return nil + } + var problems []string + for _, t := range m.Invokes { + if seat, verb, ok := catalogue.SeatInvoke(t); ok && seat == meshvault.Seat && verb == meshvault.VerbOwnPut { + problems = append(problems, fmt.Sprintf("%s invokes %s of the seat %s and declares no runs-as: the vault puts a module's own "+ + "secret only for the account the module runs as (design 47 H2 ยง822)", m.Module, verb, seat)) + } + } + return problems +} + // capabilityProblems are the words of a claim outside the vocabulary, and capabilities on a claim of a // seat that is not kinded. func capabilityProblems(module string, c catalogue.Claim, kinded bool) []string { diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index cb1e6aaea..ec6a1a964 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -4445,6 +4445,22 @@ func caseRunsAsIsAnAccountOfTheModulesOwn(t *testing.T) { } } +func caseOwnPutNeedsRunsAs(t *testing.T) { + for _, row := range []struct { + why, invoke, runsAs string + refused bool + }{ + {"a get without runs-as", "seat:mesh-vault.get", "", false}, + {"an own-put without runs-as", "seat:mesh-vault.own-put", "", true}, + {"an own-put with runs-as", "seat:mesh-vault.own-put", "shop", false}, + } { + got := OwnPutProblems(catalogue.Manifest{Module: "shop", RunsAs: row.runsAs, Invokes: []string{row.invoke}}) + if (len(got) != 0) != row.refused || (row.refused && !strings.Contains(got[0], "shop") && !strings.Contains(got[0], "own-put")) { + t.Errorf("%s: refused = %v, want %v", row.why, got, row.refused) + } + } +} + func caseRuntimeHealthIsRefusedWithoutAnAccountOfItsOwn(t *testing.T) { _, err := ParseManifest(ownAccountManifest(t, false, map[string]any{"kind": "tool", "tool": "keeper_health"})) if err == nil || !strings.Contains(err.Error(), "runtime-health") || !strings.Contains(err.Error(), "runs-as") { @@ -6535,6 +6551,7 @@ func TestRulesSecrets(t *testing.T) { t.Run("HearingARestrictedStreamNeedsAnAccountOfItsOwn", caseHearingARestrictedStreamNeedsAnAccountOfItsOwn) t.Run("ParseManifestForInputsReadsAValueFallingBackToAPredefinedKey", caseParseManifestForInputsReadsAValueFallingBackToAPredefinedKey) t.Run("RunsAsIsAnAccountOfTheModulesOwn", caseRunsAsIsAnAccountOfTheModulesOwn) + t.Run("OwnPutNeedsRunsAs", caseOwnPutNeedsRunsAs) t.Run("RuntimeHealthIsRefusedWithoutAnAccountOfItsOwn", caseRuntimeHealthIsRefusedWithoutAnAccountOfItsOwn) t.Run("TheBussAccountSaysNothingOnTheBus", caseTheBussAccountSaysNothingOnTheBus) t.Run("TheCatalogueCheckRefusesAnIdentityThatOverflowsWhatItRequires", caseTheCatalogueCheckRefusesAnIdentityThatOverflowsWhatItRequires)