Files
SamWaf/wafenginecore/checkbot.go
T
samwaf 9087dbff2d feat:add owasp
#IB5RG5 #IAWF3C #4
2024-11-28 13:53:15 +08:00

38 lines
794 B
Go

package wafenginecore
import (
"SamWaf/innerbean"
"SamWaf/model/detection"
"SamWaf/wafbot"
"net/http"
"net/url"
)
/*
*
检测爬虫
*/
func (waf *WafEngine) CheckBot(r *http.Request, weblogbean *innerbean.WebLog, formValue url.Values) detection.Result {
result := detection.Result{
JumpGuardResult: false,
IsBlock: false,
Title: "",
Content: "",
}
isBot, isNormalBot, BotName := wafbot.DetermineNormalSearch(weblogbean.USER_AGENT, weblogbean.SRC_IP)
if isBot == true {
if isNormalBot {
weblogbean.GUEST_IDENTIFICATION = BotName
} else {
weblogbean.GUEST_IDENTIFICATION = BotName
weblogbean.RISK_LEVEL = 1
result.IsBlock = true
result.Title = BotName
result.Content = "请正确访问"
return result
}
}
return result
}