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
This commit is contained in:
2026-11-25 17:19:06 +01:00
parent af5a7e5870
commit d4ea1f3445
3 changed files with 37 additions and 0 deletions
+1
View File
@@ -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
@@ -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 {
@@ -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)