From 5e1e84ee5d9f10167a21c500d5cdb564584e36cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Mon, 19 Oct 2026 13:17:13 +0200 Subject: [PATCH] cmd/docker-trust: Use standard regexps for name validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The plugin only used lazyregexp for two small, fixed name patterns. Replaced it with regexp.MustCompile without changing validation. Signed-off-by: Paweł Gronowski --- cmd/docker-trust/trust/key_generate.go | 4 ++-- cmd/docker-trust/trust/signer_add.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/docker-trust/trust/key_generate.go b/cmd/docker-trust/trust/key_generate.go index cf42ffc9bc..16398933e4 100644 --- a/cmd/docker-trust/trust/key_generate.go +++ b/cmd/docker-trust/trust/key_generate.go @@ -5,12 +5,12 @@ import ( "fmt" "os" "path/filepath" + "regexp" "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cmd/docker-trust/internal/trust" - "github.com/docker/cli/internal/lazyregexp" "github.com/spf13/cobra" "github.com/theupdateframework/notary" "github.com/theupdateframework/notary/trustmanager" @@ -41,7 +41,7 @@ func newKeyGenerateCommand(dockerCLI command.Streams) *cobra.Command { } // key names can use lowercase alphanumeric + _ + - characters -var validKeyName = lazyregexp.New(`^[a-z0-9][a-z0-9\_\-]*$`).MatchString +var validKeyName = regexp.MustCompile(`^[a-z0-9][a-z0-9\_\-]*$`).MatchString // validate that all of the key names are unique and are alphanumeric + _ + - // and that we do not already have public key files in the target dir on disk diff --git a/cmd/docker-trust/trust/signer_add.go b/cmd/docker-trust/trust/signer_add.go index 0d94b9c46f..f4e938f010 100644 --- a/cmd/docker-trust/trust/signer_add.go +++ b/cmd/docker-trust/trust/signer_add.go @@ -7,12 +7,12 @@ import ( "io" "os" "path" + "regexp" "strings" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/cmd/docker-trust/internal/trust" - "github.com/docker/cli/internal/lazyregexp" "github.com/docker/cli/opts" "github.com/spf13/cobra" "github.com/theupdateframework/notary/client" @@ -45,7 +45,7 @@ func newSignerAddCommand(dockerCLI command.Cli) *cobra.Command { return cmd } -var validSignerName = lazyregexp.New(`^[a-z0-9][a-z0-9\_\-]*$`).MatchString +var validSignerName = regexp.MustCompile(`^[a-z0-9][a-z0-9\_\-]*$`).MatchString func addSigner(ctx context.Context, dockerCLI command.Cli, options signerAddOptions) error { signerName := options.signer