From e361e2d42470bcb51995a507045a8f934974bef5 Mon Sep 17 00:00:00 2001 From: Tom OBrien Date: Mon, 25 Oct 2021 11:31:48 +0200 Subject: [PATCH] fix: allowing regex underscore for container registry enforcement While not best practice, underscore can be used and so should be allowed. --- pkg/webhook/pod/containerregistry_registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/webhook/pod/containerregistry_registry.go b/pkg/webhook/pod/containerregistry_registry.go index fcbacd65..1ab58f75 100644 --- a/pkg/webhook/pod/containerregistry_registry.go +++ b/pkg/webhook/pod/containerregistry_registry.go @@ -54,7 +54,7 @@ func (r registry) Tag() string { func NewRegistry(value string) Registry { reg := make(registry) - r := regexp.MustCompile(`(((?P[a-zA-Z0-9-.]+)\/)?((?P[a-zA-Z0-9-.]+)\/))?(?P[a-zA-Z0-9-.]+)(:(?P[a-zA-Z0-9-.]+))?`) + r := regexp.MustCompile(`(((?P[a-zA-Z0-9-._]+)\/)?((?P[a-zA-Z0-9-._]+)\/))?(?P[a-zA-Z0-9-._]+)(:(?P[a-zA-Z0-9-._]+))?`) match := r.FindStringSubmatch(value) for i, name := range r.SubexpNames() { if i > 0 && i <= len(match) {