From 402865c88125af982a1e931d6e0c381693160b8e Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Tue, 10 Dec 2024 13:28:05 -0600 Subject: [PATCH] OK but what about SOME oppression --- nomad/structs/actions.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nomad/structs/actions.go b/nomad/structs/actions.go index db78efd395..231c04cbd2 100644 --- a/nomad/structs/actions.go +++ b/nomad/structs/actions.go @@ -9,11 +9,16 @@ package structs import ( "errors" + "fmt" + "regexp" "slices" "github.com/hashicorp/go-multierror" ) +// validJobActionName is used to validate a action name. +var validJobActionName = regexp.MustCompile(`^[^\x00\s]{1,128}$`) + type Action struct { Name string Command string @@ -80,6 +85,9 @@ func (a *Action) Validate() error { if a.Command == "" { mErr = multierror.Append(mErr, errors.New("command cannot be empty")) } + if !validJobActionName.MatchString(a.Name) { + mErr = multierror.Append(mErr, fmt.Errorf("invalid name '%s'", a.Name)) + } return mErr.ErrorOrNil() }