From 3c2b1f665461548b5a35ab89ff0b602e92f0b1ce Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 2 Oct 2026 03:17:28 +1000 Subject: [PATCH] fix(storepkg): validate every declared authority grant at the package descriptor Descriptor.Validate duplicated only the forge-permission half of Authority.Validate, so a descriptor could declare a blank credential service, egress host, trigger or tool and be installed: the acceptance record refused the same blank, leaving the descriptor the operator is shown disagreeing with the record the package is bounded by. Delegate to Authority.Validate, the one validation of a grant list, and cover it with the blank cases the descriptor now has to refuse. --- internal/domain/storepkg/descriptor.go | 6 ++---- internal/domain/storepkg/descriptor_test.go | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/internal/domain/storepkg/descriptor.go b/internal/domain/storepkg/descriptor.go index 124621c85..3da325616 100644 --- a/internal/domain/storepkg/descriptor.go +++ b/internal/domain/storepkg/descriptor.go @@ -109,10 +109,8 @@ func (d Descriptor) Validate() error { return fmt.Errorf("required package %q digest must be a sha256 digest", ref.Name) } } - for _, permission := range d.Authority.ForgePermissions { - if !validForgePermission(permission) { - return fmt.Errorf("invalid forge permission %q", permission) - } + if err := d.Authority.Validate(); err != nil { + return err } for i, file := range d.Files { if err := validateFile(file); err != nil { diff --git a/internal/domain/storepkg/descriptor_test.go b/internal/domain/storepkg/descriptor_test.go index 5ceca3639..87cc9d666 100644 --- a/internal/domain/storepkg/descriptor_test.go +++ b/internal/domain/storepkg/descriptor_test.go @@ -89,6 +89,11 @@ func TestDescriptorValidate(t *testing.T) { }, wantErr: "executable", }, {name: "invalid forge permission", edit: func(d *Descriptor) { d.Authority.ForgePermissions = []string{"admin"} }, wantErr: "forge permission"}, + // Authority.Validate is the one validation of a grant list; the + // descriptor must not accept a blank grant the acceptance record + // would later refuse (docs/prds/store.md, "Authority"). + {name: "blank egress host", edit: func(d *Descriptor) { d.Authority.EgressHosts = []string{" "} }, wantErr: "egress host 0: name is required"}, + {name: "blank tool", edit: func(d *Descriptor) { d.Authority.Tools = []string{""} }, wantErr: "tool 0: name is required"}, } for _, tc := range cases {