提交 8a06cac5 编写于 作者: U UlricQin

bugfix: check perm for alert_rule_delete_batch

上级 60d5c6b5
package http
import (
"fmt"
"net/http"
"strconv"
"strings"
......@@ -79,7 +80,25 @@ func alertRuleOfGroupDel(c *gin.Context) {
var f idsForm
bind(c, &f)
f.Validate()
loginUser(c).MustPerm("alert_rule_delete")
me := loginUser(c).MustPerm("alert_rule_delete")
// 可能大部分alert_rule都来自同一个alert_rule_group,所以权限判断可以无需重复判断
cachePerm := make(map[string]struct{})
for i := 0; i < len(f.Ids); i++ {
ar := AlertRule(f.Ids[i])
cacheKey := fmt.Sprintf("%d,%d", f.Ids[i], ar.GroupId)
if _, has := cachePerm[cacheKey]; has {
continue
}
arg := AlertRuleGroup(ar.GroupId)
alertRuleWritePermCheck(arg, me)
cachePerm[cacheKey] = struct{}{}
}
renderMessage(c, models.AlertRulesDel(f.Ids))
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册