clirelease

package
v0.7.47-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 16 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 CompareVersions added in v0.7.10

func CompareVersions(a, b string) (cmp int, ok bool)

CompareVersions orders two released CLI versions: -1 when a is older than b, 0 when they are the same, 1 when a is newer. A dev release comes before the release of its own number (0.7.10-dev.2 before 0.7.10). ok is false when either is not a released version.

func SumOf

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

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

func ValidVersion added in v0.7.10

func ValidVersion(v string) bool

ValidVersion says whether v is the shape of a released CLI version: x.y.z, or x.y.z-dev.n for a release of the dev line.

Types

type Binary

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

Binary is a release's Linux binary for one architecture, checked, with the signed sums and signature it was checked against, so that another machine can check it again.

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.

func Verify added in v0.7.10

func Verify(keys *KeySet, version, arch string, sums, sig, bin []byte) (*Binary, error)

Verify checks a release's Linux binary for arch: sig must be a current key's signature over sums naming the CLI at version, and bin must be the file sums gives for that architecture. 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