diff --git a/pkg/config/config.go b/pkg/config/config.go index 47b87ccf5..296412056 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -645,7 +645,8 @@ type ExecConfig struct { CustomDenyPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"` CustomAllowPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"` TimeoutSeconds int ` env:"PICOCLAW_TOOLS_EXEC_TIMEOUT_SECONDS" json:"timeout_seconds"` // 0 means use default (60s) - EnvSet map[string]string ` json:"env_set"` // env vars to set for all exec commands + EnvSet map[string]string ` json:"env_set"` // env vars to set for all exec commands + EnvAllowlist []string ` json:"env_allowlist"` // additional env vars to allow (extends default) } type SkillsToolsConfig struct { diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 66e3c2ca7..b0405f763 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -138,11 +138,15 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf timeout = time.Duration(config.Tools.Exec.TimeoutSeconds) * time.Second } - // Get envSet from config (if provided) + // Get envSet and envAllowlist from config (if provided) var envSet map[string]string + var envAllowlist []string if config != nil && config.Tools.Exec.EnvSet != nil { envSet = config.Tools.Exec.EnvSet } + if config != nil && config.Tools.Exec.EnvAllowlist != nil { + envAllowlist = config.Tools.Exec.EnvAllowlist + } return &ExecTool{ workingDir: workingDir, @@ -151,7 +155,7 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf allowPatterns: nil, customAllowPatterns: customAllowPatterns, restrictToWorkspace: restrict, - cachedEnv: shell.BuildSanitizedEnv(os.Environ(), nil, envSet, nil), + cachedEnv: shell.BuildSanitizedEnv(os.Environ(), envAllowlist, envSet, nil), }, nil }