Documentation ¶
Index ¶
- Constants
- type Callback
- type Deliverer
- type Delivery
- type DirectDeliverer
- type Event
- type Key
- type KeyStore
- type MockKeyStore
- func (m *MockKeyStore) BumpExpiration(ctx context.Context, ID uuid.UUID, n time.Duration) error
- func (m *MockKeyStore) DeleteKey(ctx context.Context, ID uuid.UUID) error
- func (m *MockKeyStore) GC(ctx context.Context) (n int64, err error)
- func (m *MockKeyStore) KeyByID(ctx context.Context, ID uuid.UUID) (Key, error)
- func (m *MockKeyStore) Keys(ctx context.Context) ([]Key, error)
- func (m *MockKeyStore) PutKey(ctx context.Context, ID uuid.UUID, key *rsa.PublicKey, n time.Duration) error
- type MockStore
- func (m *MockStore) Created(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) DeleteNotifications(ctx context.Context, id uuid.UUID) error
- func (m *MockStore) Deleted(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) Failed(ctx context.Context) ([]uuid.UUID, error)
- func (m *MockStore) Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error)
- func (m *MockStore) PutNotifications(ctx context.Context, opts PutOpts) error
- func (m *MockStore) Receipt(ctx context.Context, id uuid.UUID) (Receipt, error)
- func (m *MockStore) ReceiptByUOID(ctx context.Context, id uuid.UUID) (Receipt, error)
- func (m *MockStore) SetDeleted(ctx context.Context, id uuid.UUID) error
- func (m *MockStore) SetDelivered(ctx context.Context, id uuid.UUID) error
- func (m *MockStore) SetDeliveryFailed(ctx context.Context, id uuid.UUID) error
- type Notification
- type NotificationHandle
- type Notificationer
- type Page
- type Poller
- type PollerOpt
- type Processor
- type PutOpts
- type Reason
- type Receipt
- type Receipter
- type Status
- type Store
- type VulnSummary
Constants ¶
const (
// max number of UOIDs that we will queue in a channel
MaxChanSize = 1024
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct { NotificationID uuid.UUID `json:"notification_id"` Callback url.URL `json:"callback"` }
Callback holds the details for clients to call back the Notifier and receive notifications.
func (Callback) MarshalJSON ¶
func (*Callback) UnmarshalJSON ¶
type Deliverer ¶
type Deliverer interface { // A unique name for the deliverer implementation Name() string // Deliver will push the notification ID to subscribed clients. // // If delivery fails a clairerror.ErrDeliveryFailed error must be returned. Deliver(ctx context.Context, nID uuid.UUID) error }
Deliverer provides the method set for delivering notifications
type Delivery ¶
type Delivery struct { // a Deliverer implemention to invoke. Deliverer Deliverer // contains filtered or unexported fields }
Delivery handles the business logic of delivering notifications.
func NewDelivery ¶
type DirectDeliverer ¶
type DirectDeliverer interface {
Notifications(ctx context.Context, n []Notification) error
}
DirectDeliverer implementations are used in coordination with the Deliverer interface.
DirectDeliverer(s) expect this method to be called prior to their Deliverer methods. Implementations must still implement both Deliverer and DirectDeliverer methods for correct use.
Implementations will be provided a list of notifications in which they can directly deliver to subscribed clients.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event is delivered on the poller's channel when a new UpdateOperation is discovered.
type KeyStore ¶
type KeyStore interface { // Keys returns all stored public keys. Keys(ctx context.Context) ([]Key, error) // KeyByID returns a public key if exists. // Returns clairerror.ErrKeyNotFound if key does not exist. KeyByID(ctx context.Context, ID uuid.UUID) (Key, error) // PutKey persists a public key with an initial expiration of n + current time. // // BumpExpiration is expected to be called periodically to keep the public key alive. PutKey(ctx context.Context, ID uuid.UUID, key *rsa.PublicKey, n time.Duration) error // DeleteKey removes a public key from the keystore. // // Returns clairerror.ErrKeyNotFound if key does not exist. DeleteKey(ctx context.Context, ID uuid.UUID) error // BumpExpiration sets the public key's expiration to n + // current time. BumpExpiration(ctx context.Context, ID uuid.UUID, n time.Duration) error // GC performs garbage collection o f expired public certificates. // N is the number of records deleted. // // Implementations are free to define efficient GC procedures. // Callers of this method may repeat GC until 0 is returned. GC(ctx context.Context) (n int64, err error) }
KeyStore stores and retrieves RSA public keys in PKIX, ASN.1 DER form
internally x509.ParsePKIXPublicKey is used to parse and return a *rsa.PublicKey to the caller.
type MockKeyStore ¶
type MockKeyStore struct { Keys_ func(ctx context.Context) ([]Key, error) KeyByID_ func(ctx context.Context, ID uuid.UUID) (Key, error) PutKey_ func(ctx context.Context, ID uuid.UUID, key *rsa.PublicKey, n time.Duration) error DeleteKey_ func(ctx context.Context, ID uuid.UUID) error BumpExpiration_ func(ctx context.Context, ID uuid.UUID, n time.Duration) error GC_ func(ctx context.Context) (n int64, err error) }
MockKeyStore implements a mock KeyStore.
func (*MockKeyStore) BumpExpiration ¶
BumpExpiration sets the public key's expiration to (n minutes) + (time of call).
func (*MockKeyStore) DeleteKey ¶
DeleteKey removes a public key from the keystore.
Returns clairerror.ErrKeyNotFound if key does not exist.
func (*MockKeyStore) GC ¶
func (m *MockKeyStore) GC(ctx context.Context) (n int64, err error)
GC performs garbage collection of expired public certificates. N is the number of records deleted.
Implementations are free to define efficient GC procedures. Callers of this method may repeat GC until 0 is returned.
func (*MockKeyStore) KeyByID ¶
KeyByID returns a public key if exists. Returns clairerror.ErrKeyNotFound if key does not exist.
type MockStore ¶
type MockStore struct { Notifications_ func(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) PutNotifications_ func(ctx context.Context, opts PutOpts) error DeleteNotitfications_ func(ctx context.Context, id uuid.UUID) error Receipt_ func(ctx context.Context, id uuid.UUID) (Receipt, error) ReceiptByUOID_ func(ctx context.Context, id uuid.UUID) (Receipt, error) Created_ func(ctx context.Context) ([]uuid.UUID, error) Failed_ func(ctx context.Context) ([]uuid.UUID, error) Deleted_ func(ctx context.Context) ([]uuid.UUID, error) SetDelivered_ func(ctx context.Context, id uuid.UUID) error SetDeliveredFailed_ func(ctx context.Context, id uuid.UUID) error SetDeleted_ func(ctx context.Context, id uuid.UUID) error }
MockStore implements a mock Store.
func (*MockStore) DeleteNotifications ¶
DeleteNotifications garbage collects all notifications associated with a notification id.
Normally Receipter.SetDeleted will be issues first, however application logic may decide to gc notifications which have not been set deleted after some period of time, thus this condition should not be checked.
func (*MockStore) Notifications ¶
func (m *MockStore) Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error)
Notifications retrieves the list of notifications associated with a notification id
func (*MockStore) PutNotifications ¶
PutNotifications persists the provided notifications and associates them with the provided notification id
PutNotifications must update the latest update operation for the provided updater in such a way that UpdateOperation returns the the provided update operation id when queried with the updater name
PutNotifications must create a Receipt with status created status on successful persistence of notifications in such a way that Receipter.Created() returns the persisted notification id.
func (*MockStore) ReceiptByUOID ¶
ReceiptByUOID returns the Receipt for a given UOID
func (*MockStore) SetDeleted ¶
SetDeleted marks the provided notification id as deleted
func (*MockStore) SetDelivered ¶
SetDelivered marks the provided notification id as delivered
type Notification ¶
type Notification struct { ID uuid.UUID `json:"id"` Manifest claircore.Digest `json:"manifest"` Reason Reason `json:"reason"` Vulnerability VulnSummary `json:"vulnerability"` }
Notification summarizes a change in the vulnerabilities affecting a manifest
The mentioned Vulnerability will be the most severe vulnerability discovered in an update operation.
Receiving clients are expected to filter notifications by severity in such a way that they receive all vulnerabilities at or above a particular claircore.Severity level.
type NotificationHandle ¶
NotificationHandle is a handle a client may use to retrieve a list of associated notification models
type Notificationer ¶
type Notificationer interface { // Notifications retrieves the list of notifications associated with a // notification id // // If a Page is provided the returned notifications will be a subset of the total // and it's len will be no larger then Page.Size. // // This method should interpret the page.Next field as the requested page and // set the returned page.Next field to the next page to receive or -1 if // paging has been exhausted. // // Page maybe nil to receive all notifications. Notifications(ctx context.Context, id uuid.UUID, page *Page) ([]Notification, Page, error) // PutNotifications persists the provided notifications and associates // them with the provided notification id // // PutNotifications must update the latest update operation for the provided // updater in such a way that UpdateOperation returns the the provided update // operation id when queried with the updater name // // PutNotifications must create a Receipt with status created status on // successful persistence of notifications in such a way that Receipter.Created() // returns the persisted notification id. PutNotifications(ctx context.Context, opts PutOpts) error // DeleteNotifications garbage collects all notifications associated // with a notification id. // // Normally Receipter.SetDeleted will be issues first, however // application logic may decide to gc notifications which have not been // set deleted after some period of time, thus this condition should not // be checked. DeleteNotifications(ctx context.Context, id uuid.UUID) error }
Notificationer implements persistence methods for Notification models
type Page ¶
type Page struct { // the max number of elements returned in a page Size uint64 `json:"size"` // the next id to retrieve Next *uuid.UUID `json:"next,omitempty"` }
Page communicates a bare-minimum paging procotol with clients
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller implements new Update Operation discovery via an event channel.
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
Processor listen for new UOIDs, creates notifications, and persists these notifications for later retrieval.
Processor(s) create atomic boundaries, no two Processor(s) will be creating notifications for the same UOID at once.
func NewProcessor ¶
type PutOpts ¶
type PutOpts struct { // the updater triggering a notification Updater string // the update operation id triggering the notification UpdateID uuid.UUID // the notification id clients will use to retrieve the // list of notifications NotificationID uuid.UUID // a slice of notifications to persist. these notifications // will be retrievable via the notification id Notifications []Notification }
PutOpts is provided to Notificationer.Put with fields necessary to persist a notification id
type Receipt ¶
type Receipt struct { // the id a client may use to retrieve a set of notifications NotificationID uuid.UUID // the current status of the notification Status Status // the timestamp of the last status update TS time.Time }
Receipt represents the current status of a notification
type Receipter ¶
type Receipter interface { // Receipt returns the Receipt for a given notification id Receipt(ctx context.Context, id uuid.UUID) (Receipt, error) // ReceiptByUOID returns the Receipt for a given UOID ReceiptByUOID(ctx context.Context, id uuid.UUID) (Receipt, error) // Created returns a slice of notification ids in created status Created(ctx context.Context) ([]uuid.UUID, error) // Failed returns a slice of notification ids to in delivery failed status Failed(ctx context.Context) ([]uuid.UUID, error) // Deleted returns a slice of notification ids in deleted status Deleted(ctx context.Context) ([]uuid.UUID, error) // SetDelivered marks the provided notification id as delivered SetDelivered(ctx context.Context, id uuid.UUID) error // SetDeliveryFailed marks the provided notification id failed to be delivered SetDeliveryFailed(ctx context.Context, id uuid.UUID) error // SetDeleted marks the provided notification id as deleted SetDeleted(ctx context.Context, id uuid.UUID) error }
Receipter implements persistence methods for Receipt models
type Status ¶
type Status string
Status defines the possible states of a notification.
const ( // A notification is created and ready to be delivered to a client Created Status = "created" // A notification has been successfully delivered to a client Delivered Status = "delivered" // A notification failed to be delivered DeliveryFailed Status = "delivery_failed" // The client has read the notification and issued a delete Deleted Status = "deleted" )
type Store ¶
type Store interface { Notificationer Receipter }
Store is an aggregate interface implementing all methods necessary for a notifier persistence layer
type VulnSummary ¶
type VulnSummary struct { Name string `json:"name"` Description string `json:"description"` Package *claircore.Package `json:"package,omitempty"` Distribution *claircore.Distribution `json:"distribution,omitempty"` Repo *claircore.Repository `json:"repo,omitempty"` Severity string `json:"severity"` FixedInVersion string `json:"fixed_in_version"` Links string `json:"links"` }
VulnSummary summarizes a vulnerability which triggered a notification
func (*VulnSummary) FromVulnerability ¶
func (vs *VulnSummary) FromVulnerability(v claircore.Vulnerability)