supplychain

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package supplychain implements the Dependencies & Licenses inventory accepted in ADR-0017: preserved SBOM observations, immutable snapshots, component occurrences, and their collection lifecycle.

Index

Constants

View Source
const (
	ProducerGitHub Producer = "github"
	ProducerImport Producer = "import"

	SubjectSource   Subject = "source"
	SubjectArtifact Subject = "artifact"

	// AssuranceUnknown: the document names no subject revision GraphNest can
	// bind. GHES exports are always unknown; HEAD is never copied in.
	AssuranceUnknown Assurance = "unknown"
	// AssuranceProducerAsserted: the producer claimed a revision; nothing
	// verified it.
	AssuranceProducerAsserted Assurance = "producer_asserted"
	AssuranceVerified         Assurance = "verified"
)
View Source
const (
	DefaultMaxComponents    = 50000
	DefaultMaxRelationships = 500000
	DefaultMaxWarnings      = 200
)
View Source
const DerivedSPDXVersion = "SPDX-2.3"

DerivedSPDXVersion identifies the GraphNest-produced document shape.

View Source
const ParserVersion = 1

ParserVersion is recorded on every snapshot so a normalization change can be told apart from a change in the observed document.

View Source
const StreamGitHubSource = "github:source"

StreamGitHubSource is the stream key of GHES dependency-graph observations.

Variables

View Source
var (
	ErrUnsupportedFormat = errors.New("unsupported_format")
	ErrQuotaExceeded     = errors.New("quota_exceeded")
	ErrImportTooLarge    = errors.New("import_too_large")
)
View Source
var (
	ErrMalformed          = errors.New("malformed_document")
	ErrUnsupportedVersion = errors.New("unsupported_version")
	ErrTooLarge           = errors.New("too_large")
	// ErrNoJob: no runnable job is queued.
	ErrNoJob = errors.New("no supply chain job available")
	// ErrFenced: a publication or completion lost its lease; another worker
	// holds a newer lease or the job was cancelled. Nothing was written.
	ErrFenced = errors.New("supply chain job lease lost")
)
View Source
var (
	ErrForbidden      = errors.New("forbidden")
	ErrInvalidRequest = errors.New("invalid_request")
	ErrNotFound       = errors.New("not_found")
	ErrNoInventory    = errors.New("no_inventory")
)

Functions

func DecodeComponentCursor

func DecodeComponentCursor(value string) (componentCursor, bool)

func DecodeCoordinateKey

func DecodeCoordinateKey(key string) (ecosystem, namespace, name, version string, ok bool)

DecodeCoordinateKey turns a portfolio component key back into coordinates.

func ImportStreamKey

func ImportStreamKey(subject Subject, label string) string

ImportStreamKey builds the stream key for an import subject and label.

func StreamProducer

func StreamProducer(stream string) (Producer, Subject)

StreamProducer returns the producer and subject encoded in a stream key.

func ValidStream

func ValidStream(stream string) bool

ValidStream reports whether a stream selector is one the service serves: the GitHub source stream or an import stream (import:<subject>:<label>).

Types

type Assurance

type Assurance string

Producer is who produced the document; Subject is what it describes.

type Authorizer

type Authorizer interface {
	AllAuthorizedRepositories(context.Context, authn.Principal) ([]repository.Repository, error)
	AuthorizedRepository(context.Context, authn.Principal, int64) (repository.Repository, error)
}

Authorizer resolves the live principal's repository scope. *authz.Postgres satisfies it (postgres imports this package for its models, so the authz package cannot be imported here).

type Checksum

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

type Collection

type Collection struct {
	ID, RepositoryID  int64
	JobID             *int64
	Producer          Producer
	StreamKey         string
	StartedAt         time.Time
	FinishedAt        time.Time
	Outcome           Outcome
	HTTPStatus        *int
	RetryAfterSeconds *int
	SnapshotID        *int64
	DocumentID        *int64
	ErrorCode         string
	Message           string
	ProjectionError   string
}

type Collector

