archive

package
v1.24.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExtractorPanic = errors.New("extractor panic")

ErrExtractorPanic is the sentinel wrapped by every error returned from recoverExtractor. Callers may inspect with errors.Is to branch on panic recovery without string matching.

View Source
var GzMIME = map[string]struct{}{
	"application/gzip":              {},
	"application/gzip-compressed":   {},
	"application/gzipped":           {},
	"application/x-gunzip":          {},
	"application/x-gzip":            {},
	"application/x-gzip-compressed": {},
	"gzip/document":                 {},
}

Functions

func CPUQuota added in v1.24.0

func CPUQuota() (int, bool)

CPUQuota returns the cgroup-derived CPU ceiling for this process, expressed as a count of logical CPUs (ceil(quota/period), floored at 1). The second return is false when no cgroup ceiling applies.

func EffectiveMaxConcurrency added in v1.24.0

func EffectiveMaxConcurrency(configured int) int

EffectiveMaxConcurrency clamps the operator-configured concurrency to the minimum of itself, runtime.GOMAXPROCS(0), and the cgroup CPU quota.

func ExtractArchiveToTempDir

func ExtractArchiveToTempDir(ctx context.Context, c malcontent.Config, path string) (string, error)

extractArchiveToTempDir creates a temporary directory and extracts the archive file for scanning.

func ExtractBz2

func ExtractBz2(ctx context.Context, d, f string) error

Extract Bz2 extracts bzip2 files.

func ExtractDeb

func ExtractDeb(ctx context.Context, d, f string) (retErr error)

ExtractDeb extracts .deb packages.

func ExtractGzip

func ExtractGzip(ctx context.Context, d string, f string) error

extractGzip extracts .gz archives.

func ExtractRPM

func ExtractRPM(ctx context.Context, d, f string) (retErr error)

extractRPM extracts .rpm packages.

func ExtractTar

func ExtractTar(ctx context.Context, d string, f string) (err error)

extractTar extracts .apk and .tar* archives.

func ExtractUPX added in v1.8.0

func ExtractUPX(ctx context.Context, d, f string) (err error)

func ExtractZip

func ExtractZip(ctx context.Context, d string, f string) (err error)

ExtractZip extracts zip-format archives (.ear, .jar, .war, .whl, .zip).

func ExtractZlib

func ExtractZlib(ctx context.Context, d string, f string) error

extractZlib extracts extension-agnostic zlib-compressed files.

func ExtractZstd added in v1.9.0

func ExtractZstd(ctx context.Context, d string, f string) error

ExtractZstd extracts .zst and .zstd archives.

func ExtractionMethod

func ExtractionMethod(ext string) func(context.Context, string, string) error

func IsValidPath

func IsValidPath(target, dir string) bool

isValidPath checks if the target file is within the given directory.

func OCI

func OCI(ctx context.Context, path string, useAuth bool, maxImageSize int64) (string, error)

OCI returns a directory with the extracted image directories/files in it.

func OCIWithConfig added in v1.24.0

func OCIWithConfig(ctx context.Context, path string, c *malcontent.Config) (string, error)

OCIWithConfig accepts a fully-populated Config for OCI transport-hardening knobs.

func ValidateResolvedPath added in v1.21.0

func ValidateResolvedPath(target, dir, clean string) error

ValidateResolvedPath checks that the target path still resides within the extraction directory after resolving symlinks in its parent directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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