mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
81f3feeecf69f3e29d6de3e4ee213b32905eaaa4
59
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8d44175601 |
refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d209071ec3 |
feat(network): devvm-why and the agents' note point at a tool that skipped the proxy
With nothing blocked, the proxy's /blocked answer (devvm-why) adds that a DNS or connection error for an allowed host means the tool skipped the proxy, to turn on its own proxy setting or give it $HTTPS_PROXY, and links troubleshooting's A host on the allowlist doesn't resolve. The agents' note in ~/.claude/CLAUDE.md and ~/.codex/AGENTS.md says the same in one sentence. Tests: proxy_test's empty answer, network.txtar asks a running proxy's /blocked, and the e2e network section checks that curl --noproxy fails for github.com, devvm-why's hint and the note in CLAUDE.md. Docs: internals and safety network pages. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
36f910839e |
fix(desktop): browsers reach the web through a local proxy that adds the VM's password
Chrome, Chromium and Firefox ignore the password in HTTP(S)_PROXY, so in devvm desktop they asked for the proxy's username and password on every site. The guest setup now writes devvm-local-proxy, which socat (now in the desktop layer) serves on 127.0.77.1:3128, the VM's loopback alone. For each connection it reads the request's head, drops the client's Proxy-Authorization and Proxy-Connection, adds the VM's password and sends it to devvm's proxy, then socat carries the rest both ways. It takes only CONNECT HOST:PORT and absolute http(s):// requests, the latter with Connection: close, so each connection's one request carries the password. devvm-desktop starts it and points the Xfce session's http_proxy, https_proxy, HTTP_PROXY and HTTPS_PROXY at it; on Xfce, Chrome and Chromium read those, and Firefox reads them first with its default system proxy setting. A blocked host still gets the proxy's 403. - proxy.LocalProxyAddr, LocalProxyPort, IsLocalProxyAddr: the one owner of the address, sent to the guest as DEVVM_LOCAL_PROXY (vm.localProxy). - vmssh: the port forwarder never forwards a server on 127.0.77.1. - Tests: netpolicy's TestLocalProxy runs sync.sh's script (bash 3.2 on macOS) against a fake proxy: the password replaced, Connection: close, a tunnel, the 403 passed on, origin-form and junk refused with 400 before any connection; TestListeners, TestIsLocalProxyAddr, TestLocalProxy (vm), sync.txtar. e2e desktop (tests/e2e.sh, still the bash section): the session's variables, the listener on 127.0.77.1 alone, curl without a password to github.com, example.com's 403 over CONNECT and plain HTTP, 400 for origin form, nothing on this machine's 3128. - Docs: using/desktop.md (Browsers), internals/desktop.md (The local proxy), design.md's desktop note, ports.md, network.md's setup. Security review (security-audit skill, guidance mode, local IPC and proxy request handling): - Fixed by design: devvm forwards every VM port by default, so a local proxy on 127.0.0.1 would have put a password-less route to the VM's proxy, and its secrets, on the host's localhost for every local user. The forwarder now skips the local proxy's address on every port. - The password goes only to the VM's proxy, whose address is fixed in the script, never to an address a request names, in the one header the local proxy adds; devvm's proxy strips Proxy-Authorization before forwarding. It's never in a process's arguments (bash builtins only). - Web pages: requests from a page to the loopback are origin form, refused with 400 before any connection; a page can't send CONNECT or an absolute-form line, and DNS rebinding changes only Host. - No new power in the VM: the same password is in /etc/environment; the script is mode 700, the VM user's. - Residual: a program in the VM can hold up to 256 connections slowly (30 s a line, 100 headers), only against the VM's own browsing; an ssh -L the user types to 127.0.77.1:3128 would expose it, as any forward they choose. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
db90ab1b5b |
fix(tools): opencode 2 in VMs, with its Codex logins and its database
devvm's pinned mise (2026.10.7) resolves aqua's "latest" to GitHub's latest release, which opencode keeps on its 1.x line (v1.19.5) while it publishes 2.x beside it, so ls-remote lists 2.2.5 but lock picks 1.19.5. The shared tools' mise.toml holds opencode at "2", which locks the newest 2.x on every platform (linux-arm64/x64 and their musl entries, the same assets as 1.x). opencode 2 keeps its logins in its SQLite database and imports auth.json once, as it makes its credential table. devvm agent login opencode runs its Codex logins (opencode auth login openai --method chatgpt-browser or chatgpt-headless), which still post to auth.openai.com/oauth/token with Codex's client ID, so the capture and the host's refresh are unchanged; its Sign in with ChatGPT (/api/accounts/oauth/token, a client of its own and an id_token checked against OpenAI's keys) stays refused by the proxy's guard. An API key saved into a VM whose opencode has made its database is imported with opencode auth import (OpencodeKeyImport). Tests: TestOpencodeKeyImport, the login argv, agent_login.txtar's import and its failure, the guard on opencode 2's token-sharing path; e2e's network VM gets opencode and a device-code login against the fake endpoint. tests/e2e-mise.lock bumped (opencode 2.2.5, claude 2.1.318, pnpm 12.18.0). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
760e602d18 |
fix(agents): host-side login refreshes trust the user's CAs
An agent's OAuth refresh (Claude Code, Codex, opencode) runs in the VM's proxy on the host and goes through the company proxy, but trusted only the system's roots, so a company proxy that inspects TLS made it fail. Each secret lookup's context now carries the proxy's own roots, the system's and upstream_cas (proxy.WithRoots, RootsOf), which the refresh's client trusts through the new fetch.Client.Trust. Tests: fetch TestTrust, agentlogin TestRefreshTrustsTheProxysRoots and proxy TestLookupRoots, each against a TLS server signed by a test CA; the e2e network section's Claude refresh check now expects success. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
62cdd16dd4 |
feat(agents): devvm agent login claude, Claude Code's login captured in the VM for every VM
Claude Code logs in from inside a VM, so this machine never needs it, and devvm keeps one Claude Code login on the host for every VM with Claude Code: the subscription's OAuth login, or a Claude Code token from claude setup-token. The newest replaces the other. The VM holds placeholders alone, so claude /login in a VM no longer leaves real tokens there. - Capture: every VM's proxy captures at platform.claude.com and console.anthropic.com /v1/oauth/token (agentlogin.Endpoints), only for a VM whose image has Claude Code (netpolicy.Capturer). setup-token's code grant (expires_in, agentlogin.SetupToken) gives the claude secret (agentlogin.ClaudeToken, secrets.Token's checks) and the VM the secret's placeholder. Any other code grant goes in the store's .claude/.credentials.json (a File of kind agentlogin.ClaudeOAuth: claudeAiOauth accessToken, refreshToken, expiresAt ms, scopes); the VM's reply holds sk-ant-oat01-devvm-proxy-managed-oauth-<salt> and a managed refresh token, and the VM's own refresh is answered from the store. Refused: a new login without user:inference (Console), any login or refresh with org:create_api_key, an access token that isn't sk-ant-oat01- shaped. - One login: saving the claude secret (captured or devvm secret set claude) removes the OAuth login, and an OAuth capture deletes the saved token, both under the claude logins folder's lock (agentlogin.LockFolder); a token that can't be deleted is a warning. CLAUDE_CODE_OAUTH_TOKEN in devvm's environment wins, as in Claude Code (secrets.ClaudeOf(store).Login). A launch gives the VM either CLAUDE_CODE_OAUTH_TOKEN or ~/.claude/.credentials.json (placeholder, managed refresh token, expiry 2099), never both. Both bindings (claude, claude-oauth) go into Authorization for api.anthropic.com while either login exists, and Store.Get gives each the login devvm keeps now, so a running VM survives the switch. - Refresh: the host refreshes the OAuth login when due, JSON to platform.claude.com with Claude Code's client ID and the login's scopes, through the company proxy (proxy.RouteOf), under the file's lock; claude_refresh_failed says to log in again. - devvm agent login claude [--setup-token]: claude auth login --claudeai or claude setup-token in the VM without CLAUDE_CODE_OAUTH_TOKEN, the code pasted back on this terminal (no forward); the VM is set up again once the store has a new login of the kind asked for (secrets.ClaudeOf(store).Sums); claude_env_token_wins when the environment's token wins. --device-code, --api-key and --stdin are usage errors with claude, --setup-token without it. - Confirmed in Claude Code 2.1.317's linux-arm64 bundle (sha256 checked): TOKEN_URL platform.claude.com/v1/oauth/token, client ID 9d1c250a-e61b-44d9-88ed-5944d1962f5e, the JSON code and refresh bodies, setup-token's expires_in 31536000 and user:inference scope, the claudeAiOauth fields, the anthropic-beta oauth-2025-04-20 header Claude Code sends itself, claude auth login's pasted code#state on stdin. The real claude auth login logged in in e2e against the fake. - Messages: agent_login_claude_paste, claude_login_saved, claude_setup_token_saved, claude_env_token_wins, agent_login_claude_flag, agent_login_setup_token_alone, claude_refresh_failed, claude_no_login; no_claude_token, claude_token_invalid, claude_token_howto and not_setup_token point at devvm agent login claude. - Tests: TestClaudeCapture, TestClaudeSetupToken, TestClaudeOAuthGet, TestCaptureRefuses' Claude cases (agentlogin); TestOneClaudeLogin, TestClaudeBindings, TestClaudeOAuthVMCopy (secrets); TestCapturer's Claude cases (netpolicy); agent_login.txtar's Claude section; network.txtar's bindings. - e2e (network): the fake company proxy fakes Claude's token endpoint and Anthropic's API too; setup-token's request makes the claude secret; devvm agent login claude runs the real claude auth login, the store keeps the login, the claude secret goes, the VM holds placeholders and no token, the API gets the store's token for the VM's placeholder; a due login makes the host refresh through the company proxy (which fails there, as the host doesn't trust the run's CA). - Docs: Claude Code login (using/coding-agents.md), first VM, the home page, README, commands, settings, safety/network.md, internals network.md, the design note's risk that this path is unofficial, Contributing's e2e, the proxy README; the CLI reference. Security review (security-audit skill, an independent read): - Fixed: a login granting org:create_api_key would let a VM make an API key through the binding and get it unread: refused, on refresh too. - Fixed: a refresh could install a Console login when the store had none: the scope check applies to every new login. - Fixed: any VM, without Claude Code, could replace the login or delete the token with a refresh grant: only a VM with Claude Code captures. - Fixed: two captures at once could leave neither login: one lock. - Fixed: a saved token that couldn't be deleted gave the VM a 502 for a saved login: a warning instead. - Fixed: captured and refreshed access tokens are shape-checked. - Accepted, documented: the bound login reaches every api.anthropic.com path its scopes allow (profile, sessions); any VM with Claude Code can replace the login; a token Claude Code mints in a VM for another use (install-github-app) becomes devvm's login. - Unconfirmed: whether another Anthropic host also answers /v1/oauth/token (it would pass unguarded). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3a2c290d3d |
refactor(msg): messages and comments say network tier and the VM's proxy, not network policy
Every VM runs a proxy and is on one of four tiers, so the proxy's messages name the VM's proxy, the unenforced ones its network tier, and the redaction ones say devvm keeps secrets on this machine on every tier. Message IDs are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2151d1b959 |
feat(proxy): capture agents' logins at their token endpoints
A login that Codex or opencode makes inside a VM goes to devvm's agent store, and the VM gets only placeholders. Every VM's proxy intercepts OpenAI's token endpoint (auth.openai.com/oauth/token, listed in its config's captures for Codex and opencode on every tier), and its host joins the allowlist of a VM whose image has either agent. This is the proxy's first response rewriting (ModifyResponse, stdlib only). - proxy: Config.Captures, IO.Capture (Capturer: Request, Response), Exchange; a POST to the endpoint's path (cleaned, without ;params, any case) is read (64 KiB) and its 2xx reply (1 MiB) goes to IO.Capture, never to the VM; the VM gets IO.Capture's reply with only Content-Type, Cache-Control, Pragma and Date; a "login" event names the agent; what can't be read gets 502, logged as a refused block, values never logged. - agentlogin: Endpoints, Pick (the User-Agent tells opencode, Bun's, from Codex), File.CaptureRequest and File.Capture under lockLogin: Codex's auth.json (tokens, account_id, last_refresh; the id_token->API-key exchange's key in OPENAI_API_KEY, the VM's id_token placeholder swapped for the store's on the way out), opencode's auth.json openai entry, Claude Code's .credentials.json (capturer only: no VM captures Claude yet). A code replaces the login, a refresh adds to it (newest refresh token kept). The VM's reply: the bindings' placeholders, refresh token devvm-proxy-managed, expiry 2099. - secrets: Store.CaptureRequest, Store.Capture (folder private, out of backups), the token endpoints' hosts in secrets.policy. - netpolicy: Capturer (devvm _proxy's IO.Capture: the VM's salt, its agent, the bindings written again at once); devvm network log shows login lines. - e2e (network): a fake token endpoint behind a company proxy of the run's own, with the run's CA; the store gets the real tokens and key, the VM placeholders and no refresh token, no log holds a value, the next launch gets the login as placeholders. - Docs: Logins made in a VM (internals/network.md), coding-agents.md, safety/network.md (the account swap), the proxy's README. Security review (security-audit skill, plus an independent read): - Fixed: a VM could spell the path another way (/oauth/token;x) and get real tokens uncaptured: path parameters dropped before matching. - Fixed: another path on the host could hand the VM tokens: any 2xx from a token endpoint's host naming access_token, refresh_token or id_token is refused, whatever its type (web pages pass unread); 101 refused. - Fixed: 1xx replies (103 with Set-Cookie) reached the VM before ModifyResponse: dropped on token endpoints' hosts. - Fixed: Set-Cookie and other headers on a captured reply reached the VM: only four headers kept. - Fixed: an error reply to the exchange could quote the real id_token: it reaches the VM as its OAuth error code alone. - Fixed: a captured request went upstream under the VM's raw path and query: it goes to the endpoint's own path, no query. - Fixed: repeated form or JSON fields, which devvm and the endpoint could read apart, are refused. - Fixed: captures depended on the image's agents, so a self-installed Codex logged in uncaptured: every VM's proxy captures at the endpoint. - Fixed: at most 8 bodies read whole at once. - Fixed: the VM's refresh with its managed refresh token is answered from the store, so a VM's Codex isn't logged out after 8 days. - Fixed: a login saved whose bindings write failed reached the VM as a 502: it reaches the VM, the error is logged. - Accepted, documented: any VM with the agent can replace the store's login (an account of its choosing); on the open tier a program can go around the proxy; Claude Code's own /login in a VM isn't captured. - Unconfirmed: domain fronting through a sibling OpenAI host whose tunnel isn't intercepted (depends on the CDN routing on Host). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
fcbab78670 |
refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its tier, so even an open VM never holds a real secret: a request that goes around its proxy carries only the placeholder. - vm/sync.go: the open branches of stage go (the agents' logins copied as they are, the ClaudeCopy for unconfined VMs and its MCP warning, real values in ~/.config/devvm/env); stageNet is stageSecrets, run for every VM, and the salt is every VM's. - netpolicy: Prepare readies the CAs, salt and secret files on every tier, and the proxy config carries the CAs and bindings on every tier; dropCA and its caller are gone, so a VM keeps its CAs as its tier changes. - Removed without a caller left: the messages secret_unuse_copied, net_on_old_tokens and claude_mcp_secrets_copied; secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets, claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly. - Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for another host), TestStageSecretsEveryTier (every tier's setup sends the VM's CAs, the guard against a tier's own path); sync, ca, network and secret scripts for open VMs. - e2e: network checks that an open VM holds no real secret (its proxy puts the token in over TLS the VM verifies, a direct request carries only the placeholder and gets a 401); project checks an open VM's placeholder, and its company-CA checks allow for the VM's own CAs in /etc/ssl/devvm.pem. - Docs: safety/network (tiers, secrets), internals/network, the design note's tiers threat check, attack vectors, coding agents, first VM, staying safe, contributing; devvm secret's help. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c0f4b8fb5c |
feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none, in its state's net section (netpolicy.Tier), in place of on/off. Every VM has its proxy. Confined tiers start on NetProxy; open starts on the backend's own network with its proxy set in the guest (Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off. The proxy: Config.Open (every host and address, no floor, no policies), Config.DenyPolicies (files whose denies alone apply), the rule port :* (any port), and ** matching address literals (the floor still holds). Policies per tier (netpolicy.PolicySet): internet is network/internet.policy (**:*) plus your denies; none is the agents' built-in policies, the secrets' hosts and your denies; open none. Links: a client links only to a target on its tier or a stricter one, and a group's VMs are all on one tier. The self-check per tier: open asks its proxy through the guest's settings and warns (net_proxy_unreachable). devvm ls and devvm network show the tier. A backend without egress-proxy offers open alone (net_tier_backend). devvm network on/off and --network-policy/--no-network-policy map to allowlist/open. Design note, threat check and docs; e2e in the network and link sections. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ca8a91305b |
fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what) when it may not be a message (replacing fail and the direct Die calls in cli), and a.env returns its failure. checkLayout returns its error from the root's PersistentPreRunE. execute alone prints a failure (showFailure): a backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces DieLogged), a message as it is, else what failed or output_failed, with a corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130. Die is now the UI's own die, for where no command can return: a question without an answer, a run log that can't be opened. Error prints nothing once the run is interrupted. After INT, TERM or HUP, Main waited only for the logged command and then ran the cleanups while the command's own code still ran. It now also waits for the command to return, up to returnGrace (2 s), when there are cleanups to run; a run without cleanups ends at once, so the proxy and the other background processes still stop as soon as they are told to. A start's undoStart stays registered once interrupted (interruptCleanup), as the cleanups now run after the start returned. Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old ordering), TestSignalsWaitForAStuckCommandAWhile, TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure; DieLogged's tests are ErrorLogged's. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
82127e7f2c |
refactor: Lima's builds take the company proxy from settings.CompanyProxy, vm calls agentlogin.Redact, and watched's chmod blind spot is documented
- Lima's buildUpstream asks the backend's settings.CompanyProxy (Lima.Company, cp from New, else one over the backend's Getenv) instead of running settings.HostProxy and HostProxy.Upstream again, so a build's check is the one VMs' proxies use, config.toml's password saved included. TestBuildUpstreamConfig covers the missing password, the lookup, NO_PROXY and no company proxy. - secrets.Redact, a one-caller pass-through, is gone: vm's stageNet calls agentlogin.Redact, whose own tests cover it. - watched[T] misses a change of mode or owner alone (its stamp is mtime, size and inode): documented in the proxy README and internals/network.md, with TestWatchedChmodOnly. - The shared ~/.local/share/devvm/ca that development builds from before layout version 1 left: a line in Contributing's state layout section says to delete it (no migration: nothing shipped). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1131c07d28 |
fix(proxy): bound the leaf-certificate cache and a VM's CONNECTs at once
The CA keeps the leaves of the 1024 hosts used most recently (leafCacheMax, an LRU over container/list), so a binding with a wildcard host can't grow it without end. The proxy carries at most 1024 CONNECTs at once per VM (maxConnects, a semaphore taken after the password check, links' and intercepted tunnels included): one past it gets 503 with the reason "1024 tunnels open already", logged as a refused block, and proxy.log says so once until a tunnel ends. 1024 is four times Chrome's 256-socket pool and many times a package manager's (npm's 15 sockets, uv's 50 downloads). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
937a4901e1 |
fix(proxy): keep resolver and company-proxy errors out of the VM's refusal reasons
A name that doesn't resolve and a tunnel that can't connect now give the VM's 403, /blocked and the event log a fixed reason (reasonUnresolvable, reasonConnectFailed) that points at proxy.log; the error itself, which can name the host's DNS server or the company proxy's address and answer, goes to the proxy's own log alone (egress gets the proxy's logger). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8d00c42e14 |
fix(netpolicy): a VM's CAs are readied under a lock and deleted once its policy is off, and the proxy refuses minting GitHub credentials in absolute form too
- trust.InitCA takes the caller's ctx and holds the CA folder's lock (paths.CA.Lock, vms/<hash>/run/ca/lock), so two launches of one VM at once never leave a key and a certificate of different runs (TestInitCATogether failed first, TestInitCACancelled, TestInitCAMismatched). - netpolicy.Proxy.Unconfined: a VM's first start without network policy stops its proxy and then deletes its CA folder, keys and all, under that lock; a proxy that won't stop keeps them (TestUnconfined, network.txtar). - The proxy's forwarder refuses GitHub calls that make a lasting credential for every HTTPS request, so absolute-form https:// requests get the 403 that intercepted tunnels got (TestForwarderRefusesMinting failed first); the minting paths also match /repositories/ID and /organizations/ID. Each forwarder's idle upstream connections close when its request or tunnel ends. - e2e: the build proxy check expects the run log's devvm:<key>@ and no proxy key in the log. - Docs: design.md's CA threat check, network.md, overview.md's locks, space.md, safety/network.md. Baselines raised (darwin). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9568e6c47f |
fix(proxy): agents' OAuth refreshes go through the VM's proxy's company proxy
A VM's proxy refreshed Codex's and opencode's OAuth logins with net/http's environment proxy alone, so with config.toml's [proxy] the refresh went directly, and failed behind a company proxy. The proxy now makes its upstream's route for its own requests as it starts (proxy.Upstream's WithPassword, with the proxy secret it looked up, then Route) and gives it to each lookup in the lookup's context; agentlogin's refresh sets it as its transport's proxy. A proxy without an upstream routes the refresh directly, as it does the VM's requests. - proxy.WithRoute, proxy.RouteOf; upstreams.host; secrets.route. - Tests: TestRefreshGoesThroughTheProxysRoute (fails without the fix), TestLookupRoute. - Docs: How it works' Through a company proxy, network policy's Behind a company proxy, the proxy's README. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ed70aeae3b |
feat(netpolicy): config.toml's company proxy reaches devvm's own downloads and builds' checks, and VMs without policy warn
config.toml's [proxy] covers the places it missed: - devvm's own requests on this machine (the download of its mise, Ubuntu's cloud image listing, --from's registries) go through it when the environment sets no proxy. settings.CompanyProxy.Route is their transport's proxy: at the first request it looks up the proxy secret, puts it in each URL that names a user, and routes each request as a VM's proxy does (proxy.Upstream.WithPassword, proxy.Upstream.Route, reusing the proxy's NO_PROXY matching). A missing password fails the request with fetch.ErrProxy, which isn't retried; HostMise shows its message. - The mise devvm runs on this machine gets HTTPS_PROXY, HTTP_PROXY and NO_PROXY in its environment (settings.CompanyProxy.Env), with the password in the URL, as mise takes it nowhere else; never in its arguments or a file. With the environment's proxy it adds nothing. - devvm build, rebuild, the remakes' builds and tool builds check the company proxy and its saved password before anything starts (build.Builds' checkProxy, tools.Share.Build), through the one check a new VM and a VM's proxy use: settings.CompanyProxy.Upstream, which netpolicy.Proxy.Upstream now calls. secrets.Store.ProxyPassword owns the proxy_password_missing mapping. - A VM without network policy never gets config.toml's proxy, as the guest would need the password, which never leaves this machine; each start of one while config.toml is the only proxy warns (proxy_needs_policy), naming devvm network on or the shell's HTTPS_PROXY, with a doc link. Wiring: tools.Env.Proxy (its Password set by cli and vm from devvm's secrets), from.NewLookup/NewRegistry/NewPublicRegistry take the proxy, lima.New and registry.New take a *settings.CompanyProxy for Ubuntu's listing. internal/fetch stays standard library only. - Tests: TestUpstreamWithPassword, TestUpstreamRoute, TestUpstreamRouteAuthorizes, TestCompanyProxy, TestCompanyProxyPasswordMissing, TestProxyPassword, TestHostMiseThroughCompanyProxy, TestMiseCmdCompanyProxy, TestBuildChecksCompanyProxy (tools and build), TestRegistryThroughProxy, TestUbuntuThroughCompanyProxy, TestTransient's ErrProxy, and company_proxy.txtar's build, rebuild and no-policy cases. - Docs: network policy's Behind a company proxy and Without network policy, config.toml's [proxy], How it works' Through a company proxy. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2304f26bf0 |
feat(netpolicy): config.toml sets the company proxy, and a start warns when its proxy loses one
config.toml's [proxy] table (https, http, no-proxy) is the company proxy that VMs' proxies and builds go through when devvm's environment sets neither HTTPS_PROXY nor HTTP_PROXY; the environment's settings win whole, never mixed with config.toml's. Each value is checked as config.toml is read (backend.CheckProxyURL, backend.CheckNoProxy), and a URL holding a password is refused (proxy_password_in_config): config.toml is copied between machines and kept with dotfiles. The password is the host-only secret proxy (devvm secret set proxy, in the Keychain or devvm's secrets folder). A URL that names a user gets upstream.secret in the proxy's config, and the proxy looks the value up through IO.Secret as it starts (upstreamPassword), so no file of devvm's holds it. No VM is ever bound to it: devvm secret use refuses (secret_host_only) and secrets.Names drops it. A new VM and a VM's proxy refuse to start while it isn't saved (proxy_password_missing, netpolicy.Proxy.Upstream). A start whose VM's proxy last ran with an upstream and now has none warns (upstream_proxy_gone), naming config.toml, with a doc link. - settings.HostProxy: the environment's, else config.toml's; used by netpolicy, Lima's build proxy (buildUpstream) and devvm doctor's CA hint. - proxy.Upstream.Secret, proxy.UpstreamSecret; secrets.Secret.HostOnly; secrets.Token keeps spaces inside the proxy password. - Messages: proxy_password_in_config, proxy_password_missing, upstream_proxy_gone, secret_host_only, proxy_password_howto, password_prompt (answered by --stdin). - Tests: TestHostProxy, TestUpstreamSecret, TestPrepareUpstreamConfig, TestBuildUpstreamConfig, config.toml refusals, the warning in TestPrepareUpstream, company_proxy.txtar, secret.txtar and ca.txtar cases. - Docs: troubleshooting's Behind a company proxy, network policy's Behind a company proxy and secrets, config.toml's reference, How it works. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1640feb608 |
feat(netpolicy): one CA per VM, with a successor the VM trusts ahead of time
Each VM with network policy has CAs of its own in its run folder, vms/<hash>/run/ca/ (paths.VM.CA, paths.CA: ca.pem/ca.key, next.pem/ next.key; folder 700, keys 600, kept out of Time Machine on macOS), so a leaked key reaches one VM and no proxy can sign for another VM. The shared ~/.local/share/devvm/ca (Dirs.CA) is gone. trust.InitCA(paths.CA) readies the current CA and the next one at each launch: the current one stays while it has over a week left, then the next one (started) takes its place, else a new one; the next one starts a week and an hour before the current one ends and is made again when it doesn't follow it. Each CA lasts 30 days and an hour, and its common name holds its serial, so a VM's two CAs never share a subject. The proxy's config gains ca_next, ca_next_key and ca_next_sha256 (part of Sum); the proxy signs with the next CA from an hour after its start (ca.signer), so the switch needs no launch or new proxy, and a VM not opened again stays verifiable for at least 30 days less an hour after its last launch. /ca.pem serves both certificates. loadCA reads the CA files with readPrivate (no links, a key only the user may read, 64 KiB cap) instead of tls.LoadX509KeyPair. The VM's setup sends both certificates (devvm-proxy.crt, devvm-proxy-next.crt) and no key. Tests: TestInitCA, TestInitCASwitch, TestInitCAReplaced (trust); TestNextCASigns, TestLoadCA, config check rows (proxy); TestPrepare and TestPrepareRestartsTheProxy for the VM's CA files and both sums (netpolicy); TestVMFiles; network, sync and layout txtar; e2e network: a second network-policy VM with different CAs, each VM trusting only its own and holding no key, each proxy serving and presenting only its own VM's CAs, devvm rm deleting one VM's CAs. Docs: internals/network.md (The VM's CA), design.md (A CA per VM, its threat check), safety/network.md, overview.md's per-VM files, space.md, security.md, attack-vectors.md, limits.md, coding-agents.md, contributing, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a77157e267 |
refactor(proxy): one watched file helper for the bindings, the policy files and the links list
watched[T] stats its file on each call (Lstat, or Stat for a file read through a link) and reads it again when its mtime, size or inode differ, or while its last read's mtime was within 2 s of then, so two writes within one mtime tick are both seen; it parses again only when the bytes differ. Each user picks its read (readPrivate or ReadRegular with its cap), keep (last good) or none on a failure, logged once per distinct error, and an on-change hook run under the watcher's lock. - secrets: readPrivate 0o077, none on failure; the hook clears the values cache (watcher lock, then valueMu), a touch included. - policy: ReadRegular, following links, last good rules and broken deny kept; per-file state is policyFile; policy.mu and its maps go. - links: readPrivate 0o022, none on failure; the list is read again only when it changes, and an unreadable one is logged once, not per request. readLinkList goes (readLinkListFile, parseLinkList). Tests: TestWatchedSameTick, TestWatchedSettled, TestWatchedFailures, TestWatchedRefused. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bcafcda739 |
refactor(proxy): one server struct holds what a proxy runs with and keeps, and a tunnel passes the far end's bytes at once
internal/proxy keeps no package state. newServer makes a server from the config, as Main starts (it replaces Config.apply, loadPolicies and every global they set), and each part keeps what it changes under its own lock: events (the event log and recent blocks), egress (the policy, the host's addresses in hostAddrs, the company proxies in upstreams), secrets (the bindings file and the values cache, file lock taken before the values'), ca (devvm's CA and its leaves), links (the list and the sockets' folder) and nixCache (the cache's folder, checked narinfos, fetches and slots). The proxy's own log is a *log.Logger each part is given; Main's lifeline tick is a const, and run takes it for tests. What's left package-level is error sentinels and three fixed tables (notPublic, nat64, githubMinting), now in the structure test's allowedVars; the structure test no longer leaves internal/proxy out, and its rule case for the proxy fails a var. Tests make their own server with newServer (testServer, listen, logs, fakeSecret on a secrets, testCA) and all run in parallel. TestServersApart checks two servers in one process share no password, blocks, events, values or CA leaves. A tunnel to a host the policy allows passes the far end's bytes to the VM from the start (splice's before), so a server that speaks first gets its greeting through; the VM's bytes still pass only after the SNI check, which reads one byte first and the ClientHello only when it starts 0x16. TestTunnelServerSpeaksFirst failed on the code before. Docs: the proxy README (the server, files, testing), network.md's tunnel paragraph, AGENTS.md's test-seams line, Contributing's package-vars row. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
329e31be1d |
refactor(secrets): the proxy looks secrets up in-process, from one versioned bindings file
The proxy no longer runs devvm secret get for a value: proxy.IO.Secret,
which devvm _proxy sets to secrets.Store.Get, looks a binding's value up
in the proxy's own process (Keychain, devvm's secrets folder, or the
agent's login file), so internal/proxy stays standard library only.
Config.SecretCmd (secret_cmd) and the hidden devvm secret get command go,
with secret_to_terminal and secret_read_failed; Main refuses a config
with secrets and no IO.Secret.
One binding type, proxy.Binding, with kind secret|login and a login's
agent, in proxy.BindingList ({"version": 1, "bindings": [...]}), written
by secrets.Store (Encode) and read by the proxy and RefreshFiles with
proxy.ReadBindings (private regular file, no link, 1 MiB, version and
kinds checked; an unreadable file has no bindings). It replaces
proxy.binding, secrets.binding and agentlogin.Binding; the kind replaces
the name-prefix classifiers in proxy.ttlOf, secrets.loginOf and
RefreshFiles' Lookup check; proxy.InterceptLines replaces
agentlogin.Hosts and RefreshFiles' host loop.
agentlogin's user-actionable errors are typed (ErrCodexNoKey,
ErrCodexNoChatGPT, RefreshError) and secrets maps them to messages:
codex_no_key, codex_no_chatgpt, codex_refresh_failed,
opencode_refresh_failed, and login_read_failed for the rest.
Tests: proxy TestSecretValueLooksUpInProcess, TestReadBindings,
TestBindingsUnreadableHaveNone, ttlOf by kind, Main refusing secrets
without a lookup and -secret-cmd, config refusing secret_cmd; secrets
TestGet by kind, TestLoginFailed; agentlogin TestCodexBindings (kind and
agent checked on every binding), TestGetErrorsSayWhatToDo; secret.txtar
and network.txtar on the new file and without secret get; e2e's network
section keeps the fake token off argv and checks no command prints it.
Docs: the proxy README (Secrets section), internals/network.md,
safety/network.md, using/coding-agents.md, contributing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
361087f95a |
refactor(proxy): host-only modes out of proxy.Main, into agentlogin and trust
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:
- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
MCPSecrets and Redact. The salt is a parameter, not a global or
DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.
Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
8e914b17c9 |
refactor(proxy): one typed, versioned config for every proxy, read as a private file
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON (version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by backend.ProxyStarter) both use. It holds what the flags and the run folder's sidecars held: the address, the VM, the password (proxy.auth), the built-in policies and the user's files (proxy.policy), the logs, the lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix cache and its cap, the links, and the SHA-256 of devvm's binary and CA (proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole, mode 600, before each start, and starts a running VM's proxy again when the config it would start it with has another Sum. ReadConfig reads it as the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat, a regular file owned by the proxy's user that nobody else may read or write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a loopback listen address. The VM's proxy is found by _proxy -config with its own config's path. paths.VM names ProxyConfig, ProxyPID and ProxyStatus. Policy files are read only as regular files of at most 1 MiB (proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong; ErrNotPrivate for the config and the links' list); the proxy keeps a file's last rules and logs why once. hostOK refuses a name with an empty label (evil.test.., evil..test, .evil.test), so no form of a name gets past a deny the policy's own trim would miss. A build proxy that can't be spawned leaves no config behind. Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a folder, group-readable and group-writable files, a long file, other versions, unknown fields, two configs, no password, non-loopback addresses, a CA without its key, a negative cap; ReadRegular and the policy readers on a FIFO, /dev/zero and a big file without hanging; the running proxy keeping its last rules; hostOK and requests with empty labels (failing on the code before); Prepare's config, restarts on a binary change, a missing config and one others may read; concurrent config writes; the build proxy's config and its removal; proxy.txtar, network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the config's mode, password and the proxy's arguments. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c77a3fbc3b |
docs: the state layout, each part described once in its owner page
Overview's State files explains the two folders, the formats, a VM's folder file by file, its state and the locks; the data folder's listing is space.md's and the config folder's settings.md's, linked from the others. design.md gets a note on the layout and why no database. Contributing names the paths and how to add a file, socket, record, default or lock. Stale facts fixed: the claims lock in space.md and design.md, the forwarder's control socket, the config folder's version, the proxy README's Nix cache path, an export's .folder file. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f4fd373439 |
refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend, Caps, Features, Review/Require, the registry, backendtest.Fake), so another backend is an addition. State from a smolvm VM reads as an unknown backend (backend_unknown_vm, gc_orphans_unknown); nothing migrates it. The image keys of layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images rebuild once. Lima's port forwarder moves off smolvm's files first: newForwarderCmd and forwarderMain from internal/cli/smolvmports.go to limaports.go, and assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder at run time, so no image key changes). Removed: - internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its registry entry, registry.Experimental and backend_experimental. - The decider: backend.Decider/UsesDecider, Confinement.Decider and DeciderToken, internal/proxy/decider.go and its test, the proxy's -decider, -decider-to and -decider-token-file, netpolicy's KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in vm's forwarding and UsedPorts. - backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and agent_unchosen_stop. - vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped). - paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing called (a test helper now). - ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and bump.sh's ubuntu_image, with its part of bump.txtar. - assets/smolvm/ and assets/container/; the no-init-system branches of layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in features/desktop.sh and guest/ca.sh. - Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh, creating_from_image, packing_image, pack_failed, backend_experimental, agent_unchosen_stop; descriptions naming smolvm reworded. - Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a failing or hanging Lima listing instead (the limactl stub's list-fails and list-hangs); the --backend smolvm examples; e2e's --backend smolvm and its section (about 1,130 lines), the smol_* helpers and the link section's backend switch. - Coverage: internal/backend/smolvm's lines in both baselines. - Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm notes (Ports on Lima now holds the forwarder's description), the backends table's smolvm column, every page naming smolvm, the README, the home page's backends art, and AGENTS.md's smolvm rows and gotchas (and the Docker bind-mount gotcha, which nothing refers to). Kept: the docker layer, on Lima; --from's local Docker; --backend, the BACKEND column and setup's backend choice, which the next commit removes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1917072228 |
refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the default backend and smolvm stays experimental. The backend architecture (Backend, Caps, Require, the registry, backendtest.Fake) stays, so another backend is an addition. Removed: - internal/backend/docker, its registry entry and Names/Experimental's docker half; devvm _docker-connect and _docker-ports (internal/cli/dockerssh.go); assets/docker/unpack.sh. - Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS, DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256 ldflags vars and the CLI tests' Linux-build archive (linux_release). - Interfaces only Docker implemented, with their callers: backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix), DiskUser (ls's and size's disk-over warning, size's disk_used and --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover (gc --orphans' volumes, networks, containers and images), DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name. - The docker layer's runtime on a backend that makes VMs for it: vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet returns a bool now), the refusals at start and devvm network on, ls's "(sysbox)" and --json docker_layer, size_disk_default_unused. - The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix). - paths.Dirs.Docker and paths.VM.Lifeline. - assets/guest/tools.sh's linked-folder branch; services.sh's DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd. - Messages: every docker_* the backend used, docker_layer_runtime, net_docker_layer, net_off_docker_layer, committing_image, pulling_image, unpacking_tools, disk_over, size_disk_default_unused, gc_orphan_volume/_network/_container/_image, docker_connect_failed; gc_orphan_elsewhere reworded. - Tests: docker.txtar, the docker stub's engine (its --from half stays), the ssh stub's login-shell branch; e2e's --backend docker, --engine, the docker host VM and Docker Desktop runs. - Release: one GoReleaser pass, no Linux-build pin in the macOS builds, no Linux devvm in the Homebrew formula's libexec. Linux builds stay. - Docs: backends/docker.md and internals/docker.md, design.md's Docker notes, the Docker column of the feature table, and every page's mentions of the Docker backend, Docker Desktop as one, and Sysbox. Kept: the docker layer in Lima VMs, devcontainer docker-in-docker, --from with images only a local Docker has, Docker Hub references. State written by a Docker VM before this reads as an unknown backend (backend_unknown_vm). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d8a7d4de7f |
refactor(state): a folder per VM, keyed by its project folder's hash
Every file devvm keeps for a project VM is in one folder, vms/<hash>/, where <hash> is the 14-hex hash of the project folder's path that the VM's name ends with: its state, its own rules (policy), its backend's files (backend/: record.json, key, known_hosts, proxy, ports and the port forwarder's ports.*), what its runs leave (run/: proxy.*, sandbox.sb, started, lifeline.pid, secrets.*, links.*) and its logs (logs/: network.jsonl, proxy.log, links.log). Build VMs keep the same layout in run/builds/<name>/. The top-level run/ holds only what isn't one VM's or must be short: the hashed control sockets, links' link-<hash>.sock/.ctl, the QEMU wrapper and the ports lock. A folder's VM is found by its path's hash (state.ReadHash), with the name and backend its state records, so devvm --backend docker then devvm in the same folder opens the one VM, and a backend's name limit applies to new VMs only. The state records the VM's name and its ssh alias, chosen once at creation (sshconfig.ChooseAlias) and never recomputed. Links' targets match recorded names, aliases and folders (project.Targets). One teardown (vmFolders.teardown) replaces Lifecycle.forget, undoCreate's own list, Leftovers.Forget's, Proxy.Forget and space's leftoverFiles: it stops the proxy and link session, then the pieces outside the folder (clone remote or .git locks, other VMs' links and the group, host keys, the backend's leftovers), removes the folder, and writes the ssh config. Each backend's Delete and Forget remove the VM's backend/ folder (vmssh.Forwards.Forget). A new VM made where an earlier one's folder was left clears it first. devvm space counts an orphan's whole folder as leftover state and the other VMs' logs as network logs. Path builders move into paths: Dirs.VMDir, Dirs.VM and paths.VM's files (secrets' BindingsFile/PolicyFile, netpolicy's run, EventLog, ProxyLog, LinkList, VMPolicyFile, Lima's profileFile, startedFile, forwards.file, vmssh.Forwards.file, links' LinksLog/linksPID, Docker's vmFile and lifeline), ToolLockConfig, ToolLockChecked and ToolsCheckLog; the user's cache folder for Lima's and smolvm's caches is Dirs.UserCache, from HOME, not os.UserCacheDir. Dirs.VMState, LimaVMs, SmolvmVM and DockerVM go. vmname.HashOf and IsHash, project.Hash. The proxy takes the links' sockets' folder (-link-sockets, devvm's run folder) apart from the links' list, which is in the VM's run folder. Tests: a VM made and removed (rm, gc --orphans) leaves nothing under vms/, and with network policy has no file named for it outside its folder (TestTeardownLeavesNothing); a new VM over an old folder starts clean; lookup finds a VM made on another backend with a long folder name and makes no second one (TestLookupOtherBackend, and in docker.txtar); the alias stays put when a second VM shares the folder name (TestChooseAlias, ssh.txtar); every socket fits under a 35-character home with the longest VM name (TestSocketsFit); space counts an orphan's whole folder (TestLeftoverFolders); paths.VM's files; state by hash and name; the proxy refuses a socket in the list's own folder. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9f791bc96 |
refactor: one owner for the proxy's constants, URLs, variables and tunnels
The proxy owns the links' addresses and domain and the proxy user: proxy.IsLinkAddr, proxy.LinkAddr, proxy.LinkDomain and proxy.ProxyUser replace vm.IsLinkAddr, vmssh.IsLinkAddr, vm.LinkNet, vm's linkNetAddr, vm.LinkDomain, netpolicy.LinkDomain and the proxy's own isLinkAddr and linkDomain. TestLinkAddrsAgree goes, because there's nothing left to agree. The proxy's link list now refuses an IPv4-mapped address too, as vm's parser already did. backend owns the guest's view of a proxy: ProxyUser (proxy.ProxyUser), ProxyURL, GuestProxyVars, ClientProxyVars and NewProxyPassword replace four URL builders (BuildProxy.URL, Lima's, Docker's and smolvm's), the user written out in three places (netpolicy.ProxyUser, buildProxyUser, Docker's proxyUser), the guest's variable list in three (Lima's inline loop, smolvm.proxyVars, Docker's proxyVars) and the client's in two (limaProxyVars, Docker's noClientProxy list), and the two password generators. Confinement.ProxyUser goes: Docker ignored it, and every backend now uses ProxyUser. A new VM's proxy key is NewProxyPassword's 64 hex digits, as a build proxy's was; a VM keeps the key it has. doctor reads HTTPS_PROXY through backend.ReadHostProxy. In the proxy, hijack and splice replace the three CONNECT copies (tunnels to allowed hosts, tunnels to links, interception's hijack) and the relay's pipe. A tunnel passes the bytes as they are, passes on the end of what the client sent, and ends, closing both connections, when the server's bytes end or the client has gone. A relayed connection now ends with the proxy's side too, where before it waited for both. Tests: splice_test.go characterises the allowed-host tunnel, the link tunnel and the relay (a megabyte of every byte value, a half-close answered, a client that goes away ending the tunnel), written against the code before this change; TestSpliceEnds, TestHijack and TestIsLinkAddr (every LinkAddr) are new, and so are TestProxyURL, TestNewProxyPassword and TestProxyVars. TestLinkListRefused gains a mapped address. e2e: the relaunch without a company proxy says which step failed, with the launch's output, the VM's status and the proxy's log, and a link helper that doesn't start shows its output. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f2a8ddd404 |
refactor: write every file whole through state, and make private folders with state.PrivateDir
internal/state is the one writer of whole files outside the proxy: state.WriteFileMode joins state.WriteFile for another mode (0700 for the QEMU wrapper and Docker's copies of devvm's Linux build), and state.PrivateDir makes a folder the user's alone (700), refusing a file or a symbolic link there, as vmssh's runDir did. - Deleted: both writeOwn (backend's build proxy, Docker's egress), lima's writeFile (the Seatbelt profile, the QEMU wrapper, the start record), vmssh's writeWhole and runDir, Docker's copyFile, the Linux build fetch's temporary file (fetch.Open's body is read whole, its SHA-256 checked, then written with state.WriteFileMode), and Resolve's .tmp-and-rename loop. The host's mise stays fetch.Download's. - os.WriteFile to state.WriteFile: tools (Resolve's and lockVersions' mise.toml, the checked file, the tools build's files), sshagent (two), ubuntu's checksum files, docgen's pages and backendtest's fake tool images. - state.PrivateDir for nine MkdirAll and Chmod pairs (eleven folders): the run log's two, tools' logs, secrets, netpolicy's CA, run, logs and socket folder, lima's run folder and the exports folder. MakePrivate and ~/.ssh keep following a link: where they live is the user's choice. - The proxy's writers are one, writeAtomic: the login files' writeJSON and the Nix cache's size file use it, its temporary files named .<name>.tmp-* as state's are. - forbidigo bans os.WriteFile outside internal/state, internal/proxy, internal/msg/gen, internal/stubtest and tests, with its line in testdata/lint/forbidigo.go. Tests: TestWriteFileMode, TestPrivateDir (a symbolic link to a folder refused, its folder's mode unchanged), TestWriteAtomic; mode checks on the Seatbelt profile and Docker's Linux build copy. Coverage baselines raised: lima, netpolicy, proxy, secrets, ui. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2687eec488 |
refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns devvm's background processes: Detach and Spawn (own session, no input, reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status file), Handle (signals through the process started), Proc (a pid file checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL, the pid file removed once stopped), readiness by status file (Ready, WriteStatus, WaitReady: the pid and data, written in one line-ended write, never another start's), Alive and Signal (no pid below 1), and one lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content equality, a bounded wait past what the file held first). It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards' pid, stop and start wait, the build proxy's process and log-read port, links' link-session pid, stop and start, the proxy's watchLifeline and vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess, and the alive copies (netpolicy alive/signal, lima alive, vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go: the proxy and the forwarder say they're ready in a status file, and the build proxy's port comes from its own. forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside internal/daemon and internal/platform, with its line in testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS and puts internal/daemon among the leaves; depguard holds it to the standard library. Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file, groups refused, readiness, lifeline), characterisation tests first for the proxy's, the forwarders', the link sessions' and the build proxy's pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f71adb5a04 |
refactor: devvm's own files stay in the binary
assets.FS is the only copy of devvm's own files: nothing writes them to
~/.local/share/devvm/assets/<hash> any more, so an edit on disk can't
widen running proxies' allowlists or change a --from base its key
doesn't describe.
- Proxy: -builtin-policy NAME,... names policies in IO.FS (cli's _proxy
passes assets.FS; proxy stays stdlib-only). Built-ins are parsed once
at start (readBuiltins), ahead of -policy's files in the union, never
re-read; a missing one, or one with a line that isn't a rule, refuses
to start. -policy carries only the user's files.
- netpolicy: PolicyFiles(d, assets, vm, img) becomes Policies(d, vm, img)
(builtin, files); Proxy.PolicyFiles and AssetsInUse go. .proxy.policy
records both lists, a line each, for the restart check. ReadRules takes
built-ins from an fs.FS; RuleFile.Builtin.
- devvm network: built-ins labelled "# devvm: layers/base.policy";
--json entries carry "builtin": NAME or "file": PATH ("version": 1).
- Lima: createArgs ends in "-" and create() feeds base.yaml on stdin;
convert writes oci/ and, with company CAs, guest/ca.sh into its own
temp folder beside vm/ (writeScripts, state.WriteFile), mounted
read-only and deleted by the existing cleanup. Lima.assets() goes.
- Deleted: internal/state/assets.go and its test (WriteAssets,
StaleAssets, AssetsHash), paths.Dirs.Assets, gc's stale-assets plan
and the gc_assets/deleted_assets messages, space's devvm's files row.
- Tests: proxy built-ins (order, not re-read, missing/invalid refuse,
Main refuses before listening), Policies, the restart check on either
list, ReadRules/WriteRules labels, JSON shape, createArgs and create's
stdin, writeScripts' files and modes; CLI scripts check
$XDG_DATA_HOME/devvm/assets never appears after up, build and --from,
base.yaml on create's input (the limactl stub keeps it), the
conversion's mounts and script paths in its temp folder.
- Docs: design (One binary), install, overview, space, images (gc),
internals network, images and lima, safety/network, proxy README,
the network command's Long and its CLI page; AGENTS.md rule.
- Coverage baselines (darwin) raised: cli 88.2, netpolicy 87.2,
proxy 88.2, state 91.8. Dirs' method cap lowered to 41.
Image keys are unchanged: they already hash the embedded files.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
42fb9828fe |
test(proxy): TestDecider waits for the refusal it checks in the event log
The decider logs each refusal as it answers it, so on a busy machine the test could read the log before the last refusal's line was written. It now waits for that line. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
487366d186 |
fix(netpolicy): one strict parser for policy files, lines that aren't rules named, broken denies fail closed
The proxy read policy files with a laxer parser than devvm network allow's check: a line that wasn't a rule was dropped without a word, or kept as a rule that matched nothing (example.com:x became a host of that name, a rule's trailing dot never matched), so a hand-edited deny could lapse unseen. proxy.ParsePolicy is now the one parser: it returns each line that holds more than a comment, with its number and whether it's a rule, and a line is a rule only when ValidRule takes it, which is what devvm network allow and deny take. parseRule is strict: ports 1 to 65535 in digits, printable ASCII names with no empty label, brackets for IPv6 alone, no address under *., IPv4-mapped prefixes as their IPv4 ones, and one trailing dot dropped, as requests' are. A line that isn't a rule but starts with ! (proxy.BrokenDeny) fails closed: while any of a VM's policy files has one, its proxy denies every name and address, each request getting 403 and a refused block that names the file and line, with no allow advice (block honours Refused; policy.verdict and checkRefused carry it). Other lines that aren't rules are skipped. The proxy logs each one, devvm network marks it (its control characters dropped, msg.OneLine) and --json lists it in not_rules. netpolicy.PolicyWarnings warns of each (policy_broken_deny or policy_not_rule): at each launch with network policy (Proxy.Prepare), after devvm network allow, deny and rm for the file they change, and in devvm doctor for the files you edit (NotRules). AddRule and RemoveRule find rules through ParsePolicy, so ruleOf is gone. A policy file that comes back after it was missing is read again whatever its mtime, an error other than a missing file keeps its last rules and broken deny, and a leading byte-order mark isn't part of the first line. Docs: rules, broken denies and devvm network's output (safety network), the parser and the fail-closed policy (internals network), doctor's warnings (install, internals install), the e2e network section (contributing), the proxy's README. Tests: TestParsePolicy, TestPolicySkipsBadLines, TestPolicyBrokenDeny, TestPolicyFileBack, TestValidRule's new cases and FuzzParseRule's agreement and host properties (proxy); TestBuiltinPolicies, every policy file devvm ships, TestNotRules, TestPrepareWarnsPolicy, TestWriteRules and TestAddRemoveRule's new cases (netpolicy); TestDoctorReport and the network JSON shape (cli); network_rules.txtar's mark, not_rules and the warnings on a change, a launch and in doctor; e2e network: a broken deny makes the running proxy refuse an allowed host until it's gone. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aa24efe2e7 |
fix(proxy): certificates never outlast devvm's CA, and a CA that ended is named
The proxy keeps the CA it started with, because its VM trusts no other, so a VM that runs past its CA's end without a launch can't verify the proxy's certificates. Leaves were minted for a day whatever the CA had left, so they could outlast it, and once it ended every intercepted tunnel failed its handshake with a misleading reason. leafFor now caps a leaf's NotAfter and NotBefore at the CA's, keeps a leaf that ends with the CA until then, and mints none once the CA has ended (errCAEnded); a CONNECT that would be intercepted then gets 403 before its tunnel opens (caEndedRefusal), logged as a refused block, so no allow rule is suggested, with a reason that says to open the VM again, which makes a new CA, installs it and starts the proxy again. Docs: how a VM trusts the CA and what happens at its end (internals network and security, safety network), the proxy's README. Tests: TestLeafWithinCA, TestInterceptCAEnded (proxy). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6c14ee0748 |
fix(network): the event log's two writers rotate it by one rule and follow each other's rotations
devvm _links rotated a VM's event log by its own size check while the proxy still had the file open, so the proxy went on writing into the renamed .1 file, devvm network log --follow missed those lines, and the proxy's next rotation, by its stale counter, renamed the link-only log over .1 and lost the old one. Both writers now use the proxy's writer: proxy.OpenEventLog, which netpolicy.AppendEvent writes each event through. Before each line it checks that its open file is still the one at the path (os.SameFile), opens the path again when it isn't, and takes the log's size from the file. A rotation holds the file's flock and checks the name again, so two writers past the limit at once rename it only once. One exported proxy.LogLimit replaces logLimit and eventLogMax, and the limit is a field of the writer, so the proxy's tests pass their own. Tests: TestAppendEventRotatesUnderTheProxy (netpolicy; fails on the old code: the padding and the proxy's first line were lost) and TestRotateFollowsTheOtherWriter (proxy). Docs: internals/network.md's log files, design.md's link events, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5db31c92be |
feat(link): the per-VM proxy reaches a VM's links, and link names leave NO_PROXY
In a VM with network policy, an HTTP client that honors HTTP_PROXY now reaches a link through the VM's proxy, so a link added while the VM runs works at once and nothing restarts. The ssh remote forward stays the transport for every link; the proxy is a second entrance to the same host socket, and devvm _links's per-connection checks apply to both. - devvm _links writes every link the client has, carried or not, to run/<vm>.links.json (proxy.LinkList, mode 600, written whole) whenever they change or the file is gone; it stays after the session, so a link with no socket is refused rather than asked of the rules. Forget removes it with the VM. - devvm _proxy -links FILE reads it per request (regular file, no symlink, owner-only writes, 1 MiB, version 1, O_NONBLOCK), before any rule: CONNECT and absolute-form http, exact match after lower case and one trailing dot, NAME and NAME.devvm.internal. An entry counts only when its socket is proxy.LinkSocket(list folder, -vm, addr, port) and its address is in 127.77.0.0/16. Bytes pass as they are: no SNI check, interception, secrets or rules; absolute form goes in origin form without the proxy's headers, one connection per request, cancelled with the client's request; https in absolute form gets 400. No event for a carried link (devvm _links logs link); a dead socket gets 502 and link_refused "not carried", after retries for a full backlog. Any other name under devvm.internal is refused (403, a refused block). - vmssh.Links.Socket uses proxy.LinkSocket and LinkHash (same names). - The link socket's accept loop only accepts, and hands a burst on whole (5 ms quiet, 50 ms at most, or 257 waiting) before relays start, as fork-heavy relay starts let macOS's 128 backlog overflow unlogged; past the cap, refused in the loop with link_limit. Temporary accept errors back off instead of ending the link. - NO_PROXY is localhost,127.0.0.1,::1 everywhere: netpolicy.LinkEnv and linksNoProxy are gone, netpolicy.NoProxy is a constant, the start only checks the links (checkStartLinks). No dockerd or nix-daemon restart and no limactl edit on link changes. assets/guest/sync.sh: comment only. - devvm network log's help says link events land there for every VM. - Docs: using/links.md, safety/network.md, internals/network.md (Links through the proxy, -links), ports.md, lima.md, design.md (the proxy's entrance, the burst, threat-check rows for the proxy path, links added while running and untouched bytes, the sshd row reworded, Not covered), contributing, internal/proxy/README.md. - Tests: proxy TestLinkConnect, TestLinkConnectUntouched, TestLinkForward, TestLinkGone, TestLinkListRefused, TestLinkDomainRefused, TestNoLinksFile, TestLinkSocket; vmssh TestLinksBurst, TestLinksList; netpolicy TestNoProxy and the -links argument; e2e lk_proxy_added and lk_proxy_own, and lk_cap's burst without pacing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6805d194bd |
feat(link): devvm _links, the host side that carries a client's links, and the forwarder skipping links' addresses
vmssh.Links runs a running client VM's link session: one ssh master of its own to the client (never the forwarder's), started with ClearAllForwardings=yes and -N, to which each link is added with -O forward -R 127.77.x.y:PORT:<socket> and from which it's removed with -O cancel, read again every second (Want). Each forward is its own, so one the client refuses fails that link alone (Failed, which warns with link_port_taken through Link.PortTaken). Each link's end on the host is a unix socket, mode 600, in the run folder (made 700), named link-<hash of client, address, port>.sock; masters' control sockets are link-<hash>.ctl (the session's; a target's by target and start). A stale socket is replaced, anything else refused, and sockets go with their link or the session. Each connection is checked again (Check), then carried by ssh -S <target master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT through a master kept per target and start: a channel goes through the master or nowhere. At most 256 at once, then refused (link_limit). Events (link, link_refused, link_target_stopped, link_limit) go to the client's event log. The session ends once the client no longer runs its start, or has no links. vm.Links.Session builds it from the state and the backends: the client's and targets' ssh from Backend.SSH, the key its first IdentityFile, host keys devvm's pinned known_hosts (HostKeyAlias), only on a host loopback port or through the backend's ProxyCommand, FeatureSSH allowed. linkConn re-reads the states per connection: the link still in the client's state (removed), CheckLink (gone, replaced, unpublished, policy), the link features on the target's backend, the target running (Inspect, StartID: link_target_stopped otherwise; it never starts one), its ssh (ssh). devvm _links VM (hidden, one argument) runs it, failing with link_session_failed or vm_not_running. The port forwarder never forwards a listener in 127.77.0.0/16 (dialAddr, vmssh.IsLinkAddr), on any VM; a test keeps vmssh.IsLinkAddr equal to vm.IsLinkAddr on every link address and around them. netpolicy.AppendEvent writes devvm _links's events beside the proxy's, mode 600, rotating past 10 MiB; events carry target, which FormatEvent and devvm network log --json show. Tests: TestLinkArgs, TestLinkFiles, TestListenSocket, TestLinks, TestLinksSessionLost, TestLinksCap, TestIsLinkAddr, TestListeners (range exclusion) in vmssh; TestLinkAddrsAgree, TestLinkConn, TestSessionLinks, TestLinkEvents in vm; TestAppendEvent and link cases in TestFormatEvent; link_session.txtar for _links's argument and refusals; e2e's project section checks a server on 127.77.0.1 isn't forwarded while the VM's own on 127.0.0.1 with its port is. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e782de9ae8 |
feat(cli): flags local to their commands, one meaning per name, and one duration grammar
devvm [IMAGE]'s flags for a new VM (--backend, --from, --cpus, --memory, --disk, --ports, --network-policy, --no-network-policy) are the root's own, so devvm ls --cpus 4 and devvm setup --cpus 2 fail as unknown flags. build, rebuild and images rm take --backend and --from; images, gc and space take --backend as a filter of their own (images and space now filter: only that backend's rows); doctor takes --backend; restart and tools take none. ports -g is local on ports, ports add and ports rm. No command has a persistent flag. One name, one meaning: network log --follow loses -f (-f is --force's, and gc --force gains it); the hidden secret get's --force becomes --to-terminal. Flag defaults name the setting command (devvm size -g, devvm ports -g, devvm setup --backend); descriptions lose then/also openings. Special values are words: an empty flag value (flag_blank) or an empty argument (arg_blank) is refused everywhere, replacing features_empty. Durations: state.ParseDuration (a whole number and m, h, d or w) for gc --older-than, retention's ages and ssh-agent add --lifetime (which also takes forever, via sshagent.CheckLifetime), with one message, bad_duration, replacing gc_bad_age and agent_lifetime_invalid. Blanks are checked with the other usage errors (checkCommand, before checkFlags), and an unknown --backend NAME is a usage error checked first too (checkFlagValue, against registry.Names, which a test keeps equal to the registry's own). Tests: TestPersistentFlags, TestFlagNamesHaveOneMeaning, TestUpFlagsAreUpsAlone, TestParseDuration, TestCheckLifetime; root, setup, images, space, gc_history, retention, ssh_agent and network_log scripts. Docs: commands.md (Flags and values), from.md, install.md, images.md, space.md, settings.md, ssh.md, network pages; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3b1959efd2 |
feat(network): network policy rules and log under devvm network, and network -g for new VMs
devvm network allow|deny|rm RULE... [-g] and devvm network log [-f] [-n N] [--blocked] replace devvm policy and devvm log. Bare devvm network shows the VM's network policy, then its allowlist file by file. devvm network -g shows or saves whether new VMs get network policy (ask, on or off), through the network file devvm setup also writes; --network-policy and --no-network-policy beat it and skip reading it, a saved off makes a VM without the docker-layer and backend warnings, and with ask and no terminal a new VM gets it. The proxy's block messages, devvm-why's, network log --blocked's ALLOW WITH and the VM's setup note name devvm network allow. New messages: net_default_failed, net_ask_global; -g reports with network_default. Docs, the CLI reference, txtars (network_rules, network_log, network), e2e (bare devvm network's first line) and AGENTS.md follow. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6f680a6f8b |
feat(proxy): a shared, read-only Nix cache that only the host fills
VMs with network policy and the nix layer share their downloads from cache.nixos.org: the proxy answers http://devvm.proxy/nix/ itself (a reserved endpoint, never forwarded), and the guest setup puts it before https://cache.nixos.org in Nix's substituters, trusted-public-keys left as Nix's own (cache.nixos.org-1). Each VM keeps its own store and daemon; only downloads are shared, and no VM can change what another gets. The proxy (internal/proxy/nixcache.go, -nix-cache DIR and -nix-cache-max BYTES): - takes only GET and HEAD, no query, nothing escaped, of nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no suffix or .xz, .zst or .bz2 (nixPath, FuzzNixPath); 400 otherwise; - makes up nix-cache-info (priority 30, before cache.nixos.org's 40); - fetches from https://cache.nixos.org alone, when the VM's policy allows cache.nixos.org:443, through the floor or the company proxy, with the system's roots and the user's CAs, following no redirect, sending nothing of the VM's request; - keeps a narinfo when its StorePath is the path asked for, its URL is of the pattern and named by its own NarHash or FileHash, and a Sig by the pinned cache.nixos.org-1 Ed25519 key verifies over 1;StorePath;NarHash;NarSize;References (parseNarinfo, against a real narinfo and NAR of cache.nixos.org's in testdata/nix/); - fetches a NAR only after a narinfo it checked names it, never for a HEAD, once however many ask and at most four at once (fetchOnce), and keeps it when its SHA-256 and size are the narinfo's FileHash and FileSize; a cached copy of another size is dropped; - answers 404 to anything that fails, keeping nothing, so Nix goes to cache.nixos.org itself; logs each request as a nix-cache event (hit, fetched, or why not), which devvm log shows as cache; - writes files whole and renames them in, 600 in folders of 700. The cap: the nix-cache.size retention setting, 10 GiB when off (state.NixCacheDefault, proxy.NixCacheDefault), with state.ParseSize (500M, 20G, 1T). Under a flock on .lock every proxy takes a file's room before writing it (reserve, in whole blocks), deleting the least recently used files (by mtime, which a hit sets) down to nine tenths of the cap; a NAR being fetched is made its full size at once and counts, so a fetch the in-flight files leave no room for is refused. devvm gc trims to the cap, devvm gc --nix-cache empties it, and the daily retention run trims it (proxy.TrimNixCache, NixCacheUsage). devvm space has a Nix cache row (GC: what's over the cap, FREED BY gc --nix-cache, RETAIN nix-cache.size), devvm images says what it takes of its cap. netpolicy passes -nix-cache and -nix-cache-max only for images with the nix layer (nixCacheArgs; a retention file it can't read warns and uses the default). The guest setup writes /etc/nix/devvm-cache.conf through !include in nix.conf only with the nix layer and policy on, removes it otherwise, and restarts nix-daemon when it changes. VMs without network policy get no shared cache: they fetch from cache.nixos.org directly, and nothing new runs or listens on the host for them. Review (security-audit skill, on nixcache.go, its callers and the setup): a NAR could be kept under another NAR's name, as the URL isn't signed (fixed: the URL must be named by the narinfo's own hashes, and a hit of another size is dropped); files being fetched didn't count against the cap and blocks weren't counted, so one VM's parallel requests could pass it (fixed: reserve, full-size temp files, block counts, fetchOnce); a HEAD downloaded a NAR (fixed). Ruled out: stored VM input, paths out of the folder, another upstream, parser differences, cross-VM visibility beyond timing, a VM's own nix.conf. Open, documented: timing tells a VM whether some VM fetched a public path, and a VM can fill the cache to its cap. Messages: gc_nix_cache_over, gc_nix_cache, deleted_nix_cache, images_nix_cache; retention_deleted gains nix_files. Paths: Dirs.NixCache (structure limit for Dirs to 40). Flags: devvm gc --nix-cache; the CLI reference regenerated. Tests: TestNixPath, TestNix32, TestParseNarinfo, TestNixCacheServes, TestNixCacheRefuses, TestNixCachePolicy, TestNixCacheFetches, TestTrimNixCache, TestNixCacheCap, FuzzNixPath, TestParseSize, TestRetention, TestNixCacheArgs, TestFormatEvent; nix_cache.txtar (the proxy's endpoint and refusals, space, images, gc, gc --nix-cache, retention); e2e nix: the VM's substituters and keys, hello through the cache, fetched by the host (600/700), a VM's writes and other requests refused and nothing kept, a second VM's hits fetching nothing, no cache after devvm network off. Docs: the design note (internals/design.md), internals/network.md's The shared Nix cache, the VM's setup, logs and flags, internals/security.md, internals/images.md, safety/network.md's Nix and Logs, using/toolchains.md's Nix projects, using/images.md, using/space.md, using/settings.md's Retention, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f196357f43 |
feat(netpolicy): the proxy rotates a VM's network logs past 10 MiB, one old file each
A VM's <vm>.jsonl and <vm>.proxy.log grew without limit. The proxy, their only writer, now rotates each before a line would take it past 10 MiB (logLimit), keeping one old file: - the event log (-log) is the proxy's alone: renamed to <log>.1 (the previous .1 dropped) and a new one opened, 600; - the proxy's own log is also the process's stdout/stderr, which netpolicy opens, where Main's last error and a crash go. A new -proxy-log flag names that file: the proxy's logger writes through a rotating writer that copies it to <log>.1 (written whole, 600) and truncates it, so the O_APPEND writes that bypass the rotation still reach the current file. The HTTP servers' and the reverse proxy's ErrorLog is the proxy's logger, so their lines go through the rotation instead of straight to stderr. Stdlib only. Writes are serialized and each is a whole line, rotated before the write, so no line is lost, split or duplicated. A log deleted while the proxy runs starts again at the limit. The start check (logged) finds the listening line across a rotation (the rest of <log>.1 and the new log). devvm log reads <vm>.jsonl.1 before <vm>.jsonl (opened after the log, and skipped when it's the same file, so a rotation while opening reads nothing twice); --blocked counts both; -f reads a renamed log to its end, checked before the drain so no late line is missed, then follows the new one from its start; a just-rotated empty log with a .1 isn't log_empty. Review (log rotation): lost or duplicated lines across a rotation (none: mutex, rotation before the whole-line write; TestRotateConcurrent: 16 writers, every line once across both files); a VM writing faster than rotation (rotation is inline in Write, so it can't fall behind; a follower misses a file only if two rotations, 20 MiB, happen within one 250 ms tick); devvm log -f across a rotation (TestWriteLogFollowRotated); modes 600 after a rotation, a log left 644 tightened at open (TestRotateRenames, TestRotateCopies); rm deleting every rotated file (existing.txtar: .jsonl.1 and .proxy.log.1 gone). Copy rotation can lose only a write that bypasses the logger between the copy and the truncate: a runtime crash's output. Tests: proxy unit tests (rotation at the limit, one old file, a long line, a deleted log, concurrent writes, the copying rotation), netpolicy reader across a rotation and following one, logged across a rotation, log.txtar (rotated history and blocks, a just-rotated log), existing.txtar (rm). Docs: internals/network.md's Log files and -log/-proxy-log flags, safety/network.md's Logs, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
529e8132c3 |
fix(netpolicy): Lima's and a Linux engine's build proxies pass names the host can't resolve on to the company proxy
A build's proxy has policy ** alone, so it refused every name this machine can't resolve, and where only the company proxy resolves outside names, builds behind it reached nothing by name. devvm _proxy gets -upstream-unresolved, which sends such names upstream unjudged even when only ** allows them; a denied name stays refused. Lima's build proxies and a Linux Docker engine's start with it: without a company proxy those builds reach internal addresses directly anyway. Docker Desktop's build proxy starts without it, as its builds are kept off this machine's own services, which a company proxy on its loopback could reach. Tests: TestUpstreamUnresolved covers the flag; Lima's build test checks the build proxy gets it; TestBuildOnDesktop's exact arguments keep it off. Docs: safety/network.md, using/troubleshooting.md, internals/design.md, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
080d57dd28 |
fix(netpolicy): builds reach a company proxy through a proxy of their own; ** refuses names the host can't resolve
From an independent review of the company-proxy change. 1. Builds never get the company proxy's credentials. Each build behind a company proxy goes through a devvm _proxy of its own on the host (backend.ProxyStarter / BuildProxy, shared by Lima and Docker; Docker Desktop's build proxy moved into it): policy **, a new random password, the company proxy in its -upstream file, -lifeline on the build VM's hostagent or the container's docker container wait. Builds get only http://devvm:<one-time>@<host>:<port> (each variable the host sets) and the host's NO_PROXY. - Lima: image builds, the tools build and --from's conversion VM reach it at 192.168.5.2; on macOS the build's Seatbelt profile allows that one loopback port (NetInternet + ProxyPort), so a loopback company proxy works for macOS builds too. guestProxyURL is gone. limactl runs without the host's proxy variables (Lima logged them, password and all, into devvm's run log; found by the new e2e check); only a NetDirect start gets them back for propagateProxyEnv. - assets/oci/build.sh: the /etc/os-release probe runs under env -i; chroot_run passes only the build proxy's variables (bootify.sh's downloads behind a company proxy). - Docker: buildNet takes Desktop's path (own network, relay, build proxy) on any engine behind a company proxy; hostProxyEnv is gone. A Linux engine's build behind one needs devvm's Linux build. - Settings the proxy can't go through are refused before anything is made (upstream_proxy_scheme, reworded for builds too). 2. noClientProxy on the tools' unpack container and the relay. 3. floorUpstream: a name the host can't resolve goes upstream only when an allow rule names it (itself or *.domain: policy.byName); with only ** it's refused (errUnresolved, logged as the reason). 4. CONNECT replies are read through a 64 KiB io.LimitReader (maxConnectReply); bytes after the answer stay the tunnel's. Tests: backend (TestProxyStarter, TestProxyStarterFails, TestListeningPort, TestBuildProxyStop), lima (TestBuildImageHostProxy on linux and darwin with the Seatbelt port, TestBuildImageHostProxyRefused, TestConfineProxyEnv), docker (TestBuildHostProxy for a Linux engine with and without a company proxy, unpack's empty proxy pairs), proxy (TestUpstreamUnresolved, TestUpstreamConnectReplyLimit). CLI: docker.txtar (a Linux engine's build behind a company proxy; every container create and run, kept by the stub in containers-made, sets the empty -e pairs), from.txtar (builds' proxy folders gone). e2e: images (a build sees only its own proxy), from (a --from alpine:3.21 base with every feature and a layer behind a company proxy with a password: the registry, Alpine's mirror and the layer reach it through the builds' proxies; the password is in no converted disk, image, log, build file or process's arguments); corp_start/corp_stop shared with network. Docs: internals/design (A company proxy: the ** case, builds, checks; build confinement), safety/network, internals/network, images, lima, docker, using/troubleshooting, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2f559eaaa5 |
feat(netpolicy): network policy behind a company proxy; host proxy credentials kept out of images
Behind a company proxy, network policy's proxy connected to servers itself and reached nothing. It now reaches allowed hosts through the host's HTTPS_PROXY / HTTP_PROXY, still deciding each request by the name the VM asked for. Step 1, credentials (traced in the code and the backends' published docs; not yet proven on a real build, which the new e2e checks do): - Lima: build VMs (images, the tools build, --from's conversion VM) started with propagateProxyEnv on, its default. Lima's 07-etc-environment.sh writes the propagated settings into the guest's /etc/environment between #LIMA-START/#LIMA-END on each boot, and a stopped build VM's disk keeps it, so an image built with HTTPS_PROXY=http://user:pass@... kept the password. Fixed: propagateProxyEnv is on only for NetDirect; build scripts get the variables exported on their input (a loopback proxy as host.lima.internal), and /etc/sudoers.d/devvm-build-proxy keeps them for sudo until the scripts end. - Docker: the CLI puts ~/.docker/config.json's proxies into every container it creates, and a commit keeps them (Docker's docs). Fixed: every container devvm makes sets each proxy variable empty (noClientProxy); a Linux engine's build gets the host's settings from an env file (hostProxyEnv); Desktop's build proxy goes through the company proxy. - smolvm: passes the host's proxy only with --use-host-proxy, which devvm doesn't use: nothing to fix. The upstream: - backend.HostProxy (new): ReadHostProxy (capitals, then lowercase), None, Upstream (the proxy's -upstream file; only http:// proxies: upstream_proxy_scheme, upstream_proxy_invalid), Env. - internal/proxy/upstream.go (new): -upstream FILE; ParseUpstream, ErrUpstreamScheme; NO_PROXY as Go reads it; localhost, *.localhost and loopback/unspecified addresses always direct; CONNECT by name with Proxy-Authorization: Basic for tunnels and for the TLS connections that put secrets in (checked against the system roots and -upstream-cas); plain HTTP in absolute form, canonical host, credentials only in the header to the upstream; floorUpstream: addresses judged as before, a name refused when the host's resolver answers with any internal or denied address, unjudged when it can't resolve; Event.Upstream (host:port), and devvm log's "through host:port". - hostOK refuses shorthand addresses (127.1, 2130706433, 0x7f000001), which a company proxy may read as inet_aton does (found in review). - netpolicy: Proxy.Getenv, run/<vm>.proxy.upstream (mode 600), stale() (a changed upstream starts the proxy again), writeUpstream for both files. Also, from a review of the company-CA change: a proxy that needed starting again and didn't end within 2 s of SIGTERM was kept, with its old roots, silently. Stop now sends SIGKILL after 2 s and reports whether it ended; Prepare fails with proxy_stop_failed instead of keeping it (Proxy.Signal seam). Messages: proxy_stop_failed, upstream_proxy_scheme, upstream_proxy_invalid, with doc links. Tests: proxy (TestParseUpstream, TestNoProxy, TestUpstreamTunnel, TestUpstreamNoProxyDirect, TestUpstreamPlainHTTP, TestUpstreamIntercept, shorthand hosts in TestOddHostsRefused), backend (TestHostProxy), lima (TestBuildImageHostProxy, TestGuestProxyURL, propagateProxyEnv expectations), docker (TestBuildHostProxy, create's empty proxy variables), netpolicy (TestPrepareUpstream, TestPrepareStopsTheOldProxy, FormatEvent's upstream). e2e: images (a layer built with a fake proxy password: its script and sudo see it; the image's disk, Lima's files and devvm's logs don't), network (a devvm _proxy as the company proxy: allowed hosts through it by name, blocked ones never reach it, its password nowhere, and back to direct). Docs: safety/network (Behind a company proxy, Without network policy), using/troubleshooting (Behind a company proxy), internals/network (Through a company proxy, restarts, -upstream), internals/design (A company proxy: what an upstream changes, credentials, builds, checks), internals/images, internal/proxy/README.md. Review (security-audit skill, independent pass over the proxy change): the shorthand-address bypass, fixed; a VM-controlled name can force the unjudged branch, documented; refusals name the company proxy's address (no credentials), accepted as on the direct path; a loopback company proxy isn't reachable from macOS builds, documented. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
906d598954 |
feat(trust): VMs, builds and the proxy trust a company's CAs from ~/.config/devvm/ca
Behind a proxy that inspects TLS, VMs and build VMs couldn't make TLS
connections. The CA certificates in ~/.config/devvm/ca (*.pem, *.crt) are
now read at each launch, build and proxy start, checked, and trusted;
images never keep them.
- internal/trust (new): Read parses every PEM block with crypto/x509 and
refuses anything but CA certificates (ca_not_certificate, ca_not_ca,
ca_invalid, naming the file); only the re-encoded certificates leave the
host. Env/GuestEnv (NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem,
SSL_CERT_FILE, REQUESTS_CA_BUNDLE, PIP_CERT, UV_SYSTEM_CERTS), Build
(a build's Add/Remove root scripts from guest/ca.sh), Script (Env
exported at a build script's start), Name, Bundle.
- assets/guest/ca.sh (new): installs exactly DIR's devvm-*.crt into
/usr/local/share/ca-certificates (update-ca-certificates --fresh), or
into the bundle file itself when there's no update-ca-certificates (the
old bundle kept and put back), writes /etc/ssl/devvm.pem; without DIR,
removes all of devvm's. sync.sh runs it with the proxy's CA
(ca/devvm-proxy.crt) and the user's (ca/devvm-extra-N.crt).
- backend: ImageSpec.Trust and ToolsSpec.Trust (backend.Trust{Add,
Remove}); VMSpec.Env. Lima runs Add after the start and Remove after the
scripts (runScript's root mode, sudo sh), the --from conversion VM runs
Add and oci/build.sh runs ca.sh in the image's chroot around bootify.sh
(guest/ mounted read-only, CA_SH argument); smolvm and Docker run Add
before prepare.sh and Remove after sshd.sh; tools builds run Add only.
Lima's clone sets the guest environment, so starts edit nothing.
- vm: every project VM starts with trust.Env (netpolicy.Env keeps only the
proxy's variables); the setup sends ca.sh and ca/; Dirs.TrustedCAs.
- proxy: -upstream-cas FILE adds CAs to the system roots for its own TLS
connections; netpolicy writes run/<vm>.proxy.cas and restarts a proxy
whose bundle changed.
- doctor: doctor_proxy_ca when HTTPS_PROXY is set and the folder has no
CAs (Say), a refused folder warned about.
- Tests: internal/trust unit tests (folder reading, scripts, ca.sh run in a
stand-in root with and without update-ca-certificates); ca.txtar; sync,
up, network, smolvm txtars and the limactl stub (clone's .env, list
shows lima.yaml's env); e2e: images (a layer built with a test CA, its
key unchanged, its image's copy without CA files), project ("a company's
CA" section), tools (node fetch), smolvm and docker build checks.
- Docs: using/settings (a company's CA), using/troubleshooting (TLS errors
behind a company proxy), internals/network and internals/images,
safety/network, design (assets written out), oci README, doctor's help.
- Structure: Dirs at 38 methods, trust.Env a table, trust above backends.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c5cb300f64 |
ci(lint): Markdown and scripts outside docs/content checked; scan.sh table mode
markdownlint now checks every Markdown file but the vendored security-audit skill's: the root files, assets/ and internal/ READMEs and the docs-voice skill. Vale checks README, SECURITY, CONTRIBUTING, CHANGELOG and the two READMEs with every devvm rule, AGENTS.md and the docs-voice SKILL.md without Filler (they name those words in the rule against them), and not tropes.md (its lists and examples are what the rules flag). shellcheck now checks the docs-voice skill's scan.sh and facts.sh. Fixes: compact table delimiters in assets/oci/README.md and internal/proxy/README.md (MD060); tropes.md's nested code span (MD038) and MD028 off in it, as each example is two adjacent quotes. scan.sh's table mode counted sentences with a bare grep, so set -e and pipefail ended it with an empty table when nothing ended a sentence; it uses hits(), which tolerates no match, and prints zeros. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
32c3c48f8f |
docs(readme): getting started in the docs' wording; landing page, SECURITY.md
README: the landing page's pitch and what a VM gets, install, a first VM with the network policy prompt and the build lines, working on a clone, staying safe, and links to every docs section on devvm.dev. Landing page: network policy on by default, --clone in its own bullet, agents' secrets instead of API keys. SECURITY.md: Verifying a release in full sentences with a link to the signature's page, secrets in What counts, VMs without network policy spelled out in Out of scope. assets/oci/README.md, internal/proxy/README.md: a light docs-voice pass; container image, a secret, the decider token. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
09d25457d5 |
docs(site): user pages, How it works and Contributing, sections moved into place
Sections move verbatim; new pages open with a one-sentence placeholder. Moved pages: safety/clone.md -> using/clone.md; safety/security.md -> internals/security.md. New pages: using/ports-size.md, using/settings.md, using/troubleshooting.md, internals/overview.md, internals/install.md, internals/images.md, internals/ports.md (placeholder only), internals/network.md, internals/git-protection.md, internals/backends.md, internals/lima.md, internals/smolvm.md, internals/docker.md. Moved sections: - getting-started/install.md: the install script's steps, the Docker Linux-build fetch, the signature paragraph, doctor --fixes and its keys, "devvm is one binary", removing old versions -> internals/install.md - getting-started/commands.md: An existing VM, Stopping a VM, Deleting a VM -> internals/overview.md; Size and ports -> using/ports-size.md; Environment -> using/settings.md - using/images.md: Ubuntu's cloud image, Versions, Building tools, Building, Caching (Rebuilding, Outdated VMs) -> internals/images.md; Ports, Size, Disk use -> using/ports-size.md; Where state lives -> using/settings.md; Build logs and interrupts -> using/troubleshooting.md - using/from.md: How it's converted (The image is untrusted), Digests -> internals/images.md - using/coding-agents.md: MCP servers, Keys in settings files -> internals/network.md - safety/network.md: the start-up list, The proxy, The self-check, How the proxy puts them in, Agents' logins and settings, devvm _proxy -> internals/network.md - safety/git-protection.md: What's locked, On each launch, What a lock can't stop -> internals/git-protection.md - safety/attack-vectors.md: Staying safe -> safety/_index.md (The habits), with a copy of the security model's reach table - backends/_index.md: Features, Missing and unreviewed features, VM names -> internals/backends.md - backends/lima.md: A Lima home of its own, Confinement, Clones and overlays, Ports -> internals/lima.md - backends/smolvm.md: Its machines through No init system -> internals/smolvm.md - backends/docker.md: What's devvm's in Docker, Building images, What devvm sets on a VM, Network policy, No init system, ssh for editors, Ports, SSH agent forwarding, Shared tools -> internals/docker.md Titles and weights follow the target tree; How it works is weight 95, after the CLI reference. Index pages list the new pages. Links, message doc links (internal/msg/docs.go), the home page, README.md, SECURITY.md, internal/proxy/README.md and AGENTS.md point at the new places. Contributing and AGENTS.md say what goes on user pages, How it works and Contributing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
857c0e8c53 |
docs(site): sections in the reader's order, attack vectors and a first-VM page
The docs move into a folder per sidebar section, in the order a new user needs them: getting-started (install, first-vm, commands), using (images, customizing, from, devcontainer, coding-agents, ssh, limits), safety (attack-vectors, network, clone, git-protection, security), backends (backends.md as the section's _index.md, lima, smolvm, docker), internals (design), cli, and contributing (contributing.md as its _index.md, testing, maintaining). Each section has an _index.md listing its pages, and the docs index is grouped the same way. Commands is now Everyday commands, SSH is SSH and editors. New pages: - safety/attack-vectors.md: Staying safe first (seven habits), then common attacks sorted into Blocked, Kept inside the VM, Narrowed, not closed, and Left to you. - getting-started/first-vm.md: making a VM, the first run, what's in it, coding agents, coming back to it. Links to Staying safe from the home page, README, security, install, coding agents and clone. Every relative link, the home page's, the README's, SECURITY.md's, CONTRIBUTING.md's, AGENTS.md's, the proxy and oci READMEs', release.sh's hints and the recording's URL use the new paths. internal/msg/docs.go names pages by path (using/images#...), and checkDoc takes a section's _index.md for its folder (backends#...). contributing/_index.md describes the sections and how links name them. Also carries the docs edits made alongside the forwarder work in the tree (backends, images, limits, security, design, commands and the generated devvm ports page), whose code isn't in this commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> |