type Collector struct {
	Store            CollectorStore
	GitHub           SBOMReader
	Owner            string
	MaxDocumentBytes int64
	Limits           Limits
	Logger           *slog.Logger
	Observer         Observer
	Now              func() time.Time
	// Poll is how long the worker waits when no job is available.
	Poll time.Duration
	// Enricher is optional; nil means no license enrichment is configured.
	Enricher Enricher
}

Collector leases refresh jobs and turns GHES SBOM exports into published snapshots. It runs in the server process, independent of the indexer.

func (*Collector) Run

func (collector *Collector) Run(ctx context.Context) error

Run leases and processes jobs until the context ends. Expired leases from crashed workers are reaped on start and before each idle wait.

func (*Collector) RunOnce

func (collector *Collector) RunOnce(ctx context.Context) (bool, error)

RunOnce claims and processes at most one job. It reports whether a job was claimed so callers can drain a queue deterministically in tests.

type CollectorStore

type CollectorStore interface {
	ClaimSupplyChainJob(context.Context, string) (Job, error)
	RenewSupplyChainLease(context.Context, int64, string, int64) error
	ReapExpiredSupplyChainJobs(context.Context, int) (int64, error)
	RepositoryForIndex(context.Context, int64) (repository.Repository, error)
	PublishSupplyChainSnapshot(context.Context, Publication) (Collection, error)
	RecordSupplyChainFailure(context.Context, Failure) (Collection, error)
	RecordSupplyChainProjectionError(context.Context, int64, string) error
	ProjectSupplyChainPackages(context.Context, int64, int64) (int, error)
	DueSupplyChainStreams(context.Context, string, time.Time, int) ([]int64, error)
	EnqueueSupplyChainJob(context.Context, int64, string, string, string, int, time.Time) (Job, bool, error)
	SupplyChainQueueDepths(context.Context) (map[string]int64, error)
}

CollectorStore is what the worker needs from PostgreSQL.

type Component

type Component struct {
	ID, SnapshotID      int64
	Ordinal             int
	ElementID           string
	Name                string
	Version             *string
	PURL                *string
	Ecosystem           string
	PURLNamespace       string
	PURLName            string
	PURLVersion         string
	Qualifiers          map[string]string
	LicenseDeclaredRaw  *string
	LicenseConcludedRaw *string
	DownloadLocation    *string
	Supplier            *string
	Checksums           []Checksum
	IsRoot              bool
}

Component is one occurrence in one snapshot. Identity is document-scoped: the same package in two snapshots is two occurrences.

type ComponentsRequest

type ComponentsRequest struct {
	Stream           string
	RepositoryIDs    []int64
	Ecosystem        string
	Search           string
	License          string
	AssessmentStatus string
	Cursor           string
	Limit            int
}

ComponentsRequest bounds a portfolio component query.

type Enricher

type Enricher interface {
	EnqueueSnapshot(ctx context.Context, snapshotID int64) (int, error)
}

Enricher receives every newly published snapshot so license lookups can be queued. It must not block publication on registry availability.

type ExportRow

type ExportRow struct {
	ElementID, Name, Version, PURL, Ecosystem, DeclaredRaw, ConcludedRaw string
	IsRoot                                                               bool
	AssessmentStatus, Expression                                         string
}

ExportRow is one CSV export line.

type FacetCount

type FacetCount struct {
	Value string
	Count int
}

type Failure

type Failure struct {
	RepositoryID      int64
	JobID             *int64
	JobOwner          string
	JobFence          int64
	Producer          Producer
	Subject           Subject
	StreamKey         string
	StartedAt         time.Time
	FinishedAt        time.Time
	Outcome           Outcome
	HTTPStatus        *int
	RetryAfterSeconds *int
	ErrorCode         string
	Message           string
}

Failure records an attempt that produced no new snapshot.

type Format

type Format string

Format identifies a stored document's syntax; only formats the normalizer understands are accepted.

const FormatCycloneDX16JSON Format = "cyclonedx-1.6-json"

FormatCycloneDX16JSON is the CycloneDX 1.6 JSON document format.

const FormatSPDX23JSON Format = "spdx-2.3-json"

type ImportRecord

