(b *testing.B)
| 370 | } |
| 371 | |
| 372 | func BenchmarkTemplateSQLInjection(b *testing.B) { |
| 373 | template, err := waf.Template() |
| 374 | if err != nil { |
| 375 | b.Fatal(err) |
| 376 | } |
| 377 | var group = template.FindRuleGroupWithCode("sqlInjection") |
| 378 | if group == nil { |
| 379 | b.Fatal("group not found") |
| 380 | return |
| 381 | } |
| 382 | |
| 383 | b.ResetTimer() |
| 384 | |
| 385 | b.RunParallel(func(pb *testing.PB) { |
| 386 | for pb.Next() { |
| 387 | req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234"+types.String(rand.Int()%10000), nil) |
| 388 | if err != nil { |
| 389 | b.Fatal(err) |
| 390 | } |
| 391 | req.Header.Set("User-Agent", testUserAgent) |
| 392 | |
| 393 | _, _, result, err := group.MatchRequest(requests.NewTestRequest(req)) |
| 394 | if err != nil { |
| 395 | b.Fatal(err) |
| 396 | } |
| 397 | _ = result |
| 398 | } |
| 399 | }) |
| 400 | } |
| 401 | |
| 402 | func testTemplate20001(a *assert.Assertion, t *testing.T, template *waf.WAF) { |
| 403 | // enable bot rule set |
nothing calls this directly
no test coverage detected