Documentation
¶
Overview ¶
Package security provides shared security validation functions.
Index ¶
Constants ¶
const MaxPageText = 120
MaxPageText is how much page-provided text reaches the terminal.
Variables ¶
This section is empty.
Functions ¶
func CleanPageText ¶ added in v0.5.0
CleanPageText makes text from a page safe to print in the operator's terminal: control characters (escape sequences that could clear the screen, fake a prompt or write the clipboard) and format characters (bidi overrides that reorder what is shown, zero-width spaces) are dropped, and the text is cut to MaxPageText runes. Callers still label it as the page's words.
func SetTestBypassSSRF ¶
func SetTestBypassSSRF(enabled bool)
SetTestBypassSSRF enables or disables the SSRF validation bypass for testing. It is safe for concurrent use.
func StrictCSP ¶ added in v0.5.0
StrictCSP is the policy for a page from a URL: no inline script except tinkerdown's own (by nonce), no eval, and nothing loaded from or sent to another origin.
func UnsafeHTML ¶ added in v0.5.0
UnsafeHTML reports which kinds of unsafe markup doc contains: forbidden elements, on* event handlers, srcdoc, and javascript: or vbscript: URLs.
func UnsafeTemplate ¶ added in v0.5.0
UnsafeTemplate reports UnsafeHTML's findings for an lvt template, and any template action outside a text node or an attribute value: in a tag or attribute name, a comment, or a raw-text element. Those build markup at render time that no check of the source can see. It also refuses the trim markers {{- and -}}, which delete the text around an action and so change how the rendered markup tokenizes.
func ValidateHTTPURL ¶
ValidateHTTPURL checks for SSRF vulnerabilities by blocking requests to internal networks. It rejects localhost, private IP ranges, link-local addresses, and cloud metadata endpoints. Hostnames are resolved to detect DNS rebinding attacks targeting internal addresses.
Blocked results are cached for up to 30 seconds. If a hostname transiently resolves to an internal address (e.g. during DNS propagation), it will remain blocked until the cache entry expires, even if the DNS record is corrected sooner.
Types ¶
This section is empty.