type ImportRecord struct {
	ID             int64
	RepositoryID   int64
	StreamKey      string
	DocumentSHA256 []byte
	Format         Format
	UploadedBy     string
	UploadLabel    string
	ByteSize       int64
	Outcome        string
	SnapshotID     *int64
	ErrorCode      string
	Message        string
	CreatedAt      time.Time
}

ImportRecord is one upload attempt.

type ImportRequest

type ImportRequest struct {
	RepositoryID int64 // GitHub ID
	// Subject is "source" or "artifact"; Label distinguishes streams of the
	// same subject (e.g. "ort", "syft-image"). Stream key: import:<subject>:<label>.
	Subject Subject
	Label   string
	// SubjectRevision is the uploader's claim of the source commit the document
	// describes. It is recorded as producer_asserted, never verified.
	SubjectRevision string
	ContentType     string
	Document        []byte
}

ImportRequest is an authenticated upload of an SBOM produced elsewhere.

type ImportStore

type ImportStore interface {
	SupplyChainUploadAllowed(ctx context.Context, repositoryID int64, subject string) (bool, error)
	SupplyChainImportCount(ctx context.Context, repositoryID int64, since time.Time) (int, error)
	SupplyChainImportByDigest(ctx context.Context, repositoryID int64, streamKey string, digest []byte) (ImportRecord, bool, error)
	RecordSupplyChainImport(ctx context.Context, record ImportRecord) (int64, error)
	PublishSupplyChainSnapshot(ctx context.Context, publication Publication) (Collection, error)
	ProjectSupplyChainPackages(ctx context.Context, repositoryID, snapshotID int64) (int, error)
}

ImportStore is the persistence the importer needs beyond Store.

type Importer

type Importer struct {
	Store            ImportStore
	Authorizer       Authorizer
	Enricher         Enricher
	MaxDocumentBytes int64
	Limits           Limits
	// QuotaPerRepository bounds imports per repository per QuotaWindow.
	QuotaPerRepository int
	QuotaWindow        time.Duration
	Now                func() time.Time
}

Importer accepts SPDX 2.3 JSON and CycloneDX 1.6 JSON uploads into import streams. Documents are preserved byte-for-byte; publication reuses the same atomic path as GitHub collection.

func (*Importer) Import

func (importer *Importer) Import(ctx context.Context, principal authn.Principal, request ImportRequest) (api.SupplyChainImportResponse, error)

Import validates, authorizes, deduplicates, normalizes, and publishes.

type Job

