Documentation
¶
Index ¶
- Constants
- func ValidateCookieName(name string) error
- func ValidateCookieValue(value string) error
- func ValidateCredential(cred string, maxLen int, checkColon bool, credType string) error
- func ValidateFieldName(name string, fieldType string) error
- func ValidateHeaderKeyValue(key, value string) error
- func ValidateInputString(input string, maxLen int, name string, additionalChecks func(rune) error) error
- func ValidateQueryKey(key string) error
- func ValidateToken(token string) error
Constants ¶
const ( MaxCredLen = 255 // Maximum credential length (username/password) MaxTokenLen = 2048 // Maximum bearer token length MaxKeyLen = 256 // Maximum query parameter key length MaxValueLen = 8192 // Maximum query parameter value length MaxFilenameLen = 256 // Maximum filename length for uploads MaxCookieNameLen = 256 MaxCookieValueLen = 4096 MaxCookieDomainLen = 255 MaxCookiePathLen = 1024 MaxHeaderKeyLen = 256 MaxHeaderValueLen = 8192 )
Common validation constants
Variables ¶
This section is empty.
Functions ¶
func ValidateCookieName ¶
ValidateCookieName validates HTTP cookie names. Prevents cookie injection and enforces RFC 6265 compliance.
func ValidateCookieValue ¶
ValidateCookieValue validates HTTP cookie values. Prevents cookie injection and enforces RFC 6265 compliance.
func ValidateCredential ¶
ValidateCredential validates credentials for Basic Auth. Prevents injection attacks and enforces RFC 7617 (username cannot contain colon).
func ValidateFieldName ¶
ValidateFieldName validates form field names and filenames. Prevents XSS and injection attacks in multipart forms.
func ValidateHeaderKeyValue ¶
ValidateHeaderKeyValue validates HTTP header keys and values. Prevents header injection and enforces HTTP/1.1 and HTTP/2 compatibility.
func ValidateInputString ¶
func ValidateInputString(input string, maxLen int, name string, additionalChecks func(rune) error) error
ValidateInputString performs common string validation to prevent injection attacks. Checks for control characters, CRLF injection, and length limits. This consolidates validation logic used across multiple components.
func ValidateQueryKey ¶
ValidateQueryKey validates query parameter keys. Prevents parameter pollution and injection attacks.
func ValidateToken ¶
ValidateToken validates bearer tokens according to RFC 6750. Prevents header injection and enforces token format rules.
Types ¶
This section is empty.