mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
23 lines
633 B
Go
23 lines
633 B
Go
package identity
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
ctr "github.com/memohai/memoh/internal/containerd"
|
|
)
|
|
|
|
// ValidateChannelIdentityID enforces a conservative ID charset for isolation.
|
|
func ValidateChannelIdentityID(channelIdentityID string) error {
|
|
if channelIdentityID == "" {
|
|
return fmt.Errorf("%w: channel identity id required", ctr.ErrInvalidArgument)
|
|
}
|
|
const allowedRunes = "-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
for _, r := range channelIdentityID {
|
|
if !strings.ContainsRune(allowedRunes, r) {
|
|
return fmt.Errorf("%w: invalid channel identity id", ctr.ErrInvalidArgument)
|
|
}
|
|
}
|
|
return nil
|
|
}
|