attribution

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package attribution provides types and functions for working with attribution information.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPurl is returned when the purl string is empty or whitespace-only.
	ErrEmptyPurl = errors.New("empty purl string")
	// ErrUnsupportedPurlType is returned when the purl type is not supported for URL generation.
	ErrUnsupportedPurlType = errors.New("unsupported purl type")
)

Sentinel errors for PurlToURL function.

Functions

func PurlToURL

func PurlToURL(purlString string, logger *slog.Logger) (*string, error)

PurlToURL constructs a package management URL from a purl string. Returns ErrEmptyPurl if the purl string is empty or whitespace-only. Returns ErrUnsupportedPurlType if the purl type is not supported for URL generation. Returns other errors if the purl string is malformed. The logger parameter is optional; pass nil to disable logging.

Types

type Attribution

type Attribution struct {
	// Name is the package name
	Name string `json:"name"`
	// License is the declared license
	License *string `json:"license,omitempty"`
	// URL is the package URL
	URL *string `json:"url,omitempty"`
	// Purl is the package purl
	Purl string `json:"purl"`
}

Attribution represents a simplified view of an SBOM package with essential fields.

The goal is to be able to use this to point to: - Describe the package - Outline it's license and usage restrictions - Provide a way to confirm the information yourself.

func Deduplicate

func Deduplicate(attributions []Attribution, logger *slog.Logger) []Attribution

Deduplicate removes duplicate attributions based on Purl, falling back to Name. The first occurrence of each unique attribution is kept. The logger parameter is optional; pass nil to disable logging.

Jump to

Keyboard shortcuts

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