From fb5029bad1d23fd76d7ca74bb1790c6a9ce52fe3 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 9 Jun 2022 19:44:11 +0800 Subject: [PATCH] =?UTF-8?q?WAF=E8=A7=84=E5=88=99=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0${requestURL}=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/waf/checkpoints/request_url.go | 21 +++++++++++++++++++++ internal/waf/checkpoints/utils.go | 11 +++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 internal/waf/checkpoints/request_url.go diff --git a/internal/waf/checkpoints/request_url.go b/internal/waf/checkpoints/request_url.go new file mode 100644 index 0000000..88c8727 --- /dev/null +++ b/internal/waf/checkpoints/request_url.go @@ -0,0 +1,21 @@ +package checkpoints + +import ( + "github.com/TeaOSLab/EdgeNode/internal/waf/requests" + "github.com/iwind/TeaGo/maps" +) + +type RequestURLCheckpoint struct { + Checkpoint +} + +func (this *RequestURLCheckpoint) RequestValue(req requests.Request, param string, options maps.Map) (value interface{}, sysErr error, userErr error) { + return req.Format("${requestURL}"), nil, nil +} + +func (this *RequestURLCheckpoint) ResponseValue(req requests.Request, resp *requests.Response, param string, options maps.Map) (value interface{}, sysErr error, userErr error) { + if this.IsRequest() { + return this.RequestValue(req, param, options) + } + return +} diff --git a/internal/waf/checkpoints/utils.go b/internal/waf/checkpoints/utils.go index 120d1aa..23aa7e2 100644 --- a/internal/waf/checkpoints/utils.go +++ b/internal/waf/checkpoints/utils.go @@ -40,17 +40,24 @@ var AllCheckpoints = []*CheckpointDefinition{ { Name: "请求URI", Prefix: "requestURI", - Description: "包含URL参数的请求URI,比如/hello/world?lang=go", + Description: "包含URL参数的请求URI,类似于 /hello/world?lang=go", HasParams: false, Instance: new(RequestURICheckpoint), }, { Name: "请求路径", Prefix: "requestPath", - Description: "不包含URL参数的请求路径,比如/hello/world", + Description: "不包含URL参数的请求路径,类似于 /hello/world", HasParams: false, Instance: new(RequestPathCheckpoint), }, + { + Name: "请求URL", + Prefix: "requestURL", + Description: "完整的请求URL,包含协议、域名、请求路径、参数等,类似于 https://example.com/hello?name=lily", + HasParams: false, + Instance: new(RequestURLCheckpoint), + }, { Name: "请求内容长度", Prefix: "requestLength",