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 ¶
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 ¶
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.
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" )