archive

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package archive opens the containers that trust stores hide in, so the certificates packed inside them are scanned too: zip-family archives (jar, war, ear, whl, apk, zip), tar, cpio and ar archives, gzip, zstd, xz and bzip2 streams, Debian and RPM packages, and PyInstaller one-file executables.

Members are reported as "outer!/inner", nested as deep as MaxDepth. Decompressed content keeps its file's name, so a tarball's members appear as "app.tar.zst!/member". Expansion is bounded per member and per top-level file while reading, never by trusting a declared size, so a hostile archive cannot exhaust memory. Anything not opened, because of a limit or because it could not be parsed, is reported as skipped, never silently ignored.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLimits = Limits{MaxDepth: 4, MaxMemberSize: 256 << 20, MaxArchiveSize: 1 << 30}

DefaultLimits are generous for real software and small enough for a laptop or a CI runner. Peak memory for one file stays near MaxArchiveSize plus one member being read.

Functions

func IsExecutable

func IsExecutable(b []byte) bool

IsExecutable reports whether b starts like an ELF, Mach-O or PE file. It lives apart from executable.go so that file stays a verbatim copy of emudhra-scan's.

func Walk

func Walk(path string, data []byte, lim Limits, visit Visit, skip Skip)

Walk calls visit for data and, if data is an archive, for each member, recursively.

Types

type Limits

type Limits struct {
	MaxDepth       int   // nesting levels opened below the file itself
	MaxMemberSize  int64 // largest single decompressed member
	MaxArchiveSize int64 // total decompressed bytes per top-level file
}

Limits on expansion.

type Skip

type Skip func(path, reason string)

Skip reports something that could not be opened.

type Visit

type Visit func(path string, data []byte)

Visit receives the file itself and every member found inside it.

Jump to

Keyboard shortcuts

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