spdx

package
v1.5.49 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator struct {
	// Creator is the value of the Creator relationship.
	Creator string
	// CreatorType is the key of the Creator relationship.
	// In accordance to the SPDX v2 spec, CreatorType should be one of "Person", "Organization", or "Tool".
	CreatorType string
}

Creator describes the creator of the SPDX document that will be produced from the encoding.

type Decoder added in v1.5.49

type Decoder struct {
	// The data format to decode.
	Format Format
	// The PURL converter to use for parsing PURLs into IndexRecords.
	PURLConverter purl.Converter
}

Decoder defines an SPDX decoder that converts SPDX documents to claircore.IndexReport.

func NewDefaultDecoder added in v1.5.49

func NewDefaultDecoder(options ...DecoderOption) *Decoder

NewDefaultDecoder creates a Decoder with default values and sets optional fields based on the provided options.

func (*Decoder) Decode added in v1.5.49

func (d *Decoder) Decode(ctx context.Context, r io.Reader) (*claircore.IndexReport, error)

Decode decodes an SPDX document from r and returns a claircore.IndexReport.

Known limitations:

  • Only package indexing via PURL ExternalRefs is supported.

type DecoderOption added in v1.5.49

type DecoderOption func(*Decoder)

DecoderOption is a type for configuring a Decoder.

func WithDecoderFormat added in v1.5.49

func WithDecoderFormat(f Format) DecoderOption

WithDecoderFormat sets the format for decoding.

func WithDecoderPURLConverter added in v1.5.49

func WithDecoderPURLConverter(registry purl.Converter) DecoderOption

WithDecoderPURLConverter sets the PURL converter registry for parsing PURLs.

type Encoder

type Encoder struct {
	// The target SPDX version in which to encode.
	Version Version
	// The data format in which to encode.
	Format Format
	// The SPDX document creator information.
	Creators []Creator
	// The SPDX document name field.
	DocumentName string
	// The SPDX document namespace field.
	DocumentNamespace string
	// The SPDX document comment field.
	DocumentComment string
	// The PURL converter to use.
	PURLConverter purl.Converter
}

Encoder defines an SPDX encoder and accepts certain values from the caller to use in the SPDX document.

func NewDefaultEncoder

func NewDefaultEncoder(options ...EncoderOption) *Encoder

NewDefaultEncoder creates an Encoder with default values and sets optional fields based on the provided options.

func (*Encoder) Encode

func (e *Encoder) Encode(ctx context.Context, w io.Writer, ir *claircore.IndexReport) error

Encode encodes a claircore.IndexReport that writes to w. We first convert the IndexReport to an SPDX doc of the latest version, then convert that doc to the specified version. We assume there's no data munging going from the latest to the specified version.

type EncoderOption added in v1.5.49

type EncoderOption func(*Encoder)

EncoderOption is a type for configuring an Encoder.

func WithDocumentComment

func WithDocumentComment(comment string) EncoderOption

WithDocumentComment is used to set the SPDX document comment field.

func WithDocumentName

func WithDocumentName(name string) EncoderOption

WithDocumentName is used to set the SPDX document name field.

func WithDocumentNamespace

func WithDocumentNamespace(namespace string) EncoderOption

WithDocumentNamespace is used to set the SPDX document namespace field.

func WithPURLConverter added in v1.5.49

func WithPURLConverter(registry purl.Converter) EncoderOption

WithPURLConverter is used to set the purl converter registry.

type Format

type Format string

Format describes the data format for the SPDX document.

const FormatJSON Format = "json"

type Version

type Version string

Version describes the SPDX version to target.

const (
	V2_3 Version = "v2.3"
)

Jump to

Keyboard shortcuts

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