Documentation
¶
Overview ¶
Package security provides security validation and protection utilities
Index ¶
- func ConstantTimeCompare(a, b string) bool
- func SafeIntConversion(value int64, bitSize int) (int64, error)
- func SafeUintConversion(value int64, bitSize int) (uint64, error)
- func SanitizeSQL(input string) string
- func ValidateAlphanumeric(s string) error
- func ValidateEmail(email string) error
- func ValidateURL(url string) error
- type InputValidator
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeCompare ¶
ConstantTimeCompare performs constant-time comparison of two strings Returns true if strings are equal, false otherwise
func SafeIntConversion ¶
SafeIntConversion safely converts between integer types checking for overflow
func SafeUintConversion ¶
SafeUintConversion safely converts to unsigned integer checking for overflow
func SanitizeSQL ¶
SanitizeSQL performs basic SQL injection prevention This is a basic implementation - use prepared statements for production
func ValidateAlphanumeric ¶
ValidateAlphanumeric checks if a string contains only alphanumeric characters
func ValidateEmail ¶
ValidateEmail performs basic email validation
Types ¶
type InputValidator ¶
type InputValidator struct {
// MaxStringLength is the maximum allowed string length
MaxStringLength int
// AllowedPathPrefixes are the allowed path prefixes for file operations
AllowedPathPrefixes []string
}
InputValidator provides methods for validating and sanitizing user input
func NewInputValidator ¶
func NewInputValidator() *InputValidator
NewInputValidator creates a new input validator with default settings
func (*InputValidator) ValidateFilePath ¶
func (v *InputValidator) ValidateFilePath(path string) error
ValidateFilePath validates a file path for security issues
func (*InputValidator) ValidateIPAddress ¶
func (v *InputValidator) ValidateIPAddress(addr string) error
ValidateIPAddress validates an IP address or hostname
func (*InputValidator) ValidatePort ¶
func (v *InputValidator) ValidatePort(port int) error
ValidatePort validates a network port number
func (*InputValidator) ValidateStringLength ¶
func (v *InputValidator) ValidateStringLength(s string) error
ValidateStringLength checks if a string length is within acceptable bounds
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter provides basic rate limiting functionality
func NewRateLimiter ¶
func NewRateLimiter(limit int, windowSeconds int64) *RateLimiter
NewRateLimiter creates a new rate limiter