(t *testing.T)
| 339 | } |
| 340 | |
| 341 | func TestTemplateSQLInjection(t *testing.T) { |
| 342 | template, err := waf.Template() |
| 343 | if err != nil { |
| 344 | t.Fatal(err) |
| 345 | } |
| 346 | var group = template.FindRuleGroupWithCode("sqlInjection") |
| 347 | if group == nil { |
| 348 | t.Fatal("group not found") |
| 349 | return |
| 350 | } |
| 351 | // |
| 352 | //for _, set := range group.RuleSets { |
| 353 | // for _, rule := range set.Rules { |
| 354 | // t.Logf("%#v", rule.singleCheckpoint) |
| 355 | // } |
| 356 | //} |
| 357 | |
| 358 | req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234", nil) |
| 359 | if err != nil { |
| 360 | t.Fatal(err) |
| 361 | } |
| 362 | req.Header.Set("User-Agent", testUserAgent) |
| 363 | _, _, result, err := group.MatchRequest(requests.NewTestRequest(req)) |
| 364 | if err != nil { |
| 365 | t.Fatal(err) |
| 366 | } |
| 367 | if result != nil { |
| 368 | t.Log(result) |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | func BenchmarkTemplateSQLInjection(b *testing.B) { |
| 373 | template, err := waf.Template() |
nothing calls this directly
no test coverage detected