From e57603c30dae8dc73009912986ef83f96cbb12e1 Mon Sep 17 00:00:00 2001 From: Kaloyan Naumov Date: Thu, 26 Nov 2026 17:20:22 +0000 Subject: [PATCH 1/2] The operations guide says what LOOM_CODE_GIT_CA_FILE settles and what it does not The guide's paragraph for LOOM_CODE_GIT_CA_FILE read as if the setting made a forge under a private authority indexable. It settles trust only: in the repository-job sandbox the egress proxy still refuses a remote whose name resolves to a loopback, private or link-local address, and no setting admits one, so such a forge indexes only as an operator repository on a host without the sandbox. The guide now says so. It also says what the bundle applies to (every git a repository job runs, the compiler tier's dependency fetches and submodule updates included, so the bundle must hold the public roots when any of those reach a public host) and that the path is not checked when the setting loads: it must be absolute and inside the sandbox's read-only /etc/ssl, and a relative or `~/` path, or a link leaving /etc/ssl, fails in git's own words. The "CA bundles" paragraph now counts three bundles and says which one git uses through the proxy. The unit test imports asyncio at the top of the module. No behaviour changes. Signed-off-by: Kaloyan Naumov --- docs/operations/code-index-operations.md | 28 ++++++++++++++++++------ tests/unit/test_gitrepo_ca_file.py | 4 ++-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/docs/operations/code-index-operations.md b/docs/operations/code-index-operations.md index 740da22376..dc88053e41 100644 --- a/docs/operations/code-index-operations.md +++ b/docs/operations/code-index-operations.md @@ -137,11 +137,22 @@ Name a `git_remote` host in ASCII, as punycode for an internationalised name: a add refuses any other, so the two spell a host alike. A git server under a private certificate authority needs `LOOM_CODE_GIT_CA_FILE`: a PEM -bundle git verifies https remotes with in place of the image's default roots, so include -the public roots when other remotes are public. Repository jobs read no system or global -git config and inherit no `GIT_SSL_CAINFO` or `SSL_CERT_FILE`, so this setting is how a -bundle reaches them. Put it under `/etc/ssl`, which the repository-job sandbox mounts. -Through the forward proxy, `LOOM_CODE_GIT_PROXY_CA_FILE` takes its place when set. +bundle git verifies https remotes with in place of the image's default roots. The bundle +applies to every git a repository job runs, the compiler tier's dependency fetches and +submodule updates included, not only the entry's remote, so include the public roots +when any of those reach a public host. Repository jobs read no system or global git +config and inherit no `GIT_SSL_CAINFO` or `SSL_CERT_FILE`, so this setting is how a +bundle reaches them. Loom does not check the path when it loads the setting: name an +absolute path to a file the job can see. Inside the repository-job sandbox that is the +tree it mounts read-only, `/etc/ssl`; a relative path, a `~/` path, or a link that +leaves `/etc/ssl` resolves differently there than on the host, and git fails the job +with its own words. Through the forward proxy, `LOOM_CODE_GIT_PROXY_CA_FILE` takes its +place when set. + +The setting settles trust, not reach. In the sandbox the egress proxy refuses a remote +whose name resolves to a loopback, private or link-local address, whatever bundle is +set, and no setting admits one. A forge on a private address therefore indexes only as an +operator repository on a host that does not run the sandbox (see _Without the sandbox_). An entry whose `git_remote` is a local path or `file://` mirror is known by its `repo`, which a page add of the same repository must match: name a mirror of a repository on a @@ -860,8 +871,11 @@ uses the proxy, repository jobs are plain processes, so a compiler tier's build Loom's user and can read the token file. Run compiler tiers there only for repositories you trust. -**The CA bundles.** There are two, one for each TLS connection, and neither stands in -for the other. `LOOM_CODE_GIT_PROXY_TLS_CA_FILE` is git's `http.proxySSLCAInfo` (in git +**The CA bundles.** There are three. +`LOOM_CODE_GIT_CA_FILE` (above) is git's `http.sslCAInfo` for the remotes with no proxy, +and through the proxy while `LOOM_CODE_GIT_PROXY_CA_FILE` is unset. The proxy's own +certificate is always `LOOM_CODE_GIT_PROXY_TLS_CA_FILE`, never one of the other two. +`LOOM_CODE_GIT_PROXY_TLS_CA_FILE` is git's `http.proxySSLCAInfo` (in git since release 2.27, older than the git every repository job already needs): the bundle git verifies an `https://` proxy's own certificate with, before it sends the identity and the token. Without it git checks the proxy against its default roots, so a proxy diff --git a/tests/unit/test_gitrepo_ca_file.py b/tests/unit/test_gitrepo_ca_file.py index 4cb36c3654..41b0457e0a 100644 --- a/tests/unit/test_gitrepo_ca_file.py +++ b/tests/unit/test_gitrepo_ca_file.py @@ -4,6 +4,8 @@ from __future__ import annotations +import asyncio + import pytest from server.code.app.index import git_proxy, gitrepo @@ -40,8 +42,6 @@ async def _proxy_env(env: dict[str, str]) -> dict[str, str]: def test_through_the_proxy_its_bundle_wins_when_set( monkeypatch: pytest.MonkeyPatch, proxy_ca: str, want: str ) -> None: - import asyncio - monkeypatch.setattr(settings, "code_git_ca_file", "/etc/ssl/private-ca/bundle.pem") monkeypatch.setattr(settings, "code_git_proxy_url", "http://proxy.example.com:3128") monkeypatch.setattr(settings, "code_git_proxy_ca_file", proxy_ca) From 06978e458d10a1a0a762aca37008bac0656543c7 Mon Sep 17 00:00:00 2001 From: Kaloyan Naumov Date: Thu, 26 Nov 2026 21:04:56 +0000 Subject: [PATCH 2/2] Name the trees the repository-job sandbox mounts for the git CA bundle A link out of /etc/ssl can still work: the sandbox also mounts /usr and /etc/ca-certificates read-only, so a link into /usr/share/ca-certificates resolves to the same file. Say the target must be visible to the job and keep /etc/ssl as the suggested location. Signed-off-by: Kaloyan Naumov --- docs/operations/code-index-operations.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/operations/code-index-operations.md b/docs/operations/code-index-operations.md index dc88053e41..83c2e38cf2 100644 --- a/docs/operations/code-index-operations.md +++ b/docs/operations/code-index-operations.md @@ -143,10 +143,11 @@ submodule updates included, not only the entry's remote, so include the public r when any of those reach a public host. Repository jobs read no system or global git config and inherit no `GIT_SSL_CAINFO` or `SSL_CERT_FILE`, so this setting is how a bundle reaches them. Loom does not check the path when it loads the setting: name an -absolute path to a file the job can see. Inside the repository-job sandbox that is the -tree it mounts read-only, `/etc/ssl`; a relative path, a `~/` path, or a link that -leaves `/etc/ssl` resolves differently there than on the host, and git fails the job -with its own words. Through the forward proxy, `LOOM_CODE_GIT_PROXY_CA_FILE` takes its +absolute path to a file the job can see. The sandbox mounts `/etc/ssl`, +`/etc/ca-certificates` and `/usr` read-only, so `/etc/ssl` is the place to put the +bundle; a link works when its target is inside one of those trees too. A relative path, +a `~/` path, or a link whose target is outside them resolves differently there than on +the host, and git fails the job with its own words. Through the forward proxy, `LOOM_CODE_GIT_PROXY_CA_FILE` takes its place when set. The setting settles trust, not reach. In the sandbox the egress proxy refuses a remote