ociplugins

package
v2.3.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 Imports: 30 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

pkg/ociplugins/client.go

pkg/ociplugins/config.go

Package ociplugins fetches, verifies and caches plugins distributed as OCI artifacts.

Signature verifier contract

Signatures are verified by a SecurityService (the Enterprise plugin security service; Community builds have no verifier). Three seams let it reach registries exactly as plugin pulls do:

  • NewRemoteRepository builds the repository client, with the same insecure-registry rules, registry auth and netguard SSRF guard as Pull.
  • VerifySignature is called with a reference whose Digest is the top-level digest the plugin reference resolved to (the image index for a multi-arch plugin), which is the digest publish-plugin.sh signs.
  • The registry auth config named by the plugin reference (?auth=) is carried on the context: AuthConfigFrom(ctx) returns it, so the verifier passes it to NewRemoteRepository.

pkg/ociplugins/errors.go

pkg/ociplugins/fetcher.go

pkg/ociplugins/parser.go

pkg/ociplugins/storage.go

Index

Examples

Constants

View Source
const (
	// TlogPolicyRequired requires a transparency-log entry for the signature,
	// as cosign verify --key does.
	TlogPolicyRequired = "required"
	// TlogPolicyOptional checks a transparency-log entry when the signature
	// has one and accepts a signature without.
	TlogPolicyOptional = "optional"
	// TlogPolicyDisabled verifies signatures against the key only, for
	// air-gapped signing (cosign sign --tlog-upload=false).
	TlogPolicyDisabled = "disabled"
)

Transparency-log policies for signature verification (OCIConfig.TlogPolicy).

View Source
const DefaultMaxPluginSize = 512 * 1024 * 1024 // 512MB

DefaultMaxPluginSize bounds a single plugin binary when the configuration does not set MaxPluginSize. Plugin binaries are statically linked Go executables and routinely run to tens of megabytes.

View Source
const DefaultTykPublicKey = `` /* 177-byte string literal not displayed */

DefaultTykPublicKey is the official Tyk plugin signing public key (ECDSA P-256). This key is always included in the trusted keys list and cannot be disabled via environment variables. Additional keys can be added via OCI_PLUGINS_PUBKEY_* env vars.

Variables

This section is empty.

Functions

func AuthConfigFrom added in v2.3.0

func AuthConfigFrom(ctx context.Context) string

AuthConfigFrom returns the registry auth config name set by WithAuthConfig, or "" if none was set.

func CheckRegistryHost added in v2.3.0

func CheckRegistryHost(ref *OCIReference) error

CheckRegistryHost applies the plugin host rule (netguard.CheckPluginHost) to ref's registry: unless ALLOW_INTERNAL_NETWORK_ACCESS=true, a registry that is, or resolves to, an internal address, or does not resolve, is refused. Every fetch, signature read and cache lookup goes through it.

func LoadPublicKeysFromDirectory added in v2.3.0

func LoadPublicKeysFromDirectory(dir string) ([]string, error)

LoadPublicKeysFromDirectory returns the paths of the public key files in dir (cosign.pub, key.pub, *.pub, *.pem, *.key).

func LoadPublicKeysFromEnv

func LoadPublicKeysFromEnv() []string

LoadPublicKeysFromEnv loads public keys from environment variables Supports multiple formats: - OCI_PLUGINS_PUBKEY_<NUMBER> - Numbered keys with PEM content - OCI_PLUGINS_PUBKEY_<NAME> - Named keys with PEM content - OCI_PLUGINS_PUBKEY_FILE_<NAME> - File path references

func LoadRegistryAuthFromEnv

func LoadRegistryAuthFromEnv() map[string]RegistryAuth

LoadRegistryAuthFromEnv loads registry authentication configuration from environment variables Environment variables pattern: OCI_PLUGINS_REGISTRY_<NAME>_USERNAME OCI_PLUGINS_REGISTRY_<NAME>_PASSWORD_ENV OCI_PLUGINS_REGISTRY_<NAME>_TOKEN_ENV

func NewRemoteRepository added in v2.3.0

func NewRemoteRepository(cfg *OCIConfig, ref *OCIReference, authConfigName string) (*remote.Repository, error)

NewRemoteRepository returns a repository client for ref's repository that reaches the registry exactly as plugin pulls do: plain HTTP for insecure registries, the registry auth named by authConfigName (or configured for the registry), and the netguard-validating HTTP client for every request, authenticated or anonymous. The Enterprise signature verifier uses it to read signatures, so they are fetched under the same SSRF policy.

func ParseOCICommand

func ParseOCICommand(command string) (*OCIReference, *OCIPluginParams, error)

ParseOCICommand parses an OCI command string and returns the reference and parameters

Example

ExampleParseOCICommand demonstrates how to parse OCI plugin commands

// Basic OCI reference with digest and explicit architecture
ref, params, err := ParseOCICommand("oci://nexus.example.com/plugins/ner@sha256:0123deadbeef456?arch=linux/amd64")
if err != nil {
	panic(err)
}

fmt.Printf("Registry: %s\n", ref.Registry)
fmt.Printf("Repository: %s\n", ref.Repository)
fmt.Printf("Digest: %s\n", ref.Digest)
fmt.Printf("Architecture: %s\n", params.Architecture)

// OCI reference with parameters
_, params2, err := ParseOCICommand("oci://registry.com/plugins/test@sha256:abc123?arch=linux/arm64&pubkey=test.pub")
if err != nil {
	panic(err)
}

fmt.Printf("Architecture: %s\n", params2.Architecture)
fmt.Printf("Public Key: %s\n", params2.PublicKey)
Output:
Registry: nexus.example.com
Repository: plugins/ner
Digest: sha256:0123deadbeef456
Architecture: linux/amd64
Architecture: linux/arm64
Public Key: test.pub

func ParsePublicKey added in v2.3.0

func ParsePublicKey(pemBytes []byte) (crypto.PublicKey, error)

ParsePublicKey parses the first PEM block of a PKIX public key (ECDSA, RSA or Ed25519).

func ParseTlogPolicy added in v2.3.0

func ParseTlogPolicy(value string) (string, error)

ParseTlogPolicy normalizes a transparency-log policy setting: "" is TlogPolicyRequired, and anything but the three policies is an error.

func PublicKeyPath added in v2.3.0

func PublicKeyPath(cfg *OCIConfig, keyID string) (string, error)

PublicKeyPath returns the file a key ID resolves to, for callers that need a path (plugin_security.Service.GetPublicKeyPath). It is "" for a key that is not read from a file (embedded or environment keys); use ResolvePublicKey for the key itself.

func ReadTrustedRootFile added in v2.3.0

func ReadTrustedRootFile(path string) ([]byte, error)

ReadTrustedRootFile reads a Sigstore trusted-root override (OCIConfig.TrustedRootFile), bounded like ValidateTrustedRootFile.

func ResolvePublicKey added in v2.3.0

func ResolvePublicKey(cfg *OCIConfig, keyID string) ([]byte, error)

ResolvePublicKey returns the PEM bytes of the public key that keyID names, for verifying plugin signatures. An empty keyID means the first configured default key. keyID is resolved in this order:

  • "embedded:<anything>": the built-in Tyk signing key (DefaultTykPublicKey);
  • a number N: the PEM in OCI_PLUGINS_PUBKEY_N;
  • a name: the PEM in OCI_PLUGINS_PUBKEY_<NAME>, else the file named by OCI_PLUGINS_PUBKEY_FILE_<NAME>;
  • "env:VAR": the PEM in VAR;
  • "file:/path": the file at /path;
  • a path (contains "/", or ends in .pub or .pem): that file;
  • otherwise, a configured default key whose reference contains keyID.

The key must be PEM; nothing is written to disk.

func ValidateOCIReference

func ValidateOCIReference(ref *OCIReference, config *OCIConfig) error

ValidateOCIReference performs additional validation on an OCI reference

func ValidatePublicKey added in v2.3.0

func ValidatePublicKey(keyPath string) error

ValidatePublicKey checks if a public key file exists and is accessible

func ValidateTrustedRootFile added in v2.3.0

func ValidateTrustedRootFile(path string) error

ValidateTrustedRootFile checks that a trusted-root override, if set, is a readable regular file of bounded size (see ReadTrustedRootFile).

func WithAuthConfig added in v2.3.0

func WithAuthConfig(ctx context.Context, name string) context.Context

WithAuthConfig returns a context carrying the registry auth config name (OCIPluginParams.AuthConfig) for a signature verifier to use.

Types

type ContentStorage

type ContentStorage struct {
	// contains filtered or unexported fields
}

ContentStorage manages content-addressed storage for plugins

func NewContentStorage

func NewContentStorage(baseDir string, maxSize int64, gcInterval time.Duration) (*ContentStorage, error)

NewContentStorage creates a new content storage instance

func (*ContentStorage) CalculateSize

func (s *ContentStorage) CalculateSize() (int64, error)

CalculateSize returns the total size of the cache in bytes

func (s *ContentStorage) CreateActiveLink(name, digest, arch string) error

CreateActiveLink creates or updates a symlink to mark a plugin as active

func (*ContentStorage) GarbageCollect

func (s *ContentStorage) GarbageCollect(keepVersions int) error

GarbageCollect removes old plugin versions, keeping the specified number

func (*ContentStorage) GetActivePath

func (s *ContentStorage) GetActivePath(name string) (string, error)

GetActivePath returns the path to the active version of a plugin

func (*ContentStorage) GetBlob

func (s *ContentStorage) GetBlob(digest string) ([]byte, error)

GetBlob retrieves blob data by digest

func (*ContentStorage) GetExecutablePath

func (s *ContentStorage) GetExecutablePath(digest, arch string) string

GetExecutablePath returns the path to an executable by digest and architecture, or "" if either is not a valid path component.

func (*ContentStorage) HasExecutable

func (s *ContentStorage) HasExecutable(digest, arch string) bool

HasExecutable checks if an executable exists for the given digest and architecture

func (*ContentStorage) HasMetadata

func (s *ContentStorage) HasMetadata(digest, arch string) bool

HasMetadata checks if metadata exists for a plugin

func (*ContentStorage) ListAllMetadata

func (s *ContentStorage) ListAllMetadata() ([]*PluginMetadata, error)

ListAllMetadata returns metadata for all cached plugins

func (*ContentStorage) LoadMetadata

func (s *ContentStorage) LoadMetadata(digest, arch string) (*PluginMetadata, error)

LoadMetadata loads plugin metadata by digest and architecture

func (*ContentStorage) StoreBlob

func (s *ContentStorage) StoreBlob(data []byte) (string, error)

StoreBlob stores raw blob data and returns the digest

func (*ContentStorage) StoreExecutable

func (s *ContentStorage) StoreExecutable(digest, arch string, data []byte) (string, error)

StoreExecutable stores a plugin binary and returns the executable path

func (*ContentStorage) StoreMetadata

func (s *ContentStorage) StoreMetadata(digest, arch string, metadata *PluginMetadata) error

StoreMetadata stores plugin metadata

func (*ContentStorage) UpdateLastAccessed

func (s *ContentStorage) UpdateLastAccessed(digest, arch string) error

UpdateLastAccessed updates the last accessed time for a plugin

type ErrCacheCorrupted

type ErrCacheCorrupted struct {
	Path   string
	Reason string
}

ErrCacheCorrupted indicates the plugin cache is corrupted

func (*ErrCacheCorrupted) Error

func (e *ErrCacheCorrupted) Error() string

type ErrCacheUnchecked added in v2.3.0

type ErrCacheUnchecked struct {
	Path   string
	Reason string
}

ErrCacheUnchecked indicates a cached plugin has no recorded binary hash (it was cached by an earlier release, or its metadata was rewritten by one after a rollback), so it cannot be integrity-checked until it is fetched again.

func (*ErrCacheUnchecked) Error added in v2.3.0

func (e *ErrCacheUnchecked) Error() string

type ErrIncompatibleArchitecture

type ErrIncompatibleArchitecture struct {
	PluginArch  string
	RuntimeArch string
}

ErrIncompatibleArchitecture indicates the plugin is not compatible with the current architecture

func (*ErrIncompatibleArchitecture) Error

type ErrInvalidOCIReference

type ErrInvalidOCIReference struct {
	Reference string
	Reason    string
}

ErrInvalidOCIReference indicates an invalid OCI reference format

func (*ErrInvalidOCIReference) Error

func (e *ErrInvalidOCIReference) Error() string

type ErrNetworkTimeout

type ErrNetworkTimeout struct {
	Operation string
	Registry  string
}

ErrNetworkTimeout indicates a network operation timed out

func (*ErrNetworkTimeout) Error

func (e *ErrNetworkTimeout) Error() string

type ErrPluginNotFound

type ErrPluginNotFound struct {
	Reference string
}

ErrPluginNotFound indicates the plugin was not found in the registry

func (*ErrPluginNotFound) Error

func (e *ErrPluginNotFound) Error() string

type ErrRegistryNotAllowed

type ErrRegistryNotAllowed struct {
	Registry          string
	AllowedRegistries []string
}

ErrRegistryNotAllowed indicates the registry is not in the allowlist

func (*ErrRegistryNotAllowed) Error

func (e *ErrRegistryNotAllowed) Error() string

type ErrSignatureVerificationFailed

type ErrSignatureVerificationFailed struct {
	Reference string
	Reason    string
}

ErrSignatureVerificationFailed indicates cosign signature verification failed

func (*ErrSignatureVerificationFailed) Error

type LocalPlugin

type LocalPlugin struct {
	Reference      *OCIReference    `json:"reference"`
	Params         *OCIPluginParams `json:"params"`
	ExecutablePath string           `json:"executable_path"` // Path to executable binary
	ConfigPath     string           `json:"config_path"`     // Optional config JSON path
	CacheDir       string           `json:"cache_dir"`       // Storage location
	Verified       bool             `json:"verified"`        // Cosign verification status
	FetchTime      time.Time        `json:"fetch_time"`      // When downloaded
	Config         *PluginConfig    `json:"config"`          // Parsed from OCI config layer
}

LocalPlugin represents a plugin that has been fetched and is available locally

type OCIConfig

type OCIConfig struct {
	// Cache settings
	CacheDir     string `yaml:"cache_dir" json:"cache_dir"`
	MaxCacheSize int64  `yaml:"max_cache_size" json:"max_cache_size"`

	// MaxPluginSize bounds a single plugin binary. Layer sizes come from
	// registry-supplied descriptors, so the binary is streamed against this
	// limit rather than trusting the descriptor.
	MaxPluginSize int64 `yaml:"max_plugin_size" json:"max_plugin_size"`

	// Default security settings
	DefaultPublicKeys []string `yaml:"default_public_keys" json:"default_public_keys"`
	AllowedRegistries []string `yaml:"allowed_registries" json:"allowed_registries"`

	// Authentication
	RegistryAuth map[string]RegistryAuth `yaml:"registry_auth" json:"registry_auth"`

	// Network settings
	Timeout       time.Duration `yaml:"timeout" json:"timeout"`
	RetryAttempts int           `yaml:"retry_attempts" json:"retry_attempts"`

	// Security settings
	RequireSignature bool `yaml:"require_signature" json:"require_signature"`

	// TlogPolicy sets whether a signature needs a transparency-log (Rekor)
	// entry: TlogPolicyRequired (the default when empty), TlogPolicyOptional
	// or TlogPolicyDisabled. See EffectiveTlogPolicy.
	TlogPolicy string `yaml:"tlog_policy" json:"tlog_policy"`
	// TrustedRootFile overrides the embedded Sigstore trusted root (a
	// trusted_root.json), for private Sigstore deployments and key rotation.
	TrustedRootFile string `yaml:"trusted_root_file" json:"trusted_root_file"`

	// Registry connection settings
	InsecureRegistries []string `yaml:"insecure_registries" json:"insecure_registries"`

	// Garbage collection
	GCInterval   time.Duration `yaml:"gc_interval" json:"gc_interval"`
	KeepVersions int           `yaml:"keep_versions" json:"keep_versions"`
}

OCIConfig holds the configuration for OCI plugin operations

func DefaultOCIConfig

func DefaultOCIConfig() *OCIConfig

DefaultOCIConfig returns a configuration with sensible defaults

func (*OCIConfig) EffectiveTlogPolicy added in v2.3.0

func (c *OCIConfig) EffectiveTlogPolicy() string

EffectiveTlogPolicy returns the transparency-log policy, TlogPolicyRequired when none is set.

