Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileValidator ¶
type FileValidator struct {
ValidationThreshold int64 // Files larger than this are validated first
HeaderSize int64 // Size of header to read for validation
}
Example ¶
Example usage demonstration
// Create validator (100KB threshold)
// validator := NewFileValidator(100)
// Validate a file
// err := validator.ValidateLargeFile("path/to/file.go")
// if err != nil {
// log.Printf("File rejected: %v", err)
// return // Don't load the file!
// }
// fileID, err := loadFile("path/to/file.go") // Safe to load
func NewFileValidator ¶
func NewFileValidator(thresholdKB int64) *FileValidator
func (*FileValidator) ValidateLargeFile ¶
func (fv *FileValidator) ValidateLargeFile(path string) error
ValidateLargeFile reads only the header and validates the file is legitimate Returns error if file is invalid/malicious (image saved as code, binary data, etc.)
Click to show internal directories.
Click to hide internal directories.