Skip to content

Commit d27d2c3

Browse files
committed
Remove dangerous tpl funcs in Sprig that's enabled by default.
`env` and `expandenv` template functions in the Sprig library allow accessing system environment variables within campaign templates.
1 parent 6fc6c1e commit d27d2c3

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cmd/init.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,11 @@ func initTplFuncs(i *i18n.I18n, u *UrlConfig) template.FuncMap {
988988
}
989989

990990
// Copy spring functions.
991-
maps.Copy(funcs, sprig.GenericFuncMap())
991+
sprigFuncs := sprig.GenericFuncMap()
992+
delete(sprigFuncs, "env")
993+
delete(sprigFuncs, "expandenv")
994+
995+
maps.Copy(funcs, sprigFuncs)
992996

993997
return funcs
994998
}

internal/manager/manager.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,11 @@ func (m *Manager) makeGnericFuncMap() template.FuncMap {
621621
}
622622

623623
// Copy spring functions.
624-
maps.Copy(funcs, sprig.GenericFuncMap())
624+
sprigFuncs := sprig.GenericFuncMap()
625+
delete(sprigFuncs, "env")
626+
delete(sprigFuncs, "expandenv")
627+
628+
maps.Copy(funcs, sprigFuncs)
625629

626630
return funcs
627631
}

0 commit comments

Comments
 (0)