type OCIPluginClient

type OCIPluginClient struct {
	// contains filtered or unexported fields
}

OCIPluginClient handles OCI-based plugin operations

func NewOCIPluginClient

func NewOCIPluginClient(config *OCIConfig) (*OCIPluginClient, error)

NewOCIPluginClient creates a new OCI plugin client

func (*OCIPluginClient) Close

func (c *OCIPluginClient) Close() error

Close shuts down the OCI client and cleans up resources

func (*OCIPluginClient) FetchPlugin

func (c *OCIPluginClient) FetchPlugin(ctx context.Context, ref *OCIReference, params *OCIPluginParams) (*LocalPlugin, error)

FetchPlugin fetches a plugin by OCI reference, verifies it, and returns local information

Example

ExampleOCIPluginClient_FetchPlugin demonstrates how to fetch a plugin from an OCI registry

// NOTE: This is a demonstration example - it won't work without a real registry

// Create client configuration
config := &OCIConfig{
	CacheDir:          "/tmp/plugin-cache",
	RequireSignature:  false, // Disable for demo
	AllowedRegistries: []string{"nexus.example.com"},
	Timeout:           30,
	RetryAttempts:     3,
}

// Create client
_, err := NewOCIPluginClient(config)
if err != nil {
	panic(err)
}

// Parse OCI reference with explicit architecture
ref, params, err := ParseOCICommand("oci://nexus.example.com/plugins/ner@sha256:0123deadbeef456?arch=linux/amd64")
if err != nil {
	panic(err)
}

// This would fetch from the registry in a real scenario
fmt.Printf("Would fetch plugin: %s\n", ref.FullReference())
fmt.Printf("Target architecture: %s\n", params.Architecture)
Output:
Would fetch plugin: nexus.example.com/plugins/ner@sha256:0123deadbeef456
Target architecture: linux/amd64

func (*OCIPluginClient) GarbageCollect

func (c *OCIPluginClient) GarbageCollect(ctx context.Context, keepVersions int) error

GarbageCollect removes old plugin versions from cache

func (*OCIPluginClient) GetActivePlugin

func (c *OCIPluginClient) GetActivePlugin(name string) (string, error)

GetActivePlugin returns the path to the active version of a plugin

func (*OCIPluginClient) GetCacheSize

func (c *OCIPluginClient) GetCacheSize() (int64, error)

GetCacheSize returns the current size of the plugin cache

func (*OCIPluginClient) GetPlugin

func (c *OCIPluginClient) GetPlugin(ref *OCIReference, params *OCIPluginParams) (*LocalPlugin, error)

GetPlugin returns a local plugin if it exists in cache

func (*OCIPluginClient) HasPlugin

func (c *OCIPluginClient) HasPlugin(digest, arch string) bool

HasPlugin checks if a plugin exists in the cache

func (*OCIPluginClient) ListCached

func (c *OCIPluginClient) ListCached() ([]*LocalPlugin, error)

ListCached returns information about all cached plugins

func (*OCIPluginClient) ListCachedByArchitecture

func (c *OCIPluginClient) ListCachedByArchitecture(arch string) ([]*LocalPlugin, error)

ListCachedByArchitecture returns cached plugins filtered by architecture

func (*OCIPluginClient) ListCachedByRegistry

func (c *OCIPluginClient) ListCachedByRegistry(registry string) ([]*LocalPlugin, error)

ListCachedByRegistry returns cached plugins filtered by registry

func (*OCIPluginClient) SecurityService added in v2.3.0

func (c *OCIPluginClient) SecurityService() SecurityService

SecurityService returns the security service set with SetSecurityService, or nil if none was set.

func (*OCIPluginClient) SetActivePlugin

func (c *OCIPluginClient) SetActivePlugin(name string, ref *OCIReference, params *OCIPluginParams) error

SetActivePlugin creates a symlink to mark a plugin as the active version

func (*OCIPluginClient) SetSecurityService

func (c *OCIPluginClient) SetSecurityService(service SecurityService)

SetSecurityService sets the security service that verifies signatures. A client with signatures required and no security service refuses every fetch ("no signature verifier configured").

type OCIPluginParams

