Documentation
¶
Overview ¶
Package archive extracts hostile input under size and count limits. Lexical checks reject obvious escapes, while os.Root enforces the boundary. os.Root.Symlink does not validate the target, so a final pass resolves links after every archive entry exists. Extraction is not transactional: a caller receiving an error must discard destDir because it may be partial.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrPathTraversal = errors.New("archive: entry escapes the extraction root") ErrAbsolutePath = errors.New("archive: entry has an absolute path") ErrSymlinkEscape = errors.New("archive: symlink target escapes the extraction root") ErrHardlinkEscape = errors.New("archive: hardlink target escapes the extraction root") ErrDeviceNode = errors.New("archive: entry is a device, fifo or socket node") ErrUnsupportedType = errors.New("archive: entry has an unsupported type") ErrTooManyFiles = errors.New("archive: entry count exceeds the configured limit") ErrFileTooLarge = errors.New("archive: a single entry exceeds the configured size limit") ErrUncompressedTooLarge = errors.New("archive: total uncompressed size exceeds the configured limit") ErrCompressedTooLarge = errors.New("archive: compressed input exceeds the configured limit") ErrNestingTooDeep = errors.New("archive: entry path nesting exceeds the configured limit") ErrUnknownFormat = errors.New("archive: unrecognized archive format") )
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format string
Format identifies the archive container
func DetectFormat ¶
DetectFormat guesses the format from a file name
type Limits ¶
type Limits struct {
MaxCompressedBytes int64
MaxUncompressedBytes int64
MaxFiles int
MaxFileBytes int64
MaxDepth int
}
Limits bounds what Extract will do. Zero disables a given limit, which Extract treats as "unbounded" - callers scanning hostile input should always set every field.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits is a conservative ceiling for scanning a single published package or MCP-declared archive, not for general-purpose archive tools
type Result ¶
Result summarizes what Extract wrote