mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
df1d76bbd9 |
fix(desktop): devvm desktop's relay goes on after an accept error
devvm desktop's relay returned at any error from its listener's Accept, so running out of open files in a burst (EMFILE) ended devvm desktop. It now waits and tries again, as devvm's other accept loops do, with their one owner, daemon.AcceptRetry: 5 ms, doubling up to a second, logging only the first error of a run, and it still ends with its context or its listener's close. - internal/desktop/relay.go: Serve uses daemon.AcceptRetry. - Tests: TestRelayAcceptRetries (a listener that fails three Accepts with EMFILE, then carries a viewer; the run logged once). - Docs: processes' desktop relay, structure's internal/daemon row; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a7cc12521e |
test(fuzz): fuzz targets with properties, fuzzed nightly
Twenty-three new fuzz targets, built-in Go fuzzing, each checking a property rather than only that nothing panics: parsers of what a VM or the network sends fail closed and keep to their caps, a secret goes only where it's bound, and no planted secret survives a redaction. - internal/proxy: FuzzCursorFrames (passes only what came; no message over frameMax or holding a JWT's start, decompressed and unescaped), FuzzInject (a binding's value only to a host it names, judged apart from the matcher in NormHost's form, for its path and methods, in its own header, which held the exact placeholder once; other headers untouched), FuzzParseBindings, FuzzLinkList, FuzzParseUpstream (errors hold no more of the URL than its scheme), FuzzNoProxy, FuzzParseNarinfo (only cache.nixos.org-1's signed narinfo is taken). - internal/agentlogin: FuzzParseTokenRequest, FuzzRedact (secrets planted eight ways in JSON and TOML settings), FuzzCapture (the VM's reply holds none of the endpoint's tokens). - internal/redact: FuzzSplit (a password written in parts through Split, as the run log writes it, never survives). - internal/jsonc: FuzzStrip, differential against encoding/json. - internal/upgrade: FuzzParsePublicKey, FuzzVerify, FuzzEntryName, FuzzUnpack. - internal/vmssh: FuzzParseHostKeys, FuzzParsePorts. - internal/vm: FuzzParseCloneState, FuzzParseInit, FuzzParseKept, FuzzParseLFSPointer. - internal/desktop: FuzzHandshakeVM. What they found, each fixed with a regression test: - NO_PROXY: an entry with port 0 (git.test:0) was read as the host on every port, and git.test:080 or :+80 as port 80, which Go's clients match against nothing; an entry whose port no request has, or that isn't plain decimal, now matches nothing (TestNoProxy, testdata/fuzz/FuzzNoProxy). FuzzHostSites' NO_PROXY site allows this difference from its frozen copy, and the design note lists it. - A JSON token request with more after its object was judged by its first object; it's refused now (TestCaptureRefuses). The Fuzz workflow runs nightly rather than two minutes weekly: five minutes a target, eight at a time, each target's corpus restored from and saved to a cache of its own (a failing input added to it, so it fails nightly until fixed), new inputs minimized in at most 1,000 runs, and one issue, "Fuzzing found failing inputs", opened, commented on when the failing targets change and closed on a clean night, by a separate job with issues: write that runs no repo code, on main alone. Target names must be unique across packages. bump.sh moves an action in a folder of its repo (actions/cache/restore, /save) with its repo's releases. Docs: Contributing's Fuzzing (running a target, the nightly run, every target's property), Maintaining's Fuzzing failures and its actions bump, the proxy README, the NO_PROXY and token request facts in How it works' network page and the design note. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cc94465400 |
test(leaktest): goroutine leak checks, and the leaks they found
A new internal/leaktest, standard library only, so the proxy's and the daemon's tests use it too (depguard's proxy rule allows it, and the structure test holds it to tests and to importing nothing of devvm's): - leaktest.Main(m), in TestMain: once the tests pass, every goroutine's stack (runtime.Stack), a settle of 5 s, then a failure naming those still running, but the standard library's own that outlive every test (allowed: signal.Notify's loop, an HTTP client's idle connections); then Go 1.27's goroutineleak profile, which fails on any goroutine blocked for good. - leaktest.Check(t), first in a test: its own goroutines, followed by parent through those still running, and by which ran before it, never by ID (each thread takes a batch of IDs). Main runs in proxy, vmssh, daemon, desktop, ui, vm, backend/lima, platform, cli and gitprotect (main_test.go, or the TestMain they had). Check runs in TestLinksEndStuckRelays (replacing its NumGoroutine count), TestForwarder, the desktop relay's serve helper, TestRunChild, TestPinWaits, and the proxy's new close tests. The structure test's goroutines rule (internal/structure/goroutines_test.go): goroutineSites lists every function outside tests that starts a goroutine, with a go statement, a wait group's Go, or time's or context's AfterFunc, function literals in package-level vars included, as "file: Func", with its waiter, or "detached: " and why nothing waits. A new one fails until listed, a listed one that starts none fails, and a package that starts one fails until its tests call leaktest.Main. Leaks it found, each fixed with a test: - The proxy's close left its connections running: http.Server's Close neither closes a connection a handler took (a CONNECT's tunnel, a WebSocket upgrade ReverseProxy takes) nor waits for a handler. conns (conns.go) holds every connection the listener accepted (track) and counts every handler (handle); serve calls closeConns once Serve returns, which closes them, closes any accepted after, and waits up to 5 s for the handlers. splice also ends when its client's connection can't be read (closed, reset), rather than half-closing the far end and waiting on it; a failed write to the server (one that answered early and closed) still lets its answer through. Tests: TestCloseConns (a tunnel and an upgrade), TestConnectAfterClose, TestSpliceEndsWhenItsClientCloses, TestSpliceKeepsAnEarlyAnswer; the tests' listen closes as the proxy does, and the fake upstream closes its target once its client's end comes. - platform's runChild left its signal-passing goroutine blocked on a channel signal.Stop never closes; it now closes it and waits (TestRunChild). - platform's WaitExit and WatchFolders blocked in poll(2) and read(2), which closing their fd from the stop doesn't wake on every kernel (Debian's didn't), and a retried call could land on a reused fd. They now wait in Go's poller (pollable), which the stop wakes (TestPinWaits, with a wait stopped before its process ends). Docs: Contributing's tests page (Goroutine leaks), the structure page (the goroutines rule, goroutineSites, the layers, the packages), the Go lint rules' depguard line, the proxy's shutdown in How it works' processes page and the proxy's README, and AGENTS.md. Coverage baselines: internal/leaktest's line on both systems, netpolicy's raise on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2545de19f3 |
test(e2e): the Go runner is the entry point, mise run e2e -- FLAGS, and tests/e2e.sh goes
TestE2E already set up the sandbox, slots, locks and flags itself, so the 898-line script only handed over. The run is now `mise run e2e -- FLAGS` (go test -tags e2e from tests/e2e, CGO_ENABLED=0) with the same flags: --only, --from, --clean, --every-feature, --slots, --slot, --newest-base, --golden, plus --reuse. - options: the flags named as the script's options; the hand-over flags (lock-holder, count, total, started, summary) and the ported/unported split are gone. - e2eUbuntuRelease, a const in sandbox_test.go, holds the Ubuntu pin; scripts/bump.sh e2e-ubuntu moves it (get_const), and TestE2EUbuntuPins, bump.txtar and the E2E workflow read it there. - From the script into Go: the OpenSSL-not-LibreSSL host check, and --newest-base's start line and its UPSTREAM DRIFT summary. - The script's leftover bash helpers (perl vm_state, no_leak, ca_*, lima_listens, the retry list, its heartbeat) are gone with it. - mise's e2e:go task merges into e2e; TestCommandLines drops its $D rule. - Docs (contributing, testing, maintaining, internals) and AGENTS.md name mise run e2e; testing.md's "Porting a section" becomes "Adding a section". Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d2dc8c74b6 |
feat(layers): desktop is a built-in layer, not one of base's features
devvm --layers desktop (or desktop under the picker's Layers heading) gives a VM the Xfce desktop devvm desktop opens; base no longer has it. - assets/features/desktop.sh moves to assets/layers/desktop.sh, with a built-in layer's header, and assets/layers/desktop.policy (no rules: its packages come from the distribution's archive, which base's policy has). - image.DesktopLayer joins image.Builtins (desktop, docker, nix, sorted): reserved, listed under Layers, taken by --layers and completion, its policy read by netpolicy.Policies. - build: desktopFeature and chosenFeatures' special case are gone; until a choice is made, base gets every feature. devvm setup --features desktop is no_feature. - devvm desktop: desktop_no_feature becomes desktop_no_layer (devvm rm, then devvm --layers desktop), linked to the desktop page. The picker's row: pick_layer_desktop. - apt snapshot: base.sh's /etc/apt/apt.conf.d/50devvm-snapshot stays in base's image, and only guest/sync.sh (project VMs) removes it, so a layer built on base installs from the same snapshot and package lists; said in base.sh, desktop.sh and internals/images.md. - No backend feature: desktop builds and runs like any layer on Lima. base's image key changes (desktop leaves the features, base.sh's comment changes), so base rebuilds, now about 400 MB smaller without the desktop on the --from tier's every-feature base, and for anyone who chose it. Tests: TestBuiltins; TestOwnFeatures (devvm's features without desktop, every one until chosen, desktop refused); TestLayersAndCheckLayers, TestCompleteParts, TestPartFlags and TestUpPicker list desktop under Layers; TestBuiltinPolicies allows desktop.policy alone without rules; testscript: desktop.txtar (a base VM refused with desktop_no_layer, its build without the layer's script; --layers desktop builds the desktop image), setup.txtar (--features desktop is no_feature), the layer lists in build, layer, up and up_checks. e2e: the desktop section checks a base VM has none of the desktop's programs and is refused, then makes its VM with --layers desktop; from's Alpine VM gets the desktop layer too. Docs: using/desktop.md, using/images.md (built-in layers, desktop), using/customizing.md, using/from.md, using/_index.md, getting-started/commands.md, internals/desktop.md, internals/images.md (the desktop layer, the snapshot in layers), internals/design.md, contributing; the CLI reference for devvm desktop. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e2e3c70d81 |
feat(desktop): a desktop feature and devvm desktop, over VNC, on every backend
The desktop feature (assets/features/desktop.sh, not chosen until you choose it, about 370 MB) installs Xfce and TigerVNC's Xvnc from base's package snapshot, and devvm-desktop, which starts Xvnc on display :1 on a socket of the VM user's own (/run/devvm-desktop/vnc.sock, 0600 in a 0700 folder), with no TCP port (-rfbport -1, -nolisten tcp) and no password of its own, the clipboard on or off as asked (vncconfig on a running one), then an Xfce session in a D-Bus session of its own. Nothing starts it at boot: devvm desktop does, on every backend. devvm desktop gets the VM ready as devvm ssh does, refuses a VM without the feature (desktop_no_feature), starts its desktop (desktop_start_failed), and serves it on 127.0.0.1 alone until Ctrl+C or the VM stops (desktop_vm_stopped), on the VM's own port (desktop_port, among netpolicy.UsedPorts, so no forwarder or new VM takes it), showing the address and password (desktop_ready) and opening vnc://127.0.0.1:PORT in Screen Sharing on macOS (--no-open; desktop_open_failed). --clipboard shares the clipboard both ways for that run. internal/desktop's Relay is the guarantee, not the VM's server: it speaks RFB 3.3/3.7/3.8 as a server, offers VNC authentication alone, checks the answer against the VM's password (8 characters of 31, about 40 bits, crypto/rand, kept in the VM's state as desktop_password, never sent to the VM) one check at a time with a second's wait after a wrong one, and only then opens an ssh -W channel to the VM's socket through devvm's ssh config (pinned host key, no session, agent or forwarding), closed by its input first so the VM's sshd ends its side. Without --clipboard it drops every ClientCutText (extended ones too) and ends a connection on a message type it can't size. At most 8 connections. Also: vm.Desktop (Open, serve, listener, dial), vm.ready (devvm ssh's launch without the Include prompt), Env.OpenURL; build's chosen features leave desktop out until it's chosen; messages desktop_failed, desktop_no_feature, desktop_start_failed, desktop_ready, desktop_open_failed, desktop_vm_stopped, with doc links. Tests: internal/desktop (passwords, Response, wrong passwords refused with no dial, 3.3/3.7/3.8, not a viewer, the clipboard dropped or carried, an unknown message ending the connection, a VM server asking for a password), internal/vm (the password kept and remade, the listener's port kept and replaced, ssh's arguments), internal/build (desktop off until chosen), testdata/script/desktop.txtar (no VM, no feature, a stopped VM started, the forward asked for with the clipboard off and on, the same port and password, Screen Sharing opened or failing, the VM stopping, the start failing), setup.txtar, docgen; tests/e2e.sh's desktop section (Lima, with network policy) and checks in the smolvm and Docker sections; TestE2EDesktop. Docs: using/desktop.md (new), customizing.md's features, commands.md, internals/desktop.md (new), design.md's note on the desktop, contributing/testing.md's manual Screen Sharing check, the CLI reference. Review (security-audit skill, guidance mode, local IPC and loopback listener classes), against the review's list: - another local user or process reaching the port: 127.0.0.1 alone, without address reuse; VNC authentication checked on the host before any ssh, constant-time, about 1 guess a second globally (thousands of years); the password in the VM's state (0600 file, 0700 folder), shown only on stdout with the address, never in open's arguments or the run log (e2e: no run log, no host process's arguments); - never in an image or the VM: the VM's server has no password; e2e greps the VM's files for it (found the first time only in the VM's journal, from the check's own sudo command line, now fed on its input); - the server on no address but loopback on each backend, even if root changes it: Xvnc has no TCP listener (e2e on each backend), the relay is the only way in and lives on the host; root's own server without a password (e2e, Lima) still gets no viewer without devvm's password; - clipboard off really off: the relay drops the viewer's clipboard whatever the server accepts (e2e: root's server records a key event but never the clipboard); the VM's clipboard to the viewer can't be filtered without decoding screen updates, documented, Screen Sharing's setting; - nothing from the VM toward the host: a local ssh -W channel, which ssh's client asks for; the VM reaches neither the relay's port nor anything new (e2e: with network policy, no direct connection out, nor to the port); a VM that reaches host loopback (no policy, Docker Desktop) meets the password like anyone; - network policy unchanged: no policy file or allowlist changes; the self-check passes with the desktop running (e2e). Left as documented residuals: the VM's clipboard sent by a changed server; a local process or VM keeping the relay's 8 slots busy or failing checks (availability only). Co-Authored-By: Claude Opus 5.5 <[email protected]> |