Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: Remove dangerous template functions from attribute-view calculation https://github.com/siyuan-note/siyuan/security/advisories/GHSA-v97v-gxxg-rhmq

Daniel36c297bd656f
diff --git a/kernel/av/calc_template.go b/kernel/av/calc_template.go
index b6c7e9fc60..1d4679f8ab 100644
--- a/kernel/av/calc_template.go
+++ b/kernel/av/calc_template.go
@@ -182,6 +182,12 @@ func pushRollupTemplateErr(err error) {
// templateFuncMap 在 sprig 函数集基础上,补充表格计算专用的条件计数函数 countif。
func templateFuncMap() template.FuncMap {
tplFuncs := sprig.TxtFuncMap()
+
+ // 因为安全原因移除一些函数,与 filesys.BuiltInTemplateFuncs 保持一致 https://github.com/siyuan-note/siyuan/security/advisories/GHSA-v97v-gxxg-rhmq
+ delete(tplFuncs, "env")
+ delete(tplFuncs, "expandenv")
+ delete(tplFuncs, "getHostByName")
+
tplFuncs["countif"] = util.CountIf
return tplFuncs
}