type Job struct {
	ID, RepositoryID int64
	StreamKey        string
	Reason           string
	State            JobState
	Priority         int
	Attempt          int
	MaxAttempts      int
	RunAfter         time.Time
	LeaseOwner       string
	LeaseExpiresAt   *time.Time
	Fence            int64
	RequestedBy      string
	ErrorCode        string
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

type JobState

type JobState string
const (
	JobQueued     JobState = "queued"
	JobRunning    JobState = "running"
	JobSucceeded  JobState = "succeeded"
	JobFailed     JobState = "failed"
	JobCancelled  JobState = "cancelled"
	JobSuperseded JobState = "superseded"
)

type LicenseStore

type LicenseStore interface {
	SupplyChainAssessments(context.Context, int64, []int64) (map[int64]license.Assessment, error)
	SupplyChainAssessmentCounts(context.Context, int64) (map[string]int, error)
	SupplyChainComponentByElement(context.Context, int64, string) (Component, error)
	LicenseEvidenceHistory(context.Context, license.Coordinates, int) ([]license.Evidence, error)
}

LicenseStore is the optional evidence read side. When nil, component pages carry no assessments and the detail view reports enrichment as not configured.

type Limits

type Limits struct {
	MaxComponents    int
	MaxRelationships int
	MaxWarnings      int
}

Limits bound normalization so a hostile or huge document cannot exhaust the worker.

type Normalized

type Normalized struct {
	SPDXVersion       string
	DataLicense       string
	DocumentSPDXID    string
	DocumentName      string
	DocumentNamespace string
	CreatedAtClaimed  *time.Time
	ProducerTool      string
	RootElementIDs    []string
	Components        []Component
	Relationships     []Relationship
	Warnings          []Warning
	WarningCount      int
}

Normalized is the parser output that a store publishes as a snapshot.

func NormalizeCycloneDX16

func NormalizeCycloneDX16(document []byte, limits Limits) (Normalized, error)

NormalizeCycloneDX16 turns a CycloneDX 1.6 JSON BOM into snapshot content. The metadata.component (if any) is the root; nested components are flattened into occurrences with a CONTAINS edge from their parent; dependencies become DEPENDS_ON edges; license choices are recorded verbatim (an expression, an SPDX id, or a name/url) so nothing is invented.

func NormalizeSPDX23

func NormalizeSPDX23(document []byte, limits Limits) (Normalized, error)

NormalizeSPDX23 turns an SPDX 2.3 JSON document into snapshot content. It keeps every package as an occurrence (PURL or not, version or not), keeps every relationship with its direction, finds roots through both documentDescribes and DESCRIBES relationships, and reports structural problems as warnings rather than inventing data. Ambiguity that would make the inventory wrong (no packages array, duplicate document IDs that cannot be disambiguated, unsupported version) is an error.

type Observer

type Observer interface {
	ObserveSupplyChainCollection(outcome string, duration time.Duration)
	SetSupplyChainQueueDepth(state string, depth int64)
}

Observer receives bounded telemetry: outcomes by class and queue depths, never component or repository identifiers.

type Outcome

type Outcome string

Outcome classifies one collection attempt. Only Published and Unchanged count as success; none of the others may move a stream's latest snapshot.

const (
	OutcomePublished   Outcome = "published"
	OutcomeUnchanged   Outcome = "unchanged"
	OutcomeUnavailable Outcome = "unavailable"
	OutcomeForbidden   Outcome = "forbidden"
	OutcomeRateLimited Outcome = "rate_limited"
	OutcomeNotFound    Outcome = "not_found"
	OutcomeMalformed   Outcome = "malformed"
	OutcomeTooLarge    Outcome = "too_large"
	OutcomeTransient   Outcome = "transient"
	OutcomeCancelled   Outcome = "cancelled"
	OutcomeError       Outcome = "error"
)

func (Outcome) Retryable

func (outcome Outcome) Retryable() bool

Retryable reports whether a job may attempt collection again after this outcome; permanent document or access failures are not retried.

func (Outcome) Success

func (outcome Outcome) Success() bool

Success reports whether the outcome leaves the stream with a current inventory produced by this attempt.

type PURL

type PURL struct {
	Type, Namespace, Name, Version string
	Qualifiers                     map[string]string
}

PURL is a decoded package URL (https://github.com/package-url/purl-spec). Only what the inventory records is decoded: type, namespace, name, version, and qualifiers. The subpath is preserved inside the original string.

func ParsePURL

func ParsePURL(value string) (PURL, error)

ParsePURL decodes a package URL leniently enough for real producer output (percent-encoded namespaces, missing versions) while rejecting values that are not package URLs at all. It never invents a version.

func (PURL) QualifierKeys

func (purl PURL) QualifierKeys() []string

QualifierKeys returns qualifier names in stable order for deterministic output.

type Portfolio

type Portfolio struct {
	Store      PortfolioStore
	Snapshots  Store
	Authorizer Authorizer
	Interval   time.Duration
	MaxResults int
	Now        func() time.Time
}

Portfolio serves the cross-repository views. It shares the Service's authorizer so REST and MCP agree on scope.

func (*Portfolio) Compare

func (portfolio *Portfolio) Compare(ctx context.Context, principal authn.Principal, githubID, baseID, headID int64) (api.SupplyChainSnapshotComparison, error)

Compare diffs two authorized snapshots of the same repository: component coordinate changes, declared-license changes, resolved-edge changes, and metadata-only changes (timestamps, IDs, parser version) reported apart.

func (*Portfolio) Component

func (portfolio *Portfolio) Component(ctx context.Context, principal authn.Principal, streamKey, key string, requested []int64) (api.SupplyChainPortfolioComponentDetail, error)

Component returns the cross-repository detail of one coordinate: where it occurs within the authorized set and with what assessment.

func (*Portfolio) Components

func (portfolio *Portfolio) Components(ctx context.Context, principal authn.Principal, request ComponentsRequest) (api.SupplyChainPortfolioComponentList, error)

Components lists unique coordinates across the authorized latest snapshots, server-paginated with a cursor bound to the filter set.

func (*Portfolio) ExportCSV

func (portfolio *Portfolio) ExportCSV(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, snapshotID int64, writer io.Writer) (Snapshot, error)

ExportCSV writes the components of one authorized snapshot as CSV with snapshot and provenance identifiers in a header comment row. Cells that could be interpreted as spreadsheet formulas are prefixed with an apostrophe.

func (*Portfolio) Facets

func (portfolio *Portfolio) Facets(ctx context.Context, principal authn.Principal, streamKey string, requested []int64) (api.SupplyChainFacets, error)

Facets returns bounded filter facets within the authorized scope.

func (*Portfolio) Overview

func (portfolio *Portfolio) Overview(ctx context.Context, principal authn.Principal, streamKey string, requested []int64) (api.SupplyChainOverview, error)

Overview reports inventory state across the authorized repositories with every denominator named.

type PortfolioComponent

type PortfolioComponent struct {
	Key                 string
	Ecosystem           string
	Namespace           string
	Name                string
	Version             string
	PURL                string
	RepositoryCount     int
	OccurrenceCount     int
	AssessmentStatuses  []string
	Expression          string
	DeclaredRaw         []string
	Scopes              []string
	NewestCollectedAt   time.Time
	OldestCollectedAt   time.Time
	RepositoryGitHubIDs []int64
}

PortfolioComponent is one unique coordinate across the authorized set.

type PortfolioFilter

type PortfolioFilter struct {
	RepositoryIDs     []int64
	StreamKey         string
	Ecosystem         string
	Search            string
	LicenseExpression string
	AssessmentStatus  string
	Scope             string
	AfterKey          string
	Limit             int
}

PortfolioFilter bounds a cross-repository component query. RepositoryIDs is the authorized scope, already intersected with any requested selection.

type PortfolioOccurrence

type PortfolioOccurrence struct {
	RepositoryGitHubID int64
	Repository         string
	SnapshotID         int64
	CollectedAt        time.Time
	ElementID          string
	Scope              string
	DeclaredRaw        *string
	AssessmentStatus   string
	Expression         string
}

PortfolioOccurrence is one repository's occurrence of a coordinate.

type PortfolioOverview

type PortfolioOverview struct {
	Repositories        int
	WithInventory       int
	Stale               int
	Failed              int
	NeverCollected      int
	OptedOut            int
	Occurrences         int
	UniqueCoordinates   int
	WithoutPURL         int
	WithoutVersion      int
	AssessmentCounts    map[string]int
	UnassessedComponent int
	WarningTotal        int
	OldestCollectedAt   *time.Time
	NewestCollectedAt   *time.Time
	Ecosystems          []FacetCount
}

PortfolioOverview counts inventory state across the authorized set.

type PortfolioStore

type PortfolioStore interface {
	SupplyChainOverview(context.Context, []int64, string, time.Time) (PortfolioOverview, error)
	SupplyChainPortfolioComponents(context.Context, PortfolioFilter) ([]PortfolioComponent, error)
	SupplyChainPortfolioFacets(context.Context, []int64, string) (map[string][]FacetCount, error)
	SupplyChainCoordinateOccurrences(context.Context, []int64, string, string, string, string, string, int) ([]PortfolioOccurrence, error)
	SnapshotComponentKeys(context.Context, int64) (map[string][2]string, error)
	SnapshotEdgeKeys(context.Context, int64) (map[string]bool, error)
	SupplyChainExportRows(context.Context, int64) ([]ExportRow, error)
}

PortfolioStore is the cross-repository read side. Every method takes the caller's authorized repository IDs and never reads beyond them.

type Producer

type Producer string

Producer is who produced the document; Subject is what it describes.

type Publication

type Publication struct {
	RepositoryID     int64
	JobID            *int64
	JobOwner         string
	JobFence         int64
	Producer         Producer
	Subject          Subject
	StreamKey        string
	Format           Format
	MediaType        string
	Document         []byte
	Normalized       Normalized
	CollectedAt      time.Time
	StartedAt        time.Time
	HTTPStatus       *int
	SubjectRevision  string
	SubjectAssurance Assurance
	// UploadedBy and UploadLabel identify an import's uploader separately
	// from the document's claimed producer.
	UploadedBy  string
	UploadLabel string
}

Publication is the atomic input of a successful collection: the original document bytes, the normalized content, and the attempt metadata.

type Relationship

type Relationship struct {
	FromElement string
	Type        string
	ToElement   string
	Resolved    bool
}

Relationship preserves the document's edge direction and type verbatim. Resolved is false when either end is not a component (or the document) in the snapshot; such an edge is a diagnostic, not a dependency path.

type SBOMReader

type SBOMReader interface {
	DependencySBOMDocument(ctx context.Context, installationID int64, owner, name string, maxBytes int64) (githubapp.SBOMDocument, error)
}

SBOMReader is the lossless GitHub SBOM export reader.

type Scheduler

type Scheduler struct {
	Store    CollectorStore
	Interval time.Duration
	Batch    int
	Now      func() time.Time
	Rand     *rand.Rand
}

Scheduler enqueues scheduled refreshes for due streams with jitter so a fleet of repositories does not refresh in lockstep.

func (*Scheduler) Tick

func (scheduler *Scheduler) Tick(ctx context.Context) (int, error)

Tick enqueues jobs for streams last attempted before now-interval. Returns how many jobs were created.

type Service

type Service struct {
	Store      Store
	Authorizer Authorizer
	Interval   time.Duration
	MaxResults int
	Now        func() time.Time
	// License is optional evidence storage; EnrichmentEcosystems lists the
	// ecosystems with configured registry routes.
	License              LicenseStore
	EnrichmentEcosystems []string
}

Service is the shared inventory read/refresh layer used by REST (and later MCP). Every method authorizes the repository with the live principal first and only then touches supply-chain rows scoped to that repository.

func (*Service) AuthorizedRepositoryIDs

func (service *Service) AuthorizedRepositoryIDs(ctx context.Context, principal authn.Principal) ([]int64, error)

AuthorizedRepositoryIDs returns the internal IDs of every repository the principal may read. It is the scope passed to snapshot/job lookups by ID.

func (*Service) Collections

func (service *Service) Collections(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, cursor string, limit int) (api.SupplyChainCollectionList, error)

func (*Service) ComponentDetail

func (service *Service) ComponentDetail(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, snapshotID int64, elementID string) (api.SupplyChainComponentDetail, error)

ComponentDetail returns one occurrence with its producer declarations, registry evidence history, relationships, and assessment. Evidence is keyed by coordinates shared across repositories, so it is only reachable through an occurrence in an authorized snapshot.

func (*Service) Components

func (service *Service) Components(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, snapshotID int64, cursor string, limit int, search string) (api.SupplyChainComponentList, error)

Components pages the latest snapshot's occurrences for the selected stream (or a specific authorized snapshot). Scope is computed from the snapshot's resolved DEPENDS_ON edges leaving a root; without roots every scope is unknown rather than presented as direct.

func (*Service) Document

func (service *Service) Document(ctx context.Context, principal authn.Principal, snapshotID int64) ([]byte, string, string, Snapshot, error)

Document returns the original bytes of an authorized snapshot's document. Authorization is evaluated at retrieval time with the live principal.

func (*Service) ExportSPDX

func (service *Service) ExportSPDX(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, snapshotID int64, publicOrigin string) ([]byte, Snapshot, error)

ExportSPDX writes a derived SPDX 2.3 JSON document for one authorized snapshot with GraphNest as the creator. It never mutates or re-serves the original: the original stays downloadable as-is, and this document names it (snapshot ID, SHA-256, producer, collected time) as an external reference so the two are never confused. Assessments are emitted as licenseComments, not as licenseConcluded: GraphNest concludes nothing on a publisher's behalf, and review decisions live outside this document.

func (*Service) JobStatus

func (service *Service) JobStatus(ctx context.Context, principal authn.Principal, jobID int64) (api.SupplyChainJob, error)

func (*Service) Refresh

func (service *Service) Refresh(ctx context.Context, principal authn.Principal, githubID int64, streamKey string) (api.SupplyChainRefreshResponse, error)

Refresh enqueues bounded background collection. It never collects inline. Administrator access is the bootstrap write permission (decision D5).

func (*Service) Snapshots

func (service *Service) Snapshots(ctx context.Context, principal authn.Principal, githubID int64, streamKey string, limit int) ([]api.SupplyChainSnapshot, error)

func (*Service) Status

func (service *Service) Status(ctx context.Context, principal authn.Principal, githubID int64, streamKey string) (api.SupplyChainRepositoryStatus, error)

type Snapshot

type Snapshot struct {
	ID, RepositoryID, DocumentID int64
	Producer                     Producer
	Subject                      Subject
	StreamKey                    string
	CollectedAt                  time.Time
	CreatedAtClaimed             *time.Time
	ProducerTool                 string
	DocumentNamespace            string
	DocumentName                 string
	SPDXVersion                  string
	DataLicense                  string
	SubjectRevision              string
	SubjectAssurance             Assurance
	RootElementIDs               []string
	ParserVersion                int
	ComponentCount               int
	EdgeCount                    int
	WarningCount                 int
	Warnings                     []Warning
	PublishedAt                  time.Time
	DocumentSHA256               []byte
	DocumentFormat               Format
	DocumentBytes                int64
	UploadedBy                   string
	UploadLabel                  string
}

type Store

type Store interface {
	SupplyChainStream(context.Context, int64, string) (Stream, error)
	SupplyChainSnapshot(context.Context, int64, []int64) (Snapshot, error)
	SupplyChainSnapshots(context.Context, int64, string, int64, int) ([]Snapshot, error)
	SupplyChainDocument(context.Context, int64, []int64) ([]byte, string, []byte, error)
	SupplyChainComponents(context.Context, int64, int, int, string) ([]Component, error)
	SupplyChainRelationships(context.Context, int64, string, int) ([]Relationship, error)
	SupplyChainCollections(context.Context, int64, string, int64, int) ([]Collection, error)
	SupplyChainJob(context.Context, int64, []int64) (Job, error)
	SupplyChainActiveJob(context.Context, int64, string) (Job, bool, error)
	EnqueueSupplyChainJob(context.Context, int64, string, string, string, int, time.Time) (Job, bool, error)
}

Store is what the service needs from PostgreSQL. It is satisfied by *postgres.Store; the service never receives unauthorized IDs from callers without re-scoping them to the authorized repository set.

type Stream

type Stream struct {
	RepositoryID       int64
	StreamKey          string
	Producer           Producer
	Subject            Subject
	LatestSnapshotID   *int64
	LatestCollectionID *int64
	LastSuccessAt      *time.Time
	LastAttemptAt      *time.Time
	LastOutcome        Outcome
	OptOut             bool
}

type Subject

type Subject string

Producer is who produced the document; Subject is what it describes.

type Warning

type Warning struct {
	Code    string `json:"code"`
	Element string `json:"element,omitempty"`
	Detail  string `json:"detail,omitempty"`
}

Directories

Path Synopsis
Package license resolves exact-version license evidence from explicitly configured registry routes.
Package license resolves exact-version license evidence from explicitly configured registry routes.
Package policy evaluates SPDX license expression trees against a versioned organization policy.
Package policy evaluates SPDX license expression trees against a versioned organization policy.
Package review records human license conclusions, policy evaluation results, and scoped usage decisions.
Package review records human license conclusions, policy evaluation results, and scoped usage decisions.
Package spdxexpr parses SPDX 2.3 license expressions with a bounded grammar and a pinned license list.
Package spdxexpr parses SPDX 2.3 license expressions with a bounded grammar and a pinned license list.

Jump to

Keyboard shortcuts

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