mirror of
https://gitee.com/samwaf/SamWaf.git
synced 2026-11-03 03:31:58 +08:00
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package wafenginecore
|
||
|
||
import (
|
||
"SamWaf/global"
|
||
"SamWaf/innerbean"
|
||
"SamWaf/model/detection"
|
||
"net/url"
|
||
)
|
||
|
||
/*
|
||
*
|
||
检测cc
|
||
*/
|
||
func (waf *WafEngine) CheckCC(weblogbean *innerbean.WebLog, formValue url.Values) detection.Result {
|
||
result := detection.Result{
|
||
JumpGuardResult: false,
|
||
IsBlock: false,
|
||
Title: "",
|
||
Content: "",
|
||
}
|
||
// cc 防护 (局部检测 )
|
||
if waf.HostTarget[weblogbean.HOST].PluginIpRateLimiter != nil {
|
||
limiter := waf.HostTarget[weblogbean.HOST].PluginIpRateLimiter.GetLimiter(weblogbean.SRC_IP)
|
||
if !limiter.Allow() {
|
||
weblogbean.RISK_LEVEL = 1
|
||
result.IsBlock = true
|
||
result.Title = "触发IP频次访问限制1"
|
||
result.Content = "您的访问被阻止超量了1"
|
||
return result
|
||
}
|
||
}
|
||
// cc 防护 (全局检测 )
|
||
if waf.HostTarget[global.GWAF_GLOBAL_HOST_NAME].Host.GUARD_STATUS == 1 && waf.HostTarget[global.GWAF_GLOBAL_HOST_NAME].PluginIpRateLimiter != nil {
|
||
limiter := waf.HostTarget[global.GWAF_GLOBAL_HOST_NAME].PluginIpRateLimiter.GetLimiter(weblogbean.SRC_IP)
|
||
if !limiter.Allow() {
|
||
weblogbean.RISK_LEVEL = 1
|
||
result.IsBlock = true
|
||
result.Title = "【全局】触发IP频次访问限制"
|
||
result.Content = "您的访问被阻止超量了"
|
||
return result
|
||
}
|
||
}
|
||
return result
|
||
}
|