type OCIPluginParams struct {
	Architecture string `json:"architecture"` // linux/amd64, linux/arm64
	PublicKey    string `json:"public_key"`   // Key identifier or path
	AuthConfig   string `json:"auth_config"`  // Auth configuration name
}

OCIPluginParams represents parsed parameters from OCI command

type OCIReference

type OCIReference struct {
	Registry   string            `json:"registry"`   // nexus.example.com
	Repository string            `json:"repository"` // plugins/ner
	Digest     string            `json:"digest"`     // sha256:...
	Tag        string            `json:"tag"`        // optional, mainly for development
	Params     map[string]string `json:"params"`     // Query parameters

	// Exemption is the plugin's "Allow internal host" exemption
	// (netguard.CommandExemption): its registry may be an internal address.
	// Set by the caller that knows the plugin; never parsed from a command.
	Exemption netguard.Exemption `json:"-"`
}

OCIReference represents a parsed OCI reference

func NormalizeOCIReference

func NormalizeOCIReference(ref *OCIReference) *OCIReference

NormalizeOCIReference ensures consistent formatting of OCI references

func (*OCIReference) FullReference

func (r *OCIReference) FullReference() string

FullReference returns the complete OCI reference

Example

ExampleOCIReference_FullReference demonstrates reference formatting

// Reference with digest
ref1 := &OCIReference{
	Registry:   "registry.com",
	Repository: "plugins/test",
	Digest:     "sha256:abc123",
}
fmt.Printf("With digest: %s\n", ref1.FullReference())

// Reference with tag
ref2 := &OCIReference{
	Registry:   "registry.com",
	Repository: "plugins/test",
	Tag:        "v1.0.0",
}
fmt.Printf("With tag: %s\n", ref2.FullReference())

// Reference without digest or tag (defaults to latest)
ref3 := &OCIReference{
	Registry:   "registry.com",
	Repository: "plugins/test",
}
fmt.Printf("Default: %s\n", ref3.FullReference())
Output:
With digest: registry.com/plugins/test@sha256:abc123
With tag: registry.com/plugins/test:v1.0.0
Default: registry.com/plugins/test:latest

func (*OCIReference) FullRepo

func (r *OCIReference) FullRepo() string

FullRepo returns the full repository path (registry/repository)

type ORASFetcher

type ORASFetcher struct {
	// contains filtered or unexported fields
}

ORASFetcher handles OCI artifact fetching using oras-go

func NewORASFetcher

func NewORASFetcher(config *OCIConfig) (*ORASFetcher, error)

NewORASFetcher creates a new ORAS fetcher

func (*ORASFetcher) CheckExists

func (f *ORASFetcher) CheckExists(ctx context.Context, ref *OCIReference, params *OCIPluginParams) (bool, error)

CheckExists verifies if an artifact exists in the registry without downloading

func (*ORASFetcher) Pull

func (f *ORASFetcher) Pull(ctx context.Context, ref *OCIReference, params *OCIPluginParams) (*PullResult, error)

Pull fetches a plugin from an OCI registry and returns the resolved descriptor, platform manifest, config and binary data

func (*ORASFetcher) PullManifest

func (f *ORASFetcher) PullManifest(ctx context.Context, ref *OCIReference, params *OCIPluginParams) (*ocispec.Descriptor, *ocispec.Manifest, error)

PullManifest fetches just the manifest without downloading layers

type PluginConfig

type PluginConfig struct {
	Name           string   `json:"name"`
	Version        string   `json:"version"`
	PluginAPI      string   `json:"plugin_api"`
	OS             string   `json:"os"`
	Arch           string   `json:"arch"`
	LibC           string   `json:"libc,omitempty"`
	HostMinVersion string   `json:"host_min_version,omitempty"`
	Capabilities   []string `json:"capabilities,omitempty"`
	Notes          string   `json:"notes,omitempty"`
}

PluginConfig represents the configuration metadata stored in the OCI artifact

type PluginMetadata

type PluginMetadata struct {
	Reference    *OCIReference    `json:"reference"`
	Params       *OCIPluginParams `json:"params"`
	FetchTime    time.Time        `json:"fetch_time"`
	Config       *PluginConfig    `json:"config"`
	Verified     bool             `json:"verified"`
	Size         int64            `json:"size"`
	LastAccessed time.Time        `json:"last_accessed"`
	Version      string           `json:"version"` // From plugin config
	// BinarySHA256 is the hex SHA-256 of the executable as fetched. Loading
	// from the cache checks the file against it.
	BinarySHA256 string `json:"binary_sha256,omitempty"`
	// SignatureChecked records that the fetch ran the signature check
	// (signatures were required) and it passed. An entry cached without it
	// is fetched again once signatures are required.
	SignatureChecked bool `json:"signature_checked,omitempty"`
	// SignatureKey is the public key ID that verified the signature: the
	// key the command named, or else the configured default key that
	// verified it. "" is an entry cached by an earlier release for a
	// command naming no key, which was checked with the first default key.
	SignatureKey string `json:"signature_key,omitempty"`
	// SignedDigest is the digest whose signature verified: ResolvedDigest,
	// or ManifestDigest when only the platform manifest is signed. Set only
	// when signatures were enforced.
	SignedDigest string `json:"signed_digest,omitempty"`
	// ResolvedDigest is the top-level digest (index or manifest) the
	// reference resolved to. The cache key (Reference.Digest) is the
	// platform manifest for a multi-arch tag.
	ResolvedDigest string `json:"resolved_digest,omitempty"`
	// ManifestDigest is the platform manifest the binary was read from.
	ManifestDigest string `json:"manifest_digest,omitempty"`
}

PluginMetadata represents cached metadata about a plugin

type PullResult added in v2.3.0

type PullResult struct {
	// Resolved is the top-level descriptor the reference resolved to: the
	// image index for a multi-arch plugin, else the manifest. Its digest is
	// the one publish-plugin.sh signs, so signatures are checked against it.
	// The platform manifest is bound to it through the index's
	// content-addressed descriptor list.
	Resolved *ocispec.Descriptor
	// Manifest is the platform manifest the binary was read from (Resolved
	// itself for a single-platform plugin).
	Manifest *ocispec.Descriptor
	Config   *PluginConfig
	Binary   []byte
}

PullResult is what Pull fetched for a plugin reference.

type RegistryAuth

type RegistryAuth struct {
	Username            string `yaml:"username" json:"username"`
	PasswordEnv         string `yaml:"password_env" json:"password_env"`                 // Environment variable name
	Token               string `yaml:"token" json:"token"`                               // Direct token (less secure)
	TokenEnv            string `yaml:"token_env" json:"token_env"`                       // Token from environment
	Entitlement         string `yaml:"entitlement" json:"entitlement"`                   // Direct entitlement/bearer token
	EntitlementEnv      string `yaml:"entitlement_env" json:"entitlement_env"`           // Entitlement token from environment
	EntitlementUsername string `yaml:"entitlement_username" json:"entitlement_username"` // Username for entitlement auth (default: "token")
}

RegistryAuth holds authentication configuration for a specific registry

func LoadRegistryAuthForRegistry

func LoadRegistryAuthForRegistry(registryName string) *RegistryAuth

LoadRegistryAuthForRegistry loads authentication for a specific registry

type SecurityService

type SecurityService interface {
	VerifySignature(ctx context.Context, ref *OCIReference, pubKeyID string) error
	VerifyBundle(ctx context.Context, ref *OCIReference, issuer, subject string) error
	// Deprecated: cosign policy files are not supported by the in-process
	// verifier; use VerifySignature.
	VerifyWithPolicy(ctx context.Context, ref *OCIReference, policyPath string) error
}

SecurityService defines the interface for signature verification This allows the OCI client to use enterprise security features when available

type SignatureCapability added in v2.3.0

type SignatureCapability interface {
	VerifiesSignatures() bool
}

SignatureCapability is implemented by a SecurityService that may be unable to verify signatures. The Community Edition service reports false: its VerifySignature accepts everything, so the client still loads plugins when signatures are required but records them as unverified (Verified and SignatureChecked false), and an Enterprise build sharing the cache verifies them again.

Directories

Path Synopsis
Package ocitest provides an in-memory OCI distribution registry for tests that exercise the real ORAS fetcher (and signature verifiers) end to end.
Package ocitest provides an in-memory OCI distribution registry for tests that exercise the real ORAS fetcher (and signature verifiers) end to end.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL