sbom

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sbom generates SPDX SBOM documents for scafctl catalog artifacts.

Index

Constants

View Source
const MediaType = "application/spdx+json"

MediaType is the IANA media type for SPDX JSON SBOM documents.

Variables

This section is empty.

Functions

func Generate

func Generate(sol *solution.Solution, opts GenerateOptions) ([]byte, error)

Generate creates an SPDX 2.3 JSON SBOM document from a solution.

Types

type AnnotationSPDX

type AnnotationSPDX struct {
	Annotator string `json:"annotator"`
	Date      string `json:"annotationDate"`
	Type      string `json:"annotationType"`
	Comment   string `json:"comment"`
}

AnnotationSPDX is a free-form annotation on a package.

type Checksum

type Checksum struct {
	Algorithm string `json:"algorithm"`
	Value     string `json:"checksumValue"`
}

Checksum is a hash for an SPDX package.

type CreationInfo

type CreationInfo struct {
	Created  string   `json:"created"`
	Creators []string `json:"creators"`
}

CreationInfo contains metadata about when and how the SBOM was created.

type Document

type Document struct {
	SPDXVersion    string          `json:"spdxVersion"`
	DataLicense    string          `json:"dataLicense"`
	SPDXID         string          `json:"SPDXID"`
	Name           string          `json:"name"`
	Namespace      string          `json:"documentNamespace"`
	CreationInfo   CreationInfo    `json:"creationInfo"`
	Packages       []Package       `json:"packages"`
	Relationships  []Relationship  `json:"relationships,omitempty"`
	ExtractedTexts []ExtractedText `json:"hasExtractedLicensingInfos,omitempty"`
}

Document represents an SPDX 2.3 JSON document.

type ExternalRef

type ExternalRef struct {
	Category string `json:"referenceCategory"`
	Type     string `json:"referenceType"`
	Locator  string `json:"referenceLocator"`
}

ExternalRef links to an external identifier (e.g., purl).

type ExtractedText

type ExtractedText struct {
	ID   string `json:"licenseId"`
	Name string `json:"name"`
	Text string `json:"extractedText"`
}

ExtractedText holds extracted license text for custom licenses.

type GenerateOptions

type GenerateOptions struct {
	// Namespace is the SPDX document namespace URI.
	// If empty, a default based on the solution name and version is used.
	Namespace string

	// ContentDigest is the sha256 digest of the primary content layer.
	ContentDigest string

	// BundleDigest is the sha256 digest of the bundle layer (empty if no bundle).
	BundleDigest string

	// BinaryName is the tool name (e.g., "scafctl") for the creator field.
	BinaryName string
}

GenerateOptions configures SBOM generation.

type Package

type Package struct {
	SPDXID           string           `json:"SPDXID"`
	Name             string           `json:"name"`
	Version          string           `json:"versionInfo,omitempty"`
	Supplier         string           `json:"supplier,omitempty"`
	DownloadLocation string           `json:"downloadLocation"`
	FilesAnalyzed    bool             `json:"filesAnalyzed"`
	Checksums        []Checksum       `json:"checksums,omitempty"`
	ExternalRefs     []ExternalRef    `json:"externalRefs,omitempty"`
	Description      string           `json:"description,omitempty"`
	PrimaryPurpose   string           `json:"primaryPackagePurpose,omitempty"`
	Annotations      []AnnotationSPDX `json:"annotations,omitempty"`
}

Package represents an SPDX package (the solution or a dependency).

type Relationship

type Relationship struct {
	Element string `json:"spdxElementId"`
	Type    string `json:"relationshipType"`
	Related string `json:"relatedSpdxElement"`
}

Relationship describes a dependency or composition link.

Jump to

Keyboard shortcuts

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