Documentation
¶
Overview ¶
Package source resolves image references to the platform images to scan, pulling directly from the registry without a Docker daemon.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoPlatform = errors.New("no matching platform")
ErrNoPlatform is returned when the filter matches no platform of an image.
Functions ¶
func ParseAllowPrivate ¶ added in v0.2.0
ParseAllowPrivate checks entries of Network.AllowPrivate.
Types ¶
type Image ¶
type Image struct {
// Ref is the reference, or for a local input the name of the image in
// it (the input path if it names none).
Ref string
// Input is the path of a local layout or archive, empty for a registry.
Input string
// Digest of the manifest or index the reference points to.
Digest string
Platforms []PlatformImage
// contains filtered or unexported fields
}
Image is a resolved image reference.
type Mirror ¶
Mirror serves the images of Registry under Prefix, e.g. a Harbor proxy cache project for Docker Hub: docker.io=harbor.example.com/dockerhub pulls docker.io/library/nginx from harbor.example.com/dockerhub/library/nginx. A mirror is trusted for tags; digests are verified.
func ParseMirror ¶
ParseMirror parses "registry=host[/path]".
type Network ¶ added in v0.2.0
type Network struct {
Restrict bool
// AllowPrivate lists registries that may use private addresses: a host
// ("harbor.example.com"), a host with port, a wildcard for subdomains
// ("*.dkr.ecr.eu-central-1.amazonaws.com", e.g. for VPC endpoints) or a
// network ("10.0.0.0/8").
AllowPrivate []string
}
Network limits where meles connects to when it pulls images. In a cluster the references come from anyone who may create a pod (operator) or a run (server); without limits they would let meles send requests to internal services and the cloud metadata endpoint, and show the answers in reports and events (SSRF).
With Restrict, meles
- never connects to loopback, link-local (169.254.0.0/16 with the cloud metadata endpoint, fe80::/10), unspecified or multicast addresses,
- connects to private addresses (10/8, 172.16/12, 192.168/16, 100.64/10, fc00::/7) only for hosts and networks in AllowPrivate,
- speaks plain HTTP only with Options.Insecure,
- keeps at most a short, printable excerpt of the body of an error response.
The check applies to the resolved address of every connection, so it holds for redirects, token realms and DNS names alike. Hosts of mirrors and of the HTTP(S)_PROXY are allowed. Through a proxy, meles connects only to the proxy; the proxy has to enforce its own rules for the targets.
type Options ¶
type Options struct {
Platforms PlatformFilter
Keychain authn.Keychain
// Insecure allows plain HTTP registries (for tests and local registries).
Insecure bool
// Mirrors are tried in order before the registry itself, which is the
// fallback if all fail (as containerd does).
Mirrors []Mirror
// Logger notes failed mirrors; nil for none.
Logger *slog.Logger
// Network restricts the addresses meles connects to (operator, server
// and Harbor adapter); the zero value restricts nothing (CLI).
Network Network
// Input reads the image from a local OCI image layout or docker save
// archive instead of a registry; the reference then names the image in
// it, empty for the only one. Close the Image when done.
Input string
}
Options configure Fetch.
type PlatformFilter ¶
type PlatformFilter struct {
// contains filtered or unexported fields
}
PlatformFilter selects the platforms of a multi-arch image. The zero value selects all platforms.
func ParsePlatforms ¶
func ParsePlatforms(s string) (PlatformFilter, error)
ParsePlatforms parses "all", "host" or a comma-separated list such as "linux/amd64,linux/arm64".
func (PlatformFilter) Match ¶
func (f PlatformFilter) Match(p v1.Platform) bool
Match reports whether p is selected.
func (PlatformFilter) String ¶
func (f PlatformFilter) String() string