Documentation
¶
Overview ¶
Package advisoryfeed reads a file based advisory feed and matches the images apps run against it. It is off unless a feed is configured.
Index ¶
- Constants
- func NormalizeRepository(s string) string
- func ParsePublicKey(s string) (ed25519.PublicKey, error)
- func SeverityRank(s string) int
- func Verify(key ed25519.PublicKey, data, sigB64 []byte) error
- type Affected
- type Config
- type Entry
- type Feed
- type Image
- type Match
- type Range
- type Service
- type Snapshot
Constants ¶
const ( SeverityCritical = "critical" SeverityHigh = "high" SeverityMedium = "medium" SeverityLow = "low" )
Severities, highest first.
const ( EnvFeed = "APP_ADVISORY_FEED" EnvPubKey = "APP_ADVISORY_FEED_PUBKEY" EnvRefresh = "APP_ADVISORY_FEED_REFRESH" EnvMaxBytes = "APP_ADVISORY_FEED_MAX_BYTES" )
Environment variables. Everything is off while EnvFeed is empty.
const ( SigUnsigned = "unsigned" SigVerified = "verified" SigInvalid = "invalid" )
Signature states shown wherever a feed is shown. Unsigned means no public key is configured, so the content is not authenticated.
const SchemaVersion = 1
SchemaVersion is the only feed version this build understands.
Variables ¶
This section is empty.
Functions ¶
func NormalizeRepository ¶
NormalizeRepository lowercases and strips the default registry and library prefixes so "node" and "docker.io/library/node" compare equal.
func ParsePublicKey ¶
ParsePublicKey decodes a base64 ed25519 public key from configuration.
func SeverityRank ¶
SeverityRank orders severities, higher is worse; unknown is 0.
Types ¶
type Affected ¶
type Affected struct {
Repository string `json:"repository"`
Digests []string `json:"digests,omitempty"`
Tags []string `json:"tags,omitempty"`
Ranges []Range `json:"ranges,omitempty"`
}
Affected names an image repository and the content that is affected. At least one of Digests, Tags or Ranges is required so an entry never matches a whole repository by accident.
type Config ¶
Config is read once from the environment.
func ConfigFromEnv ¶
ConfigFromEnv reads the feed settings through lookup.
type Entry ¶
type Entry struct {
ID string `json:"id"`
Severity string `json:"severity"`
Summary string `json:"summary"`
Affected []Affected `json:"affected"`
FixedIn string `json:"fixed_in,omitempty"`
Reference string `json:"reference,omitempty"`
}
Entry is one advisory.
type Feed ¶
type Feed struct {
Version int `json:"version"`
GeneratedAt time.Time `json:"generated_at,omitempty"`
Entries []Entry `json:"entries"`
}
Feed is the document an operator or a publisher provides.
type Image ¶
type Image struct {
App string `json:"app"`
Ref string `json:"image"`
Digest string `json:"digest,omitempty"`
}
Image is one running image of an app. Digest may be empty.
type Match ¶
type Match struct {
App string `json:"app"`
Image string `json:"image"`
Digest string `json:"digest,omitempty"`
AdvisoryID string `json:"advisory_id"`
Severity string `json:"severity"`
Summary string `json:"summary"`
FixedIn string `json:"fixed_in,omitempty"`
Reference string `json:"reference,omitempty"`
Hint string `json:"hint"`
}
Match is one advisory that applies to one running image.
func MatchImages ¶
MatchImages compares every image against every advisory. The result is ordered worst severity first, then app, then advisory id.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service loads the feed lazily and caches matches until the feed or the image set changes. There is no background loop.
type Snapshot ¶
type Snapshot struct {
Enabled bool `json:"enabled"`
Source string `json:"source,omitempty"`
Signature string `json:"signature,omitempty"`
Error string `json:"error,omitempty"`
GeneratedAt time.Time `json:"generated_at,omitempty"`
LoadedAt time.Time `json:"loaded_at,omitempty"`
Entries []Entry `json:"entries"`
Fingerprint string `json:"-"`
}
Snapshot is the loaded feed and how far it can be trusted.
func (Snapshot) UsesDigests ¶
UsesDigests reports whether any entry selects by digest, so callers can skip resolving digests when none can match.