security

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 7 Imported by: 0

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.)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL