upgrade

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package upgrade downloads plexd release binaries from the GitHub release channel and verifies their Sigstore bundles before they are trusted.

Index

Constants

View Source
const DefaultReleaseBaseURL = "https://github.com/plexsphere/plexd/releases/download"

DefaultReleaseBaseURL is the base URL of the GitHub release download channel.

View Source
const DefaultSigningIdentityRegexp = `^https://github\.com/plexsphere/plexd/\.github/workflows/release\.yml@refs/tags/v.+$`

DefaultSigningIdentityRegexp is the certificate SAN regexp that a release bundle's signing identity must match: the plexd release workflow signed for a tagged version.

View Source
const DefaultSigningIssuer = "https://token.actions.githubusercontent.com"

DefaultSigningIssuer is the expected OIDC issuer of the signing certificate.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ReleaseBaseURL is the base URL of the GitHub release download channel.
	// Release assets are fetched from {ReleaseBaseURL}/{tag}/{asset}.
	// Default: https://github.com/plexsphere/plexd/releases/download
	ReleaseBaseURL string `yaml:"release_base_url"`

	// SigningIdentityRegexp is the regexp the signing certificate's SAN must
	// match. It is compiled by Validate.
	// Default: ^https://github\.com/plexsphere/plexd/\.github/workflows/release\.yml@refs/tags/v.+$
	SigningIdentityRegexp string `yaml:"signing_identity_regexp"`

	// SigningIssuer is the exact OIDC issuer the signing certificate must carry.
	// Default: https://token.actions.githubusercontent.com
	SigningIssuer string `yaml:"signing_issuer"`

	// TrustedRootPath is the path to a Sigstore trusted root JSON file. When
	// empty the embedded public-good trusted root is used.
	// Default: "" (use the embedded trusted root)
	TrustedRootPath string `yaml:"trusted_root_path"`
}

Config holds the configuration for release download and Sigstore verification.

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults()

ApplyDefaults sets default values for empty fields. TrustedRootPath is left empty by design so the embedded trusted root remains the default.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that the configuration is usable. It compiles SigningIdentityRegexp so a malformed pattern is rejected before verification.

type Fetcher

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

Fetcher downloads plexd release assets from the GitHub release channel.

func NewFetcher

func NewFetcher(cfg Config) *Fetcher

NewFetcher creates a Fetcher for the given configuration.

func (*Fetcher) FetchBinary

func (f *Fetcher) FetchBinary(ctx context.Context, version string) (io.ReadCloser, error)

FetchBinary downloads the plexd binary for the given version and returns its body, capped at maxBinaryBytes so a hostile mirror cannot fill the disk before the checksum is verified. The caller must close the returned reader.

func (*Fetcher) FetchBundle

func (f *Fetcher) FetchBundle(ctx context.Context, version string) ([]byte, error)

FetchBundle downloads the Sigstore bundle for the given version. The body is read through an io.LimitReader capped at maxBundleBytes.

type Verifier

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

Verifier checks a plexd release Sigstore bundle against a trusted root and a required signing identity. It performs no network I/O.

func NewVerifier

func NewVerifier(cfg Config) (*Verifier, error)

NewVerifier builds a Verifier from the given configuration. The trusted root is read from cfg.TrustedRootPath when set, otherwise the embedded public-good root is used. The signing-identity regexp is compiled here so a malformed pattern is rejected at construction.

func (*Verifier) Verify

func (v *Verifier) Verify(bundleJSON []byte, sha256Hex string) error

Verify checks that bundleJSON is a valid Sigstore bundle for an artifact with the given hex-encoded SHA-256 digest, signed by the configured identity and chaining to the trusted root. Any failure (unparsable bundle, digest or identity mismatch, untrusted chain) is returned as a wrapped error rather than a panic.

Jump to

Keyboard shortcuts

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