Skip to content

Commit

Permalink
OK but what about SOME oppression
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Dec 10, 2024
1 parent 5c2bf53 commit 402865c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nomad/structs/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

0 comments on commit 402865c

Please sign in to comment.