MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkTemplateSQLInjection

Function BenchmarkTemplateSQLInjection

internal/waf/template_test.go:372–400  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

370}
371
372func 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
402func testTemplate20001(a *assert.Assertion, t *testing.T, template *waf.WAF) {
403 // enable bot rule set

Callers

nothing calls this directly

Calls 7

TemplateFunction · 0.92
NewTestRequestFunction · 0.92
FindRuleGroupWithCodeMethod · 0.80
NextMethod · 0.80
StringMethod · 0.45
SetMethod · 0.45
MatchRequestMethod · 0.45

Tested by

no test coverage detected