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

Function TestDetectXSS_Strict

internal/waf/injectionutils/utils_xss_test.go:38–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestDetectXSS_Strict(t *testing.T) {
39 var a = assert.NewAssertion(t)
40 a.IsFalse(injectionutils.DetectXSS(`<xml></xml>`, false))
41 a.IsTrue(injectionutils.DetectXSS(`<xml></xml>`, true))
42 a.IsFalse(injectionutils.DetectXSS(`<img src=\"\"/>`, false))
43 a.IsFalse(injectionutils.DetectXSS(`<img src=\"test.jpg\"/>`, true))
44 a.IsFalse(injectionutils.DetectXSS(`<a href="aaaa"></a>`, true))
45 a.IsFalse(injectionutils.DetectXSS(`<span style="color: red"></span>`, false))
46 a.IsTrue(injectionutils.DetectXSS(`<span style="color: red"></span>`, true))
47 a.IsFalse(injectionutils.DetectXSS("https://example.com?style=list", false))
48 a.IsTrue(injectionutils.DetectXSS("https://example.com?style=list", true))
49}
50
51func BenchmarkDetectXSS_MISS(b *testing.B) {
52 var result = injectionutils.DetectXSS("<html><body><span>RequestId: 1234567890</span></body></html>", false)

Callers

nothing calls this directly

Calls 1

DetectXSSFunction · 0.92

Tested by

no test coverage detected