Documentation
¶
Overview ¶
Package security holds the guards every piece of external input passes through: URL validation (SSRF), graph-file path containment, file-size caps, and label sanitisation. It mirrors the threat model of the Python original's graphify/security.py.
Index ¶
Constants ¶
const ( // MaxGraphFileBytes rejects graph.json files larger than this before parsing, // so a crafted multi-gigabyte file cannot exhaust memory. MaxGraphFileBytes = 512 * 1024 * 1024 )
Variables ¶
This section is empty.
Functions ¶
func CheckGraphFileSize ¶
CheckGraphFileSize returns an error if path exceeds MaxGraphFileBytes.
func SanitizeLabel ¶
SanitizeLabel strips control characters and caps length, making a label safe to embed in JSON or plain text. For raw HTML injection, additionally escape it.
func ValidateGraphPath ¶
ValidateGraphPath resolves path and verifies it stays inside base (the graphify-out directory), which must exist. Prevents path traversal when a caller is handed an attacker-influenced graph path.
func ValidateURL ¶
ValidateURL rejects any URL that is not http/https or that resolves to a private, loopback, link-local, or cloud-metadata address (SSRF defence).
Types ¶
This section is empty.