vexsync

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 14 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 vexsync imports VEX decisions made elsewhere: the vendor CSAF VEX feeds an administrator configures, materialized onto the scanned artifacts they speak about, and the decisions of federated peers, kept as suggestions and applied where the peer is trusted with them. It also builds the document of a repository's own decisions that its peers fetch.

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncRunning = errors.New("a sync of the VEX feed is already running")

ErrSyncRunning is returned by SyncFeed when a sync of the feed is already running, in this process or another one.

Functions

This section is empty.

Types

type Service

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

Service syncs the vendor VEX feeds, materializes their statements and exchanges VEX decisions with federated peers.

func NewService

func NewService(db Store, fetcher *csaf.Fetcher, gen *sbom.Generator, log *logger.Logger) *Service

NewService returns the service. Without WithClusterLock there are no other replicas to exclude.

func (*Service) ApplyFeeds

func (s *Service) ApplyFeeds(ctx context.Context) error

ApplyFeeds materializes the statements of every feed onto the latest scans, so new scans and new artifacts pick up the feeds' decisions. A feed being synced elsewhere is skipped: its sync materializes it.

func (*Service) PeerVEXDocument

func (s *Service) PeerVEXDocument(ctx context.Context, repoID, format string) ([]byte, error)

PeerVEXDocument is the OpenVEX document a repository serves to its federated peers: its local decisions only, never those imported from a feed or a peer, so decisions do not echo between peers.

func (*Service) ReceivePeerVEX

func (s *Service) ReceivePeerVEX(ctx context.Context, repoID, repoFormat string, peer *federation.Peer, doc []byte) error

ReceivePeerVEX imports the VEX document a peer of the repository publishes, as the peer's trust says: ignore does nothing, suggest keeps each decision about a scanned artifact of the repository as a suggestion, apply also writes a pending suggestion to the artifact's statements unless a statement of another source is there (a local decision is never overridden), and marks it accepted. Suggestions the document no longer holds are deleted.

func (*Service) StartSync

func (s *Service) StartSync(feedID string) bool

StartSync syncs the feed in the background, under a fresh context bounded by syncTimeout, and reports whether it started: false when this process is already syncing the feed.

func (*Service) Stop

func (s *Service) Stop()

Stop cancels the syncs StartSync started and waits for them to end.

func (*Service) SyncFeed

func (s *Service) SyncFeed(ctx context.Context, feedID string) (models.VEXFeedSyncResult, error)

SyncFeed fetches the documents of the feed changed since its cursor, stores them, records the outcome on the feed and materializes its statements. A fetch that failed, or rejected documents, are in the result (and on the feed); the error is non-nil when the sync could not run or be recorded, and ErrSyncRunning when the feed is already being synced.

func (*Service) WithClusterLock

func (s *Service) WithClusterLock(sqlDB *sql.DB) *Service

WithClusterLock makes the syncs and materializations of a feed take a Postgres advisory lock on a pinned connection of sqlDB, so one replica at a time works on a feed.

type Store

type Store interface {
	ListVEXFeeds(ctx context.Context) ([]*models.VEXFeed, error)
	GetVEXFeed(ctx context.Context, id string) (*models.VEXFeed, error)
	ReplaceVEXFeedDocument(ctx context.Context, feedID, documentURL string, stmts []models.VEXFeedStatement) error
	ListVEXFeedStatements(ctx context.Context, feedID string) ([]models.VEXFeedStatement, error)
	RecordVEXFeedSync(ctx context.Context, feedID string, res models.VEXFeedSyncResult) error

	ListVEXTargets(ctx context.Context, repoID string) ([]models.VEXTarget, error)
	ListVEXStatements(ctx context.Context, repoID, artifactID string) ([]*models.VEXStatement, error)
	ReplaceFeedVEXStatements(ctx context.Context, feedID string, stmts []*models.VEXStatement) (int, error)
	ApplyPeerVEXStatement(ctx context.Context, s *models.VEXStatement) (bool, error)

	UpsertVEXSuggestion(ctx context.Context, s *models.VEXSuggestion) (bool, error)
	SetVEXSuggestionState(ctx context.Context, repoID, id, state, decidedBy string) error
	PruneVEXSuggestions(ctx context.Context, peerID string, keepIDs []string) (int64, error)
}

Store is the part of the database the service needs.

Jump to

Keyboard shortcuts

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