Documentation
¶
Overview ¶
Package jsonblob implements a JSON-backed recording of update operations to replay later.
Index ¶
- func ReturnEnrichment(e *driver.EnrichmentRecord)
- func ReturnVulnerability(v *claircore.Vulnerability)
- type CommonEntry
- type Entry
- type Loader
- type Store
- func (s *Store) DeleteUpdateOperations(context.Context, ...uuid.UUID) (int64, error)
- func (s *Store) DeltaUpdateVulnerabilities(ctx context.Context, updater string, fingerprint driver.Fingerprint, ...) (uuid.UUID, error)
- func (s *Store) Entries() map[uuid.UUID]*Entry
- func (s *Store) GC(_ context.Context, _ int) (int64, error)
- func (s *Store) GetLatestUpdateRef(_ context.Context, k driver.UpdateKind) (uuid.UUID, error)
- func (s *Store) GetLatestUpdateRefs(_ context.Context, k driver.UpdateKind) (map[string][]driver.UpdateOperation, error)
- func (s *Store) GetUpdateDiff(ctx context.Context, prev, cur uuid.UUID) (*driver.UpdateDiff, error)
- func (s *Store) GetUpdateOperations(_ context.Context, k driver.UpdateKind, us ...string) (map[string][]driver.UpdateOperation, error)
- func (s *Store) Initialized(context.Context) (bool, error)
- func (s *Store) RecordUpdaterSetStatus(ctx context.Context, updaterSet string, updateTime time.Time) error
- func (s *Store) RecordUpdaterStatus(ctx context.Context, updaterName string, updateTime time.Time, ...) error
- func (s *Store) Store(w io.Writer) error
- func (s *Store) UpdateEnrichments(ctx context.Context, kind string, fp driver.Fingerprint, ...) (uuid.UUID, error)
- func (s *Store) UpdateEnrichmentsIter(_ context.Context, _ string, _ driver.Fingerprint, _ datastore.EnrichmentIter) (uuid.UUID, error)
- func (s *Store) UpdateVulnerabilities(ctx context.Context, updater string, fingerprint driver.Fingerprint, ...) (uuid.UUID, error)
- func (s *Store) UpdateVulnerabilitiesIter(_ context.Context, _ string, _ driver.Fingerprint, ...) (uuid.UUID, error)
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReturnEnrichment ¶ added in v1.6.0
func ReturnEnrichment(e *driver.EnrichmentRecord)
ReturnEnrichment can be used by callers to return driver.EnrichmentRecord objects from Loader.All iterators to a common pool.
This may take some pressure off the garbage collector.
func ReturnVulnerability ¶ added in v1.6.0
func ReturnVulnerability(v *claircore.Vulnerability)
ReturnVulnerability can be used by callers to return claircore.Vulnerability objects from Loader.All iterators to a common pool.
This may take some pressure off the garbage collector.
Types ¶
type CommonEntry ¶
type CommonEntry struct {
Updater string
Fingerprint driver.Fingerprint
Date time.Time
Kind driver.UpdateKind
}
CommonEntry is an embedded type that's shared between the "normal" Entry type and the on-disk JSON produced by the Store.Store method.
type Entry ¶
type Entry struct {
CommonEntry
Vuln []*claircore.Vulnerability
Enrichment []driver.EnrichmentRecord
// contains filtered or unexported fields
}
Entry is a record of all information needed to record a vulnerability at a later date.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is an iterator over serialized records.
Users should consume the Loader.All iterator, then check for errors via Loader.Err.
func NewLoader ¶ added in v1.6.0
NewLoader returns a loader configured to read the records serialized in the provided io.Reader.
func (*Loader) All ¶ added in v1.6.0
func (l *Loader) All() iter.Seq2[*Entry, iter.Seq2[*claircore.Vulnerability, *driver.EnrichmentRecord]]
All returns an iterator-of-iterators yielding all entries in the Loader.
The inner iterator returns zero or one of the two values. If both pointers are nil, the caller must check Loader.Err.
func (*Loader) Entry
deprecated
Entry returns the latest loaded Entry.
Deprecated: Use the Loader.All iterator.
func (*Loader) Next
deprecated
Next reports whether there's an Entry to be processed.
Deprecated: Use the Loader.All iterator.
type Store ¶
A Store buffers update operations.
Store opens files in the OS-specified "temp" directories. If updates are sufficiently large, this may need to be adjusted. See os.TempDir for how to do so.
func (*Store) DeleteUpdateOperations ¶
DeleteUpdateOperations is unimplemented.
func (*Store) DeltaUpdateVulnerabilities ¶ added in v1.5.21
func (s *Store) DeltaUpdateVulnerabilities(ctx context.Context, updater string, fingerprint driver.Fingerprint, vulns []*claircore.Vulnerability, deleted []string) (uuid.UUID, error)
DeltaUpdateVulnerabilities just calls UpdateVulnerabilities. In the jsonblob flow it is assumed that we're always starting from zero. Note: deleted is ignored.
func (*Store) Entries ¶
Entries returns a map containing all the Entries stored by calls to UpdateVulnerabilities.
It is unsafe for modification because it does not return a copy of the map.
func (*Store) GetLatestUpdateRef ¶
GetLatestUpdateRef reports the latest update reference of any known updater.
func (*Store) GetLatestUpdateRefs ¶
func (s *Store) GetLatestUpdateRefs(_ context.Context, k driver.UpdateKind) (map[string][]driver.UpdateOperation, error)
GetLatestUpdateRefs reports the latest update reference for every known updater.
func (*Store) GetUpdateDiff ¶
GetUpdateDiff is unimplemented.
func (*Store) GetUpdateOperations ¶
func (s *Store) GetUpdateOperations(_ context.Context, k driver.UpdateKind, us ...string) (map[string][]driver.UpdateOperation, error)
GetUpdateOperations returns a list of UpdateOperations in date descending order for the given updaters.
The returned map is keyed by Updater implementation's unique names.
If no updaters are specified, all UpdateOperations are returned.
func (*Store) Initialized ¶ added in v0.3.0
Initialized implements vulnstore.Updater.
func (*Store) RecordUpdaterSetStatus ¶ added in v1.4.3
func (s *Store) RecordUpdaterSetStatus(ctx context.Context, updaterSet string, updateTime time.Time) error
RecordUpdaterSetStatus is unimplemented.
func (*Store) RecordUpdaterStatus ¶ added in v1.4.3
func (s *Store) RecordUpdaterStatus(ctx context.Context, updaterName string, updateTime time.Time, fingerprint driver.Fingerprint, updaterError error) error
RecordUpdaterStatus is unimplemented.
func (*Store) Store ¶
Store writes out the contents of the receiver to the provided io.Writer. It's the inverse of Load.
Store may only be called once for a series of Store.UpdateVulnerabilities and Store.UpdateEnrichments calls, as it deallocates resources as it writes them.
It should be possible to call this as often as needed to flush resources to disk.
func (*Store) UpdateEnrichments ¶ added in v0.5.0
func (s *Store) UpdateEnrichments(ctx context.Context, kind string, fp driver.Fingerprint, es []driver.EnrichmentRecord) (uuid.UUID, error)
UpdateEnrichments creates a new EnrichmentUpdateOperation, inserts the provided EnrichmentRecord(s), and ensures enrichments from previous updates are not queries by clients.
func (*Store) UpdateEnrichmentsIter ¶ added in v1.5.28
func (s *Store) UpdateEnrichmentsIter(_ context.Context, _ string, _ driver.Fingerprint, _ datastore.EnrichmentIter) (uuid.UUID, error)
UpdateEnrichmentsIter is unimplemented.
func (*Store) UpdateVulnerabilities ¶
func (s *Store) UpdateVulnerabilities(ctx context.Context, updater string, fingerprint driver.Fingerprint, vulns []*claircore.Vulnerability) (uuid.UUID, error)
UpdateVulnerabilities records all provided vulnerabilities.
func (*Store) UpdateVulnerabilitiesIter ¶ added in v1.5.28
func (s *Store) UpdateVulnerabilitiesIter(_ context.Context, _ string, _ driver.Fingerprint, _ datastore.VulnerabilityIter) (uuid.UUID, error)
UpdateVulnerabilitiesIter is unimplemented.
Notes ¶
Bugs ¶
On Linux, the disk buffering unconditionally uses what os.TempDir reports. On most systems, this will be a tmpfs, which means the contents are stored in RAM anyway. To mitigate this, set the "TMPDIR" environment variable for any process that's using this package.
Store.Entries reports seemingly-empty entries when populated via Store.UpdateVulnerabilities.