(a *assert.Assertion, t *testing.T, template *waf.WAF)
| 400 | } |
| 401 | |
| 402 | func testTemplate20001(a *assert.Assertion, t *testing.T, template *waf.WAF) { |
| 403 | // enable bot rule set |
| 404 | for _, g := range template.Inbound { |
| 405 | if g.Code == "bot" { |
| 406 | g.IsOn = true |
| 407 | break |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | for _, bot := range []string{ |
| 412 | "Googlebot", |
| 413 | "AdsBot-Google", |
| 414 | "bingbot", |
| 415 | "BingPreview", |
| 416 | "facebookexternalhit", |
| 417 | "Slurp", |
| 418 | "Sogou", |
| 419 | "Baiduspider http://baidu.com", |
| 420 | } { |
| 421 | req, err := http.NewRequest(http.MethodPost, "http://example.com/", nil) |
| 422 | if err != nil { |
| 423 | t.Fatal(err) |
| 424 | } |
| 425 | req.Header.Set("User-Agent", bot) |
| 426 | result, err := template.MatchRequest(requests.NewTestRequest(req), nil, firewallconfigs.ServerCaptchaTypeNone) |
| 427 | if err != nil { |
| 428 | t.Fatal(err) |
| 429 | } |
| 430 | a.IsNotNil(result.Set) |
| 431 | if result.Set != nil { |
| 432 | a.IsTrue(lists.ContainsAny([]string{"20001"}, result.Set.Code)) |
| 433 | } else { |
| 434 | t.Log("break:", bot) |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | func BenchmarkTemplatePathTraversal(b *testing.B) { |
| 440 | runtime.GOMAXPROCS(4) |
no test coverage detected