image

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package image analyzes container images: it reads the files that record what an image holds — the OS package databases, os-release, Go binaries' build info, shipped node packages — and hands back plain findings. The image is read as a docker-archive stream, obtained from podman or from any reader.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileTooLarge = errors.New("file too large")

ErrFileTooLarge reports a package database beyond what is kept in memory.

View Source
var ErrPodmanFailed = errors.New("podman failed")

ErrPodmanFailed reports that podman exited with an error; the error carries podman's own message.

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	// Reference is the name the image was analyzed under.
	Reference string
	// Id is the image ID ("sha256:...").
	Id       string
	RepoTags []string
	// Layers are the image's layer diff IDs, lowest first.
	Layers []string

	OsRelease      *ospkg.OsRelease
	OsReleasePath  string
	OsReleaseLayer string

	ApkPackages      []*ospkg.ApkPackage
	ApkDatabasePath  string
	ApkDatabaseLayer string

	// DpkgStatuses are the dpkg status files found (var/lib/dpkg/status and the status.d entries), each with the
	// installed packages it lists.
	DpkgStatuses []*DpkgStatus

	GoBinaries   []*GoBinary
	NodePackages []*NodePackage

	// Warnings tell what the analysis saw but could not list, e.g. an RPM database.
	Warnings []string
}

Analysis is what was found in an image. Every finding names the layer (by diff ID) that last wrote the file it was read from: for a package database that is the layer that installed, or last changed, the packages it lists.

func AnalyzeArchive

func AnalyzeArchive(reader io.Reader, reference string) (*Analysis, error)

AnalyzeArchive analyzes the image a docker-archive stream holds (see dockerarchive.Read for the reference).

func (*Analysis) DpkgPackages

func (analysis *Analysis) DpkgPackages() []*ospkg.DpkgPackage

DpkgPackages lists the installed packages of all dpkg status files, in file order.

type DpkgStatus

type DpkgStatus struct {
	Path     string
	Layer    string
	Packages []*ospkg.DpkgPackage
}

DpkgStatus is one dpkg status file and the installed packages it lists.

type GoBinary

type GoBinary struct {
	// Path is the path inside the image, without a leading slash.
	Path string
	// Layer is the diff ID of the layer that last wrote the executable.
	Layer string
	Info  *buildinfo.BuildInfo
}

GoBinary is an executable built by Go, with the modules embedded in it.

type NodePackage

type NodePackage struct {
	Path string
	// Layer is the diff ID of the layer that last wrote the manifest.
	Layer   string
	Name    string
	Version string
	License string
}

NodePackage is a package.json found under a node_modules directory.

type Store

type Store struct {
	// Podman is the podman executable to run; "podman" (found in PATH) when empty.
	Podman string
}

Store reads images from the local podman store.

func (*Store) Analyze

func (store *Store) Analyze(ctx context.Context, reference string) (*Analysis, error)

Analyze saves and analyzes an image from the store.

func (*Store) Save

func (store *Store) Save(ctx context.Context, reference string) (io.ReadCloser, error)

Save streams the image as a docker archive (`podman save --format docker-archive`). Closing the reader waits for podman and reports its failure, so a Close error tells why a truncated stream ended.

Directories

Path Synopsis
Package dockerarchive reads container images in the docker-archive format — what `podman save --format docker-archive` writes, and `docker save` in its classic layout — as a stream, resolving the layers into the final root filesystem view of the files a caller chose to capture.
Package dockerarchive reads container images in the docker-archive format — what `podman save --format docker-archive` writes, and `docker save` in its classic layout — as a stream, resolving the layers into the final root filesystem view of the files a caller chose to capture.

Jump to

Keyboard shortcuts

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