kern-sandbox 0.2.22 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -8
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,14 +78,20 @@ spawns a **fresh** box on that shared workspace, so file state persists but in-m
|
|
|
78
78
|
(write to disk for continuity). `withSandbox` opens the session and cleans it up, even on throw:
|
|
79
79
|
|
|
80
80
|
```js
|
|
81
|
-
await kern.withSandbox(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
await kern.withSandbox(
|
|
82
|
+
{ setup: "pip install pandas matplotlib", memoryMb: 1536 },
|
|
83
|
+
async (sbx) => {
|
|
84
|
+
await sbx.writeFile("data.csv", "a,b\n1,2\n3,4\n");
|
|
85
|
+
const r = await sbx.runCode(
|
|
86
|
+
"import matplotlib; matplotlib.use('Agg')\n" +
|
|
87
|
+
"import pandas as pd, matplotlib.pyplot as plt\n" +
|
|
88
|
+
"df = pd.read_csv('data.csv'); print(df.describe())\n" +
|
|
89
|
+
"df.plot(); plt.savefig('out.png')",
|
|
90
|
+
);
|
|
91
|
+
console.log(r.stdout); // network off, capped, isolated
|
|
92
|
+
const chart = await sbx.readFile("out.png"); // a Uint8Array of the PNG
|
|
93
|
+
},
|
|
94
|
+
);
|
|
89
95
|
```
|
|
90
96
|
|
|
91
97
|
`setup` is the **only** moment the network is on (a separate box that installs deps into the workspace
|
|
@@ -214,6 +220,13 @@ memory, scratch that does not survive a call, and the two writable places a tool
|
|
|
214
220
|
`network: false` gives the run phase no network and `network: true` gives it the host's. `egressAllow`
|
|
215
221
|
is the middle one, and usually the one an agent wants:
|
|
216
222
|
|
|
223
|
+
**`network: true` includes the host's LOOPBACK, which is where unauthenticated services live.** It
|
|
224
|
+
puts the box in the host's network namespace, so `127.0.0.1` inside the box is the host's
|
|
225
|
+
`127.0.0.1`: a reviewer's cell connected to `127.0.0.1:22` and read back `SSH-2.0-OpenSSH_9.6p1`,
|
|
226
|
+
and a developer's laptop is where a database, a Redis and a dashboard sit bound to localhost with no
|
|
227
|
+
password. The same connect is refused under the default `network: false`, and `egressAllow` refuses
|
|
228
|
+
it too, because that one goes through kern's proxy rather than through the host's stack.
|
|
229
|
+
|
|
217
230
|
```js
|
|
218
231
|
await withSandbox({ egressAllow: ["pypi.org", "files.pythonhosted.org"] }, async (sbx) => { /* ... */ });
|
|
219
232
|
```
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const crypto = require("crypto");
|
|
|
36
36
|
const zlib = require("zlib");
|
|
37
37
|
const { spawn, spawnSync } = require("child_process");
|
|
38
38
|
|
|
39
|
-
const VERSION = "0.2.
|
|
39
|
+
const VERSION = "0.2.23";
|
|
40
40
|
|
|
41
41
|
const DEFAULT_IMAGE = "python:3.12-slim";
|
|
42
42
|
const WORKSPACE = "/workspace"; // where the persistent workspace is mounted inside every box
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kern-sandbox",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
4
4
|
"description": "kern is a fast, rootless sandbox and virtual resource runtime for any workload, including untrusted and LLM-generated code; kern-sandbox is its Node/TypeScript binding. Run untrusted or agent-generated code (Python/JS/Bash) in a real, kernel-enforced box in single-digit milliseconds, with no cloud, no account and no VM.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sandbox",
|