mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 11:47:41 +00:00
fix: allow agent workspace directories in media local roots (#17136)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 7545ef1e19
Co-authored-by: MisterGuy420 <255743668+MisterGuy420@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -371,4 +371,34 @@ describe("local media root guard", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects default OpenClaw state per-agent workspace-* roots without explicit local roots", async () => {
|
||||
const { STATE_DIR } = await import("../config/paths.js");
|
||||
const readFile = vi.fn(async () => Buffer.from("generated-media"));
|
||||
|
||||
await expect(
|
||||
loadWebMedia(path.join(STATE_DIR, "workspace-clawdy", "tmp", "render.bin"), {
|
||||
maxBytes: 1024 * 1024,
|
||||
readFile,
|
||||
}),
|
||||
).rejects.toThrow(/not under an allowed directory/i);
|
||||
});
|
||||
|
||||
it("allows per-agent workspace-* paths with explicit local roots", async () => {
|
||||
const { STATE_DIR } = await import("../config/paths.js");
|
||||
const readFile = vi.fn(async () => Buffer.from("generated-media"));
|
||||
const agentWorkspaceDir = path.join(STATE_DIR, "workspace-clawdy");
|
||||
|
||||
await expect(
|
||||
loadWebMedia(path.join(agentWorkspaceDir, "tmp", "render.bin"), {
|
||||
maxBytes: 1024 * 1024,
|
||||
localRoots: [agentWorkspaceDir],
|
||||
readFile,
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
kind: "unknown",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user