imagesrc

package
v3.156.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package imagesrc reads a container image for `vulnetix scan image`: from a registry, from a local docker or podman image store, or from an archive, and unpacks its filesystem so the image's own package databases can be read.

Registry credentials come from the user's own docker configuration and credential helpers (authn.DefaultKeychain), the same ones `docker pull` uses; nothing is stored or sent anywhere else. A local image is exported with the engine's own `save` command rather than through a daemon client library, which keeps the engine's API out of the CLI.

Index

Constants

View Source
const DefaultMaxBytes int64 = 8 << 30

DefaultMaxBytes caps an unpacked image. Images past it are usually build toolchains, and reading them should be a deliberate choice (--max-size).

Variables

View Source
var ErrTooLarge = errors.New("image is larger than the unpack limit")

ErrTooLarge stops an unpack that would exceed the cap.

Functions

func Flatten

func Flatten(img v1.Image, dir string, opts FlattenOptions) error

Flatten applies the image's layers in order into dir, as a container runtime would: a whiteout (.wh.<name>) deletes what lower layers put there, an opaque whiteout (.wh..wh..opq) empties its directory. Nothing is written outside dir: entries whose path climbs out are refused, and links are recreated, never followed. Device nodes are skipped.

Types

type FlattenOptions

type FlattenOptions struct {
	MaxBytes int64
	// AfterLayer is called once a layer is applied, with its index and whether
	// it wrote a package database; a caller reads the databases then to learn
	// which layer installed each package.
	AfterLayer func(index int, touchedPackageDB bool) error
}

FlattenOptions control an unpack.

type Image

type Image struct {
	Image  v1.Image
	Meta   Meta
	Config *v1.ConfigFile
	// contains filtered or unexported fields
}

Image is an opened image.

func Open

func Open(ctx context.Context, ref string, opts Options) (*Image, error)

Open reads the image ref names.

func (*Image) Close

func (i *Image) Close()

Close releases what Open made on disk.

type Meta

type Meta struct {
	Ref        string
	Registry   string
	Repository string
	Tag        string
	// Digest is the platform manifest digest.
	Digest string
	// ManifestListDigest is the index the platform manifest was reached through.
	ManifestListDigest string
	Platform           string
	ReadFrom           Source
}

Meta is what identifies the image that was read.

type Options

type Options struct {
	Source Source
	// Platform is os/arch[/variant], e.g. linux/amd64; empty means the host's
	// linux architecture.
	Platform string
	// TempDir holds a local engine's export while it is read.
	TempDir string
}

Options select the image.

type Source

type Source string

Source says where to read the image from.

const (
	// SourceAuto tries a local engine for a reference it holds, then the registry.
	SourceAuto     Source = "auto"
	SourceRegistry Source = "registry"
	SourceDocker   Source = "docker"
	SourcePodman   Source = "podman"
	// SourceArchive reads a `docker save` / `podman save` tarball.
	SourceArchive Source = "archive"
)

Jump to

Keyboard shortcuts

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