zip

package
v1.0.35 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package zip provides secure zip archive extraction with path traversal protection.

Index

Constants

View Source
const (
	// MaxFileSize is the maximum size of a single extracted file (100MB)
	MaxFileSize = 100 * 1024 * 1024
	// MaxTotalSize is the maximum total extracted size (500MB)
	MaxTotalSize = 500 * 1024 * 1024
	// MaxFiles is the maximum number of files to extract
	MaxFiles = 1000
	// MaxDepth is the maximum nesting depth for extracted directories
	MaxDepth = 10
)

Variables

This section is empty.

Functions

func Extract

func Extract(zipPath, destDir string, opts Options) error

Extract safely extracts a zip file to the destination directory

Types

type FileSystem

type FileSystem interface {
	MkdirAll(path string, perm os.FileMode) error
	OpenFile(name string, flag int, perm os.FileMode) (io.WriteCloser, error)
	Remove(name string) error
}

FileSystem abstracts filesystem operations for testing

type Options

type Options struct {
	MaxFileSize  int64
	MaxTotalSize int64
	MaxFiles     int
	MaxDepth     int
}

Options configures zip extraction behavior

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns safe default extraction options

Jump to

Keyboard shortcuts

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