purl

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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoneNamespace is a placeholder namespace for PURLs that are not associated with
	// a specific namespace (optional according to the PURL spec), this is a canonical
	// value that can be used with [Registry.RegisterPurlType] to register a PURL type
	// without a namespace.
	NoneNamespace = "none"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Converter

type Converter interface {
	Generate(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)
	Parse(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)
}

Converter is an interface that provides methods for generating and parsing PURLs.

type ErrUnhandledPurl

type ErrUnhandledPurl struct {
	Type      string
	Namespace string
}

ErrUnhandledPurl is returned when a PURL parser is not registered for a PURL type.

func (ErrUnhandledPurl) Error

func (e ErrUnhandledPurl) Error() string

Error returns the error message.

type ErrUnknownDetector

type ErrUnknownDetector struct{ DetectorName string }

ErrUnknownDetector is returned when a PURL generator is not registered for a detector.

func (ErrUnknownDetector) Error

func (e ErrUnknownDetector) Error() string

Error returns the error message.

type GenerateFunc

type GenerateFunc func(ctx context.Context, ir *claircore.IndexRecord) (packageurl.PackageURL, error)

GenerateFunc produces a PackageURL for a given IndexRecord.

type ParseFunc

type ParseFunc func(ctx context.Context, purl packageurl.PackageURL) ([]*claircore.IndexRecord, error)

ParseFunc produces IndexRecords for a given PackageURL.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a thread-safe registry of PURL generators and parsers.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new PURLRegistry.

func (*Registry) Generate

Generate finds a registered generator by the package's claircore.Detector.Name and returns the generated PackageURL.

func (*Registry) Parse

Parse finds a registered parser and transform functions by the PURL's namespace and type. It then runs all transform functions and returns the parsed IndexRecords.

func (*Registry) RegisterDetector

func (r *Registry) RegisterDetector(s indexer.PackageScanner, GenFn GenerateFunc)

RegisterDetector registers using an indexer.PackageScanner (for its Name).

func (*Registry) RegisterPurlType

func (r *Registry) RegisterPurlType(purlType string, purlNamespace string, ParseFn ParseFunc, transformFuncs ...TransformerFunc)

RegisterPurlType registers using a purl type. Transform functions are applied in registration order to the PackageURL before it is parsed.

type TransformerFunc

type TransformerFunc func(ctx context.Context, purl *packageurl.PackageURL) error

TransformerFunc transforms a PackageURL before it is parsed. Transform functions should take care to not overwrite existing qualifiers. If the Namespace or Type is modified, it will not affect the parsing of the PURL.If that is desired behaviour a new PURL Type and Namespace should be registered.

Jump to

Keyboard shortcuts

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