archiveutil

package
v1.0.0-rc.14 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package archiveutil provides shared, path-traversal-safe archive extraction. It is used both by the modeld install flow (unpacking downloaded release bundles) and by node-side model receipt (unpacking a pushed OpenVINO IR bundle) — two independent callers writing untrusted archive content to disk, where a single reviewed implementation of the escape checks matters more than call-site convenience.

Index

Constants

View Source
const PreviousDirectoryPrefix = ".previous-"

PreviousDirectoryPrefix reserves sibling directories for interrupted replacements.

Variables

This section is empty.

Functions

func ExtractTar

func ExtractTar(r io.Reader, dest string) error

ExtractTar unpacks a tar stream from r into dest, rejecting any entry that would escape dest (absolute paths, `..`, escaping sym/hardlinks). Regular file modes are preserved. Symlinks and hardlinks are supported but validated to stay within dest. r is a raw tar stream — callers wrap it in a gzip.Reader first for a .tar.gz archive.

func RecoverDirectories

func RecoverDirectories(root string) error

RecoverDirectories recovers interrupted replacements before a directory store opens. No reader or writer may use the store until this operation succeeds.

func RecoverDirectory

func RecoverDirectory(dst string) error

RecoverDirectory restores an interrupted replacement or removes its obsolete backup. The caller must exclude other writers and readers for dst during recovery.

func ReplaceDirectory

func ReplaceDirectory(src, dst string) error

ReplaceDirectory activates src while retaining dst until activation succeeds. The caller must exclude readers and writers for dst. RecoverDirectory restores an interrupted replacement before the destination is used after a restart.

func SafeJoin

func SafeJoin(dest, name string) (string, error)

SafeJoin resolves an archive entry name (forward-slash separated) against dest and guarantees the result stays within dest. It rejects empty paths, absolute paths, and `..` traversal.

func SafeLinkTarget

func SafeLinkTarget(dest, linkDir, linkname string) error

SafeLinkTarget validates a symlink: linkDir is the directory containing the link, linkname is the (possibly relative) target as stored in the archive. The resolved target must stay within dest, and absolute targets are rejected.

func ValidateLinks(root *os.Root) error

ValidateLinks requires each archive symlink to resolve inside root, including forward references and chains through other symlinks.

func WriteFileFromReader

func WriteFileFromReader(root *os.Root, target string, r io.Reader, mode fs.FileMode) error

WriteFileFromReader creates target (with parents) and copies r into it with the given mode. A duplicate entry cannot replace an existing file or link.

func WriteTar

func WriteTar(ctx context.Context, dir string, out io.Writer) error

WriteTar streams regular files from dir in deterministic relative-path order. The caller must retain an immutable directory until the operation returns.

Types

This section is empty.

Jump to

Keyboard shortcuts

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