mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-03 23:20:25 +08:00
WAF增加“请求报头最大长度”参数
This commit is contained in:
37
internal/waf/checkpoints/request_header_max_length.go
Normal file
37
internal/waf/checkpoints/request_header_max_length.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package checkpoints
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/utils"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type RequestHeaderMaxLengthCheckpoint struct {
|
||||
Checkpoint
|
||||
}
|
||||
|
||||
func (this *RequestHeaderMaxLengthCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
|
||||
var maxLen int
|
||||
for _, v := range req.WAFRaw().Header {
|
||||
for _, subV := range v {
|
||||
var l = len(subV)
|
||||
if l > maxLen {
|
||||
maxLen = l
|
||||
}
|
||||
}
|
||||
}
|
||||
value = maxLen
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *RequestHeaderMaxLengthCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value any, hasRequestBody bool, sysErr error, userErr error) {
|
||||
if this.IsRequest() {
|
||||
return this.RequestValue(req, param, options, ruleId)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *RequestHeaderMaxLengthCheckpoint) CacheLife() utils.CacheLife {
|
||||
return utils.CacheShortLife
|
||||
}
|
||||
@@ -243,13 +243,21 @@ var AllCheckpoints = []*CheckpointDefinition{
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
Name: "单个Header值",
|
||||
Name: "单个报头值",
|
||||
Prefix: "header",
|
||||
Description: "单个Header值",
|
||||
Description: "单个报头值",
|
||||
HasParams: true,
|
||||
Instance: new(RequestHeaderCheckpoint),
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
Name: "请求报头最大长度",
|
||||
Prefix: "headerMaxLength",
|
||||
Description: "最长的请求报头的长度。",
|
||||
HasParams: false,
|
||||
Instance: new(RequestHeaderMaxLengthCheckpoint),
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
Name: "国家/地区名称",
|
||||
Prefix: "geoCountryName",
|
||||
|
||||
Reference in New Issue
Block a user