2020-11-18 19:35:38 +08:00
|
|
|
package checkpoints
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
|
|
|
|
"github.com/iwind/TeaGo/maps"
|
|
|
|
|
"github.com/iwind/TeaGo/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type RequestGeneralHeaderLengthCheckpoint struct {
|
|
|
|
|
Checkpoint
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) IsComposed() bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 09:34:34 +08:00
|
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) RequestValue(req requests.Request, param string, options maps.Map, ruleId int64) (value interface{}, hasRequestBody bool, sysErr error, userErr error) {
|
2020-11-18 19:35:38 +08:00
|
|
|
value = false
|
|
|
|
|
|
2022-07-16 17:05:37 +08:00
|
|
|
var headers = options.GetSlice("headers")
|
2020-11-18 19:35:38 +08:00
|
|
|
if len(headers) == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-16 17:05:37 +08:00
|
|
|
var length = options.GetInt("length")
|
2020-11-18 19:35:38 +08:00
|
|
|
|
|
|
|
|
for _, header := range headers {
|
2021-07-18 15:51:49 +08:00
|
|
|
v := req.WAFRaw().Header.Get(types.String(header))
|
2020-11-18 19:35:38 +08:00
|
|
|
if len(v) > length {
|
|
|
|
|
value = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 09:34:34 +08:00
|
|
|
func (this *RequestGeneralHeaderLengthCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map, ruleId int64) (value interface{}, hasRequestBody bool, sysErr error, userErr error) {
|
2020-11-18 19:35:38 +08:00
|
|
|
return
|
|
|
|
|
}
|