@@ -38,7 +38,8 @@ func FuzzHCLStringHelpers(f *testing.F) {
3838 })
3939}
4040
41- // FuzzHCLRunCommandOptions: run_cmd must never panic on any mix of option flags and commands.
41+ // FuzzHCLRunCommandOptions: run_cmd must never panic on any mix of recognized option flags.
42+ // Fuzz input is filtered to known --terragrunt-* flags so the fuzzer cannot launch arbitrary host commands.
4243func FuzzHCLRunCommandOptions (f * testing.F ) {
4344 if runtime .GOOS == "windows" {
4445 f .Skip ("run_cmd happy-path requires bash; skip on Windows" )
@@ -50,8 +51,6 @@ func FuzzHCLRunCommandOptions(f *testing.F) {
5051 "--terragrunt-global-cache" ,
5152 "--terragrunt-quiet\x00 --terragrunt-no-cache" ,
5253 "--terragrunt-quiet\x00 --terragrunt-quiet" ,
53- "--terragrunt-quiet\x00 /bin/echo\x00 hi" ,
54- "/bin/echo\x00 hi" ,
5554 "--terragrunt-no-cache\x00 --terragrunt-global-cache" ,
5655 "--unknown-flag" ,
5756 "" ,
@@ -61,7 +60,17 @@ func FuzzHCLRunCommandOptions(f *testing.F) {
6160 }
6261
6362 f .Fuzz (func (t * testing.T , raw string ) {
64- args := strings .Split (raw , "\x00 " )
63+ parts := strings .Split (raw , "\x00 " )
64+
65+ args := make ([]string , 0 , len (parts )+ 2 )
66+ for _ , part := range parts {
67+ switch part {
68+ case "--terragrunt-quiet" , "--terragrunt-no-cache" , "--terragrunt-global-cache" :
69+ args = append (args , part )
70+ }
71+ }
72+
73+ args = append (args , "/bin/echo" , "hi" )
6574
6675 l := logger .CreateLogger ()
6776 ctx , pctx := newTestParsingContext (t , "" )
0 commit comments