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]>
80 lines
2.8 KiB
Go
80 lines
2.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/devvmhq/devvm/internal/backend"
|
|
"github.com/devvmhq/devvm/internal/backend/lima"
|
|
"github.com/devvmhq/devvm/internal/minisign"
|
|
"github.com/devvmhq/devvm/internal/platform"
|
|
"github.com/devvmhq/devvm/internal/testbuild"
|
|
"github.com/devvmhq/devvm/internal/upgrade"
|
|
"github.com/devvmhq/devvm/packaging"
|
|
)
|
|
|
|
// A release, as this test binary is (built without the test build's
|
|
// flag), reads none of the test overrides, whatever its environment
|
|
// says: its mise is the pinned one, its backends check the real
|
|
// /dev/kvm and its host is this machine. The CLI tests' test build reads
|
|
// them all (the scripts).
|
|
func TestReleaseReadsNoOverrides(t *testing.T) {
|
|
if testbuild.On() {
|
|
t.Skip("a test build")
|
|
}
|
|
if o, err := readOverrides(func(string) string { return "/x" }); o != (Overrides{}) || err != nil {
|
|
t.Errorf("readOverrides = %+v, %v", o, err)
|
|
}
|
|
for _, k := range []string{
|
|
"DEVVM_HOST_MISE", "DEVVM_KVM", "DEVVM_UBUNTU_URL", "DEVVM_UNREVIEWED",
|
|
"DEVVM_REPO_URL", "DEVVM_RELEASE_KEY", "DEVVM_RELEASE_KEYS", "DEVVM_RELEASE_CA", "DEVVM_TEST_VERSION", "DEVVM_HISTORY_MAX", "DEVVM_TOOL_SLOTS", "DEVVM_LIMA_TEMPLATES",
|
|
platform.TestCPUs, platform.TestMemoryGiB, platform.TestFreeGiB, platform.TestListWait,
|
|
} {
|
|
t.Setenv(k, "1")
|
|
}
|
|
t.Setenv("XDG_DATA_HOME", t.TempDir())
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
t.Setenv("DEVVM_LIMA_HOME", t.TempDir())
|
|
u, _, _ := testUI()
|
|
a := newApp(u)
|
|
tl, err := a.tools()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if tl.Mise != "" || tl.MaxSlots != 0 {
|
|
t.Errorf("mise = %q, slots %d", tl.Mise, tl.MaxSlots)
|
|
}
|
|
r, err := a.registry()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
b, _ := r.Lookup("lima")
|
|
if l, _ := backend.As[*lima.Lima](b); l.KVM != "/dev/kvm" || len(r.Unreviewed) != 0 || l.Templates() == "1" {
|
|
t.Errorf("KVM %q, let through %v, templates %q", l.KVM, r.Unreviewed, l.Templates())
|
|
}
|
|
if got, want := a.host().CPUs(), (platform.Host{}).CPUs(); got != want {
|
|
t.Errorf("the host's CPUs = %d, want %d", got, want)
|
|
}
|
|
// devvm upgrade's releases are GitHub's, checked with the keys built in.
|
|
up, err := a.upgrader()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if up.Source.URL != upgrade.Repo || up.Source.Key != packaging.MinisignKey() || up.Current != devvmVersion() {
|
|
t.Errorf("upgrade's source %q, key %q, version %q", up.Source.URL, up.Source.Key, up.Current)
|
|
}
|
|
// The release keys are keys/'s: none until they're made, or all three.
|
|
have := 0
|
|
for _, r := range minisign.Roles() {
|
|
want := packaging.Key(minisign.KeyFile(minisign.Release, r))
|
|
if want != "" {
|
|
have++
|
|
}
|
|
if k, ok := up.Source.Keys[r]; k != want || ok != (want != "") {
|
|
t.Errorf("upgrade's %s key %q, want keys/'s %q", r, k, want)
|
|
}
|
|
}
|
|
if have != 0 && have != len(minisign.Roles()) {
|
|
t.Errorf("%d of the release keys built in", have)
|
|
}
|
|
}
|