clirelease

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package clirelease decides whether a CLI binary is one of Agentry's signed releases: SHA256SUMS signed with an update-signing key this build carries, a signed trusted comment naming the product and the version, and the binary's own line in those sums. A remote runhost runs only such a binary, so a release this package refuses never reaches a server.

The key set is embedded, never read from disk: a file beside the binary is one an attacker who can write there could replace. A build from source carries an empty set and verifies nothing.

Index

Constants

View Source
const Product = "agentry-cli"

Product is the name the signed trusted comment gives the CLI.

Variables

View Source
var (
	// ErrNoKeys means this build carries no update-signing key.
	ErrNoKeys = errors.New("this build carries no update-signing key, so it can verify no CLI release (a build from source cannot set up a remote runhost; use a release of the CLI)")
	// ErrUnknownKey means the signature names a key this build does not trust.
	ErrUnknownKey = errors.New("the release is signed with a key this build does not trust")
	// ErrBadSignature means the signature does not cover the bytes given.
	ErrBadSignature = errors.New("the release's signature does not match its SHA256SUMS")
	// ErrRetiredKey means the release is genuine but its key is retired, so
	// nothing is installed from it.
	ErrRetiredKey = errors.New("the release is signed with a retired key")
)
View Source
var BaseURL = "https://github.com/blaktron/agentry-cli/releases/download"

BaseURL is where releases are downloaded from: the CLI's public releases.

Functions

func BinaryName

func BinaryName(version, arch string) string

BinaryName is a release's Linux binary for an architecture (amd64, arm64).

func SumOf

func SumOf(sums []byte, file string) (string, error)

SumOf is the SHA-256 that sums gives file, in hex.

Types

type Binary

type Binary struct {
	Version string
	Arch    string
	Name    string
	Bytes   []byte
	SHA256  string
}

Binary is a release's Linux binary for one architecture, checked.

func Fetch

func Fetch(ctx context.Context, client *http.Client, keys *KeySet, version, arch string) (*Binary, error)

Fetch downloads the release version's Linux binary for arch and checks it: the signature over SHA256SUMS against keys, then the binary's hash against its signed line. Nothing it returns is unchecked.

type KeyEntry

type KeyEntry struct {
	Name      string `json:"name"`
	PublicKey string `json:"publicKey"`
	KeyID     string `json:"keyID"`
	Retired   bool   `json:"retired"`
}

KeyEntry is one key in keys.json.

type KeySet

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

KeySet is the set of keys a release may be signed with.

func Carried

func Carried() (*KeySet, error)

Carried is the key set this build embeds.

func ParseKeys

func ParseKeys(data []byte) (*KeySet, error)

ParseKeys reads a keys.json. An entry whose stated id is not its public key's id is refused, as is a repeated name or id.

func (*KeySet) Empty

func (s *KeySet) Empty() bool

Empty says whether the set holds no key, so verifies nothing.

func (*KeySet) VerifySums

func (s *KeySet) VerifySums(sums, sig []byte, product, version string) error

VerifySums checks that sig is a current key's signature over sums and that its signed comment names product at version. The signature is checked against each key in turn, never chosen by the key id it claims, which is unsigned.

Jump to

Keyboard shortcuts

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