zipx

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package zipx provides safe ZIP validation and extraction with limits against zip-slip, oversized archives, and special files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unzip

func Unzip(srcZip, destDir string, p Policy) (err error)

Unzip extracts srcZip into destDir according to policy p. It enforces limits, prevents zip-slip, and skips unsafe entries.

func Validate

func Validate(zipPath string) (err error)

Validate checks that zipPath is a readable ZIP file. Returns io.ErrUnexpectedEOF if it is not.

Types

type Policy

type Policy struct {
	MaxFiles      int   // maximum number of files allowed
	MaxTotalBytes int64 // maximum total uncompressed bytes
	MaxFileBytes  int64 // maximum size per file
	AllowSymlinks bool  // whether symlinks are allowed
	PreserveTimes bool  // whether to preserve file mtimes
}

Policy defines extraction limits and behavior.

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy returns conservative defaults: 20k files, 2 GiB total, 512 MiB per file, no symlinks, no times.

Jump to

Keyboard shortcuts

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