sbom

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sbom is the application-layer service behind `pf sbom` - extraction internal/app/doctor already did for `pf doctor`. cmd/platform-factory/sbom.go now only parses flags, calls Service, and formats the result (text vs JSON is a presentation concern, so it stays in the CLI layer); path collection and SBOM generation live here, testable without going through the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document = engine.Document

Document is re-exported so callers of this package never need to import internal/sbom directly.

type Service

type Service struct {
	// Stat reports file info for a path - normally os.Stat.
	Stat func(name string) (os.FileInfo, error)
	// WalkDir walks a directory tree - normally filepath.WalkDir.
	WalkDir func(root string, fn fs.WalkDirFunc) error
}

Service holds every dependency CollectPaths needs, injectable so tests never touch the real filesystem.

func New

func New() Service

New returns a Service wired to the real filesystem.

func (Service) CollectPaths

func (s Service) CollectPaths(args []string) (map[string]string, error)

CollectPaths maps each argument to component entries: a regular file becomes one component keyed by its cleaned path, a directory contributes every regular file it contains, keyed by path. Keying by on-disk path keeps component names unique across arguments and makes the sorted output deterministic. Non-regular entries (symlinks, device nodes, sockets) are skipped, since only regular files have content to hash and classify.

func (Service) Generate

func (s Service) Generate(paths map[string]string) (Document, error)

Generate produces the SBOM document for the given path set (as returned by CollectPaths): each component records the file's sha256 digest, size, detected kind, and native ELF dependencies. It uses no external tools, so the inventory is available on hosts without syft and is byte-for-byte deterministic (components are sorted by name).

func (Service) WriteJSON

func (s Service) WriteJSON(w io.Writer, doc Document) error

WriteJSON writes doc in canonical JSON form.

Jump to

Keyboard shortcuts

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