15 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 a8f0517579 feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut
in its 900 MB fails base's build, and a stall hangs it. devvm now
downloads the pinned image itself through fetch.Resumable
(ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage),
resuming across cuts, stalls and runs, and gives Lima that file. Lima
2.3 checks a local file against the digest before it copies it.

- Before downloading, it takes the image from Lima's own download cache
  when that holds it with the pin's SHA-256: copied into a new file of
  devvm's own, mode 600, hashed as it's written, capped, stopped by the
  context, and kept only once it checks out. Lima's cache is never
  changed, and a base whose dated release Ubuntu may have removed still
  builds again.
- One devvm downloads at a time (images/locks/ubuntu-image), another
  waiting under ubuntu_image_waiting and looking again under the lock
  (TestUbuntuImageAfterWait, which fails without that second look).
- The download goes through the company proxy and trusts the user's CAs
  (Lima.Roots, from trust.Pool, which internal/cli passes through the
  registry), as do the Finder's lookups (TestNewTrustsRoots, and the
  registry's TestOverrides). An untrusted certificate is
  ubuntu_untrusted, naming the CAs' folder, one from a trusted CA
  that's for another host, out of date or not valid yet
  ubuntu_bad_certificate (check the clock and what answers for the
  host), and any other that fails to verify (a SHA-1 signature, a CA's
  name constraints, a key for clients alone) ubuntu_certificate_invalid,
  naming Go's reason, for the lookups (the listing, the checksums, their
  signature: TestLookupCertificates) and the download alike
  (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410)
  ubuntu_release_gone, which names devvm rebuild base; none is retried.
  ubuntu_download_failed no longer starts with devvm.
- fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a
  CertificateInvalidError that's Expired) and fetch.Unverified (any
  failure to verify, with its reason, so every error the other two
  name), beside fetch.Gone, are the one
  place that tells a certificate's failures apart: Transient asks
  Unverified, the lookups and the download ask all three, host mise
  asks Untrusted, and a forbidigo rule keeps x509's and tls's
  verification errors in internal/fetch (TestCertificateClasses,
  TestTransient, testdata/lint, the owners doc's row).
- An https address, or a test build's file:// DEVVM_UBUNTU_URL, read
  from disk the same way; anything else is refused. The CLI tests'
  sandbox has a stand-in of this host's image in the store.
- Base's record keeps the image's address, and the key is as it was: it
  hashes the pin (release, file, digest), not the location.
- devvm gc --caches frees devvm's copies that no record names and that
  aren't pinned now, unchanged for an hour, a stopped .part and a killed
  import's .import included, and those of a kept image once its .img is
  there. A pin it can't read fails it.
- Of Lima's cache, it frees only an entry that devvm's own state shows a
  build of devvm's left: a base record names its address, devvm has its
  own copy of the image, and the installed Lima's own templates
  (share/lima/templates beside limactl, Lima.Templates) don't name it.
  An entry no record names may be the user's own Lima's, so it stays,
  and none is freed when the templates can't be read, with a line in
  the run log naming the folder and why. A test build's
  DEVVM_LIMA_TEMPLATES stands in for the templates folder.
- ubuntu.ParseImage reads a record's image as Image.String writes it,
  and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in
  place of Lima's own regex.
- devvm space shows the copies as a cloud images row, freed by gc
  --caches, kept as state, as a release Ubuntu removed can't be
  downloaded again.

0.1.0's frozen state runs the new commands (fixture_v010_cloud_image):
devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's
base record keeps and never changes the entry, base builds from devvm's
own copy, and gc --caches keeps that copy, frees Lima's entry the
record names and devvm's own stale copies, and keeps an older entry no
record names.

Docs: images.md (the download, its failures, the import, gc's rules),
space.md, backends/lima.md, settings.md (the lookups and the download
trust your CAs), troubleshooting.md, overview.md, testing.md,
tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed
lines, which later commits make highlights, What to do 5 and 6, and the
release page's Ubuntu's cloud image in devvm's folder.

New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting,
ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate,
ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted.
Lima.LocalImage is the seam, Lima.ImageClient the client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 cb7177b32c feat(ui): waits for another devvm's lock show a status line; a project folder devvm can't read says so
Lock waits:
- platform.LockFile and LockFileShared take a platform.Waiting, called
  once they find the lock held, never when it's free, whose end they call
  once the wait ends; LockFileWaiting, LockFileSharedWaiting and their
  delays (ShareNote, OCINote, WaitNote, groupsNote, makingNote) go.
- msg.Waiting makes one from a Reporter's Status and a label;
  msg.WithStatus and msg.StatusOf carry the run's Status in its context
  for the two packages that take no Reporter, internal/state and
  internal/trust, which cli's execute sets; forbidigo keeps StatusOf to
  them, and AGENTS.md says so.
- Every lock that waits shows its own label: vm_state_waiting (a VM's
  state, its deletion), claims_waiting, layout_waiting, git_lock_waiting,
  ca_waiting, packages_waiting, rebuilds_waiting, ubuntu_pin_waiting,
  custom_secrets_waiting, forwarder_waiting, agent_store_waiting, and the
  waits that printed a line after a delay, which now show theirs as a
  status line: share_waiting, oci_waiting, image_build_waiting,
  group_waiting, making_waiting.
- An agent's login file's lock (agentlogin's lockLogin, a folder's flock
  that a VM's proxy holds while it refreshes the login) tries first
  without waiting and shows agentlogin.File's Waiting
  (agent_login_waiting) while it waits; secrets fills it from its
  Reporter, for SaveLogins, Claude Code's logins folder and every File.
- The structure test's status-lines rule counts a LockFile or
  LockFileShared whose waiting is nil as slow work; the build port's
  record, a file just made that never waits, is listed in statusSites.
- Without a terminal, or with -v, a status line draws nothing, so the
  waits that printed an info line after a delay no longer print it there;
  the CHANGELOG and the troubleshooting page say so. from.txtar's check
  that a free conversion lock printed no wait goes, as TestLockOCI checks
  it.

The layout's migration runs under a status line (layout_migrating),
only when there are migrations to run.

Backend calls outside a launch: TestCommandStatusLines runs devvm ls,
ports, size, network, tools, git-protect, history export, stop and rm on
a running and a stopped VM and fails on a backend call with no status
line showing, with a control that each makes one.

A project folder devvm can't open and read (vm_folder_unreadable) was
taken for another folder's VM (vm_other_folder, which offers rm and
adopt, and adopt went on); the finder now keeps why (target.unread), and
every command on the folder's VM, from the folder or a subfolder of it,
names the folder and why; devvm rm VM run elsewhere goes by the VM's
name as before.

platform.UniqueFolderID had no caller but its test: FolderStat.Unique,
from the open folder, replaced it; it goes, and its test checks
StatFolder's Unique instead.

Tests: TestLockFileWaiting (rewritten: called only when held, its end
once got or given up, shared too), TestVMLockWaits, TestCheckLayoutWaits,
TestCheckLayout (migrations under layout_migrating, nothing shown
otherwise), TestLockGroups, TestLockShare, TestMaking, TestLockOCI and
the build lock's test (status lines, not info lines), TestLockLogin,
TestInitCACancelled (ca_waiting), the status-lines rule's lock cases,
TestCommandStatusLines, TestUnreadableFolder (a subfolder of it too),
TestStatFolderUnique.

Docs: Contributing's CLI page (Status lines) and structure page, the cli
and codebase-standards skills (the guards), AGENTS.md's Go conventions,
internals/images.md and design.md (the waits), using/troubleshooting.md,
using/vms.md (a folder devvm can't read); CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 15:10:22 -07:00
w3cjandClaude Opus 5.5 d55476d3e2 feat(images): the prelude is one line, so build scripts keep their line numbers
Every script a build runs with bash, devvm's own and the user's layers,
now gets the prelude as one line, eval $'…', in place of its #! line, so
bash's errors and $LINENO give the script's own line numbers. A script
without a #! line is one line further down.

- shell.QuoteLine: ANSI-C quoting for bash, on one line of printable
  ASCII; every other byte as \xHH, so a multibyte locale's lead byte
  (Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a
  quote, and a NUL panics as a caller's bug. image's layer rule allows
  internal/shell, a leaf.
- image.WithPrelude, the one place the prelude and a script are joined
  (OwnScript calls it), used by base.sh, apt.sh, the built-in layers and
  features, the user's layers, shared-tools/build.sh and oci/build.sh.
  Every devvm script has a #! line. A leading UTF-8 BOM goes before the
  #! check.
- A build's exports for a company proxy (lima's proxyExports) and the
  user's CAs (trust's exports) end in "; ", not a newline, so they share
  the first line and move no line either; backend.Trust.Env says so.
- The stub logs a bash -s script's second line, which is the script's
  own second line with or without the prelude.
- Keys: every build script's bytes change, so base, every image and
  every shared tool image are built again once; the CHANGELOG's After
  you upgrade says so with git-lfs, and what VMs say until devvm update,
  and Breaking has its own heading.
- Tests: TestQuoteLine (every byte but NUL, a break-out word, in
  /bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK,
  zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL,
  TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real
  prelude's line gives the prelude back; a layer under set -euo pipefail
  gets the names, keeps its function and its line numbers, with and
  without exports before it).
- e2e nix: the layer copy no longer adds the prelude itself.
- Docs: images.md's prelude section, Customizing's layer bullet,
  structure.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:46:30 -07:00
w3cjandClaude Opus 5.5 5c8aeafcbc test: gosec's G703 off in test files, where it reports a helper's write on some runs only
gosec's taint analysis reported internal/gitprotect's test helper write
(G703) on some runs and not others, which failed macOS CI's lint at
4f99e407 and passed on its re-run. A nolint there would fail nolintlint
on the runs that don't report it, so .golangci.yml excludes G703 in
_test.go files, as it does for tests/e2e, and the 12 nolint:gosec
comments that only covered G703 in tests go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 12:50:32 -07:00
CJandClaude Opus 5.5 b3a188712f fix(tools): the host's mise trusts the system's and devvm's CAs (#9)
devvm's host mise didn't trust the CAs in ~/.config/devvm/ca, so behind a
network that inspects TLS, resolving the shared tools' versions failed with
UnknownIssuer and a message to check the connection.

The host mise and its download now trust the folder's checked CAs: mise gets
them as MISE_EXTRA_CA_CERTS, and on Linux also an SSL_CERT_FILE bundle of the
system's roots plus those CAs (SSL_CERT_DIR only when the user set neither
variable). On macOS, mise's Sigstore client still needs the CA trusted in the
Keychain, as the docs say. A certificate failure now shows tools_untrusted,
pointing at the CA docs.

Refs #1

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-07 08:33:56 -07:00
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-05 15:55:21 -07:00
w3cjandClaude Opus 5.5 40d6f45296 fix: the phase review's findings in --clone, --from's output check and tool builds' CAs
- --clone refuses a symlink anywhere in objects or refs (a pack folder, a
  loose object's folder), not only at their top, which could copy another
  repo's objects into the VM.
- A worktree's seed push sends its upstream only when it is one ref: a
  branch.<name>.merge pattern (refs/heads/*) pushed every branch.
- The rm/clone off fetch passes --refmap=, so a remote the repo names after
  the clone's address can't update branches outside saved/devvm/*.
- Undoing devvm clone off checks .git (gitprotect Check) before its locks
  come off, as leftBehind does: a clone VM's .git is never checked again.
- --from's converted disk must have its first 1024 bytes zero before the
  ext4 superblock, so a qcow2 or VMDK header can't sit in front of one; the
  glibc file is checked a plain file before it is read (a link to a FIFO).
- Tool builds get the CAs' variables from the backend (Trust.Env), as image
  builds' steps do; trust.CAs.Script, the caller-side copy, is gone.
- image.isAgent unexported (used only in image).

Tests: TestOwnRepo (pack folder, loose folder), TestSeedRefs (a pattern
upstream), TestCloneRm (a remote named as the clone URL), TestSetCloneUndo
(git_replaced on undo), TestCheckConverted (qcow2 before a superblock, a
short disk, glibc a link to a FIFO), TestBuildToolsTrust. Docs:
internals/git-protection, using/clone, internals/images, internals/design
(the pin's name). Coverage baselines raised (darwin, linux).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 18:01:00 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-04 13:57:19 -07:00
w3cjandClaude Opus 5.5 21db9467f2 refactor(build): one image recipe, which the key hashes and the backend runs
An image's recipe is the ordered list of steps its build runs, each a
script with its name, arguments and whether it runs as root
(image.Recipe, image.Step). internal/build puts it together once
(recipe.go: inputs, plan, basePlan), image.Input.Key hashes it, and
backend.ImageSpec carries the same recipe to the backend, which runs it
as it is. image.Inputs, which read the files a second time for the key,
is gone, with its fixtures; its tests move to internal/build.

The user's CAs' variables are no longer written into the scripts sent:
backend.Trust.Env holds them and Lima puts them before each step, so what
the backend is given is exactly what the key hashed.

Two new tests check that every byte and argument sent into a build
changes the key: TestKeyHashesWhatABuildSends (build, on the fake) and
TestKeyHashesWhatLimaSends (Lima driven by build, its commands, inputs
and the conversion's files). Written first against the code as it was,
the Lima test found two gaps, fixed here:
- a --from conversion's user (name, uid, home folder) and the converted
  disk's size went into the image but not its key: Lima's KeyFiles holds
  them (madeArgs, with a User seam);
- the conversion was given all of oci/, try.sh and README.md included,
  which base's key doesn't hash: it gets image.ConversionScripts only.

Every image's key changes, as keys hash the recipe's fields: images are
built again on next use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 06:02:19 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-03 20:54:41 -07:00
w3cjandClaude Opus 5.5 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]>
2026-11-03 19:04:31 -07:00
w3cjandClaude Opus 5.5 1cfc8e24f1 test: share the stubs sandbox, message checks and recorders across Go tests
internal/stubtest puts testdata/stubs first on PATH with a folder of its
own (New, New with only some stubs), reads and writes the stubs' files
(Calls, Reset, Touch, Write, Read, Path, Log) and has one ExecRunner. It
replaces the stub setups of the Lima, Docker and smolvm backends' tests,
vm's --clone tests and platform's Keychain tests, and the backends' own
execRunner, reset and touch copies. The structure test holds it to tests
and to importing only internal/msg.

msg.IDOf and msg.NamesOf replace the names(), isMsg, id and shown helpers
and the errors.AsType checks that only read a message's ID or names;
msg.Recorder replaces the inline recorders tests set as Info, Warn or Say.
backendtest.Stored replaces the four stored fakes with disks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 13:24:43 -07:00
w3cjandClaude Opus 5.5 65b669f9dc fix(trust): removed CAs reach update-ca-certificates' hooks; the CA folder follows no links
guest/ca.sh: update-ca-certificates (Debian's, --fresh or not) tells the
hooks in /etc/ca-certificates/update.d only of the CAs it links, never of
a file deleted from /usr/local/share/ca-certificates, so Java's cacerts
(ca-certificates-java's jks-keystore) and Mono's store kept a removed CA,
in VMs and in images whose layer installs Java. ca.sh now runs each hook
run-parts would (no dots in its name) with a "-/etc/ssl/certs/NAME.pem"
line for each CA it removed, as update-ca-certificates does for a
deselected CA; a hook that fails is said in the run log and stops
nothing. Alpine's and the no-update-ca-certificates paths are unchanged.

trust.Read: the CA folder and each *.pem/*.crt in it are checked with
os.Lstat and no link is followed (ca_folder_link, ca_link): a link into a
project folder would let that project's VM choose the CA every VM, build
and proxy trusts. A file or folder it can't read fails with a message
naming it and carrying the error (ca_unreadable, ca_folder_unreadable).

Messages: ca_link, ca_folder_link, ca_unreadable, ca_folder_unreadable
(linked to using/settings#a-companys-ca).

Tests: TestCAShHooks (removals told to each hook, adds not, a failing
hook stops nothing, dotted names skipped), TestReadRefuses (a file's
link, a dangling link, a linked folder, an unreadable file and folder).
e2e (images): a layer installing default-jre-headless and
ca-certificates-java has the CA in cacerts while it builds, its image's
cacerts keeps none, and a project VM on it drops the CA from cacerts at
the launch after it's removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-31 00:10:33 -07:00
w3cjandClaude Opus 5.5 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]>
2026-10-30 17:54:01 -07:00