clair: github.com/coreos/clair/pkg/tarutil Index | Files

package tarutil

import "github.com/coreos/clair/pkg/tarutil"

Package tarutil implements some tar utility functions.

Index

Package Files

tarutil.go

Variables

var (
    // ErrCouldNotExtract occurs when an extraction fails.
    ErrCouldNotExtract = errors.New("tarutil: could not extract the archive")

    // ErrExtractedFileTooBig occurs when a file to extract is too big.
    ErrExtractedFileTooBig = errors.New("tarutil: could not extract one or more files from the archive: file too big")

    // MaxExtractableFileSize enforces the maximum size of a single file within a
    // tarball that will be extracted. This protects against malicious files that
    // may used in an attempt to perform a Denial of Service attack.
    MaxExtractableFileSize int64 = 200 * 1024 * 1024 // 200 MiB

)

type FilesMap Uses

type FilesMap map[string][]byte

FilesMap is a map of files' paths to their contents.

func ExtractFiles Uses

func ExtractFiles(r io.Reader, filenames []string) (FilesMap, error)

ExtractFiles decompresses and extracts only the specified files from an io.Reader representing an archive. The files to be extracted are specified by regexp

type TarReadCloser Uses

type TarReadCloser struct {
    *tar.Reader
    io.Closer
}

TarReadCloser embeds a *tar.Reader and the related io.Closer It is the caller's responsibility to call Close on TarReadCloser when done.

func NewTarReadCloser Uses

func NewTarReadCloser(r io.Reader) (*TarReadCloser, error)

NewTarReadCloser attempts to detect the compression algorithm for an io.Reader and returns a TarReadCloser wrapping the Reader to transparently decompress the contents.

Gzip/Bzip2/XZ detection is done by using the magic numbers: Gzip: the first two bytes should be 0x1f and 0x8b. Defined in the RFC1952. Bzip2: the first three bytes should be 0x42, 0x5a and 0x68. No RFC. XZ: the first three bytes should be 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00. No RFC.

func (*TarReadCloser) Close Uses

func (r *TarReadCloser) Close() error

Close cleans up the resources used by a TarReadCloser.

type XzReader Uses

type XzReader struct {
    io.ReadCloser
    // contains filtered or unexported fields
}

XzReader implements io.ReadCloser for data compressed via `xz`.

func NewXzReader Uses

func NewXzReader(r io.Reader) (*XzReader, error)

NewXzReader returns an io.ReadCloser by executing a command line `xz` executable to decompress the provided io.Reader.

It is the caller's responsibility to call Close on the XzReader when done.

func (*XzReader) Close Uses

func (r *XzReader) Close() error

Close cleans up the resources used by an XzReader.

Package tarutil imports 11 packages (graph) and is imported by 23 packages. Updated 2019-04-10. Refresh now. Tools for package owners.