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.
This commit is contained in:
1 parent
e10d862f6a
commit
3c2b1f6654
2 files changed
+7
-4
No files matched your search
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user