@namzu/sandbox 2.0.2 → 2.0.3
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/CHANGELOG.md +29 -0
- package/package.json +12 -2
- package/dist/backends/aci-standby-pool/__tests__/unenforceable-controls.test.d.ts +0 -2
- package/dist/backends/aci-standby-pool/__tests__/unenforceable-controls.test.d.ts.map +0 -1
- package/dist/backends/aci-standby-pool/__tests__/unenforceable-controls.test.js +0 -61
- package/dist/backends/aci-standby-pool/__tests__/unenforceable-controls.test.js.map +0 -1
- package/dist/backends/docker/__tests__/hardening.test.d.ts +0 -2
- package/dist/backends/docker/__tests__/hardening.test.d.ts.map +0 -1
- package/dist/backends/docker/__tests__/hardening.test.js +0 -32
- package/dist/backends/docker/__tests__/hardening.test.js.map +0 -1
- package/dist/backends/docker/__tests__/leaf-permissions.smoke.test.d.ts +0 -40
- package/dist/backends/docker/__tests__/leaf-permissions.smoke.test.d.ts.map +0 -1
- package/dist/backends/docker/__tests__/leaf-permissions.smoke.test.js +0 -157
- package/dist/backends/docker/__tests__/leaf-permissions.smoke.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/agent-timeout-clamp.test.d.ts +0 -16
- package/dist/backends/firecracker/__tests__/agent-timeout-clamp.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/agent-timeout-clamp.test.js +0 -37
- package/dist/backends/firecracker/__tests__/agent-timeout-clamp.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/backend.test.d.ts +0 -13
- package/dist/backends/firecracker/__tests__/backend.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/backend.test.js +0 -361
- package/dist/backends/firecracker/__tests__/backend.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/control-plane-mtls.test.d.ts +0 -19
- package/dist/backends/firecracker/__tests__/control-plane-mtls.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/control-plane-mtls.test.js +0 -209
- package/dist/backends/firecracker/__tests__/control-plane-mtls.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/egress-policy.test.d.ts +0 -2
- package/dist/backends/firecracker/__tests__/egress-policy.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/egress-policy.test.js +0 -67
- package/dist/backends/firecracker/__tests__/egress-policy.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/fixtures/ipc-path.d.ts +0 -21
- package/dist/backends/firecracker/__tests__/fixtures/ipc-path.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/fixtures/ipc-path.js +0 -30
- package/dist/backends/firecracker/__tests__/fixtures/ipc-path.js.map +0 -1
- package/dist/backends/firecracker/__tests__/fixtures/mtls-pki.d.ts +0 -39
- package/dist/backends/firecracker/__tests__/fixtures/mtls-pki.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/fixtures/mtls-pki.js +0 -149
- package/dist/backends/firecracker/__tests__/fixtures/mtls-pki.js.map +0 -1
- package/dist/backends/firecracker/__tests__/protocol.test.d.ts +0 -6
- package/dist/backends/firecracker/__tests__/protocol.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/protocol.test.js +0 -67
- package/dist/backends/firecracker/__tests__/protocol.test.js.map +0 -1
- package/dist/backends/firecracker/__tests__/transport.test.d.ts +0 -20
- package/dist/backends/firecracker/__tests__/transport.test.d.ts.map +0 -1
- package/dist/backends/firecracker/__tests__/transport.test.js +0 -457
- package/dist/backends/firecracker/__tests__/transport.test.js.map +0 -1
- package/dist/egress/__tests__/allowlist.test.d.ts +0 -2
- package/dist/egress/__tests__/allowlist.test.d.ts.map +0 -1
- package/dist/egress/__tests__/allowlist.test.js +0 -85
- package/dist/egress/__tests__/allowlist.test.js.map +0 -1
- package/dist/egress/__tests__/proxy.test.d.ts +0 -2
- package/dist/egress/__tests__/proxy.test.d.ts.map +0 -1
- package/dist/egress/__tests__/proxy.test.js +0 -177
- package/dist/egress/__tests__/proxy.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -28
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -649
- package/dist/index.test.js.map +0 -1
- package/src/backends/aci-standby-pool/__tests__/unenforceable-controls.test.ts +0 -69
- package/src/backends/docker/__tests__/hardening.test.ts +0 -43
- package/src/backends/docker/__tests__/leaf-permissions.smoke.test.ts +0 -169
- package/src/backends/firecracker/__tests__/agent-timeout-clamp.test.ts +0 -48
- package/src/backends/firecracker/__tests__/backend.test.ts +0 -429
- package/src/backends/firecracker/__tests__/control-plane-mtls.test.ts +0 -261
- package/src/backends/firecracker/__tests__/egress-policy.test.ts +0 -91
- package/src/backends/firecracker/__tests__/fixtures/ipc-path.ts +0 -31
- package/src/backends/firecracker/__tests__/fixtures/mtls-pki.ts +0 -166
- package/src/backends/firecracker/__tests__/protocol.test.ts +0 -75
- package/src/backends/firecracker/__tests__/transport.test.ts +0 -534
- package/src/egress/__tests__/allowlist.test.ts +0 -103
- package/src/egress/__tests__/proxy.test.ts +0 -212
- package/src/index.test.ts +0 -709
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @namzu/sandbox
|
|
2
2
|
|
|
3
|
+
## 2.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48d9d67: Published tarballs no longer contain test files.
|
|
8
|
+
|
|
9
|
+
`files: ["dist", "src", ...]` reads as "the build output and the sources" and
|
|
10
|
+
means "everything the compiler emitted and everything in the tree", so every
|
|
11
|
+
compiled test, its declaration, and both source maps shipped to the registry —
|
|
12
|
+
and for the twelve packages that also ship `src`, the raw test sources went with
|
|
13
|
+
them.
|
|
14
|
+
|
|
15
|
+
Measured on the versions currently published:
|
|
16
|
+
|
|
17
|
+
| package | files | of which tests | unpacked |
|
|
18
|
+
| ------------ | ----------- | -------------- | ------------------ |
|
|
19
|
+
| `@namzu/sdk` | 3879 → 2239 | 1640 (42%) | 12.73 MB → 6.81 MB |
|
|
20
|
+
| `@namzu/cli` | 462 → 282 | 180 (39%) | 1.21 MB → 0.73 MB |
|
|
21
|
+
|
|
22
|
+
Nothing you can import changes. Every package restricts `exports` to `"."`, so
|
|
23
|
+
Node refused a deep subpath into those files already — they were weight in the
|
|
24
|
+
tarball and nothing else. Hence `patch`: there is no consumer-visible surface
|
|
25
|
+
here, only less to download.
|
|
26
|
+
|
|
27
|
+
The exclusions are at the packaging layer, not the compiler. Adding `exclude`
|
|
28
|
+
to `tsconfig.json` would have kept tests out of `dist` and also dropped them
|
|
29
|
+
from `tsc --noEmit`, silently ending type-checking of the entire test suite —
|
|
30
|
+
trading a packaging defect for a much worse one.
|
|
31
|
+
|
|
3
32
|
## 2.0.2
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@namzu/sandbox",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Pluggable sandbox provider for @namzu/sdk. Process-level isolation (bubblewrap on Linux, Seatbelt on macOS, via @anthropic-ai/sandbox-runtime) for developer dev loops; container-level isolation (HTTP worker + JWT-authenticated egress proxy) for multi-tenant production. Backend selected at construction time; the SDK consumes both through the same SandboxProvider interface.",
|
|
5
5
|
"license": "FSL-1.1-MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist",
|
|
26
|
+
"!dist/**/*.test.*",
|
|
27
|
+
"!dist/**/*.proc-test.*",
|
|
28
|
+
"!dist/**/__tests__",
|
|
29
|
+
"!dist/**/__fixtures__",
|
|
30
|
+
"!dist/**/test-setup.*",
|
|
26
31
|
"src",
|
|
32
|
+
"!src/**/*.test.*",
|
|
33
|
+
"!src/**/*.proc-test.*",
|
|
34
|
+
"!src/**/__tests__",
|
|
35
|
+
"!src/**/__fixtures__",
|
|
36
|
+
"!src/**/test-setup.*",
|
|
27
37
|
"LICENSE.md",
|
|
28
38
|
"README.md",
|
|
29
39
|
"CHANGELOG.md"
|
|
@@ -40,7 +50,7 @@
|
|
|
40
50
|
"@types/node": "^22.19.17",
|
|
41
51
|
"typescript": "^5.5.0",
|
|
42
52
|
"vitest": "^3.2.6",
|
|
43
|
-
"@namzu/sdk": "^
|
|
53
|
+
"@namzu/sdk": "^15.0.0"
|
|
44
54
|
},
|
|
45
55
|
"scripts": {
|
|
46
56
|
"build": "tsc --build",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unenforceable-controls.test.d.ts","sourceRoot":"","sources":["../../../../src/backends/aci-standby-pool/__tests__/unenforceable-controls.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { assertEnforceable } from '../index.js';
|
|
3
|
-
/**
|
|
4
|
-
* The claim API rejects every property override that is not a config map,
|
|
5
|
-
* so a memory cap, a process cap, environment variables and an egress
|
|
6
|
-
* policy have nowhere to ride through on this backend. They were accepted
|
|
7
|
-
* and dropped: a host that asked for `deny-all` and 512 MB got full
|
|
8
|
-
* outbound network and no cap, with no error and no warning — from the same
|
|
9
|
-
* call shape that IS enforced on the sibling container backend.
|
|
10
|
-
*
|
|
11
|
-
* Switching backends therefore removed the blast-radius controls silently,
|
|
12
|
-
* which is the worst way to lose them. namzu already holds the norm for
|
|
13
|
-
* this next door: a policy accepted and quietly ignored is worse than one
|
|
14
|
-
* that is refused.
|
|
15
|
-
*/
|
|
16
|
-
const opts = (extra = {}) => ({
|
|
17
|
-
workingDirectory: '/w',
|
|
18
|
-
...extra,
|
|
19
|
-
});
|
|
20
|
-
describe('controls this backend cannot apply', () => {
|
|
21
|
-
it.each([
|
|
22
|
-
['an egress policy', { egress: { kind: 'deny-all' } }],
|
|
23
|
-
['a memory limit', { memoryLimitMb: 512 }],
|
|
24
|
-
['a process limit', { maxProcesses: 32 }],
|
|
25
|
-
['environment variables', { env: { SECRET: 'x' } }],
|
|
26
|
-
])('refuses %s', (_name, extra) => {
|
|
27
|
-
expect(() => assertEnforceable(opts(extra))).toThrow(/cannot enforce per-sandbox/);
|
|
28
|
-
});
|
|
29
|
-
it('names every field it cannot honour, not just the first', () => {
|
|
30
|
-
try {
|
|
31
|
-
assertEnforceable(opts({ egress: { kind: 'deny-all' }, memoryLimitMb: 512, maxProcesses: 8 }));
|
|
32
|
-
expect.unreachable();
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
const message = err.message;
|
|
36
|
-
// A host fixing one and hitting the next on the following run
|
|
37
|
-
// learns the shape one failure at a time.
|
|
38
|
-
expect(message).toContain('egress');
|
|
39
|
-
expect(message).toContain('memory');
|
|
40
|
-
expect(message).toContain('process');
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
it('says where the limits do belong', () => {
|
|
44
|
-
// Refusing without saying what to do instead is a dead end; these
|
|
45
|
-
// are a property of the pooled profile.
|
|
46
|
-
expect(() => assertEnforceable(opts({ memoryLimitMb: 512 }))).toThrow(/container group profile/);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('what it does allow through', () => {
|
|
50
|
-
it('accepts a request that asks for nothing it cannot apply', () => {
|
|
51
|
-
expect(() => assertEnforceable(opts())).not.toThrow();
|
|
52
|
-
});
|
|
53
|
-
it('accepts a timeout, which is applied by the caller not the pool', () => {
|
|
54
|
-
expect(() => assertEnforceable(opts({ timeoutMs: 30_000 }))).not.toThrow();
|
|
55
|
-
});
|
|
56
|
-
it('treats an empty env bag as asking for nothing', () => {
|
|
57
|
-
// A host spreading an empty object should not be refused for it.
|
|
58
|
-
expect(() => assertEnforceable(opts({ env: {} }))).not.toThrow();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=unenforceable-controls.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unenforceable-controls.test.js","sourceRoot":"","sources":["../../../../src/backends/aci-stand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AAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hardening.test.d.ts","sourceRoot":"","sources":["../../../../src/backends/docker/__tests__/hardening.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { resolveNetwork } from '../index.js';
|
|
3
|
-
/**
|
|
4
|
-
* `EgressPolicy` was accepted by the type, threaded through the options,
|
|
5
|
-
* and silently ignored by this backend. That is worse than not supporting
|
|
6
|
-
* it: a host that set `deny-all` believed the container had no network,
|
|
7
|
-
* and it had whatever `config.network` said.
|
|
8
|
-
*/
|
|
9
|
-
describe('resolveNetwork', () => {
|
|
10
|
-
it('leaves the configured network alone when no policy is supplied', () => {
|
|
11
|
-
expect(resolveNetwork('bridge', undefined)).toBe('bridge');
|
|
12
|
-
});
|
|
13
|
-
it('enforces deny-all natively', () => {
|
|
14
|
-
// Docker can actually do this one, so there is no excuse for
|
|
15
|
-
// accepting the policy and ignoring it.
|
|
16
|
-
expect(resolveNetwork('bridge', { kind: 'deny-all' })).toBe('none');
|
|
17
|
-
});
|
|
18
|
-
it('allow-all keeps the configured network', () => {
|
|
19
|
-
expect(resolveNetwork('my-bridge', { kind: 'allow-all' })).toBe('my-bridge');
|
|
20
|
-
});
|
|
21
|
-
it('REFUSES a host allowlist rather than silently granting full access', () => {
|
|
22
|
-
// This backend has no proxy to filter through. Downgrading a
|
|
23
|
-
// restrictive policy to "allow everything" is the failure mode that
|
|
24
|
-
// makes a security control worse than useless.
|
|
25
|
-
expect(() => resolveNetwork('bridge', { kind: 'static', allowedHosts: ['example.com'] })).toThrow(/cannot enforce an egress policy/);
|
|
26
|
-
expect(() => resolveNetwork('bridge', { kind: 'resolver', resolve: async () => [] })).toThrow(/cannot enforce an egress policy/);
|
|
27
|
-
});
|
|
28
|
-
it('names what it can do, so the failure is actionable', () => {
|
|
29
|
-
expect(() => resolveNetwork('bridge', { kind: 'static', allowedHosts: [] })).toThrow(/deny-all/);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=hardening.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hardening.test.js","sourceRoot":"","sources":["../../../../src/backends/docker/__tests__/hardening.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C;;;;;GAKG;AAEH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACzE,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACrC,6DAA6D;QAC7D,wCAAwC;QACxC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC7E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC7E,6DAA6D;QAC7D,oEAAoE;QACpE,+CAA+C;QAC/C,MAAM,CAAC,GAAG,EAAE,CACX,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,CAC3E,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAA;QAE5C,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAC5F,iCAAiC,CACjC,CAAA;IACF,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IACjG,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Docker smoke test — leaf-mount permission semantics.
|
|
3
|
-
*
|
|
4
|
-
* Concern raised in review: the Dockerfile pre-creates only the parent
|
|
5
|
-
* dirs (`/mnt`, `/mnt/user-data`, `/mnt/skills`) as root-owned 0555.
|
|
6
|
-
* The runtime claim is that:
|
|
7
|
-
*
|
|
8
|
-
* 1. When `outputs` IS bound, uid 1001 (the worker user) can write
|
|
9
|
-
* into it.
|
|
10
|
-
* 2. When a leaf path (e.g. `/mnt/user-data/uploads`) is NOT bound,
|
|
11
|
-
* the path simply does not exist — `stat` returns ENOENT, NOT
|
|
12
|
-
* a writable empty dir.
|
|
13
|
-
*
|
|
14
|
-
* Both of those are kernel-level mount-namespace properties, not
|
|
15
|
-
* unit-testable. This file exercises them against a real docker
|
|
16
|
-
* daemon. Run via:
|
|
17
|
-
*
|
|
18
|
-
* pnpm --filter @namzu/sandbox test:smoke
|
|
19
|
-
* # or, from the monorepo root:
|
|
20
|
-
* pnpm sandbox:smoke
|
|
21
|
-
*
|
|
22
|
-
* Excluded from the default `pnpm test` run by `vitest.config.ts`.
|
|
23
|
-
*
|
|
24
|
-
* Pre-requisites:
|
|
25
|
-
* - `docker` CLI on PATH.
|
|
26
|
-
* - A pre-built reference image. By default this test looks for
|
|
27
|
-
* `namzu-sandbox-worker:smoke`. Override with the
|
|
28
|
-
* `NAMZU_SANDBOX_SMOKE_IMAGE` env. Build the image once with:
|
|
29
|
-
* `docker build -t namzu-sandbox-worker:smoke -f packages/sandbox/worker/Dockerfile packages/sandbox`
|
|
30
|
-
* - A host-side scratch directory the test creates and tears down.
|
|
31
|
-
*
|
|
32
|
-
* On a developer machine without docker the test self-skips with a
|
|
33
|
-
* clear message. On CI (`process.env.CI === 'true'`) the same
|
|
34
|
-
* pre-conditions FAIL FAST instead of skipping, so a CI
|
|
35
|
-
* misconfiguration cannot silently mask a regression — see the
|
|
36
|
-
* `.github/workflows/sandbox-smoke.yml` workflow which is meant to
|
|
37
|
-
* always run with docker available.
|
|
38
|
-
*/
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=leaf-permissions.smoke.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"leaf-permissions.smoke.test.d.ts","sourceRoot":"","sources":["../../../../src/backends/docker/__tests__/leaf-permissions.smoke.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Docker smoke test — leaf-mount permission semantics.
|
|
3
|
-
*
|
|
4
|
-
* Concern raised in review: the Dockerfile pre-creates only the parent
|
|
5
|
-
* dirs (`/mnt`, `/mnt/user-data`, `/mnt/skills`) as root-owned 0555.
|
|
6
|
-
* The runtime claim is that:
|
|
7
|
-
*
|
|
8
|
-
* 1. When `outputs` IS bound, uid 1001 (the worker user) can write
|
|
9
|
-
* into it.
|
|
10
|
-
* 2. When a leaf path (e.g. `/mnt/user-data/uploads`) is NOT bound,
|
|
11
|
-
* the path simply does not exist — `stat` returns ENOENT, NOT
|
|
12
|
-
* a writable empty dir.
|
|
13
|
-
*
|
|
14
|
-
* Both of those are kernel-level mount-namespace properties, not
|
|
15
|
-
* unit-testable. This file exercises them against a real docker
|
|
16
|
-
* daemon. Run via:
|
|
17
|
-
*
|
|
18
|
-
* pnpm --filter @namzu/sandbox test:smoke
|
|
19
|
-
* # or, from the monorepo root:
|
|
20
|
-
* pnpm sandbox:smoke
|
|
21
|
-
*
|
|
22
|
-
* Excluded from the default `pnpm test` run by `vitest.config.ts`.
|
|
23
|
-
*
|
|
24
|
-
* Pre-requisites:
|
|
25
|
-
* - `docker` CLI on PATH.
|
|
26
|
-
* - A pre-built reference image. By default this test looks for
|
|
27
|
-
* `namzu-sandbox-worker:smoke`. Override with the
|
|
28
|
-
* `NAMZU_SANDBOX_SMOKE_IMAGE` env. Build the image once with:
|
|
29
|
-
* `docker build -t namzu-sandbox-worker:smoke -f packages/sandbox/worker/Dockerfile packages/sandbox`
|
|
30
|
-
* - A host-side scratch directory the test creates and tears down.
|
|
31
|
-
*
|
|
32
|
-
* On a developer machine without docker the test self-skips with a
|
|
33
|
-
* clear message. On CI (`process.env.CI === 'true'`) the same
|
|
34
|
-
* pre-conditions FAIL FAST instead of skipping, so a CI
|
|
35
|
-
* misconfiguration cannot silently mask a regression — see the
|
|
36
|
-
* `.github/workflows/sandbox-smoke.yml` workflow which is meant to
|
|
37
|
-
* always run with docker available.
|
|
38
|
-
*/
|
|
39
|
-
import { spawnSync } from 'node:child_process';
|
|
40
|
-
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
41
|
-
import { tmpdir } from 'node:os';
|
|
42
|
-
import { join } from 'node:path';
|
|
43
|
-
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
44
|
-
import { createSandboxProvider } from '../../../index.js';
|
|
45
|
-
const IMAGE = process.env.NAMZU_SANDBOX_SMOKE_IMAGE ?? 'namzu-sandbox-worker:smoke';
|
|
46
|
-
const IS_CI = process.env.CI === 'true';
|
|
47
|
-
function dockerAvailable() {
|
|
48
|
-
const probe = spawnSync('docker', ['version', '--format', '{{.Server.Version}}'], {
|
|
49
|
-
stdio: 'ignore',
|
|
50
|
-
});
|
|
51
|
-
return probe.status === 0;
|
|
52
|
-
}
|
|
53
|
-
function imagePresent(image) {
|
|
54
|
-
const probe = spawnSync('docker', ['image', 'inspect', image], { stdio: 'ignore' });
|
|
55
|
-
return probe.status === 0;
|
|
56
|
-
}
|
|
57
|
-
const skipReason = !dockerAvailable()
|
|
58
|
-
? 'docker daemon not reachable — skipping smoke test'
|
|
59
|
-
: !imagePresent(IMAGE)
|
|
60
|
-
? `image ${IMAGE} not present — build it with \`docker build -t ${IMAGE} -f packages/sandbox/worker/Dockerfile packages/sandbox\` and re-run`
|
|
61
|
-
: null;
|
|
62
|
-
// CI fail-fast: the smoke workflow is meant to always have docker +
|
|
63
|
-
// the reference image. Skipping silently in that environment would
|
|
64
|
-
// let a regression land without the test even attempting to run.
|
|
65
|
-
// Locally (no `CI=true`) skipping with a hint is the right behaviour
|
|
66
|
-
// for a developer who hasn't built the image yet.
|
|
67
|
-
if (IS_CI && skipReason) {
|
|
68
|
-
throw new Error(`smoke test pre-condition not satisfied on CI: ${skipReason}. Configure the workflow to install docker and build the reference image before running.`);
|
|
69
|
-
}
|
|
70
|
-
describe.skipIf(skipReason !== null)('docker smoke — leaf permissions', () => {
|
|
71
|
-
let outputsHost;
|
|
72
|
-
beforeAll(() => {
|
|
73
|
-
outputsHost = mkdtempSync(join(tmpdir(), 'namzu-sandbox-smoke-out-'));
|
|
74
|
-
});
|
|
75
|
-
afterAll(() => {
|
|
76
|
-
if (outputsHost) {
|
|
77
|
-
rmSync(outputsHost, { recursive: true, force: true });
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
it('uid 1001 can write to the outputs bind, and the host sees the file', async () => {
|
|
81
|
-
const provider = createSandboxProvider({
|
|
82
|
-
backend: { tier: 'container', image: IMAGE },
|
|
83
|
-
layout: {
|
|
84
|
-
outputs: { source: { type: 'hostDir', hostPath: outputsHost } },
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
const sandbox = await provider.create();
|
|
88
|
-
try {
|
|
89
|
-
const result = await sandbox.exec('sh', [
|
|
90
|
-
'-c',
|
|
91
|
-
'id -u && echo "smoke" > /mnt/user-data/outputs/hello.txt',
|
|
92
|
-
]);
|
|
93
|
-
expect(result.exitCode).toBe(0);
|
|
94
|
-
expect(result.stdout.trim()).toBe('1001');
|
|
95
|
-
// Host-side read confirms the bind round-trips.
|
|
96
|
-
const hostContent = readFileSync(join(outputsHost, 'hello.txt'), 'utf8');
|
|
97
|
-
expect(hostContent.trim()).toBe('smoke');
|
|
98
|
-
}
|
|
99
|
-
finally {
|
|
100
|
-
await sandbox.destroy();
|
|
101
|
-
}
|
|
102
|
-
}, 60_000);
|
|
103
|
-
it('unbound leaves do not exist — uploads/transcripts/tool_results are ENOENT, not empty', async () => {
|
|
104
|
-
const provider = createSandboxProvider({
|
|
105
|
-
backend: { tier: 'container', image: IMAGE },
|
|
106
|
-
layout: {
|
|
107
|
-
outputs: { source: { type: 'hostDir', hostPath: outputsHost } },
|
|
108
|
-
// Intentionally leave uploads / toolResults / transcripts
|
|
109
|
-
// unbound. The Dockerfile pre-creates only the parents
|
|
110
|
-
// (`/mnt/user-data`, `/mnt/skills`); leaves should not
|
|
111
|
-
// exist and `stat` should fail.
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
const sandbox = await provider.create();
|
|
115
|
-
try {
|
|
116
|
-
for (const leafPath of [
|
|
117
|
-
'/mnt/user-data/uploads',
|
|
118
|
-
'/mnt/user-data/tool_results',
|
|
119
|
-
'/mnt/transcripts',
|
|
120
|
-
]) {
|
|
121
|
-
const result = await sandbox.exec('sh', ['-c', `stat ${leafPath} 2>&1; echo --rc=$?`]);
|
|
122
|
-
// `stat` returns non-zero on ENOENT; the rc line carries
|
|
123
|
-
// the failure. Either is the contract; we accept either
|
|
124
|
-
// "No such file" or "cannot stat" wording across distros.
|
|
125
|
-
expect(result.stdout).toMatch(/--rc=[1-9]/);
|
|
126
|
-
expect(result.stdout.toLowerCase()).toMatch(/no such file|cannot stat|does not exist/);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
await sandbox.destroy();
|
|
131
|
-
}
|
|
132
|
-
}, 60_000);
|
|
133
|
-
it('uid 1001 cannot mkdir into the root-owned 0555 parent /mnt/user-data', async () => {
|
|
134
|
-
const provider = createSandboxProvider({
|
|
135
|
-
backend: { tier: 'container', image: IMAGE },
|
|
136
|
-
layout: {
|
|
137
|
-
outputs: { source: { type: 'hostDir', hostPath: outputsHost } },
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
const sandbox = await provider.create();
|
|
141
|
-
try {
|
|
142
|
-
// The model trying to "create the missing leaf dir" hits
|
|
143
|
-
// the 0555 root-owned parent and is denied — exactly what
|
|
144
|
-
// distinguishes "not bound" from "writable empty dir".
|
|
145
|
-
const result = await sandbox.exec('sh', [
|
|
146
|
-
'-c',
|
|
147
|
-
'mkdir /mnt/user-data/fake 2>&1; echo --rc=$?',
|
|
148
|
-
]);
|
|
149
|
-
expect(result.stdout).toMatch(/--rc=[1-9]/);
|
|
150
|
-
expect(result.stdout.toLowerCase()).toMatch(/permission denied/);
|
|
151
|
-
}
|
|
152
|
-
finally {
|
|
153
|
-
await sandbox.destroy();
|
|
154
|
-
}
|
|
155
|
-
}, 60_000);
|
|
156
|
-
});
|
|
157
|
-
//# sourceMappingURL=leaf-permissions.smoke.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"leaf-permissions.smoke.test.js","sourceRoot":"","sources":["../../../../src/backends/docker/__tests__/leaf-permissions.smoke.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,WA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B,CAAC;IACF,CAAC,EAAE,MAAM,CAAC,CAAA;IAEV,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACrF,MAAM,QAAQ,GAAG,qBAAqB,CAAC;YACtC,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE;YAC5C,MAAM,EAAE;gBACP,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE;aAC/D;SACD,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAA;QACvC,IAAI,CAAC;YACJ,yDAAyD;YACzD,0DAA0D;YAC1D,uDAAuD;YACvD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE;gBACvC,IAAI;gBACJ,8CAA8C;aAC9C,CAAC,CAAA;YACF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;YAC3C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;QACjE,CAAC;gBAAS,CAAC;YACV,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACxB,CAAC;IACF,CAAC,EAAE,MAAM,CAAC,CAAA;AACX,CAAC,CAAC,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `resolveTimeoutMs` is the guest agent's only guard against a
|
|
3
|
-
* caller-requested `timeoutMs` that has no schema ceiling upstream (it
|
|
4
|
-
* traces back to the bash tool's model-authored `timeout` argument — see
|
|
5
|
-
* `packages/sdk/src/tools/builtins/bash.ts`). A request above the cap must
|
|
6
|
-
* be refused (the sibling `worker/server.js` answers `invalid_timeout` on
|
|
7
|
-
* response), not silently shortened — a caller that asked for more and got
|
|
8
|
-
* less without being told would believe its process was protected for the
|
|
9
|
-
* duration it actually asked for.
|
|
10
|
-
*
|
|
11
|
-
* Pure-function test, no socket/process involved, so it runs on every
|
|
12
|
-
* platform (unlike `backend.test.ts` / `transport.test.ts`, which spawn
|
|
13
|
-
* `/bin/sh` and skip on Windows).
|
|
14
|
-
*/
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=agent-timeout-clamp.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-timeout-clamp.test.d.ts","sourceRoot":"","sources":["../../../../src/backends/firecracker/__tests__/agent-timeout-clamp.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `resolveTimeoutMs` is the guest agent's only guard against a
|
|
3
|
-
* caller-requested `timeoutMs` that has no schema ceiling upstream (it
|
|
4
|
-
* traces back to the bash tool's model-authored `timeout` argument — see
|
|
5
|
-
* `packages/sdk/src/tools/builtins/bash.ts`). A request above the cap must
|
|
6
|
-
* be refused (the sibling `worker/server.js` answers `invalid_timeout` on
|
|
7
|
-
* response), not silently shortened — a caller that asked for more and got
|
|
8
|
-
* less without being told would believe its process was protected for the
|
|
9
|
-
* duration it actually asked for.
|
|
10
|
-
*
|
|
11
|
-
* Pure-function test, no socket/process involved, so it runs on every
|
|
12
|
-
* platform (unlike `backend.test.ts` / `transport.test.ts`, which spawn
|
|
13
|
-
* `/bin/sh` and skip on Windows).
|
|
14
|
-
*/
|
|
15
|
-
import { createRequire } from 'node:module';
|
|
16
|
-
import { describe, expect, it } from 'vitest';
|
|
17
|
-
const require_ = createRequire(import.meta.url);
|
|
18
|
-
const agent = require_('../../../../agent/agent.cjs');
|
|
19
|
-
describe('agent.cjs resolveTimeoutMs', () => {
|
|
20
|
-
it('passes through a caller value within the cap', () => {
|
|
21
|
-
expect(agent.resolveTimeoutMs(10_000)).toBe(10_000);
|
|
22
|
-
});
|
|
23
|
-
it('falls back to the default for an omitted value', () => {
|
|
24
|
-
expect(agent.resolveTimeoutMs(undefined)).toBe(5 * 60 * 1000);
|
|
25
|
-
});
|
|
26
|
-
it('refuses a request far above the cap instead of honoring or silently shortening it', () => {
|
|
27
|
-
expect(() => agent.resolveTimeoutMs(Number.MAX_SAFE_INTEGER)).toThrow(/timeoutMs/);
|
|
28
|
-
expect(() => agent.resolveTimeoutMs(10 ** 12)).toThrow(/timeoutMs/);
|
|
29
|
-
});
|
|
30
|
-
it('refuses a non-finite or non-positive value', () => {
|
|
31
|
-
expect(() => agent.resolveTimeoutMs(0)).toThrow(/timeoutMs/);
|
|
32
|
-
expect(() => agent.resolveTimeoutMs(-1)).toThrow(/timeoutMs/);
|
|
33
|
-
expect(() => agent.resolveTimeoutMs(Number.NaN)).toThrow(/timeoutMs/);
|
|
34
|
-
expect(() => agent.resolveTimeoutMs(Number.POSITIVE_INFINITY)).toThrow(/timeoutMs/);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=agent-timeout-clamp.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-timeout-clamp.test.js","sourceRoot":"","sources":["../../../../src/backends/firecracker/__tests__/agent-timeout-clamp.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAM/C,MAAM,KAAK,GAAG,QAAQ,CAAC,6BAA6B,CAAgB,CAAA;AAEpE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACvD,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM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
|
|
2
|
-
* Firecracker `SandboxBackend` end-to-end over the loopback agent.
|
|
3
|
-
*
|
|
4
|
-
* Stubs the orchestrator control plane (`fetch` for `/sandboxes` create
|
|
5
|
-
* + `:delete`) and points the returned vsock handle at a unix-socket
|
|
6
|
-
* loopback running the REAL `agent/agent.cjs`. Proves the full
|
|
7
|
-
* {@link Sandbox} handle the SDK consumes — `exec` / `writeFile` /
|
|
8
|
-
* `readFile` / `listFiles` / `destroy` / `status` — speaks the NDJSON
|
|
9
|
-
* wire over the vsock transport, and that the readiness fence waits on
|
|
10
|
-
* the agent's healthz (not the orchestrator 2xx).
|
|
11
|
-
*/
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=backend.test.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backend.test.d.ts","sourceRoot":"","sources":["../../../../src/backends/firecracker/__tests__/backend.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|