mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:27:40 +00:00
refactor(media): harden localRoots bypass (#16739)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 89dce69f50
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Reviewed-by: @steipete
This commit is contained in:
committed by
GitHub
parent
b607c41a52
commit
683aa09b55
@@ -329,10 +329,22 @@ describe("local media root guard", () => {
|
||||
});
|
||||
|
||||
it("allows any path when localRoots is 'any'", async () => {
|
||||
const result = await loadWebMedia(tinyPngFile, 1024 * 1024, { localRoots: "any" });
|
||||
const result = await loadWebMedia(tinyPngFile, {
|
||||
maxBytes: 1024 * 1024,
|
||||
localRoots: "any",
|
||||
readFile: (filePath) => fs.readFile(filePath),
|
||||
});
|
||||
expect(result.kind).toBe("image");
|
||||
});
|
||||
|
||||
it("rejects filesystem root entries in localRoots", async () => {
|
||||
await expect(
|
||||
loadWebMedia(tinyPngFile, 1024 * 1024, {
|
||||
localRoots: [path.parse(tinyPngFile).root],
|
||||
}),
|
||||
).rejects.toThrow(/refuses filesystem root/i);
|
||||
});
|
||||
|
||||
it("allows default OpenClaw state workspace and sandbox roots", async () => {
|
||||
const { STATE_DIR } = await import("../config/paths.js");
|
||||
const readFile = vi.fn(async () => Buffer.from("generated-media"));
|
||||
|
||||
Reference in New Issue
Block a user