filesafety

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

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

Jump to

Keyboard shortcuts

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