imagesbom

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Overview

Package imagesbom builds package inventories of running container images from the containerd content store (docs/architecture.md, Image inventory).

Index

Constants

View Source
const (
	StatusReady       = "ready"
	StatusPending     = "pending"
	StatusUnavailable = "unavailable"
)

Result statuses.

View Source
const (
	LabelSource   = "org.opencontainers.image.source"
	LabelRevision = "org.opencontainers.image.revision"
)

OCI annotation keys read from the image config labels.

View Source
const DefaultContentStore = "/var/lib/containerd/io.containerd.content.v1.content"

DefaultContentStore is containerd's default content store; k3s and RKE2 use their own paths (docs/install-kubernetes.md).

View Source
const Scanner = "osv-scalibr " + version.ScannerVersion

Scanner names the inventory engine and its version in every result.

Variables

This section is empty.

Functions

func DigestFromImageID

func DigestFromImageID(id string) (string, bool)

DigestFromImageID extracts the content digest from a container status imageID.

func ParseDigest

func ParseDigest(s string) (string, error)

ParseDigest validates a sha256 content digest.

Types

type Inventory

type Inventory struct {
	// contains filtered or unexported fields
}

Inventory builds one image at a time, in the background for running digests and first for requested ones.

func New

func New(o Options) (*Inventory, error)

New opens the cache under o.Dir and prepares the builder.

func (*Inventory) Get

func (i *Inventory) Get(digest string) Result

Get returns the cached inventory, pending while it is queued or building, or unavailable with the reason.

func (*Inventory) Observe

func (i *Inventory) Observe(digests []string)

Observe replaces the set of digests that run on this node; new ones are built in the background.

func (*Inventory) Run

func (i *Inventory) Run(ctx context.Context)

Run builds queued digests one at a time until ctx ends.

type Labels

type Labels struct {
	Source   string `json:"source,omitempty"`
	Revision string `json:"revision,omitempty"`
}

Labels are the OCI source and revision labels of the image config.

type Limits

type Limits struct {
	// MaxLayerBytes bounds the uncompressed layer bytes read.
	MaxLayerBytes int64
	// MaxFiles bounds the layer entries read.
	MaxFiles int
	// MaxStagedBytes bounds the package metadata files staged on disk for the extractors.
	MaxStagedBytes int64
	MaxPackages    int
	Timeout        time.Duration
}

Limits bound one build; reaching any of them marks the result truncated with the reason.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits are the build bounds used when a limit is zero.

type Options

type Options struct {
	Node         string
	ContentStore string
	// Dir holds the cache and the transient work directory; it lives under the agent state directory.
	Dir          string
	Limits       Limits
	CacheEntries int
	CacheBytes   int64
	// Settle delays background builds of newly observed digests.
	Settle time.Duration
	// Pause separates background builds so they stay low priority.
	Pause time.Duration
	// FailureRetry is how long a failed build is reported before it is tried again.
	FailureRetry time.Duration
	Arch         string
	Variant      string
	Redactor     *redact.Redactor
	Logger       *slog.Logger
	Clock        func() time.Time
}

Options configures an Inventory.

type Package

type Package struct {
	Ecosystem string `json:"ecosystem"`
	Name      string `json:"name"`
	Version   string `json:"version"`
	PURL      string `json:"purl,omitempty"`
	Location  string `json:"location,omitempty"`
}

Package is one installed package; it carries metadata only, never file contents.

type Result

type Result struct {
	Status    string    `json:"status"`
	Digest    string    `json:"digest"`
	Reason    string    `json:"reason,omitempty"`
	Labels    Labels    `json:"labels"`
	Packages  []Package `json:"packages"`
	Truncated bool      `json:"truncated"`
	Scanner   string    `json:"scanner"`
}

Result is the image.sbom.get result and the image_sbom task payload.

func Bound

func Bound(r Result, maxPackages int, maxBytes int64) (Result, error)

Bound preserves a package prefix without changing the cached inventory.

func Pending

func Pending(digest string) Result

Pending reports that a build for digest is queued or running.

func Redact

func Redact(r Result, red *redact.Redactor) Result

Redact passes every free-form string of r through the redactor before it reaches a sink.

func Unavailable

func Unavailable(digest, reason string) Result

Unavailable reports why no inventory can be returned for digest, as a sentence.

type TaskRequest

type TaskRequest struct {
	Digest string `json:"digest"`
}

TaskRequest is the JSON payload of an image_sbom node task.

Directories

Path Synopsis
Package imagesbomtest writes synthetic containerd content stores for tests of image inventory callers.
Package imagesbomtest writes synthetic containerd content stores for tests of image inventory callers.

Jump to

Keyboard shortcuts

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