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 ¶
- Variables
- type Service
- func (s *Service) ApplyFeeds(ctx context.Context) error
- func (s *Service) PeerVEXDocument(ctx context.Context, repoID, format string) ([]byte, error)
- func (s *Service) ReceivePeerVEX(ctx context.Context, repoID, repoFormat string, peer *federation.Peer, ...) error
- func (s *Service) StartSync(feedID string) bool
- func (s *Service) Stop()
- func (s *Service) SyncFeed(ctx context.Context, feedID string) (models.VEXFeedSyncResult, error)
- func (s *Service) WithClusterLock(sqlDB *sql.DB) *Service
- type Store
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewService returns the service. Without WithClusterLock there are no other replicas to exclude.
func (*Service) ApplyFeeds ¶
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 ¶
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 ¶
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 ¶
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.
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.