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

Sync from Copyberry

Copyberryee3fe378f656
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/mcp-app.html.br b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/mcp-app.html.br
index 9b0542f1e..623598d40 100644
Binary files a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/mcp-app.html.br and b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/mcp-app.html.br differ
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-000 b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-000
index d12435b90..ba8d1a01e 100644
Binary files a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-000 and b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-000 differ
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-001 b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-001
index 3cf4531b5..f8931dd0d 100644
Binary files a/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-001 and b/sdk/python/src/openai_codex_security/_bundled_plugin/mcp/server.mjs.br.part-001 differ
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/references/config-preflight.md b/sdk/python/src/openai_codex_security/_bundled_plugin/references/config-preflight.md
index bcd0e1a61..3e16f0c52 100644
--- a/sdk/python/src/openai_codex_security/_bundled_plugin/references/config-preflight.md
+++ b/sdk/python/src/openai_codex_security/_bundled_plugin/references/config-preflight.md
@@ -68,6 +68,8 @@ The onboarding workspace opens before capability preflight and does not display
After the user submits setup and the app-generated handoff provides a `scanId`, load the authoritative scan context with `get_codex_security_scan_context`, then run this preflight for the validated target and selected scan mode. The dedicated preflight worker described above is allowed and should finish before goal setup, threat modeling, scan/discovery worker creation, or other substantive analysis.
+For standard and diff scans, the app handoff starts preflight without an item count. After every structured helper result, call `update_codex_security_scan_progress` without changing phase and set `preflightChecks` to every entry from the helper's `results` array, projecting each entry to only `capability`, `reason`, `severity`, and `status`. Do not send `phaseItemsTotal`, `phaseItemsCompleted`, or `phaseProgressUnit` with `preflightChecks`: the server derives the total from the array length, counts `pass` and `fail` as completed, excludes `unknown` from completed, and derives the visible `block` or `warn` attention items. Send the full fresh results array after a clean rerun so stale issues disappear. Do not interpret item-count completion as readiness: remain in preflight for every blocked, incomplete, or error result while remediation or retry remains pending, even when every returned check was evaluated. Only after a `ready` result has published its fresh `preflightChecks` should a separate progress call advance to `threat_model`. These counts and issues belong to the current scan rather than the legacy setup-time workspace preflight, and remain visible after the scan advances. Deep Scan preflight and discovery progress remain owned by `start_codex_security_deep_scan`.
+
Continue after a `ready` result. Explain warn or suggest issues when they materially affect scan quality, capacity, or resumability, and use the documented degraded path. If the result is `blocked` or `incomplete`, follow the remediation handling below. If the helper cannot run or returns its top-level `status: "error"` envelope, report the exact blocker and retry the documented recovery path when possible. Do not call `fail_codex_security_scan` merely because the helper is temporarily unavailable or errors; leave the durable scan running and hand off for a later retry while recovery may still be possible.
When blocked or incomplete preflight includes actionable remediation, first classify the current session before choosing a remediation control. Treat `codex exec`, headless runs, automation runs, and any host that cannot actually pause for a human reply as non-interactive even if `request_user_input` or `request_codex_security_user_input` is named in this document or appears callable. In a non-interactive session, never call either user-input tool and never fall back to a chat question; go directly to the automatic-remediation path below. Only after the session is confirmed interactive, present the exact reasons and config delta in the Codex thread and optimistically call the native `request_user_input` tool so the paused scan is visibly waiting for the user's decision instead of asking only in plain chat prose:
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_cli.py b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_cli.py
index 1c855b180..10863abae 100644
--- a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_cli.py
+++ b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_cli.py
@@ -146,6 +146,7 @@ def parse_args(description: str) -> argparse.Namespace:
update_progress.add_argument("--phase-items-total", type=non_negative_int)
update_progress.add_argument("--phase-items-completed", type=non_negative_int)
update_progress.add_argument("--phase-progress-unit", choices=PHASE_PROGRESS_UNITS)
+ update_progress.add_argument("--preflight-issues-json")
update_progress.add_argument("--review-items-total", type=non_negative_int)
update_progress.add_argument("--review-items-completed", type=non_negative_int)
update_progress.add_argument("--reportable-findings-count", type=non_negative_int)
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_db.py b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_db.py
index b3432bb99..80dcc4085 100644
--- a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_db.py
+++ b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_db.py
@@ -3010,6 +3010,11 @@ def scan_result(
"total": progress["phase_items_total"],
"unit": progress["phase_progress_unit"],
},
+ "preflightProgress": {
+ "completed": progress["preflight_checks_completed"],
+ "total": progress["preflight_checks_total"],
+ },
+ "preflightIssues": json.loads(progress["preflight_issues_json"]),
"reviewPass": progress["deep_review_pass"],
"status": "canceled" if scan["canceled_at"] else scan["status"],
"updatedAt": progress["updated_at"],
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_progress.py b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_progress.py
index 1f30ce8f2..5bf13d8c4 100644
--- a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_progress.py
+++ b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_progress.py
@@ -1,6 +1,7 @@
"""Progress transition helpers for the Codex Security workbench."""
import argparse
+import json
import sqlite3
import sys
from pathlib import Path
@@ -11,6 +12,62 @@ from workbench.handoff import require_current_continuation
from workbench_constants import PHASES
from workbench_validation import require_uuid
+MAX_PREFLIGHT_ISSUES_JSON_BYTES = 64 * 1024
+MAX_PREFLIGHT_ISSUES = 32
+
+
+def _javascript_string_length(value: str) -> int:
+ return len(value.encode("utf-16-le", errors="surrogatepass")) // 2
+
+
+def _preflight_issue_text(value: Any, maximum: int, label: str) -> str:
+ if not isinstance(value, str):
+ raise SystemExit(f"Preflight issue {label} must be text.")
+ normalized = value.strip()
+ if not normalized or _javascript_string_length(normalized) > maximum:
+ raise SystemExit(f"Preflight issue {label} must contain 1 to {maximum} characters.")
+ return normalized
+
+
+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:
+ raise SystemExit("Preflight issues must be valid JSON.") from exc
+ if not isinstance(payload, list) or len(payload) > MAX_PREFLIGHT_ISSUES:
+ raise SystemExit(
+ f"Preflight issues must be an array of at most {MAX_PREFLIGHT_ISSUES} objects."
+ )
+ normalized: list[dict[str, str]] = []
+ expected_keys = {"capability", "reason", "severity", "status"}
+ for index, issue in enumerate(payload):
+ label = f"{index + 1}"
+ if not isinstance(issue, dict) or set(issue) != expected_keys:
+ raise SystemExit(
+ f"Preflight issue {label} must contain capability, reason, severity, and status."
+ )
+ severity = issue.get("severity")
+ status = issue.get("status")
+ if severity not in {"block", "warn"} or status not in {"fail", "unknown"}:
+ raise SystemExit(f"Preflight issue {label} has an invalid severity or status.")
+ normalized.append(
+ {
+ "capability": _preflight_issue_text(
+ issue.get("capability"), 128, f"{label} capability"
+ ),
+ "reason": _preflight_issue_text(issue.get("reason"), 1200, f"{label} reason"),
+ "severity": severity,
+ "status": status,
+ }
+ )
+ return json.dumps(normalized, ensure_ascii=True, separators=(",", ":"), sort_keys=True)
+
def reportable_count(
current_phase: str, requested_phase: str | None, count: int | None
@@ -29,6 +86,7 @@ def update_progress(
scan_context: Callable[[sqlite3.Connection, str], dict[str, Any]],
) -> dict[str, Any]:
scan_id = require_uuid(args.scan_id, "scan-id")
+ serialized_preflight_issues = preflight_issues_json(args.preflight_issues_json)
connection.execute("BEGIN IMMEDIATE")
try:
timestamp = now()
@@ -42,6 +100,11 @@ def update_progress(
)
if args.deep_review_pass is not None and scan["mode"] != "deep":
raise SystemExit("Only Deep Scan can record a deep review pass.")
+ if serialized_preflight_issues is not None:
+ if scan["mode"] == "deep":
+ raise SystemExit("Deep Scan preflight progress is owned by its coordinator.")
+ if scan["phase"] != "preflight" or args.phase not in {None, "preflight"}:
+ raise SystemExit("Preflight issues can only be updated during preflight.")
progress = connection.execute(
"SELECT * FROM scan_progress WHERE scan_id = ?", (scan["id"],)
).fetchone()
@@ -81,7 +144,11 @@ def update_progress(
raise SystemExit("Phase progress unit cannot change within a phase.")
updates: list[str] = []
values: list[Any] = []
+ if next_phase == "preflight" and scan["mode"] != "deep":
+ updates.extend(["preflight_checks_total = ?", "preflight_checks_completed = ?"])
+ values.extend([phase_total, phase_completed])
for column, value in (
+ ("preflight_issues_json", serialized_preflight_issues),
("review_items_total", args.review_items_total),
("review_items_completed", args.review_items_completed),
(
diff --git a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_schema.py b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_schema.py
index 3cd2786b7..7af70586f 100644
--- a/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_schema.py
+++ b/sdk/python/src/openai_codex_security/_bundled_plugin/scripts/workbench_schema.py
@@ -531,6 +531,26 @@ MIGRATIONS = (
);
""",
),
+ (
+ 21,
+ "current scan preflight state",
+ """
+ ALTER TABLE scan_progress
+ ADD COLUMN preflight_issues_json TEXT NOT NULL DEFAULT '[]';
+
+ ALTER TABLE scan_progress
+ ADD COLUMN preflight_checks_total INTEGER NOT NULL DEFAULT 0
+ CHECK (preflight_checks_total >= 0);
+
+ ALTER TABLE scan_progress
+ ADD COLUMN preflight_checks_completed INTEGER NOT NULL DEFAULT 0
+ CHECK (
+ preflight_checks_completed >= 0
+ AND preflight_checks_completed <= preflight_checks_total
+ );
+
+ """,
+ ),
)
@@ -554,6 +574,25 @@ def normalize_pre_release_migrations(connection: sqlite3.Connection, timestamp:
("phase-specific scan progress",),
)
+ preflight_progress_migration = connection.execute(
+ "SELECT name FROM schema_migrations WHERE version = 13"
+ ).fetchone()
+ if (
+ preflight_progress_migration is not None
+ and preflight_progress_migration["name"] == "current scan preflight state"
+ ):
+ target_migration = connection.execute(
+ "SELECT name FROM schema_migrations WHERE version = 21"
+ ).fetchone()
+ if target_migration is not None:
+ raise SystemExit(
+ "The Codex Security database has an unsupported pre-release migration history."
+ )
+ connection.execute(
+ "UPDATE schema_migrations SET version = 21 WHERE version = 13 AND name = ?",
+ ("current scan preflight state",),
+ )
+
migration = connection.execute(
"SELECT name FROM schema_migrations WHERE version = 2"
).fetchone()