WAF记录IP动作中IP名单如果为空时,默认为全局黑名单

This commit is contained in:
GoEdgeLab
2023-10-15 09:34:50 +08:00
parent 55d6761e24
commit b04feefe42

View File

@@ -133,8 +133,13 @@ func (this *RecordIPAction) WillChange() bool {
} }
func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (continueRequest bool, goNextSet bool) { func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (continueRequest bool, goNextSet bool) {
var ipListId = this.IPListId
if ipListId <= 0 {
ipListId = firewallconfigs.GlobalListId
}
// 是否已删除 // 是否已删除
var ipListIsAvailable = this.IPListId > 0 && !this.IPListIsDeleted && !ExistDeletedIPList(this.IPListId) var ipListIsAvailable = (ipListId == firewallconfigs.GlobalListId) || (ipListId > 0 && !this.IPListIsDeleted && !ExistDeletedIPList(ipListId))
// 是否在本地白名单中 // 是否在本地白名单中
if SharedIPWhiteList.Contains("set:"+types.String(set.Id), this.Scope, request.WAFServerId(), request.WAFRemoteIP()) { if SharedIPWhiteList.Contains("set:"+types.String(set.Id), this.Scope, request.WAFServerId(), request.WAFRemoteIP()) {
@@ -167,7 +172,7 @@ func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, re
} }
// 上报 // 上报
if this.IPListId > 0 && ipListIsAvailable { if ipListId > 0 && ipListIsAvailable {
var serverId int64 var serverId int64
if this.Scope == firewallconfigs.FirewallScopeService { if this.Scope == firewallconfigs.FirewallScopeService {
serverId = request.WAFServerId() serverId = request.WAFServerId()
@@ -181,7 +186,7 @@ func (this *RecordIPAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, re
select { select {
case recordIPTaskChan <- &recordIPTask{ case recordIPTaskChan <- &recordIPTask{
ip: request.WAFRemoteIP(), ip: request.WAFRemoteIP(),
listId: this.IPListId, listId: ipListId,
expiresAt: realExpiresAt, expiresAt: realExpiresAt,
level: this.Level, level: this.Level,
serverId: serverId, serverId: serverId,