From b9c77bb6f9b8b83574489344ef6efd207a611e98 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 00:53:19 +0530 Subject: refactor: validate JSON at every parse boundary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ten sites cast or implicitly typed JSON.parse output; JSON.parse("null") would have satisfied all of them. parseJson returns a Result and validates against a typebox schema. js.ts keeps unknown — user script output has no fixed shape. daemon/bridge.ts assigned JSON.parse straight to CdpRawMessage with no guard at all; it now uses isCdpRawMessage like the transport does. Co-Authored-By: Claude Opus 5 (1M context) --- src/domains/js.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/domains/js.ts') diff --git a/src/domains/js.ts b/src/domains/js.ts index b4a5b4c..61dbe53 100644 --- a/src/domains/js.ts +++ b/src/domains/js.ts @@ -61,7 +61,7 @@ export const executeJsTool = defineBrowserTool({ // to the raw string if parse fails (e.g. value is "undefined" sentinel). let pretty: string | undefined; try { - const parsed = JSON.parse(valueStr); + const parsed: unknown = JSON.parse(valueStr); pretty = JSON.stringify(parsed, null, 2); } catch { pretty = undefined; -- cgit v1.2.3