Documentation
¶
Overview ¶
Package security provides security validation utilities for Tinct.
Index ¶
- func SafeUint8(val int) uint8
- func SafeUint8FromUint32(val uint32) uint8
- func SafeUint8FromUint64(val uint64) uint8
- func ValidateFilePath(filePath, baseDir string) error
- func ValidateGitURL(urlStr string) error
- func ValidateHTTPURL(urlStr string) error
- func ValidatePluginPath(pluginPath, baseDir string) error
- func ValidateRuntimeHTTPURL(urlStr string) error
- type LimitedReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SafeUint8 ¶
SafeUint8 safely converts an integer to uint8 with bounds checking. Values outside 0-255 are clamped to the valid range.
func SafeUint8FromUint32 ¶
SafeUint8FromUint32 safely converts uint32 to uint8 with bounds checking.
func SafeUint8FromUint64 ¶
SafeUint8FromUint64 safely converts uint64 to uint8 with bounds checking.
func ValidateFilePath ¶
ValidateFilePath validates a file path within an archive to prevent directory traversal.
func ValidateGitURL ¶
ValidateGitURL validates a git repository URL for safe cloning. Only allows https:// and git:// protocols from trusted domains.
func ValidateHTTPURL ¶
ValidateHTTPURL validates an HTTP(S) URL for safe downloads. Only allows HTTPS from non-local hosts.
func ValidatePluginPath ¶
ValidatePluginPath validates a plugin path to prevent directory traversal. Ensures the path stays within the allowed plugin directory.
func ValidateRuntimeHTTPURL ¶ added in v0.1.28
ValidateRuntimeHTTPURL validates a URL used for runtime data fetching (e.g. remote-css, remote-json, wallpaper URLs in theme files).
By default it enforces the same rules as ValidateHTTPURL: HTTPS-only, no localhost/private IPs. If the TINCT_ALLOW_INSECURE_HTTP environment variable is set to "1" or "true", plain HTTP is also allowed but private IP / localhost blocking still applies.
Types ¶
type LimitedReader ¶
LimitedReader wraps an io.Reader and limits the total bytes that can be read. This prevents decompression bomb attacks when extracting archives.
func NewLimitedReader ¶
func NewLimitedReader(r io.Reader, maxBytes int64) *LimitedReader
NewLimitedReader creates a new LimitedReader with the specified size limit.