license

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package license validates source-data terms. Declarations describe terms; they neither grant access nor certify that derived output may be published.

Index

Constants

View Source
const Format = "ovdb-data-rights/1"
View Source
const MaxEvidenceBytes = 256 << 10

Variables

This section is empty.

Functions

func ValidateSPDX

func ValidateSPDX(value string, profile Profile) error

func ValidateURL

func ValidateURL(value string) error

ValidateURL accepts HTTPS terms links, including fragments. It never fetches them.

Types

type Declaration

type Declaration struct {
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	SPDX string `json:"spdx,omitempty" yaml:"spdx,omitempty"`
	URL  string `json:"url,omitempty" yaml:"url,omitempty"`
	Text string `json:"text,omitempty" yaml:"text,omitempty"`
	// contains filtered or unexported fields
}

Declaration retains the author's legacy scalar representation on marshaling. A nil *Declaration means omitted/inherit. A nonnil zero value is invalid. Use Normalized for resolved evidence, which always has an object shape.

func ParseJSON

func ParseJSON(data []byte, profile Profile) (Declaration, error)

ParseJSON validates a closed declaration, including supplied empty/null fields.

func ParseYAML

func ParseYAML(node *yaml.Node, profile Profile) (Declaration, error)

func (Declaration) Legacy

func (d Declaration) Legacy() bool

func (Declaration) MarshalJSON

func (d Declaration) MarshalJSON() ([]byte, error)

func (Declaration) MarshalYAML

func (d Declaration) MarshalYAML() (any, error)

func (Declaration) Normalized

func (d Declaration) Normalized() Declaration

func (*Declaration) UnmarshalJSON

func (d *Declaration) UnmarshalJSON(data []byte) error

func (*Declaration) UnmarshalYAML

func (d *Declaration) UnmarshalYAML(node *yaml.Node) error

func (Declaration) Validate

func (d Declaration) Validate(profile Profile) error

type Identity

type Identity struct {
	ServerID   string `json:"serverId"`
	DatabaseID string `json:"databaseId,omitempty"`
	Recordset  string `json:"recordset,omitempty"`
}

func (Identity) SourceID

func (i Identity) SourceID() string

SourceID encodes every identity component unambiguously, including punctuation.

type Notice

type Notice struct {
	Text string `json:"text"`
	URL  string `json:"url,omitempty"`
}

type Pin

type Pin struct {
	Role       string `json:"role"`
	Repository string `json:"repository"`
	Revision   string `json:"revision"`
	Path       string `json:"path"`
	SHA256     string `json:"sha256"`
	Bytes      int64  `json:"bytes"`
}

type Profile

type Profile uint8

Profile preserves the existing Directory and Publisher SPDX policies.

const (
	Directory Profile = iota
	Publisher
)

type PublisherHTMLDefinition added in v0.24.0

type PublisherHTMLDefinition struct {
	Format         string   `json:"format"`
	RegistryURL    string   `json:"registryUrl"`
	RegistrySHA256 string   `json:"registrySha256"`
	RegistryBytes  int64    `json:"registryBytes"`
	TermsURL       string   `json:"termsUrl"`
	TermsSHA256    string   `json:"termsSha256"`
	TermsBytes     int64    `json:"termsBytes"`
	ObservedAt     string   `json:"observedAt"`
	ResourceURL    string   `json:"resourceUrl"`
	NativeFields   []string `json:"nativeFields"`
	RightsScope    string   `json:"rightsScope"`
}

PublisherHTMLDefinition records reviewed publisher metadata, not returned dataset rows. Page hashes identify the observed HTML; trusted preparation verifies the observations without retaining those pages. This does not grant rights, assert a CSV response shape, or authenticate the configured approver.

type Scope

type Scope string
const (
	ServerScope    Scope = "server"
	DatabaseScope  Scope = "database"
	RecordsetScope Scope = "recordset"
)

type SourceRight

type SourceRight struct {
	SourceID                string                   `json:"sourceId"`
	Source                  Identity                 `json:"source"`
	Declaration             Declaration              `json:"declaration"`
	DeclarationScope        Scope                    `json:"declarationScope"`
	DeclaredAt              Identity                 `json:"declaredAt"`
	EvidenceOrigin          string                   `json:"evidenceOrigin"`
	Pins                    []Pin                    `json:"pins"`
	Attribution             *Notice                  `json:"attribution,omitempty"`
	FreeSource              *Notice                  `json:"freeSource,omitempty"`
	Transformations         []string                 `json:"transformations"`
	PublisherHTMLDefinition *PublisherHTMLDefinition `json:"publisherHtmlDefinition,omitempty"`
}

SourceRight is a source-data terms inventory entry, not an output license. This reader foundation emits only unpinned author declarations. Publisher evidence must be verified by publication/preparation before attaching pins.

func Inventory

func Inventory(rights []SourceRight) ([]SourceRight, int, error)

Inventory returns deterministic distinct source identities and rejects stale conflicting evidence. Its encoded size is reserved before releasing data.

func Resolve

func Resolve(source Identity, server, database, recordset *Declaration) (*SourceRight, error)

Resolve validates every supplied override. It chooses one whole declaration; fields of parent and child declarations are never combined.

Jump to

Keyboard shortcuts

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