frostfs-node/pkg/services/apemanager/validation.go

24 lines
559 B
Go
Raw Normal View History

package apemanager
import (
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server/ape"
apechain "git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain"
)
func decodeAndValidateChain(encodedChain []byte) (chain apechain.Chain, err error) {
if err = chain.DecodeBytes(encodedChain); err != nil {
return
}
for _, rule := range chain.Rules {
for _, name := range rule.Resources.Names {
if err = ape.ValidateResourceName(name); err != nil {
err = fmt.Errorf("invalid resource: %w", err)
return
}
}
}
return
}