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 ¶
const Product = "agentry-cli"
Product is the name the signed trusted comment gives the CLI.
Variables ¶
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") )
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 ¶
BinaryName is a release's Linux binary for an architecture (amd64, arm64).
func CompareVersions ¶ added in v0.7.10
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 ValidVersion ¶ added in v0.7.10
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.
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 ParseKeys ¶
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) VerifySums ¶
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.