mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-31 18:46:36 +08:00
记录WAF日志
This commit is contained in:
@@ -3,6 +3,7 @@ package nodes
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -13,7 +14,7 @@ func (this *HTTPRequest) doWAFRequest() (blocked bool) {
|
||||
return
|
||||
}
|
||||
|
||||
goNext, _, ruleSet, err := w.MatchRequest(this.RawReq, this.writer)
|
||||
goNext, ruleGroup, ruleSet, err := w.MatchRequest(this.RawReq, this.writer)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
return
|
||||
@@ -21,8 +22,12 @@ func (this *HTTPRequest) doWAFRequest() (blocked bool) {
|
||||
|
||||
if ruleSet != nil {
|
||||
if ruleSet.Action != waf.ActionAllow {
|
||||
// TODO 记录日志
|
||||
this.firewallPolicyId = this.web.FirewallPolicy.Id
|
||||
this.firewallRuleGroupId = types.Int64(ruleGroup.Id)
|
||||
this.firewallRuleSetId = types.Int64(ruleSet.Id)
|
||||
}
|
||||
|
||||
this.logAttrs["waf.action"] = ruleSet.Action
|
||||
}
|
||||
|
||||
return !goNext
|
||||
@@ -35,7 +40,7 @@ func (this *HTTPRequest) doWAFResponse(resp *http.Response) (blocked bool) {
|
||||
return
|
||||
}
|
||||
|
||||
goNext, _, ruleSet, err := w.MatchResponse(this.RawReq, resp, this.writer)
|
||||
goNext, ruleGroup, ruleSet, err := w.MatchResponse(this.RawReq, resp, this.writer)
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
return
|
||||
@@ -43,8 +48,12 @@ func (this *HTTPRequest) doWAFResponse(resp *http.Response) (blocked bool) {
|
||||
|
||||
if ruleSet != nil {
|
||||
if ruleSet.Action != waf.ActionAllow {
|
||||
// TODO 记录日志
|
||||
this.firewallPolicyId = this.web.FirewallPolicy.Id
|
||||
this.firewallRuleGroupId = types.Int64(ruleGroup.Id)
|
||||
this.firewallRuleSetId = types.Int64(ruleSet.Id)
|
||||
}
|
||||
|
||||
this.logAttrs["waf.action"] = ruleSet.Action
|
||||
}
|
||||
|
||||
return !goNext
|
||||
|
||||
Reference in New Issue
Block a user