feat(security): add config env_allowlist support
This commit is contained in:
parent
ceac1e7671
commit
bf7279e2a1
2 changed files with 8 additions and 3 deletions
|
|
@ -645,7 +645,8 @@ type ExecConfig struct {
|
||||||
CustomDenyPatterns []string ` env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"`
|
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"`
|
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)
|
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 {
|
type SkillsToolsConfig struct {
|
||||||
|
|
|
||||||
|
|
@ -138,11 +138,15 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf
|
||||||
timeout = time.Duration(config.Tools.Exec.TimeoutSeconds) * time.Second
|
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 envSet map[string]string
|
||||||
|
var envAllowlist []string
|
||||||
if config != nil && config.Tools.Exec.EnvSet != nil {
|
if config != nil && config.Tools.Exec.EnvSet != nil {
|
||||||
envSet = config.Tools.Exec.EnvSet
|
envSet = config.Tools.Exec.EnvSet
|
||||||
}
|
}
|
||||||
|
if config != nil && config.Tools.Exec.EnvAllowlist != nil {
|
||||||
|
envAllowlist = config.Tools.Exec.EnvAllowlist
|
||||||
|
}
|
||||||
|
|
||||||
return &ExecTool{
|
return &ExecTool{
|
||||||
workingDir: workingDir,
|
workingDir: workingDir,
|
||||||
|
|
@ -151,7 +155,7 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf
|
||||||
allowPatterns: nil,
|
allowPatterns: nil,
|
||||||
customAllowPatterns: customAllowPatterns,
|
customAllowPatterns: customAllowPatterns,
|
||||||
restrictToWorkspace: restrict,
|
restrictToWorkspace: restrict,
|
||||||
cachedEnv: shell.BuildSanitizedEnv(os.Environ(), nil, envSet, nil),
|
cachedEnv: shell.BuildSanitizedEnv(os.Environ(), envAllowlist, envSet, nil),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue