(b *testing.B)
| 437 | } |
| 438 | |
| 439 | func BenchmarkTemplatePathTraversal(b *testing.B) { |
| 440 | runtime.GOMAXPROCS(4) |
| 441 | |
| 442 | template, err := waf.Template() |
| 443 | if err != nil { |
| 444 | b.Fatal(err) |
| 445 | } |
| 446 | var group = template.FindRuleGroupWithCode("pathTraversal") |
| 447 | if group == nil { |
| 448 | b.Fatal("group not found") |
| 449 | return |
| 450 | } |
| 451 | |
| 452 | b.ResetTimer() |
| 453 | |
| 454 | b.RunParallel(func(pb *testing.PB) { |
| 455 | for pb.Next() { |
| 456 | req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234"+types.String(rand.Int()%10000)+"&name=lily&time=12345678910", nil) |
| 457 | if err != nil { |
| 458 | b.Fatal(err) |
| 459 | } |
| 460 | req.Header.Set("User-Agent", testUserAgent) |
| 461 | |
| 462 | _, _, result, err := group.MatchRequest(requests.NewTestRequest(req)) |
| 463 | if err != nil { |
| 464 | b.Fatal(err) |
| 465 | } |
| 466 | _ = result |
| 467 | } |
| 468 | }) |
| 469 | } |
| 470 | |
| 471 | func BenchmarkTemplateCC2(b *testing.B) { |
| 472 | runtime.GOMAXPROCS(4) |
nothing calls this directly
no test coverage detected