mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-18 03:41:35 +00:00
fix(browser): reject excessive viewport resizes
This commit is contained in:
@@ -48,4 +48,16 @@ describe("browser navigation commands", () => {
|
||||
expect(capture.runtimeErrors.join("\n")).toContain("Invalid width: must be a positive integer");
|
||||
expect(mocks.runBrowserResizeWithOutput).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rejects excessive resize dimensions before dispatch", async () => {
|
||||
const program = createNavigationProgram();
|
||||
|
||||
await expect(
|
||||
program.parseAsync(["browser", "resize", "8193", "768"], { from: "user" }),
|
||||
).rejects.toThrow("__exit__:1");
|
||||
|
||||
const capture = getBrowserCliRuntimeCapture();
|
||||
expect(capture.runtimeErrors.join("\n")).toContain("Invalid width: maximum is 8192");
|
||||
expect(mocks.runBrowserResizeWithOutput).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { Command } from "commander";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import { ACT_MAX_VIEWPORT_DIMENSION } from "../../browser/act-policy.js";
|
||||
import { runBrowserResizeWithOutput } from "../browser-cli-resize.js";
|
||||
import { callBrowserRequest, type BrowserParentOpts } from "../browser-cli-shared.js";
|
||||
import { danger, defaultRuntime } from "../core-api.js";
|
||||
@@ -17,6 +18,11 @@ export function registerBrowserNavigationCommands(
|
||||
defaultRuntime.exit(1);
|
||||
return undefined;
|
||||
}
|
||||
if (parsed > ACT_MAX_VIEWPORT_DIMENSION) {
|
||||
defaultRuntime.error(danger(`Invalid ${label}: maximum is ${ACT_MAX_VIEWPORT_DIMENSION}`));
|
||||
defaultRuntime.exit(1);
|
||||
return undefined;
|
||||
}
|
||||
return parsed;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user