Python
OpenShell 0.1.2: say plainly that every site cannot be allowed, and update the doc page
Rohit C Prasade3af23e4b868
diff --git a/coworker/sandbox/providers/openshell_policy.py b/coworker/sandbox/providers/openshell_policy.pyindex abb7e86a..869d11ec 100644--- a/coworker/sandbox/providers/openshell_policy.py+++ b/coworker/sandbox/providers/openshell_policy.py@@ -47,10 +47,15 @@ PROFILES: dict[str, dict[str, dict[str, Any]]] = {profile: {_POLICY_KEYS[name]: _hosts(name, hosts) for name, hosts in groups.items()}for profile, groups in network_profiles.PROFILES.items()}-# The `open` profile: any host, any port. NOT yet proved against a running gateway (the-# Linux VM was stopped when it was written, 2026-09-25); if OpenShell refuses the wildcard-# the sandbox fails to start, which is the safe way round.-PROFILES[network_profiles.OPEN] = {"open": {"name": "open", "endpoints": [{"host": "*", "port": 0}], "binaries": [dict(b) for b in _ANY_BINARY]}}+# The `open` profile ("Allow everything") cannot be written as an OpenShell policy.+# OpenShell 0.1 refuses every form of "any host" as unsafe content (`*`, `**` and `*.*`+# were all tried against a 0.1.2 gateway, 2026-10-04): each site has to be named. So this+# provider says so in plain words instead of letting `sandbox create` fail with OpenShell's.+OPEN_UNSUPPORTED = (+ "OpenShell cannot allow every site: its policy has to name each site. "+ 'In Settings > Sandbox choose "Only the sites you allow" and tick the sites the work needs.'+)+PROFILES.pop(network_profiles.OPEN, None)DEFAULT_PROFILE = network_profiles.DEFAULT_PROFILE@@ -67,6 +72,8 @@ def render(sandbox's private home folder with the copied credentials (section 11b), read-write.`extra_hosts`: "host:port" entries the grants need; `*.example.com` is a wildcard."""profile = network_profiles.check(profile)+ if network_profiles.is_open(profile):+ raise ValueError(OPEN_UNSUPPORTED)read_write = [RUNTIME_DIR, "/dev/null", "/dev/pts", *([home] if home else []), *[str(r["path"]) for r in roots if r.get("writable")]]read_only = [*_SYSTEM_READ_ONLY, *_IMAGE_TOOLS_READ_ONLY, RUNNER_MOUNT, *[str(r["path"]) for r in roots if not r.get("writable")]]policy: dict[str, Any] = {diff --git a/docs/openshell.md b/docs/openshell.mdindex 25c365eb..6394a90c 100644--- a/docs/openshell.md+++ b/docs/openshell.md@@ -59,7 +59,15 @@ crosses into the sandbox, and everything that comes back is treated as data.- A Linux machine, or a Mac with Docker Desktop.- Docker or Podman.-- OpenShell 0.0.116, the release OpenWorker is tested against.+- OpenShell 0.1.2, the release OpenWorker is tested against.++### Coming from OpenShell 0.0.x++OpenShell 0.1 cannot be installed over 0.0.x, and the two cannot talk to each other.+Remove the old one first, following NVIDIA's+[upgrade guide](https://docs.nvidia.com/openshell/latest/upgrade/0-1-0): delete its+sandboxes, uninstall it, then run the setup below. The gateway settings file from 0.0.x is+not valid for 0.1; delete `~/.config/openshell/gateway.toml` so setup can write a new one.## Set it up@@ -119,13 +127,15 @@ the agent is told.## The network allow list-Two choices, shared with the other sandboxes:+With OpenShell there is one choice:- **Only the sites you allow** (`allowlist`, the default): nothing until you tick sitesunder **Choose sites…**. The list offers code hosting (GitHub, GitLab), the packageregistries (PyPI, npm, crates.io, the Go proxy) and the search APIs (Brave, Tavily,DuckDuckGo), each with a tick box, and you can add any site of your own.-- **Allow everything** (`open`): any site, no allow list. The files are still the wall.++**Allow everything** is not available with OpenShell. Its policy has to name each site, so+a session set to it does not start and says so.A credential entry (below) also lets through the sites its tool needs.diff --git a/tests/test_sandbox_openshell.py b/tests/test_sandbox_openshell.pyindex a8143f79..eee10f88 100644--- a/tests/test_sandbox_openshell.py+++ b/tests/test_sandbox_openshell.py@@ -49,8 +49,9 @@ def test_network_profiles():ticked = policy.render(ROOTS, profile="allowlist", extra_hosts=["github.com:443", "registry.acme.dev:443"])["network_policies"]assert {"host": "registry.acme.dev", "port": 443} in ticked["credentials"]["endpoints"]assert all(entry["binaries"] for entry in ticked.values()) # OpenShell requires the field- opened = policy.render(ROOTS, profile="open")["network_policies"]- assert [e["host"] for e in opened["open"]["endpoints"]] == ["*"] # any host; unproved against a gateway+ # "Allow everything" has no OpenShell policy: 0.1 refuses any-host wildcards. Said plainly.+ with pytest.raises(ValueError, match="cannot allow every site"):+ policy.render(ROOTS, profile="open")with pytest.raises(ValueError):policy.render(ROOTS, profile="wide-open")