mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 20:10:27 +08:00
WAF SQL注入检测时支持 (http|https):// 开头的URL
This commit is contained in:
@@ -27,7 +27,7 @@ func DetectSQLInjection(input string) bool {
|
||||
}
|
||||
|
||||
// 兼容 /PATH?URI
|
||||
if input[0] == '/' {
|
||||
if input[0] == '/' || strings.HasPrefix(input, "http://") || strings.HasPrefix(input, "https://") {
|
||||
var argsIndex = strings.Index(input, "?")
|
||||
if argsIndex > 0 {
|
||||
var args = input[argsIndex+1:]
|
||||
|
||||
@@ -21,6 +21,7 @@ func TestDetectSQLInjection(t *testing.T) {
|
||||
a.IsFalse(injectionutils.DetectSQLInjection("/hello?age=22"))
|
||||
a.IsTrue(injectionutils.DetectSQLInjection("/sql/injection?id=123 or 1=1"))
|
||||
a.IsTrue(injectionutils.DetectSQLInjection("/sql/injection?id=123%20or%201=1"))
|
||||
a.IsTrue(injectionutils.DetectSQLInjection("https://example.com/sql/injection?id=123%20or%201=1"))
|
||||
}
|
||||
|
||||
func BenchmarkDetectSQLInjection(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user