Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(preflight): accept valid Unicode progress issues (#413)

mldangelo-oaid81625ae0c6d
diff --git a/sdk/typescript/_bundled_plugin/scripts/workbench_progress.py b/sdk/typescript/_bundled_plugin/scripts/workbench_progress.py
index 6282da2a1..da0c1147c 100644
--- a/sdk/typescript/_bundled_plugin/scripts/workbench_progress.py
+++ b/sdk/typescript/_bundled_plugin/scripts/workbench_progress.py
@@ -13,7 +13,6 @@ from workbench.handoff import require_current_continuation
from workbench_constants import PHASES
from workbench_validation import optional_text, require_uuid, user_text
-MAX_PREFLIGHT_ISSUES_JSON_BYTES = 64 * 1024
MAX_PREFLIGHT_ISSUES = 32
@@ -33,10 +32,6 @@ def _preflight_issue_text(value: Any, maximum: int, label: str) -> str:
def preflight_issues_json(value: str | None) -> str | None:
if value is None:
return None
- if len(value.encode("utf-8")) > MAX_PREFLIGHT_ISSUES_JSON_BYTES:
- raise SystemExit(
- f"Preflight issues must be no larger than {MAX_PREFLIGHT_ISSUES_JSON_BYTES} bytes."
- )
try:
payload = json.loads(value)
except json.JSONDecodeError as exc:
diff --git a/sdk/typescript/tests-ts/workbench-progress.test.ts b/sdk/typescript/tests-ts/workbench-progress.test.ts
new file mode 100644
index 000000000..75c9868aa
--- /dev/null
+++ b/sdk/typescript/tests-ts/workbench-progress.test.ts
@@ -0,0 +1,71 @@
+import { spawnSync } from "node:child_process";
+import { join } from "node:path";
+import { describe, expect, test } from "bun:test";
+import { PLUGIN_ROOT } from "./plugin-root.js";
+
+function validatePreflightIssues(issues: object[]) {
+ const python = Bun.which("python3") ?? Bun.which("python");
+ expect(python).not.toBeNull();
+ return spawnSync(
+ python!,
+ [
+ "-I",
+ "-B",
+ "-c",
+ [
+ "import json, sys",
+ "sys.path.insert(0, sys.argv.pop(1))",
+ "from workbench_cli import parse_args",
+ "from workbench_progress import preflight_issues_json",
+ "args = parse_args('Synthetic workbench progress')",
+ "issues = json.loads(preflight_issues_json(args.preflight_issues_json))",
+ "print(json.dumps({'count': len(issues), 'reasonLength': len(issues[0]['reason'])}))",
+ ].join("\n"),
+ join(PLUGIN_ROOT, "scripts"),
+ "update-progress",
+ "--scan-id",
+ "00000000-0000-4000-8000-000000000000",
+ "--preflight-issues-json",
+ JSON.stringify(issues),
+ ],
+ { encoding: "utf8" },
+ );
+}
+
+function issue(reason = "Preflight warning") {
+ return {
+ capability: "delegated_workers",
+ reason,
+ severity: "warn",
+ status: "fail",
+ };
+}
+
+describe("workbench preflight progress", () => {
+ test("accepts valid non-ASCII issues larger than 64 KiB", () => {
+ const issues = Array.from({ length: 24 }, () => issue("€".repeat(1_000)));
+ const serialized = JSON.stringify(issues);
+ expect(Buffer.byteLength(serialized)).toBeGreaterThan(64 * 1024);
+ expect(serialized.length).toBeLessThan(30_000);
+
+ const result = validatePreflightIssues(issues);
+
+ expect(result.status, result.stderr).toBe(0);
+ expect(JSON.parse(result.stdout)).toEqual({
+ count: 24,
+ reasonLength: 1_000,
+ });
+ });
+
+ test("preserves upstream issue-count and reason-length limits", () => {
+ const excessIssues = validatePreflightIssues(
+ Array.from({ length: 33 }, () => issue()),
+ );
+ expect(excessIssues.status).not.toBe(0);
+ expect(excessIssues.stderr).toContain("at most 32 objects");
+
+ const excessReason = validatePreflightIssues([issue("€".repeat(1_201))]);
+ expect(excessReason.status).not.toBe(0);
+ expect(excessReason.stderr).toContain("1 to 1200 characters");
+ });
+});