Documentation
¶
Overview ¶
Package archives provides recursive walking of archive and compressed-container files (zip, tar, gzip, bzip2, xz, zstd, ar/deb), yielding each contained file as a stream. It is built for tools that need to read inside nested containers — firmware images, Android APKs, Debian packages, JARs — such as scanners, indexers, and forensics utilities.
The entry point is Walk. Walking is bounded against decompression bombs and pathological nesting via Options (maximum depth and maximum total decompressed bytes). The package depends only on the standard library plus pure-Go xz and zstd decoders, so it adds no CGO.
Index ¶
Constants ¶
const ( DefaultMaxDepth = 8 // DefaultMaxBytes caps total decompressed bytes processed per top-level // input (2 GiB), a backstop against decompression bombs. DefaultMaxBytes int64 = 2 << 30 )
Default limits guarding against decompression bombs and pathological nesting.
const PathSeparator = "!/"
PathSeparator joins an archive path to a member path in virtual paths, e.g. "firmware.tar.gz!/bin/busybox". It mirrors the convention used by jar URLs.
Variables ¶
This section is empty.
Functions ¶
func IsArchiveName ¶
IsArchiveName reports whether a filename looks like a supported archive by its extension. Used to decide, before opening, whether recursion is applicable.
Types ¶
type Format ¶
type Format int
Format identifies a container/compression format.
const ( FormatNone Format = iota // not a recognized archive (leaf file) FormatZip // zip and zip-based (apk/jar/ipa/...) FormatTar // uncompressed tar FormatGzip // gzip stream FormatBzip2 // bzip2 stream FormatXz // xz stream FormatZstd // zstandard stream FormatAr // Unix ar archive (Debian .deb) )
Supported formats.
type Options ¶
type Options struct {
// MaxDepth bounds archive nesting; members deeper than this are emitted as
// opaque leaves rather than descended into. 0 uses DefaultMaxDepth.
MaxDepth int
// MaxBytes bounds total decompressed bytes per top-level input. 0 uses
// DefaultMaxBytes; negative means unlimited.
MaxBytes int64
}
Options configures a Walk.