Browse Source

fix: remove getHostByName from template funcs (#6164)

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Moritz Johner 2 weeks ago
parent
commit
6800989bdc
2 changed files with 7 additions and 1 deletions
  1. 1 1
      runtime/template/v2/template.go
  2. 6 0
      runtime/template/v2/template_test.go

+ 1 - 1
runtime/template/v2/template.go

@@ -87,7 +87,7 @@ func init() {
 	sprigFuncs := sprig.TxtFuncMap()
 	delete(sprigFuncs, "env")
 	delete(sprigFuncs, "expandenv")
-
+	delete(sprigFuncs, "getHostByName")
 	maps.Copy(tplFuncs, sprigFuncs)
 	fs := pflag.NewFlagSet("template", pflag.ExitOnError)
 	fs.StringVar(&leftDelim, "template-left-delimiter", "{{", "templating left delimiter")

+ 6 - 0
runtime/template/v2/template_test.go

@@ -222,6 +222,12 @@ func rsaEncryptOAEP(t testing.TB, publicKeyPEM []byte, hash, plaintext string) [
 	return ciphertext
 }
 
+func TestFuncMapDoesNotExposeGetHostByName(t *testing.T) {
+	if _, ok := FuncMap()["getHostByName"]; ok {
+		t.Fatalf("getHostByName should not be exposed in the template function map")
+	}
+}
+
 func TestExecute(t *testing.T) {
 	tbl := []struct {
 		name                string