Kaynağa Gözat

fix: remove getHostByName from template funcs (#6164)

Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
Moritz Johner 2 ay önce
ebeveyn
işleme
6800989bdc

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

@@ -87,7 +87,7 @@ func init() {
 	sprigFuncs := sprig.TxtFuncMap()
 	sprigFuncs := sprig.TxtFuncMap()
 	delete(sprigFuncs, "env")
 	delete(sprigFuncs, "env")
 	delete(sprigFuncs, "expandenv")
 	delete(sprigFuncs, "expandenv")
-
+	delete(sprigFuncs, "getHostByName")
 	maps.Copy(tplFuncs, sprigFuncs)
 	maps.Copy(tplFuncs, sprigFuncs)
 	fs := pflag.NewFlagSet("template", pflag.ExitOnError)
 	fs := pflag.NewFlagSet("template", pflag.ExitOnError)
 	fs.StringVar(&leftDelim, "template-left-delimiter", "{{", "templating left delimiter")
 	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
 	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) {
 func TestExecute(t *testing.T) {
 	tbl := []struct {
 	tbl := []struct {
 		name                string
 		name                string