MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / doWAFRequest

Method doWAFRequest

internal/nodes/http_request_waf.go:19–119  ·  view source on GitHub ↗

调用WAF

()

Source from the content-addressed store, hash-verified

17
18// 调用WAF
19func (this *HTTPRequest) doWAFRequest() (blocked bool) {
20 if this.web.FirewallRef == nil || !this.web.FirewallRef.IsOn {
21 return
22 }
23
24 var remoteAddr = this.requestRemoteAddr(true)
25
26 // 检查是否为白名单直连
27 if !Tea.IsTesting() && this.nodeConfig.IPIsAutoAllowed(remoteAddr) {
28 return
29 }
30
31 // 当前连接是否已关闭
32 if this.isConnClosed() {
33 this.disableLog = true
34 return true
35 }
36
37 // 是否在全局名单中
38 canGoNext, isInAllowedList, _ := iplibrary.AllowIP(remoteAddr, this.ReqServer.Id)
39 if !canGoNext {
40 this.disableLog = true
41 this.Close()
42 return true
43 }
44 if isInAllowedList {
45 return false
46 }
47
48 // 检查是否在临时黑名单中
49 if waf.SharedIPBlackList.Contains(waf.IPTypeAll, firewallconfigs.FirewallScopeServer, this.ReqServer.Id, remoteAddr) || waf.SharedIPBlackList.Contains(waf.IPTypeAll, firewallconfigs.FirewallScopeGlobal, 0, remoteAddr) {
50 this.disableLog = true
51 this.Close()
52
53 return true
54 }
55
56 var forceLog = false
57 var forceLogRequestBody = false
58 var forceLogRegionDenying = false
59 if this.ReqServer.HTTPFirewallPolicy != nil &&
60 this.ReqServer.HTTPFirewallPolicy.IsOn &&
61 this.ReqServer.HTTPFirewallPolicy.Log != nil &&
62 this.ReqServer.HTTPFirewallPolicy.Log.IsOn {
63 forceLog = true
64 forceLogRequestBody = this.ReqServer.HTTPFirewallPolicy.Log.RequestBody
65 forceLogRegionDenying = this.ReqServer.HTTPFirewallPolicy.Log.RegionDenying
66 }
67
68 // 检查IP名单
69 {
70 // 当前服务的独立设置
71 if this.web.FirewallPolicy != nil && this.web.FirewallPolicy.IsOn {
72 blockedRequest, breakChecking := this.checkWAFRemoteAddr(this.web.FirewallPolicy)
73 if blockedRequest {
74 return true
75 }
76 if breakChecking {

Callers 1

DoMethod · 0.95

Calls 7

requestRemoteAddrMethod · 0.95
isConnClosedMethod · 0.95
CloseMethod · 0.95
checkWAFRemoteAddrMethod · 0.95
checkWAFRequestMethod · 0.95
AllowIPFunction · 0.92
ContainsMethod · 0.45

Tested by

no test coverage detected