Documentation
¶
Overview ¶
Package archive creates, lists, and extracts tar.gz archives over streams. Create writes a gzip-compressed tar of filesystem paths to an io.Writer; Extract reads one from an io.Reader into a destination directory, guarding against path-traversal ("zip-slip"); List reports an archive's entry names without writing anything. Every failure carries a sentinel recoverable with errors.Is: ErrCreateArchive, ErrExtract, or — for an entry or symlink target that escapes dest — ErrPathTraversal.
Index ¶
Constants ¶
const ( // ErrCreateArchive is the leading sentinel wrapped when a tar.gz archive // cannot be created. ErrCreateArchive errs.Const = "failed to create archive" // ErrExtract is the leading sentinel wrapped when a tar.gz archive cannot be // read, listed, or extracted. ErrExtract errs.Const = "failed to extract" // ErrPathTraversal is the sentinel for a malicious archive entry whose path or // symlink target escapes the destination directory. It is distinct from // ErrExtract so callers can tell a hostile archive from an I/O fault. ErrPathTraversal errs.Const = "archive entry escapes destination" )
Every error the package can emit is declared as a const of the ecosystem's sentinel-error type errs.Const, so each one is matchable with errors.Is rather than by string comparison. Context and causes are attached with errs.Const.With, which keeps both the sentinel and the cause in the chain.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(w io.Writer, paths SourcePaths) error
Create writes a tar.gz archive of the given paths to w.