system

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 2 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 system implements the unpacker that reads installed-package data from a "system" — the local machine, a container image, a VM image, etc.

Index

Constants

View Source
const SubjectType = "system"

SubjectType is the DecomposableSubject type routed to the SystemPackages unpacker.

Variables

View Source
var DefaultOptions = Options{}

DefaultOptions is the zero-value configuration used by NewUnpacker.

Functions

This section is empty.

Types

type Filesystem

type Filesystem struct {
	FS fs.FS
}

Filesystem is a System subject wrapping an arbitrary fs.FS — a squashed container image, a mounted VM disk, a tar archive, etc. Unpackers that crack open such artifacts use it to route the inner filesystem to the SystemPackages unpacker through the registry.

func (*Filesystem) DecomposableType

func (f *Filesystem) DecomposableType() string

DecomposableType identifies this subject as a system, routing it to the SystemPackages unpacker through the registry.

func (*Filesystem) FileSystem

func (f *Filesystem) FileSystem() (fs.FS, error)

FileSystem returns the wrapped filesystem.

type LocalSystem

type LocalSystem struct {
	// Root is the path used as the filesystem root. Empty means "/".
	Root string
}

LocalSystem is a System subject describing the local machine. By default it exposes the OS root ("/"); set Root to point at a different directory, for example a mounted container or VM image root.

func (*LocalSystem) DecomposableType

func (l *LocalSystem) DecomposableType() string

DecomposableType identifies this subject as a system, routing it to the SystemPackages unpacker through the registry.

func (*LocalSystem) FileSystem

func (l *LocalSystem) FileSystem() (fs.FS, error)

FileSystem returns an fs.FS rooted at LocalSystem.Root (default "/"). Paths passed to the returned FS must be relative, so a decomposer reads the RPM database as "var/lib/rpm/Packages", not "/var/lib/rpm/Packages".

type Options

type Options struct {
	// IncludeFiles instructs system decomposers to emit a Node for every file
	// installed by each package, related to the package via a "contains"
	// edge. Off by default because it can multiply node count by a large
	// factor (a typical RHEL system has ~10⁵ files).
	IncludeFiles bool
}

Options configures the SystemPackages unpacker.

type System

type System interface {
	api.DecomposableSubject

	// FileSystem returns the system's root filesystem. Decomposers look up
	// package databases at paths relative to this root (e.g. "var/lib/rpm/...").
	FileSystem() (fs.FS, error)
}

System is the DecomposableSubject consumed by the SystemPackages unpacker. A System is anything that has installed packages and exposes a filesystem the decomposers can inspect: the local machine, a container image, a VM image, etc.

type SystemDecomposer

type SystemDecomposer interface {
	api.Decomposer

	// ExtractFromFS reads installed-package data from source and returns it as
	// a protobom NodeList. The FS root is the system's root, so paths are
	// looked up relative to it (e.g. "var/lib/rpm/Packages"). Returning
	// (nil, nil) means the decomposer's database is not present on this
	// system, which is not an error.
	ExtractFromFS(source fs.FS, opts *api.DecomposerOptions) (*sbom.NodeList, error)
}

SystemDecomposer extracts installed-package data from a system's filesystem. It extends api.Decomposer so decomposers can be registered through the shared registry while exposing a filesystem-aware Extract path that the SystemPackages unpacker uses.

Implementations look for an installed-package database under the FS root (for RPM that is var/lib/rpm/...) and return its contents as a NodeList.

type Unpacker

type Unpacker struct {
	Options Options
	// contains filtered or unexported fields
}

Unpacker is the SystemPackages unpacker. It runs each configured SystemDecomposer against the subject's filesystem and aggregates the resulting NodeLists.

func NewUnpacker

func NewUnpacker() *Unpacker

NewUnpacker returns a SystemPackages unpacker pre-loaded with the default system decomposers.

func (*Unpacker) Extract

func (u *Unpacker) Extract(_ context.Context, subject api.DecomposableSubject) ([]*sbom.NodeList, error)

Extract reads installed-package data from the given system subject. Each decomposer that produces a NodeList contributes one entry to the result; a decomposer that doesn't find its database returns (nil, nil) and is skipped.

func (*Unpacker) RegisterDecomposer

func (u *Unpacker) RegisterDecomposer(d api.Decomposer)

RegisterDecomposer adds a decomposer to the unpacker. The decomposer must implement SystemDecomposer; other decomposers are rejected silently to match the existing Unpacker interface (which can't return an error here).

func (*Unpacker) UnregisterDecomposer

func (u *Unpacker) UnregisterDecomposer(d api.Decomposer)

UnregisterDecomposer removes a decomposer from the unpacker.

Directories

Path Synopsis
Package apk implements a SystemDecomposer that reads the installed-package database used by apk-based distributions (Alpine, Wolfi, ...).
Package apk implements a SystemDecomposer that reads the installed-package database used by apk-based distributions (Alpine, Wolfi, ...).
Package deb implements a SystemDecomposer that reads the installed-package database used by dpkg-based distributions (Debian, Ubuntu, ...) and by distroless images, which ship the same database split into per-package files.
Package deb implements a SystemDecomposer that reads the installed-package database used by dpkg-based distributions (Debian, Ubuntu, ...) and by distroless images, which ship the same database split into per-package files.
internal
osrelease
Package osrelease reads the systemd os-release file from a system filesystem.
Package osrelease reads the systemd os-release file from a system filesystem.
Package rpm implements a SystemDecomposer that reads the installed-package database used by RPM-based distributions (RHEL, Fedora, openSUSE, ...).
Package rpm implements a SystemDecomposer that reads the installed-package database used by RPM-based distributions (RHEL, Fedora, openSUSE, ...).

Jump to

Keyboard shortcuts

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