An egress policy controls which hosts a sandbox can reach. Use it to run untrusted code, or to make sure a job talks only to the services it needs.
Not available yet.
Not available yet.
Not available yet.
import { Sutra } from "@mistrive/sutra";
const sutra = new Sutra({
baseUrl: "https://anchor.jgcp.mistrivedev.com",
});
// Allow only the package index. The GitHub integration stays reachable
// under every policy.
const sandbox = await sutra.sandboxes.create({
network: { egress: { mode: "ALLOW_LIST", hosts: ["pypi.org", "files.pythonhosted.org"] } },
integrations: [{ provider: "github" }],
});
await sandbox.processes.run({ shellCommand: "pip install requests" });
// Block all other traffic once setup is done.
await sandbox.update({ network: { egress: { mode: "DENY_ALL" } } });
const result = await sandbox.processes.run({ argv: ["curl", "-sS", "https://example.com"] });
console.log(result.exit?.code); // non-zero: the request is blockedfrom mistrive.sutra import Sutra
sutra = Sutra(
base_url="https://anchor.jgcp.mistrivedev.com",
)
# Allow only the package index. The GitHub integration stays reachable
# under every policy.
sandbox = sutra.sandboxes.create(
network={"egress": {"mode": "ALLOW_LIST", "hosts": ["pypi.org", "files.pythonhosted.org"]}},
integrations=[{"provider": "github"}],
)
sandbox.processes.run(shell_command="pip install requests")
# Block all other traffic once setup is done.
sandbox.update(network={"egress": {"mode": "DENY_ALL"}})
result = sandbox.processes.run(argv=["curl", "-sS", "https://example.com"])
if result.exit:
print(result.exit.code) # non-zero: the request is blocked#!/usr/bin/env bash
set -euo pipefail
# Assumes you ran `sutra auth login` (see the Quickstart).
# Allow only the package index. The GitHub integration stays reachable
# under every policy.
sutra sandboxes create demo --integration github \
--egress allow-list --allow-host pypi.org --allow-host files.pythonhosted.org
sutra processes run demo -- pip install requests
# Block all other traffic once setup is done.
sutra sandboxes update demo --egress deny-allModes
Set network.egress.mode when you create a sandbox:
| Mode | What the sandbox can reach |
|---|---|
ALLOW_ALL |
Any host. |
DENY_ALL |
No host on the internet. |
ALLOW_LIST |
Only the hosts in hosts. |
Integrations
Integrations stay reachable under every policy, including DENY_ALL. A sandbox with the GitHub integration can call GitHub even when it can reach nothing else. You do not need to add the provider’s hosts to an allow list.
Change the policy
Change the policy of a running sandbox with update. A common pattern is to allow a package index while you install dependencies, then switch to DENY_ALL before you run untrusted code.
Inbound traffic
Egress covers traffic that leaves the sandbox. To let traffic in, create a port.