@@ -422,6 +422,41 @@ func TestApply(t *testing.T) {
422422 }
423423}
424424
425+ // TestFuncMap_UnsafeSprigFunctionsRemoved pins the set of sprig functions
426+ // deliberately stripped from the template engine. Re-adding any of these
427+ // reintroduces a host-side-effect or exfiltration channel that Zarf packages
428+ // (including untrusted ones) must not reach.
429+ func TestFuncMap_UnsafeSprigFunctionsRemoved (t * testing.T ) {
430+ m := funcMap ()
431+ for _ , name := range []string {"env" , "expandenv" , "getHostByName" } {
432+ _ , present := m [name ]
433+ require .False (t , present , "sprig function %q must not be registered in funcMap" , name )
434+ }
435+ }
436+
437+ // TestApply_UnsafeSprigFunctionsRejected verifies that templates invoking the
438+ // stripped functions fail at parse time rather than silently skipping or
439+ // executing. This is the end-to-end regression guard for the funcMap stripping.
440+ func TestApply_UnsafeSprigFunctionsRejected (t * testing.T ) {
441+ tests := []struct {
442+ name string
443+ tmpl string
444+ }{
445+ {name : "env" , tmpl : `{{ env "PATH" }}` },
446+ {name : "expandenv" , tmpl : `{{ expandenv "$PATH" }}` },
447+ {name : "getHostByName" , tmpl : `{{ getHostByName "localhost" }}` },
448+ }
449+ for _ , tt := range tests {
450+ t .Run (tt .name , func (t * testing.T ) {
451+ ctx := context .Background ()
452+ _ , err := Apply (ctx , tt .tmpl , Objects {})
453+ require .Error (t , err )
454+ require .Contains (t , err .Error (), tt .name )
455+ require .Contains (t , err .Error (), "not defined" )
456+ })
457+ }
458+ }
459+
425460func TestApplyToFile (t * testing.T ) {
426461 tests := []struct {
427462 name string
0 commit comments