Documentation
¶
Overview ¶
Package validation provides input validation functions for public APIs. This package implements Tier 1 security validation for OSS distribution.
Index ¶
- func SanitizeFilename(filename string) string
- func SetConfig(config *Config)
- func ValidateChunkSize(chunkSize int64) error
- func ValidateContentLength(contentLength string) (int64, error)
- func ValidateDestination(dest string) error
- func ValidateFileSize(size int64) error
- func ValidateTimeout(timeoutSeconds int) error
- func ValidateURL(rawURL string) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SanitizeFilename ¶
SanitizeFilename removes or replaces potentially dangerous characters in a filename. Returns a safe filename that can be used across different operating systems.
func SetConfig ¶
func SetConfig(config *Config)
SetConfig sets the global validation configuration. This should only be used for testing purposes.
func ValidateChunkSize ¶
ValidateChunkSize validates that a download chunk size is reasonable. Returns an error if the chunk size is too small, too large, or invalid.
func ValidateContentLength ¶
ValidateContentLength validates HTTP Content-Length header value. Returns an error if the value is invalid or poses security risks.
func ValidateDestination ¶
ValidateDestination validates a file destination path for security and usability. Returns an error if the path is unsafe, invalid, or poses security risks.
func ValidateFileSize ¶
ValidateFileSize validates that a file size is within reasonable bounds. Returns an error if the size is negative or exceeds system limits.
func ValidateTimeout ¶
ValidateTimeout validates that a timeout duration is reasonable. Returns an error if the timeout is negative or excessively long.
func ValidateURL ¶
ValidateURL validates a download URL for security and correctness. Returns an error if the URL is malformed, uses unsupported scheme, or poses security risks.
Types ¶
type Config ¶
type Config struct {
AllowLocalhost bool // Allow localhost URLs (for testing)
}
Config holds validation configuration
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default validation configuration for production use
func TestConfig ¶
func TestConfig() *Config
TestConfig returns a validation configuration suitable for testing