Help us shape the future of Go! Take the 2026 Go Developer Survey

fuzzing

package module
v0.0.0-...-dd6c986 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyInsideTemplateLiteral

func AnyInsideTemplateLiteral(v any) templ.Component

AnyInsideTemplateLiteral exercises the non-string (JSON marshalled) branch of the template literal escaping path, which the typed string components above don't reach. A non-string value doesn't have a simple round trip to assert on, so this only proves that the script still parses and runs without throwing.

func ConstantNameAttributes

func ConstantNameAttributes(value string) templ.Component

func DynamicAttribute

func DynamicAttribute(elementName string, name string, value string) templ.Component

The components below write a fuzzed attribute name and value through each path that templ uses to render an attribute. The fuzz tests parse the output with an HTML5 parser, the same way that a browser does, and assert that no attribute was added, and that each value is inert. See GHSA-94c2-xg24-pwhv, where a javascript: URL in attributes such as <iframe src> was not sanitized, and a dynamic attribute name could add an event handler.

func SpreadAttribute

func SpreadAttribute(elementName string, name string, value string) templ.Component

func StringInsideDoubleQuotedString

func StringInsideDoubleQuotedString(v string) templ.Component

func StringInsideSingleQuotedString

func StringInsideSingleQuotedString(v string) templ.Component

func StringInsideTemplateLiteral

func StringInsideTemplateLiteral(v string) templ.Component

func StringInsideTemplateLiteralSubstitution

func StringInsideTemplateLiteralSubstitution(v string) templ.Component

func StringOutsideStringLiteral

func StringOutsideStringLiteral(v string) templ.Component

The five components below each interpolate v into the JavaScript syntax position that one of templruntime's ScriptContent* functions is responsible for escaping, and return it from getValue(). This lets the fuzz test assert a round trip: whatever string goes in must come back out unchanged, proving that no part of it was evaluated as JavaScript along the way rather than treated as inert data. See GHSA-jq3r-rjqp-mwgj, where a value inside a backtick quoted template literal was escaped as an ordinary string, so an embedded "${ ... }" substitution was evaluated as code instead of being reproduced as text.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL