WAF增加“包含SQL注入”操作符

This commit is contained in:
刘祥超
2023-12-07 20:25:35 +08:00
parent 05c98a0656
commit cc10372fe1
20 changed files with 14967 additions and 27 deletions

View File

@@ -508,6 +508,19 @@ func TestRule_Test(t *testing.T) {
a.IsTrue(rule.Test("How are you doing"))
a.IsFalse(rule.Test("How are dare"))
}
{
var rule = NewRule()
rule.Operator = RuleOperatorContainsSQLInjection
err := rule.Init()
if err != nil {
t.Fatal(err)
}
a.IsTrue(rule.Test("id=123 OR 1=1"))
a.IsTrue(rule.Test("id=456 UNION SELECT"))
a.IsTrue(rule.Test("id=456 AND select load_file('') --"))
a.IsFalse(rule.Test("id=123"))
a.IsFalse(rule.Test("id=abc123 hello world '"))
}
}
func TestRule_MatchStar(t *testing.T) {