This commit is contained in:
uubulb 2024-12-21 23:41:39 +08:00
parent 4085a928a8
commit ddd782d623
2 changed files with 2 additions and 26 deletions

View File

@ -168,20 +168,8 @@ func validateRule(c *gin.Context, r *model.AlertRule) error {
if len(r.Rules) > 0 {
for _, rule := range r.Rules {
singleton.ServerLock.RLock()
isCoverAll := rule.Cover == model.RuleCoverAll
isCoverIgnoreAll := rule.Cover == model.RuleCoverIgnoreAll
for s, enabled := range rule.Ignore {
if isCoverAll {
for id, server := range singleton.ServerList {
if enabled && id == s {
continue
}
if !server.HasPermission(c) {
singleton.ServerLock.RUnlock()
return singleton.Localizer.ErrorT("permission denied")
}
}
} else if isCoverIgnoreAll && enabled {
if enabled {
if server, ok := singleton.ServerList[s]; ok {
if !server.HasPermission(c) {
singleton.ServerLock.RUnlock()

View File

@ -364,20 +364,8 @@ func validateServers(c *gin.Context, ss *model.Service) error {
singleton.ServerLock.RLock()
defer singleton.ServerLock.RUnlock()
isCoverAll := ss.Cover == model.ServiceCoverAll
isCoverIgnoreAll := ss.Cover == model.ServiceCoverIgnoreAll
for s, enabled := range ss.SkipServers {
if isCoverAll {
for id, server := range singleton.ServerList {
if enabled && id == s {
continue
}
if !server.HasPermission(c) {
return singleton.Localizer.ErrorT("permission denied")
}
}
} else if isCoverIgnoreAll && enabled {
if enabled {
if server, ok := singleton.ServerList[s]; ok {
if !server.HasPermission(c) {
return singleton.Localizer.ErrorT("permission denied")