Skip to content

Commit b4dace1

Browse files
committed
修复非gcc下编译错误
1 parent 4edec8b commit b4dace1

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

internal/web/helpers/user_must_auth.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/TeaOSLab/EdgeAdmin/internal/goman"
88
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
99
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
10-
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
1110
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/index/loginutils"
1211
"github.com/TeaOSLab/EdgeCommon/pkg/langs"
1312
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
@@ -117,7 +116,7 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
117116
}
118117

119118
// 检测注入
120-
if injectionutils.DetectXSS(action.Request.RequestURI, false) || injectionutils.DetectSQLInjection(action.Request.RequestURI, false) {
119+
if !safeFilterRequest(action.Request) {
121120
action.ResponseWriter.WriteHeader(http.StatusForbidden)
122121
_, _ = action.ResponseWriter.Write([]byte("Denied By WAF"))
123122
return false

internal/web/helpers/user_should_auth.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
55
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
66
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
7-
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
87
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/index/loginutils"
98
"github.com/iwind/TeaGo/actions"
109
"net/http"
@@ -29,7 +28,7 @@ func (this *UserShouldAuth) BeforeAction(actionPtr actions.ActionWrapper, paramN
2928
}
3029

3130
// 检测注入
32-
if injectionutils.DetectXSS(this.action.Request.RequestURI, false) || injectionutils.DetectSQLInjection(this.action.Request.RequestURI, false) {
31+
if !safeFilterRequest(this.action.Request) {
3332
this.action.ResponseWriter.WriteHeader(http.StatusForbidden)
3433
_, _ = this.action.ResponseWriter.Write([]byte("Denied By WAF"))
3534
return false

internal/web/helpers/utils_gcc.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2024 GoEdge CDN [email protected]. All rights reserved. Official site: https://goedge.cn .
2+
//go:build gcc
3+
4+
package helpers
5+
6+
import (
7+
"github.com/TeaOSLab/EdgeAdmin/internal/waf/injectionutils"
8+
"net/http"
9+
)
10+
11+
// filter request
12+
func safeFilterRequest(req *http.Request) bool {
13+
return !injectionutils.DetectXSS(req.RequestURI, false) && !injectionutils.DetectSQLInjection(req.RequestURI, false)
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2024 GoEdge CDN [email protected]. All rights reserved. Official site: https://goedge.cn .
2+
//go:build !gcc
3+
4+
package helpers
5+
6+
import (
7+
"net/http"
8+
)
9+
10+
// filter request
11+
func safeFilterRequest(req *http.Request) bool {
12+
return true
13+
}

0 commit comments

Comments
 (0)