Documentation
¶
Overview ¶
Package quay provides a client for the Quay Security API, which exposes Clair vulnerability scan results for images hosted on a Quay instance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrQuayAuth = errors.New("quay authentication failed: verify OAuth2 Application Token")
ErrQuayAuth is returned when Quay rejects the configured token (HTTP 401). It is terminal: the scanner aborts the whole scan rather than skipping the image, because every subsequent request would fail the same way.
Functions ¶
func NewScanner ¶
func NewScanner(cfg *config.QuayConfig, log logrus.FieldLogger) (vulnerability.Scanner, error)
NewScanner returns a Quay-backed Scanner. It returns (nil, nil) when cfg is nil so callers can treat a missing Quay configuration as "no scanner". Unlike Trustify, the Quay client needs no request context to construct (bearer-token auth, no OIDC discovery), so it is built eagerly here.
Types ¶
type CVSS ¶
type CVSS struct {
Vectors string `json:"Vectors,omitempty"`
Score float64 `json:"Score,omitempty"`
}
CVSS is a single CVSS scoring entry.
func (*CVSS) UnmarshalJSON ¶
UnmarshalJSON accepts both the numeric and string representations returned by different versions of the Quay Security API for CVSS scores.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches vulnerability reports from a single Quay instance's Security API.
func NewClient ¶
func NewClient(cfg *config.QuayConfig, log logrus.FieldLogger, httpClient *http.Client) (*Client, error)
NewClient builds a Quay Security API client from the Quay backend config. It returns (nil, nil) when cfg is nil, so a caller can treat an absent Quay configuration as a disabled backend. It returns an error when the configured endpoint has no parseable host or is not HTTPS. The httpClient parameter allows injection of custom TLS config (e.g., custom CA, InsecureSkipVerify); when nil, a default client with a 30s timeout is used.
func (*Client) FetchImageSecurity ¶
func (c *Client) FetchImageSecurity(ctx context.Context, image vulnerability.ImageRef) (*Response, error)
FetchImageSecurity retrieves the Quay Security report for one deployed image.
It returns a scanned report when the image is hosted on the configured registry and Quay reports status "scanned". It returns nil when the image is skipped for a documented reason (missing reference, non-matching registry, non-"scanned" status, 404, 403). It returns ErrQuayAuth on HTTP 401 and a wrapped error on any genuine failure to reach Quay (after retries) or decode a successful response.
type Data ¶
type Data struct {
Layer *Layer `json:"Layer,omitempty"`
}
Data wraps the scanned layer of a manifest.
type Feature ¶
type Feature struct {
Name string `json:"Name,omitempty"`
VersionFormat string `json:"VersionFormat,omitempty"`
NamespaceName string `json:"NamespaceName,omitempty"`
AddedBy string `json:"AddedBy,omitempty"`
Version string `json:"Version,omitempty"`
Vulnerabilities []Vulnerability `json:"Vulnerabilities,omitempty"`
}
Feature is an installed package and the vulnerabilities affecting it.
type Layer ¶
type Layer struct {
Name string `json:"Name,omitempty"`
ParentName string `json:"ParentName,omitempty"`
NamespaceName string `json:"NamespaceName,omitempty"`
IndexedByVersion int `json:"IndexedByVersion,omitempty"`
Features []Feature `json:"Features,omitempty"`
}
Layer holds the features (installed packages) detected in a scanned image.
type Metadata ¶
type Metadata struct {
NVD NVD `json:"NVD,omitempty"`
}
Metadata carries the NVD enrichment Quay attaches to a vulnerability.
type Response ¶
Response is the top-level payload returned by the Quay Security API (GET /api/v1/repository/{namespace}/{repo}/manifest/{digest}/security). Status reports the scan state; only "scanned" carries vulnerability data.
type Vulnerability ¶
type Vulnerability struct {
Name string `json:"Name,omitempty"`
NamespaceName string `json:"NamespaceName,omitempty"`
Description string `json:"Description,omitempty"`
Link string `json:"Link,omitempty"`
Severity string `json:"Severity,omitempty"`
FixedBy string `json:"FixedBy,omitempty"`
Metadata Metadata `json:"Metadata,omitempty"`
}
Vulnerability describes a single vulnerability reported against a Feature.