Skip to content

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

:lock: https://github.com/siyuan-note/siyuan/security/advisories/GHSA-gmmv-4cc5-wr9r

Daniel74cdf2ca9fea
diff --git a/kernel/api/graph.go b/kernel/api/graph.go
index 4a5963429f..229f6ed430 100644
--- a/kernel/api/graph.go
+++ b/kernel/api/graph.go
@@ -84,8 +84,10 @@ func getGraph(c *gin.Context) {
return
}
- model.Conf.Graph.Global = global
- model.Conf.Save()
+ if model.IsAdminRoleContext(c) && !model.IsReadOnlyRoleContext(c) {
+ model.Conf.Graph.Global = global
+ model.Conf.Save()
+ }
boxID, nodes, links := model.BuildGraph(query)
if model.IsReadOnlyRoleContext(c) {
@@ -142,8 +144,10 @@ func getLocalGraph(c *gin.Context) {
return
}
- model.Conf.Graph.Local = local
- model.Conf.Save()
+ if model.IsAdminRoleContext(c) && !model.IsReadOnlyRoleContext(c) {
+ model.Conf.Graph.Local = local
+ model.Conf.Save()
+ }
boxID, nodes, links := model.BuildTreeGraph(id, keyword)
if model.IsReadOnlyRoleContext(c) {
diff --git a/kernel/api/router.go b/kernel/api/router.go
index 45031bf12c..e30f7fcd2d 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -283,7 +283,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/cloud/getCloudSpace", model.CheckAuth, model.CheckAdminRole, getCloudSpace)
ginServer.Handle("POST", "/api/sync/setSyncEnable", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncEnable)
- ginServer.Handle("POST", "/api/sync/setSyncInterval", model.CheckAuth, setSyncInterval)
+ ginServer.Handle("POST", "/api/sync/setSyncInterval", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncInterval)
ginServer.Handle("POST", "/api/sync/setSyncPerception", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncPerception)
ginServer.Handle("POST", "/api/sync/setSyncGenerateConflictDoc", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncGenerateConflictDoc)
ginServer.Handle("POST", "/api/sync/setSyncMode", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, setSyncMode)
diff --git a/kernel/api/search.go b/kernel/api/search.go
index 92b03101ed..0277c141f2 100644
--- a/kernel/api/search.go
+++ b/kernel/api/search.go
@@ -288,6 +288,10 @@ func updateEmbedBlock(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
+ if model.IsReadOnlyRoleContext(c) {
+ return
+ }
+
arg, ok := util.JsonArg(c, ret)
if !ok {
return
diff --git a/kernel/api/storage.go b/kernel/api/storage.go
index c621300fed..10bc92fd21 100644
--- a/kernel/api/storage.go
+++ b/kernel/api/storage.go
@@ -338,6 +338,10 @@ func updateRecentDocOpenTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
+ if model.IsReadOnlyRoleContext(c) {
+ return
+ }
+
arg, ok := util.JsonArg(c, ret)
if !ok {
return
@@ -360,6 +364,10 @@ func updateRecentDocViewTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
+ if model.IsReadOnlyRoleContext(c) {
+ return
+ }
+
arg, ok := util.JsonArg(c, ret)
if !ok {
return
@@ -382,6 +390,10 @@ func updateRecentDocCloseTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
+ if model.IsReadOnlyRoleContext(c) {
+ return
+ }
+
arg, ok := util.JsonArg(c, ret)
if !ok {
return
@@ -404,6 +416,10 @@ func batchUpdateRecentDocCloseTime(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
+ if model.IsReadOnlyRoleContext(c) {
+ return
+ }
+
arg, ok := util.JsonArg(c, ret)
if !ok {
return