From 790ac92c7a64df6685ebf855e7018264e05b6752 Mon Sep 17 00:00:00 2001 From: CandyWater Date: Sun, 22 Feb 2026 04:06:02 +0800 Subject: [PATCH] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- pkg/tools/shell.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) } }