diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 8e8d75dd8..8503ecdb0 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -110,7 +110,12 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf if len(allowPatterns) > 0 { allowRegex = make([]*regexp.Regexp, 0, len(allowPatterns)) for _, p := range allowPatterns { - allowRegex = append(allowRegex, regexp.MustCompile(p)) + re, err := regexp.Compile(p) + if err != nil { + fmt.Fprintf(os.Stderr, "NewExecTool: invalid allow pattern %q: %v\n", p, err) + continue + } + allowRegex = append(allowRegex, re) } }