security

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package security provides shared security validation functions.

Index

Constants

View Source
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

func CleanPageText(s string) string

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

func StrictCSP(nonce string) string

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

func UnsafeHTML(doc string) []string

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

func UnsafeTemplate(tmpl string) []string

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

func ValidateHTTPURL(rawURL string) error

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.

Jump to

Keyboard shortcuts

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