updater

package
v1.5.27 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 23 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure deprecated

Configure calls the Configure method on all the passed-in UpdaterSetFactories.

Deprecated: See Updater.

func Register deprecated

func Register(name string, f driver.UpdaterSetFactory)

Register registers an UpdaterSetFactory.

Register will panic if the same name is used twice.

Deprecated: See Updater.

func Registered deprecated

func Registered() map[string]driver.UpdaterSetFactory

Registered returns a new map populated with the registered UpdaterSetFactories.

Deprecated: See Updater.

Types

type Locker added in v1.4.5

type Locker interface {
	// TryLock returns a cancelled Context if it would need to wait to acquire
	// the named lock.
	TryLock(context.Context, string) (context.Context, context.CancelFunc)
	// Lock waits to acquire the named lock. The returned Context may be
	// cancelled if the process loses confidence that the lock is valid.
	Lock(context.Context, string) (context.Context, context.CancelFunc)
}

Locker is the Context-based locking Updater expects.

type Options added in v1.4.5

type Options struct {

	// Store is the interface used to persist parsed data.
	Store Store
	// Client is the http.Client all the Updaters will use.
	Client *http.Client

	// Locker provides system-wide locks. If multiple Updater processes are
	// running, this should be backed by a distributed lock manager.
	Locker Locker
	// Configs holds configuration functions for Updaters.
	Configs driver.Configs
	// Factories is a slice of UpdaterFactories that are used to construct
	// Updaters on demand.
	Factories []driver.UpdaterFactory
	// contains filtered or unexported fields
}

Options contains the needed options for an Updater.

The Store and Client members are required. The others are optional, but should only be omitted in specific circumstances.

type Store added in v1.4.5

type Store interface {
	// UpdateEnrichments creates a new EnrichmentUpdateOperation, inserts the
	// provided EnrichmentRecord(s), and ensures enrichments from previous
	// updates are not queries by clients.
	UpdateEnrichments(ctx context.Context, ref uuid.UUID, kind string, fp driver.Fingerprint, es []driver.EnrichmentRecord) error

	// UpdateVulnerabilities creates a new UpdateOperation, inserts the provided
	// vulnerabilities, and ensures vulnerabilities from previous updates are
	// not queried by clients.
	UpdateVulnerabilities(ctx context.Context, ref uuid.UUID, updater string, fp driver.Fingerprint, vs *driver.ParsedVulnerabilities) error

	// GetLatestUpdateOperations reports the latest update operations. It must
	// report at least one per updater, if it exists.
	GetLatestUpdateOperations(ctx context.Context) ([]driver.UpdateOperation, error)
}

Store is the common interface to a data store that Updater expects.

type Updater added in v1.4.5

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

Updater coordinates running Updaters and saving the results.

Close must be called, or the program may panic.

func New added in v1.4.5

func New(ctx context.Context, opts *Options) (*Updater, error)

New returns an Updater ready to use.

None of the resources passed in the Options struct have any of their cleanup methods called, and need to be safe for use by multiple goroutines.

func (*Updater) Close added in v1.4.5

func (u *Updater) Close() error

Close releases any resources held by the Updater.

func (*Updater) Fetch added in v1.4.5

func (u *Updater) Fetch(ctx context.Context, prev io.ReaderAt, out io.Writer) error

Fetch runs only the Fetch step of the update process, writing it out to "out".

If "prev" is populated with the output of a previous run of this method, only changes since what was recorded in "prev" are written out.

func (*Updater) Parse added in v1.4.5

func (u *Updater) Parse(ctx context.Context, in io.ReaderAt) error

Parse runs the "second half" of the update process, using the contents of "in," which must have been populated by a previous call to Fetch.

The reader at "in" must have some way to detect its size.

func (*Updater) Run added in v1.4.5

func (u *Updater) Run(ctx context.Context, strict bool) error

Run constructs new updaters, runs them, and stores the results.

Errors reported from the Updater itself will return the error immediately, but errors reported from updaters are collected and reported once all updaters have run.

Run should be preferred to explicit Fetch and Parse calls, because knowing that both methods will be running in the same process allows for better resource usage.

Notes

Bugs

  • The localLocker implementation does not respect the parent context cancellation when waiting for a lock.

Directories

Path Synopsis
Package defaults sets updater defaults.
Package defaults sets updater defaults.
driver module
Package osv is an updater for OSV-formatted advisories.
Package osv is an updater for OSV-formatted advisories.

Jump to

Keyboard shortcuts

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