core

package
v1.0.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package core implements sandbox-mediated archive inspection and extraction.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotFound = errors.New("archive: config not found in context")

ErrConfigNotFound indicates that archive configuration is unavailable in the execution context.

Functions

func Read

func Read(
	ctx context.Context,
	source string,
	name string,
	config ReadConfig,
) (_ []byte, found bool, outErr error)

Read returns the first regular entry matching name. The boolean reports whether a matching regular entry was found.

func WithConfig

func WithConfig(ctx context.Context, config Config) context.Context

WithConfig adds archive configuration to the execution context.

Types

type Config

type Config struct {
	MaxEntrySize     int64
	MaxZIPBufferSize int64
}

Config controls archive resource limits.

func ConfigFrom

func ConfigFrom(ctx context.Context) (Config, error)

ConfigFrom returns archive configuration from the execution context.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the archive module's default resource limits.

func DefaultConfigOr

func DefaultConfigOr(cfg []Config) Config

type Entry

type Entry struct {
	CompressedSize *int64  `json:"compressedSize"`
	ModTime        *string `json:"modTime"`
	LinkName       *string `json:"linkName"`
	Name           string  `json:"name"`
	Mode           string  `json:"mode"`
	Format         Format  `json:"format"`
	Size           int64   `json:"size"`

	IsDir     bool `json:"isDir"`
	IsRegular bool `json:"isRegular"`
	IsSymlink bool `json:"isSymlink"`
	// contains filtered or unexported fields
}

Entry is the public metadata returned by LIST.

func List

func List(ctx context.Context, source string, config ListConfig) (_ []Entry, outErr error)

List returns archive metadata without extracting entries.

type EntryPathError

type EntryPathError struct {
	Name   string
	Reason string
}

EntryPathError reports an archive entry name unsafe for extraction.

func (*EntryPathError) Error

func (e *EntryPathError) Error() string

type ExtractConfig

type ExtractConfig struct {
	Format  Format   `json:"format"`
	Links   string   `json:"links"`
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
	Config
	Overwrite  bool `json:"overwrite"`
	CreateDirs bool `json:"createDirs"`
}

ExtractConfig controls archive extraction.

func DefaultExtractOptions

func DefaultExtractOptions(cfg ...Config) ExtractConfig

DefaultExtractOptions returns EXTRACT defaults.

type ExtractResult

type ExtractResult struct {
	Path    *string `json:"path"`
	Reason  *string `json:"reason"`
	Name    string  `json:"name"`
	Size    int64   `json:"size"`
	IsDir   bool    `json:"isDir"`
	Skipped bool    `json:"skipped"`
}

ExtractResult describes one eligible archive entry.

func Extract

func Extract(
	ctx context.Context,
	source string,
	destination string,
	config ExtractConfig,
) (_ []ExtractResult, outErr error)

Extract safely writes eligible archive entries beneath destination.

type Format

type Format string

Format identifies a supported archive representation.

const (
	FormatAuto  Format = "auto"
	FormatZIP   Format = "zip"
	FormatTAR   Format = "tar"
	FormatTARGZ Format = "tar.gz"
)

type LimitError

type LimitError struct {
	Entry string
	Size  int64
	Limit int64
}

LimitError reports a declared or observed archive size over a configured cap.

func (*LimitError) Error

func (e *LimitError) Error() string

type ListConfig

type ListConfig struct {
	Format Format `json:"format"`
	Config
}

ListConfig controls archive listing.

func DefaultListOptions

func DefaultListOptions(cfg ...Config) ListConfig

DefaultListOptions returns LIST defaults.

type ReadConfig

type ReadConfig struct {
	Format  Format `json:"format"`
	As      string `json:"as"`
	Missing string `json:"missing"`
	Config
}

ReadConfig controls archive entry reads.

func DefaultReadOptions

func DefaultReadOptions(cfg ...Config) ReadConfig

DefaultReadOptions returns READ defaults.

Jump to

Keyboard shortcuts

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