mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.
The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.
- internal/minisign: the one owner of signature checks (moved from
internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
none, or three distinct minisign keys, none the old key),
TestCheckReleaseKeys (fixture keys from minisigntest),
TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
none or all three of packaging/keys' release keys. With none,
install.sh's release_<role>_key lines are empty or missing; with all
three, each is a minisign key, distinct, not the old release key, not
marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
signature only when the script has its key), check_signature,
signed_by_two, check_legacy; plainer warning without minisign, with
the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
upgrade.txtar (-legacy, -keys, and the keys built in, none),
install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
(real minisign), release.txtar (none, nolines, nokeyline, old, marked
and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
releases/0.2.0.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
139 lines
5.1 KiB
Go
139 lines
5.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/devvmhq/devvm/internal/backend/registry"
|
|
"github.com/devvmhq/devvm/internal/platform"
|
|
"github.com/devvmhq/devvm/internal/testbuild"
|
|
)
|
|
|
|
// Overrides are the stand-ins the tests put in a test build's
|
|
// environment, in place of what devvm would find on this machine:
|
|
// the backends' (registry.Overrides) and the host's mise, and the way
|
|
// the CLI tests answer questions. readOverrides is the only place devvm
|
|
// reads them, and only a test build (testbuild.On) does: a release has
|
|
// none, whatever its environment says. A run reads them once, through
|
|
// its app.
|
|
type Overrides struct {
|
|
registry.Overrides
|
|
// HostMise (DEVVM_HOST_MISE) stands in for devvm's pinned mise.
|
|
HostMise string
|
|
// ToolSlots (DEVVM_TOOL_SLOTS) is the most tool images that build side
|
|
// by side (tools.Env.MaxSlots), in place of backend.MaxToolSlots.
|
|
ToolSlots int
|
|
// PipedAnswers (DEVVM_PIPED_ANSWERS=1) answers questions from input
|
|
// that isn't a terminal, a line each (ui.Flags), where devvm would
|
|
// refuse them.
|
|
PipedAnswers bool
|
|
// PickOnPipe (DEVVM_PICK_ON_PIPE=1) shows the picker with a terminal
|
|
// on stdin alone (ui.Flags), as testscript's ttyin gives.
|
|
PickOnPipe bool
|
|
// Release is devvm upgrade's release source and this devvm's version.
|
|
Release ReleaseOverrides
|
|
// HistoryMax (DEVVM_HISTORY_MAX) is the most of an export of agents'
|
|
// history devvm keeps, in bytes (vm.Env.HistoryMax), in place of 2 GiB.
|
|
HistoryMax int
|
|
// ClipTools (DEVVM_CLIP_TOOLS) is the folder devvm paste runs the
|
|
// clipboard tools from (platform.Clipboard's Tools), in place of the
|
|
// system's, so the tests' stand-ins never reach the real clipboard.
|
|
ClipTools string
|
|
// PasteWait (DEVVM_PASTE_WAIT) is how long devvm paste waits for
|
|
// paste.sh in the VM, in seconds (vm.Env.PasteWait), in place of 10
|
|
// minutes for a write and 2 for a count or a delete.
|
|
PasteWait int
|
|
// Volume (DEVVM_VOLUME) is the volume every folder is on, "uuid:…",
|
|
// in place of diskutil's answer (vm.Env.Volumes); "fail" makes each
|
|
// lookup fail.
|
|
Volume string
|
|
// LockOrder, in every test build, checks the order the state's
|
|
// locks are taken in (state.CheckLockOrder), and that every lock's
|
|
// wait shows (platform.CheckWaiting).
|
|
LockOrder bool
|
|
}
|
|
|
|
// ReleaseOverrides are devvm upgrade's stand-ins: a fake release server
|
|
// in place of GitHub's, which a CA of the test's own signs, a test key in
|
|
// place of the release key, and a release's version in place of a test
|
|
// build's own.
|
|
type ReleaseOverrides struct {
|
|
// URL (DEVVM_REPO_URL) is the repository whose releases are read, as
|
|
// install.sh takes it.
|
|
URL string
|
|
// Key (DEVVM_RELEASE_KEY) is the old release key's minisign public
|
|
// key, which releases are also checked against while they bridge from
|
|
// it.
|
|
Key string
|
|
// Keys (DEVVM_RELEASE_KEYS) are the release keys' minisign public
|
|
// keys, two of which sign each release, as ROLE=KEY words, such as
|
|
// ci=RW… cosign=RW… recovery=RW… (releaseKeys).
|
|
Keys string
|
|
// CA (DEVVM_RELEASE_CA) is a PEM file of the CA the release server's
|
|
// certificate is signed by.
|
|
CA string
|
|
// Version (DEVVM_TEST_VERSION) is the version this devvm says it is.
|
|
Version string
|
|
}
|
|
|
|
// readOverrides reads a test build's overrides with getenv; a release's
|
|
// are empty. A number that isn't one fails, naming its variable, rather
|
|
// than reading as 0, which would leave the test on devvm's own value.
|
|
func readOverrides(getenv func(string) string) (Overrides, error) {
|
|
if !testbuild.On() {
|
|
return Overrides{}, nil
|
|
}
|
|
number := func(name string) (int, error) {
|
|
v := getenv(name)
|
|
if v == "" {
|
|
return 0, nil
|
|
}
|
|
n, err := strconv.Atoi(v)
|
|
if err != nil {
|
|
return 0, fmt.Errorf("%s: %w", name, err)
|
|
}
|
|
return n, nil
|
|
}
|
|
historyMax, err := number("DEVVM_HISTORY_MAX")
|
|
if err != nil {
|
|
return Overrides{}, err
|
|
}
|
|
pasteWait, err := number("DEVVM_PASTE_WAIT")
|
|
if err != nil {
|
|
return Overrides{}, err
|
|
}
|
|
toolSlots, err := number("DEVVM_TOOL_SLOTS")
|
|
if err != nil {
|
|
return Overrides{}, err
|
|
}
|
|
return Overrides{
|
|
Overrides: registry.Overrides{
|
|
Host: platform.Overrides{
|
|
CPUs: getenv(platform.TestCPUs), MemoryGiB: getenv(platform.TestMemoryGiB),
|
|
FreeGiB: getenv(platform.TestFreeGiB), ListTimeout: getenv(platform.TestListWait),
|
|
},
|
|
Unreviewed: getenv("DEVVM_UNREVIEWED"),
|
|
KVM: getenv("DEVVM_KVM"),
|
|
UbuntuURL: getenv("DEVVM_UBUNTU_URL"),
|
|
UbuntuRelease: getenv("DEVVM_UBUNTU_RELEASE"),
|
|
LimaTemplates: getenv("DEVVM_LIMA_TEMPLATES"),
|
|
Pins: getenv("DEVVM_PINS"),
|
|
SSHPorts: getenv("DEVVM_SSH_PORTS"),
|
|
PortRange: getenv("DEVVM_PORT_RANGE"),
|
|
},
|
|
HostMise: getenv("DEVVM_HOST_MISE"),
|
|
ToolSlots: toolSlots,
|
|
PipedAnswers: getenv("DEVVM_PIPED_ANSWERS") == "1",
|
|
PickOnPipe: getenv("DEVVM_PICK_ON_PIPE") == "1",
|
|
Release: ReleaseOverrides{
|
|
URL: getenv("DEVVM_REPO_URL"), Key: getenv("DEVVM_RELEASE_KEY"), Keys: getenv("DEVVM_RELEASE_KEYS"),
|
|
CA: getenv("DEVVM_RELEASE_CA"), Version: getenv("DEVVM_TEST_VERSION"),
|
|
},
|
|
HistoryMax: historyMax,
|
|
Volume: getenv("DEVVM_VOLUME"),
|
|
ClipTools: getenv("DEVVM_CLIP_TOOLS"),
|
|
PasteWait: pasteWait,
|
|
LockOrder: true,
|
|
}, nil
|
|
}
|