Repository navigation
feat(deploy): make deploy/sbx/egress-allow.env the default sbx egress allowlist - #719
Conversation
… allowlist install-host.sh seeded a fresh host's /etc/sbx/moca-egress.env with four GitHub hosts only, so every new SBX0 host started far narrower than the allow rules the live service had accumulated (package registries, distro mirrors, tool CDNs). The default now lives in deploy/sbx/egress-allow.env (45 hosts, extracted from the live SBX0 rules on 2026-11-11), and install-host.sh reads its MOCA_EGRESS_ALLOW line: - DEFAULT_EGRESS_ALLOW in the environment still overrides the file, and MOCA_EGRESS_ALLOW overrides both, exactly as before. - A copy of the script without the file falls back to the GitHub hosts and says so on stderr (uninstall keeps working from a thin checkout). - The env file is a systemd EnvironmentFile, so comments are allowed; its header documents the format and both usage paths. The RUNBOOK's guest-egress section now names the file as the seed and the per-host vs per-repo edit paths. install-host.test.sh asserts the seed matches the file (fixed-string: the list contains the *.pkg.dev wildcard) and covers the missing-file fallback; TestDefaultAllowlistFile pins the file against ParseAllow so a bad entry fails CI instead of a host boot. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
No must-fix issues found. Moving the default SBX0 egress seed into deploy/sbx/egress-allow.env keeps the old precedence: MOCA_EGRESS_ALLOW wins over DEFAULT_EGRESS_ALLOW, which wins over the file, which wins over the GitHub fallback. The seed-only-when-absent and uninstall rules are unchanged, and TestDefaultAllowlistFile pins the file against ParseAllow so a bad entry fails in CI. Three non-blocking comments are inline: a stale "Fresh host" instruction in the file header, two task-specific hosts that now land on every new host, and a fallback warning that prints even when the file isn't used.
Recommendation: all checks pass. Ready for human review.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell, Go (tests), Docs, Config (env file), Security (egress allowlist scope)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (17/17 checks)
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| # - Existing host: sudo install -m 0644 deploy/sbx/egress-allow.env /etc/sbx/moca-egress.env | ||
| # sudo systemctl restart moca-egress | ||
| # (the install never overwrites an allowlist that is already there; an edit stays) | ||
| # - Fresh host: export MOCA_EGRESS_ALLOW="$(sed -n 's/^MOCA_EGRESS_ALLOW=//p' deploy/sbx/egress-allow.env)" |
There was a problem hiding this comment.
nit: this "Fresh host" step is no longer needed. With this PR install-host.sh reads egress-allow.env from beside itself (default_egress_allow), so a fresh install from the repo seeds this list without the export. Exporting MOCA_EGRESS_ALLOW also overrides both rungs of the precedence, so anyone who follows this step and later edits the file will be surprised. Suggested fix: change this to "Fresh host: nothing to do; install-host.sh seeds /etc/sbx/moca-egress.env from this file", and keep the export only as a way to seed a different list.
There was a problem hiding this comment.
Fixed in a2576c4: the fresh-host step now reads "nothing to do -- install-host.sh seeds /etc/sbx/moca-egress.env from this file beside it", and the export is documented as the way to seed a different list on one install only. The header also notes that editing the file does not reach already-seeded hosts.
| # | ||
| # Extracted 2026-11-11 from the live SBX0 allow rules (45 hosts). | ||
|
|
||
| MOCA_EGRESS_ALLOW=dl.fedoraproject.org,export.arxiv.org,tmaproduction.blob.core.windows.net,archive.apache.org,dl.google.com,tuf-repo-cdn.sigstore.dev,mirror.openshift.com,istio-release.storage.googleapis.com,dl.k8s.io,get.helm.sh,download.java.net,mise-java.jdx.dev,mise-versions.jdx.dev,cdn.mise.run,mise.jdx.dev,unpkg.com,cdn.jsdelivr.net,sh.rustup.rs,static.crates.io,crates.io,go.dev,sum.golang.org,proxy.golang.org,registry.access.redhat.com,*.pkg.dev,registry.k8s.io,gcr.io,pkg-containers.githubusercontent.com,ghcr.io,production.cloudflare.docker.com,production.cloudfront.docker.com,auth.docker.io,registry-1.docker.io,index.docker.io,quay.io,release-assets.githubusercontent.com,raw.githubusercontent.com,objects.githubusercontent.com,codeload.github.com,api.github.com,github.com,files.pythonhosted.org,pypi.org,registry.yarnpkg.com,registry.npmjs.org |
There was a problem hiding this comment.
suggestion: the list was extracted from one live host's accumulated rules, so it is now the default for every new SBX0 host. Most entries are general infrastructure (registries, mirrors, toolchains), but a few look task-specific, notably export.arxiv.org and tmaproduction.blob.core.windows.net (a single Azure storage account). unpkg.com and cdn.jsdelivr.net also serve arbitrary user-published content. Please confirm each of these belongs in the default rather than in a per-host addition (the same treatment api.githubcopilot.com already gets in the header). Removing a host from the default later doesn't reach hosts that are already seeded, because the seed is never overwritten.
There was a problem hiding this comment.
Confirmed: all four stay (maintainer's call -- each was in live use on the host the list was extracted from). The header now documents them as deliberately kept, with the same treatment as the api.githubcopilot.com note. a2576c4.
| printf 'api.github.com,github.com,codeload.github.com,objects.githubusercontent.com\n' | ||
| fi | ||
| } | ||
| : "${DEFAULT_EGRESS_ALLOW:="$(default_egress_allow)"}" |
There was a problem hiding this comment.
nit: default_egress_allow runs at top level for every invocation unless DEFAULT_EGRESS_ALLOW is set. So with a thin copy, the "falling back to the GitHub hosts" warning also prints for --uninstall, for --no-egress, and when MOCA_EGRESS_ALLOW is exported, all cases where the default isn't used for seeding. That's harmless, but it's misleading on stderr. Suggested fix (optional): resolve the default lazily inside egress_seed, or skip the warning when MOCA_EGRESS_ALLOW is set.
There was a problem hiding this comment.
Fixed in a2576c4: the default now resolves lazily inside egress_seed, so the fallback warning prints only when the fallback value is actually consumed. Tests assert the two quiet runs (--no-egress, and MOCA_EGRESS_ALLOW exported) beside the warning case. On --uninstall the warning can still print, but only in the digestless comparison where the fallback value genuinely is what the file is compared against, so it is accurate there.
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
No must-fix issues. Moving the SBX0 default egress seed into deploy/sbx/egress-allow.env keeps the old precedence (MOCA_EGRESS_ALLOW > DEFAULT_EGRESS_ALLOW > file > GitHub fallback). The file has 45 unique entries, and the new tests cover both the seed and the missing-file fallback. Two non-blocking comments are inline and don't repeat the three already raised by clawgenti: the uninstall check for an env file with no recorded digest now compares against the new seed, and the Go test reads the file more leniently than the installer does.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell, Go (tests), Docs, Config (env file), Security (egress allowlist scope)
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing (17/17 checks)
Assisted-By: Claude Code
| # script (a systemd EnvironmentFile, so comments are allowed). DEFAULT_EGRESS_ALLOW in the | ||
| # environment overrides the file; MOCA_EGRESS_ALLOW overrides both (egress_seed). A copy of the | ||
| # script without the file falls back to the GitHub hosts and says so on stderr. | ||
| default_egress_allow() { |
There was a problem hiding this comment.
suggestion: this changes what egress_seed returns, and the uninstall path compares against egress_seed. When the manifest has no digest for the env file ([[ -z "$sha" && "$(cat "$path")" != "$(egress_seed)" ]], around line 553), the file is compared against the seed at uninstall time. That case covers a pre-digest manifest, or an env file that already existed and was recorded by line 216. On those hosts, an untouched file holding the old four-GitHub-host seed no longer matches the new 45-host seed. Uninstall logs kept ... (edited) and leaves the file behind, and a later reinstall then won't reseed it, so the host stays on the narrow list. That fails safe, but it contradicts "removed on uninstall unless edited". One option: in the no-digest branch, also treat the file as unedited when it equals the legacy GitHub-host seed.
There was a problem hiding this comment.
Fixed in a2576c4: the digestless branch now treats the legacy GitHub-only seed (LEGACY_EGRESS_ALLOW) as unedited too, so an env file an older script seeded is removed by the last uninstall and a later reinstall reseeds it, restoring "removed on uninstall unless edited". Covered by a new test case (install, overwrite the env with the legacy seed, strip digests, uninstall, assert removal).
| } | ||
| var line string | ||
| for _, l := range strings.Split(string(b), "\n") { | ||
| if v, ok := strings.CutPrefix(strings.TrimSpace(l), "MOCA_EGRESS_ALLOW="); ok { |
There was a problem hiding this comment.
nit: this test trims each line (strings.TrimSpace) before matching MOCA_EGRESS_ALLOW=. install-host.sh uses sed -n 's/^MOCA_EGRESS_ALLOW=//p', which needs the key at column 0 and keeps a trailing \r or trailing spaces. So an indented line or a CRLF file passes this test while the installer seeds something different, or falls back to the GitHub hosts. Matching the installer exactly (no trim, strings.HasPrefix(l, ...)) would make the test pin what's actually seeded.
There was a problem hiding this comment.
Fixed in a2576c4: the test now matches the installer's sed exactly -- HasPrefix at column 0, no TrimSpace -- so an indented line or a CRLF file fails the test the same way it mis-seeds (or falls back) on a host.
- egress-allow.env: the fresh-host step no longer tells the operator to export MOCA_EGRESS_ALLOW (the installer seeds from the file beside it; the export is only for seeding a different list), and the header notes that editing the file does not reach already-seeded hosts. The four hosts flagged as task-specific (export.arxiv.org, tmaproduction.blob.core.windows.net, unpkg.com, cdn.jsdelivr.net) are documented as deliberately kept. - install-host.sh: the default allowlist resolves lazily inside egress_seed, so the GitHub-hosts fallback warning prints only when the fallback value is actually consumed -- a --no-egress run, or one with MOCA_EGRESS_ALLOW exported, stays quiet. remove_egress treats the legacy GitHub-only seed as unedited in the digestless branch, so an env file an older script seeded is removed by the last uninstall instead of kept as an edit (and a later reinstall can reseed it). - allow_test.go: match the installer's sed exactly (key at column 0, no trimming), so an indented or CRLF line fails the test the same way it mis-seeds on a host. - install-host.test.sh: the fallback case also asserts the two quiet runs, and a new case covers the legacy-seed uninstall. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Follow-up at a2576c4. All five threads from 7e56d2a are addressed, and I checked each against the code: the header's fresh-host step, the documented keep of the four task-looking hosts, the lazy default_egress_allow in egress_seed (with quiet-run tests), the legacy-seed match in the digestless uninstall branch (with a test), and the column-0 match in TestDefaultAllowlistFile. Precedence is unchanged. One nit inline.
For awareness (outside the diff): deploy/microvm/setup-microvm.sh:49 still defaults to the 4 GitHub hosts, so a host that runs both installs keeps whichever moca-egress.env was written first.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell, Go (tests), Config (env file), Security (egress allowlist scope)
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (17/17 checks)
Assisted-By: Claude Code
| t.Fatalf("read: %v", err) | ||
| } | ||
| // Match install-host.sh exactly: sed -n 's/^MOCA_EGRESS_ALLOW=//p' -- the key at | ||
| // column 0, no trimming -- so an indented line or a CRLF file fails here the same |
There was a problem hiding this comment.
nit: the comment says a CRLF file fails here. The trailing \r now stays on line, but ParseAllow runs strings.TrimSpace on each comma item, so the last host loses its \r and the test still passes. That is harmless, because moca-egress parses the seeded value with the same ParseAllow, but the comment overstates the coverage. Either drop "or a CRLF file", or assert !strings.ContainsRune(line, '\r'). The indented-line case is caught correctly.
One conflict, the egress paragraph of install-host.sh's header: main's new default allowlist source (deploy/sbx/egress-allow.env, rossoctl#719) kept, with this PR's per-worker egress drop-in lines. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
What
install-host.shseeded a fresh host's/etc/sbx/moca-egress.envwith four GitHub hosts only, so every new SBX0 host started far narrower than the allow rules the live service had accumulated. The default allowlist now lives indeploy/sbx/egress-allow.env— 45 hosts extracted from the live SBX0 rules on 2026-11-11 (package registries, container registries, distro mirrors, tool CDNs, GitHub) — andinstall-host.shreads itsMOCA_EGRESS_ALLOWline.Behavior
DEFAULT_EGRESS_ALLOWin the environment still overrides the file, andMOCA_EGRESS_ALLOWoverrides both — exactly the old precedence, with the file as the new bottom rung.EnvironmentFile(comments allowed); its header documents the format and both usage paths (copy to an existing host + restart, or seed a fresh install).Tests
install-host.test.sh: the seed assertion now derives its expected value from the file (fixed-string match — the list contains the*.pkg.devwildcard, which is a regex metacharacter), plus a new case installing from a script copy withoutegress-allow.env(fallback warning + GitHub-host seed).TestDefaultAllowlistFile(remote-worker) pins the file againstParseAllow/Allowed, so a bad entry fails CI instead of surfacing as a host that won't bootmoca-egress.Assisted-By: Claude Code