mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 04:34:32 +00:00
refactor(sandbox): share bind parsing and host-path policy checks
This commit is contained in:
29
src/agents/sandbox/bind-spec.test.ts
Normal file
29
src/agents/sandbox/bind-spec.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { splitSandboxBindSpec } from "./bind-spec.js";
|
||||
|
||||
describe("splitSandboxBindSpec", () => {
|
||||
it("splits POSIX bind specs with and without mode", () => {
|
||||
expect(splitSandboxBindSpec("/tmp/a:/workspace-a:ro")).toEqual({
|
||||
host: "/tmp/a",
|
||||
container: "/workspace-a",
|
||||
options: "ro",
|
||||
});
|
||||
expect(splitSandboxBindSpec("/tmp/b:/workspace-b")).toEqual({
|
||||
host: "/tmp/b",
|
||||
container: "/workspace-b",
|
||||
options: "",
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves Windows drive-letter host paths", () => {
|
||||
expect(splitSandboxBindSpec("C:\\Users\\kai\\workspace:/workspace:ro")).toEqual({
|
||||
host: "C:\\Users\\kai\\workspace",
|
||||
container: "/workspace",
|
||||
options: "ro",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null when no host/container separator exists", () => {
|
||||
expect(splitSandboxBindSpec("/tmp/no-separator")).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user