Files
SamWaf/wafenginecore/checksensitive.go
T
2024-09-10 15:08:47 +08:00

47 lines
1.2 KiB
Go

package wafenginecore
import (
"SamWaf/innerbean"
"SamWaf/model/detection"
"net/url"
)
/*
*
检测敏感词
*/
func (waf *WafEngine) CheckSensitive(weblogbean *innerbean.WebLog, formValue url.Values) detection.Result {
result := detection.Result{
JumpGuardResult: false,
IsBlock: false,
Title: "",
Content: "",
}
if len(waf.Sensitive) == 0 {
return result
}
//敏感词检测
matchURLResult := waf.SensitiveManager.MultiPatternSearch([]rune(weblogbean.URL), true)
if len(matchURLResult) > 0 {
result.IsBlock = true
result.Title = "敏感词检测:" + string(matchURLResult[0].Word)
result.Content = "敏感词内容"
return result
}
matchBodyResult := waf.SensitiveManager.MultiPatternSearch([]rune(weblogbean.BODY), true)
if len(matchBodyResult) > 0 {
result.IsBlock = true
result.Title = "敏感词检测:" + string(matchBodyResult[0].Word)
result.Content = "敏感词内容"
return result
}
matchPostFromResult := waf.SensitiveManager.MultiPatternSearch([]rune(weblogbean.POST_FORM), true)
if len(matchPostFromResult) > 0 {
result.IsBlock = true
result.Title = "敏感词检测:" + string(matchPostFromResult[0].Word)
result.Content = "敏感词内容"
return result
}
return result
}