archiveutil

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

This section is empty.

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 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 WriteFileFromReader

func WriteFileFromReader(target string, r io.Reader, mode fs.FileMode) error

WriteFileFromReader creates target (with parents) and copies r into it with the given mode, truncating any existing file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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