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

Function TestTemplateSQLInjection

internal/waf/template_test.go:341–370  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

339}
340
341func 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
372func BenchmarkTemplateSQLInjection(b *testing.B) {
373 template, err := waf.Template()

Callers

nothing calls this directly

Calls 6

TemplateFunction · 0.92
NewTestRequestFunction · 0.92
FindRuleGroupWithCodeMethod · 0.80
LogMethod · 0.80
SetMethod · 0.45
MatchRequestMethod · 0.45

Tested by

no test coverage detected