sbom

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package sbom generates and describes container-image SBOMs for devradarctl.

Index

Constants

View Source
const DefaultScope = "all-layers"

DefaultScope is the syft cataloging scope. "all-layers" walks every image layer (not just the squashed filesystem), which surfaces packages that a later layer deletes or shadows — the safest default for inventory.

View Source
const DefaultSyftPath = "syft"

DefaultSyftPath is the syft binary looked up on PATH when none is configured.

Variables

This section is empty.

Functions

func Digest

func Digest(ctx context.Context, image string) (v1.Hash, error)

Digest resolves and returns just the manifest digest (e.g. "sha256:…") for image, without the repository prefix.

func EnsureSyft

func EnsureSyft(syftPath string) error

EnsureSyft verifies the configured syft binary is resolvable, returning an actionable error if it is not. Callers should invoke this before generation so a missing dependency fails fast with clear guidance.

func Generate

func Generate(ctx context.Context, ref string, opts Options) ([]byte, error)

Generate produces an all-layers CycloneDX-JSON SBOM for ref using syft. ref should be a digest-pinned reference (see PinnedRef) so the SBOM embeds the manifest digest. It returns the raw SBOM bytes.

func PinnedRef

func PinnedRef(ctx context.Context, image string) (string, error)

PinnedRef resolves image's manifest digest against its registry and returns a digest-pinned reference of the form "repo@sha256:…". Pinning by digest (not tag) is what makes the generated SBOM carry the manifest digest the DevRadar service needs to identify the image unambiguously.

If image already carries a digest, it is normalized and reused without a network call. Registry auth uses the ambient Docker keychain (respects docker login / credential helpers).

func Repository

func Repository(ref string) string

Repository returns just the repository component of an image reference — the grouping key for an image across its versions and digests.

func SplitRef

func SplitRef(ref string) (repository, tag, digest string)

SplitRef decomposes an image reference into its repository, tag, and digest. Any of tag/digest may be empty. The repository is the registry/path with no tag or digest — the stable identity DevRadar groups an image's SBOMs by (across versions and digests).

quay.io/jetstack/cainjector:v1.20.2@sha256:ab…  -> repo=quay.io/jetstack/cainjector tag=v1.20.2 digest=sha256:ab…
quay.io/jetstack/cainjector@sha256:ab…          -> repo=quay.io/jetstack/cainjector tag=""      digest=sha256:ab…
registry:5000/app:1.2                            -> repo=registry:5000/app           tag=1.2     digest=""
alpine                                           -> repo=alpine                       tag=""      digest=""

func Tag

func Tag(ref string) string

Tag returns just the tag component of an image reference, or "" if none.

Types

type Options

type Options struct {
	// SyftPath is the syft binary to invoke (name on PATH or absolute path).
	SyftPath string
	// Scope is the syft cataloging scope (e.g. "all-layers", "squashed").
	Scope string
}

Options controls SBOM generation.

Jump to

Keyboard shortcuts

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