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]>
235 lines
8.9 KiB
Plaintext
235 lines
8.9 KiB
Plaintext
# devvm upgrade installs the newest release the way this devvm was
|
|
# installed: install.sh's over its link, checked against the release key,
|
|
# Homebrew's with brew upgrade devvm, asking first; any other it can't.
|
|
# The release server is a fake one (release_server), and this devvm says
|
|
# it's 0.1.0.
|
|
env DEVVM_TEST_VERSION=0.1.0
|
|
chmod 0755 brews/brew
|
|
|
|
# Its flags are checked before anything runs.
|
|
! exec devvm upgrade --to latest
|
|
stderr '^devvm: upgrade_not_version value=latest\n'
|
|
! exec devvm upgrade --check --force
|
|
stderr 'usage_help command=devvm upgrade'
|
|
! exec devvm upgrade nope
|
|
stderr 'usage_help command=devvm upgrade'
|
|
|
|
# A copy that neither install.sh nor Homebrew made: --check says what's
|
|
# out, and devvm upgrade can't upgrade it.
|
|
release_server 0.2.0 0.1.0
|
|
exec devvm upgrade --check
|
|
stdout '^==> upgrade_latest_is latest=0.2.0\n==> upgrade_other_install path=\S+/devvm\n\z'
|
|
! exec devvm upgrade --force
|
|
stderr '^devvm: upgrade_other_install path=\S+/devvm$'
|
|
|
|
# A build from the source, which says no release's version.
|
|
env DEVVM_TEST_VERSION=
|
|
! exec devvm upgrade --force
|
|
stderr '^devvm: upgrade_checkout_build version=\S+$'
|
|
env DEVVM_TEST_VERSION=0.1.0
|
|
|
|
# install.sh's: ~/.local/lib/devvm/0.1.0/devvm, which bin/devvm links to.
|
|
mkdir pfx/lib/devvm/0.1.0 pfx/bin
|
|
cp_exe $DEVVM_BIN/devvm pfx/lib/devvm/0.1.0/devvm
|
|
symlink pfx/bin/devvm -> $WORK/pfx/lib/devvm/0.1.0/devvm
|
|
|
|
# No newest release where it looks, and a release not signed by devvm's own keys, the ones built in:
|
|
# nothing installed. A key that isn't one is no key.
|
|
env REPO=$DEVVM_REPO_URL
|
|
env DEVVM_REPO_URL=$REPO/nope
|
|
! exec pfx/bin/devvm upgrade --check
|
|
stderr '^devvm: upgrade_no_latest url=\S+/nope$'
|
|
env DEVVM_REPO_URL=$REPO
|
|
env KEY=$DEVVM_RELEASE_KEY
|
|
env KEYS=$DEVVM_RELEASE_KEYS
|
|
env DEVVM_RELEASE_KEY=
|
|
env DEVVM_RELEASE_KEYS=
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_bad_signature version=0\.2\.0'
|
|
env DEVVM_RELEASE_KEY=not-a-minisign-key
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_no_key'
|
|
env DEVVM_RELEASE_KEY=$KEY
|
|
env DEVVM_RELEASE_KEYS='ci=nope cosign=nope recovery=nope'
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_no_key'
|
|
env DEVVM_RELEASE_KEYS=$KEYS
|
|
! exists pfx/lib/devvm/0.2.0
|
|
|
|
# Answered no: nothing installed.
|
|
env DEVVM_PIPED_ANSWERS=1
|
|
stdin no.txt
|
|
exec pfx/bin/devvm upgrade
|
|
env DEVVM_PIPED_ANSWERS=
|
|
stdout '^==> upgrade_nothing_installed\n\z'
|
|
! exists pfx/lib/devvm/0.2.0
|
|
exec pfx/bin/devvm upgrade --check
|
|
stdout '^==> upgrade_available current=0.1.0 latest=0.2.0\n\z'
|
|
exec pfx/bin/devvm upgrade --json
|
|
stdout '^{\n "version": 1,\n "current": "0.1.0",\n "latest": "0.2.0",\n "newer": true,\n "install": "install.sh",\n "path": "\S+/pfx/lib/devvm/0.1.0/devvm"\n}\n\z'
|
|
! stderr .
|
|
|
|
# Without a terminal it asks, and refuses naming --force: nothing changes.
|
|
! exec pfx/bin/devvm upgrade
|
|
stderr '^upgrade_confirm current=0.1.0 version=0.2.0\ndevvm: no_input answer=--force$'
|
|
exists pfx/lib/devvm/0.1.0/devvm
|
|
! exists pfx/lib/devvm/0.2.0
|
|
|
|
# A release whose SHA256SUMS other keys signed is refused, and so is one
|
|
# that only an old release key signed, when it isn't this devvm's.
|
|
release_server -badsig 0.2.0
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_bad_signature version=0.2.0$'
|
|
! exists pfx/lib/devvm/0.2.0
|
|
exec pfx/bin/devvm upgrade --check
|
|
stdout upgrade_available
|
|
release_server -legacy 0.2.0
|
|
env DEVVM_RELEASE_KEY=
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_bad_signature version=0.2.0$'
|
|
! exists pfx/lib/devvm/0.2.0
|
|
|
|
# With the release keys built in, a release that only this test's release
|
|
# keys signed is refused. While devvm has none built in, it's refused for
|
|
# want of the old release key's signature; once it has them, because
|
|
# they aren't this test's. TestFetchWithoutReleaseKeys pins the first.
|
|
release_server -keys 0.2.0
|
|
env DEVVM_RELEASE_KEYS=
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_(download_failed|bad_signature) '
|
|
! exists pfx/lib/devvm/0.2.0
|
|
|
|
# Answered yes: 0.2.0 beside 0.1.0, the link switched to it. Its
|
|
# release is signed as 0.1 and 0.2's are, by the old release key alone,
|
|
# which devvm still checks, with the release keys built in.
|
|
release_server -legacy 0.2.0 0.1.0
|
|
env DEVVM_RELEASE_KEYS=
|
|
env DEVVM_PIPED_ANSWERS=1
|
|
stdin yes.txt
|
|
exec pfx/bin/devvm upgrade
|
|
env DEVVM_PIPED_ANSWERS=
|
|
stdout '^==> upgrade_done link=\S+/pfx/bin/devvm version=0.2.0\n\z'
|
|
exec pfx/bin/devvm --version
|
|
stdout '^0.2.0$'
|
|
exists pfx/lib/devvm/0.1.0/devvm pfx/lib/devvm/0.2.0/README.md
|
|
|
|
# From 0.2.0, which the release server's newest is: nothing to do; an
|
|
# older newest release is refused, and --to installs it.
|
|
env DEVVM_TEST_VERSION=0.2.0
|
|
exec pfx/lib/devvm/0.1.0/devvm upgrade --check
|
|
stdout '^==> upgrade_latest_is latest=0.2.0\n==> upgrade_other_install path=\S+/0.1.0/devvm\n\z'
|
|
cp_exe $DEVVM_BIN/devvm pfx/lib/devvm/0.2.0/devvm
|
|
exec pfx/bin/devvm upgrade --force
|
|
stdout '^==> upgrade_already_latest version=0.2.0\n\z'
|
|
# This 0.1.0's release is signed as releases are once they no longer
|
|
# bridge from the old release key, by the release keys alone.
|
|
release_server -keys 0.1.0
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_latest_older current=0.2.0 latest=0.1.0$'
|
|
exec pfx/bin/devvm upgrade --to 0.2.0
|
|
stdout '^==> upgrade_already version=0.2.0\n\z'
|
|
env DEVVM_PIPED_ANSWERS=1
|
|
stdin yes.txt
|
|
exec pfx/bin/devvm upgrade --to v0.1.0
|
|
env DEVVM_PIPED_ANSWERS=
|
|
stdout '^==> upgrade_done link=\S+/pfx/bin/devvm version=0.1.0\n'
|
|
exec pfx/bin/devvm --version
|
|
stdout '^0.1.0$'
|
|
|
|
# Prereleases: the newest release is never one, so from 0.2.0 there's
|
|
# nothing newer, and only --to installs 0.3.0-rc.1.
|
|
env DEVVM_TEST_VERSION=0.2.0
|
|
cp_exe $DEVVM_BIN/devvm pfx/lib/devvm/0.1.0/devvm
|
|
release_server 0.2.0 0.3.0-rc.1
|
|
exec pfx/bin/devvm upgrade --check
|
|
stdout '^==> upgrade_already_latest version=0.2.0\n\z'
|
|
env DEVVM_PIPED_ANSWERS=1
|
|
stdin yes.txt
|
|
exec pfx/bin/devvm upgrade --to v0.3.0-rc.1
|
|
env DEVVM_PIPED_ANSWERS=
|
|
stdout '^==> upgrade_done link=\S+/pfx/bin/devvm version=0.3.0-rc.1\n'
|
|
exec pfx/bin/devvm --version
|
|
stdout '^0.3.0-rc.1$'
|
|
|
|
# On 0.3.0-rc.1 before 0.3.0 is out, the newest release is older: said,
|
|
# and nothing installed, without a failure.
|
|
env DEVVM_TEST_VERSION=0.3.0-rc.1
|
|
cp_exe $DEVVM_BIN/devvm pfx/lib/devvm/0.3.0-rc.1/devvm
|
|
exec pfx/bin/devvm upgrade --force
|
|
stdout '^==> upgrade_prerelease_ahead current=0.3.0-rc.1 latest=0.2.0\n\z'
|
|
exec pfx/bin/devvm upgrade --check
|
|
stdout '^==> upgrade_prerelease_ahead current=0.3.0-rc.1 latest=0.2.0\n\z'
|
|
exec pfx/bin/devvm upgrade --json
|
|
stdout '"newer": false'
|
|
|
|
# Once 0.3.0 is out it's offered, never the newer prerelease 0.3.0-rc.2,
|
|
# and it replaces the prerelease.
|
|
release_server 0.3.0 0.3.0-rc.2
|
|
exec pfx/bin/devvm upgrade --check
|
|
stdout '^==> upgrade_available current=0.3.0-rc.1 latest=0.3.0\n\z'
|
|
exec pfx/bin/devvm upgrade --force
|
|
stdout '^==> upgrade_done link=\S+/pfx/bin/devvm version=0.3.0\n'
|
|
exec pfx/bin/devvm --version
|
|
stdout '^0.3.0$'
|
|
|
|
# A prerelease where only a release belongs, at releases/latest, is
|
|
# refused.
|
|
env DEVVM_TEST_VERSION=0.3.0
|
|
cp_exe $DEVVM_BIN/devvm pfx/lib/devvm/0.3.0/devvm
|
|
release_server 0.4.0-rc.1
|
|
! exec pfx/bin/devvm upgrade --force
|
|
stderr '^devvm: upgrade_no_latest url=\S+$'
|
|
! exists pfx/lib/devvm/0.4.0-rc.1
|
|
|
|
# Homebrew's: brew upgrade devvm, asked first, and never --to.
|
|
env DEVVM_TEST_VERSION=0.1.0
|
|
release_server 0.2.0
|
|
mkdir Cellar/devvm/0.1.0/bin
|
|
cp_exe $DEVVM_BIN/devvm Cellar/devvm/0.1.0/bin/devvm
|
|
env PATH=$WORK/brews${:}$PATH
|
|
! exec Cellar/devvm/0.1.0/bin/devvm upgrade
|
|
stderr '^upgrade_confirm_brew current=0.1.0 formula=devvm version=0.2.0\ndevvm: no_input answer=--force$'
|
|
! exec Cellar/devvm/0.1.0/bin/devvm upgrade --to 0.2.0 --force
|
|
stderr '^devvm: upgrade_brew_version$'
|
|
! exists brew-calls
|
|
exec Cellar/devvm/0.1.0/bin/devvm upgrade --force
|
|
stdout '^==> upgrade_brew_done\n\z'
|
|
grep '^upgrade devvm$' brew-calls
|
|
exec Cellar/devvm/0.1.0/bin/devvm upgrade --json
|
|
stdout '"install": "homebrew"'
|
|
|
|
# Homebrew's devvm-rc, which follows prereleases: its newest release is
|
|
# the newest prerelease or release, which brew upgrade devvm-rc installs,
|
|
# asked first, and never --to.
|
|
env DEVVM_TEST_VERSION=0.2.0-rc.1
|
|
release_server 0.1.0 0.2.0-rc.2 0.2.0-rc.1
|
|
mkdir Cellar/devvm-rc/0.2.0-rc.1/bin
|
|
cp_exe $DEVVM_BIN/devvm Cellar/devvm-rc/0.2.0-rc.1/bin/devvm
|
|
env RC=$WORK/Cellar/devvm-rc/0.2.0-rc.1/bin/devvm
|
|
exec $RC upgrade --check
|
|
stdout '^==> upgrade_available_prerelease current=0.2.0-rc.1 latest=0.2.0-rc.2\n\z'
|
|
! exec $RC upgrade
|
|
stderr '^upgrade_confirm_brew current=0.2.0-rc.1 formula=devvm-rc version=0.2.0-rc.2\ndevvm: no_input answer=--force$'
|
|
! exec $RC upgrade --to 0.2.0-rc.2 --force
|
|
stderr '^devvm: upgrade_brew_version$'
|
|
rm brew-calls
|
|
exec $RC upgrade --force
|
|
stdout '^==> upgrade_brew_done\n\z'
|
|
grep '^upgrade devvm-rc$' brew-calls
|
|
|
|
# Once the release is out, it's the newest.
|
|
release_server 0.2.0 0.2.0-rc.2 0.2.0-rc.1
|
|
exec $RC upgrade --check
|
|
stdout '^==> upgrade_available current=0.2.0-rc.1 latest=0.2.0\n\z'
|
|
exec $RC upgrade --json
|
|
stdout '"latest": "0.2.0"'
|
|
stdout '"install": "homebrew"'
|
|
|
|
-- yes.txt --
|
|
y
|
|
-- no.txt --
|
|
n
|
|
-- brews/brew --
|
|
#!/bin/sh
|
|
echo "$@" >> "$WORK/brew-calls"
|