mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-14 10:20:42 +00:00
test: tighten sandbox mounted path assertions
This commit is contained in:
@@ -103,9 +103,10 @@ describe("tools.fs.workspaceOnly", () => {
|
||||
await expect(
|
||||
writeTool?.execute("t2", { path: "/agent/owned.txt", content: "x" }),
|
||||
).rejects.toThrow(/Path escapes sandbox root/i);
|
||||
await expect(fs.stat(path.join(agentRoot, "owned.txt"))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
const missingOwnedFile = await fs
|
||||
.stat(path.join(agentRoot, "owned.txt"))
|
||||
.catch((error: unknown) => error);
|
||||
expect((missingOwnedFile as NodeJS.ErrnoException).code).toBe("ENOENT");
|
||||
|
||||
await expect(
|
||||
editTool?.execute("t3", { path: "/agent/secret.txt", oldText: "shh", newText: "nope" }),
|
||||
@@ -129,9 +130,10 @@ describe("tools.fs.workspaceOnly", () => {
|
||||
await expect(applyPatchTool.execute("t1", { input: APPLY_PATCH_PAYLOAD })).rejects.toThrow(
|
||||
/Path escapes sandbox root/i,
|
||||
);
|
||||
await expect(fs.stat(path.join(agentRoot, "pwned.txt"))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
const missingPatchedFile = await fs
|
||||
.stat(path.join(agentRoot, "pwned.txt"))
|
||||
.catch((error: unknown) => error);
|
||||
expect((missingPatchedFile as NodeJS.ErrnoException).code).toBe("ENOENT");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user