Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultMaxFileSize is the default maximum file size for safety checks (100MB) DefaultMaxFileSize = 100 * 1024 * 1024 // 100MB // SampleDatabaseMaxFileSize is the maximum file size for sample database files (10MB) // Sample databases should be smaller since they're downloaded from remote sources SampleDatabaseMaxFileSize = 10 * 1024 * 1024 // 10MB )
Variables ¶
This section is empty.
Functions ¶
func SafeReadFile ¶
func SafeReadFile(path string, opts *FileSafetyOptions) ([]byte, error)
SafeReadFile reads a file after performing safety checks
func ValidateFileSafety ¶
func ValidateFileSafety(fi os.FileInfo, path string, opts *FileSafetyOptions) error
ValidateFileSafety checks if a file is safe to read based on the given options
Types ¶
type FileSafetyOptions ¶
type FileSafetyOptions struct {
// MaxSize is the maximum allowed file size (0 means use DefaultMaxFileSize)
MaxSize int64
// AllowNonRegular allows reading from non-regular files (not recommended)
AllowNonRegular bool
}
FileSafetyOptions configures file safety checks
Click to show internal directories.
Click to hide internal directories.