@@ -25,13 +25,14 @@ import (
2525
2626// Config holds all configuration for the CLI
2727type Config struct {
28- Config serpent.YAMLConfigPath `yaml:"-"`
29- AllowStrings serpent.StringArray `yaml:"allow"`
30- LogLevel serpent.String `yaml:"log_level"`
31- LogDir serpent.String `yaml:"log_dir"`
32- ProxyPort serpent.Int64 `yaml:"proxy_port"`
33- PprofEnabled serpent.Bool `yaml:"pprof_enabled"`
34- PprofPort serpent.Int64 `yaml:"pprof_port"`
28+ Config serpent.YAMLConfigPath `yaml:"-"`
29+ AllowListStrings serpent.StringArray `yaml:"allowlist"` // From config file
30+ AllowStrings serpent.StringArray `yaml:"-"` // From CLI flags only
31+ LogLevel serpent.String `yaml:"log_level"`
32+ LogDir serpent.String `yaml:"log_dir"`
33+ ProxyPort serpent.Int64 `yaml:"proxy_port"`
34+ PprofEnabled serpent.Bool `yaml:"pprof_enabled"`
35+ PprofPort serpent.Int64 `yaml:"pprof_port"`
3536}
3637
3738// NewCommand creates and returns the root serpent command
@@ -49,6 +50,9 @@ func NewCommand() *serpent.Command {
4950 # Monitor all requests to specific domains (allow only those)
5051 boundary --allow "domain=github.com path=/api/issues/*" --allow "method=GET,HEAD domain=github.com" -- npm install
5152
53+ # Use allowlist from config file with additional CLI allow rules
54+ boundary --allow "domain=example.com" -- curl https://example.com
55+
5256 # Block everything by default (implicit)`
5357
5458 return cmd
@@ -95,9 +99,15 @@ func BaseCommand() *serpent.Command {
9599 {
96100 Flag : "allow" ,
97101 Env : "BOUNDARY_ALLOW" ,
98- Description : "Allow rule (repeatable). Format: \" pattern\" or \" METHOD[,METHOD] pattern\" ." ,
102+ Description : "Allow rule (repeatable). These are merged with allowlist from config file. Format: \" pattern\" or \" METHOD[,METHOD] pattern\" ." ,
99103 Value : & config .AllowStrings ,
100- YAML : "allow" ,
104+ YAML : "" , // CLI only, not loaded from YAML
105+ },
106+ {
107+ Flag : "" , // No CLI flag, YAML only
108+ Description : "Allowlist rules from config file (YAML only)." ,
109+ Value : & config .AllowListStrings ,
110+ YAML : "allowlist" ,
101111 },
102112 {
103113 Flag : "log-level" ,
@@ -199,14 +209,19 @@ func Run(ctx context.Context, config Config, args []string) error {
199209 return fmt .Errorf ("no command specified" )
200210 }
201211
202- // Parse allow list; default to deny-all if none provided
212+ // Merge allowlist from config file with allow from CLI flags
213+ allowListStrings := config .AllowListStrings .Value ()
203214 allowStrings := config .AllowStrings .Value ()
204- if len (allowStrings ) == 0 {
215+
216+ // Combine allowlist (config file) with allow (CLI flags)
217+ allAllowStrings := append (allowListStrings , allowStrings ... )
218+
219+ if len (allAllowStrings ) == 0 {
205220 logger .Warn ("No allow rules specified; all network traffic will be denied by default" )
206221 }
207222
208223 // Parse allow rules
209- allowRules , err := rulesengine .ParseAllowSpecs (allowStrings )
224+ allowRules , err := rulesengine .ParseAllowSpecs (allAllowStrings )
210225 if err != nil {
211226 logger .Error ("Failed to parse allow rules" , "error" , err )
212227 return fmt .Errorf ("failed to parse allow rules: %v" , err )
0 commit comments