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(plugin): load helpers with Python safe path (#1240)

mldangelo-oaicbb48010a79e
diff --git a/plugins/codex-security/scripts/workbench_publication.py b/plugins/codex-security/scripts/workbench_publication.py
index 537f021c2..1816c2ee3 100644
--- a/plugins/codex-security/scripts/workbench_publication.py
+++ b/plugins/codex-security/scripts/workbench_publication.py
@@ -7,11 +7,14 @@ import csv
import io
import os
import sqlite3
+import sys
from contextlib import closing
from pathlib import Path
from typing import Any
from urllib.parse import quote
+# Some plugin hosts launch Python with safe-path isolation enabled.
+sys.path.insert(0, str(Path(__file__).resolve().parent))
from finalize_scan_contract import (
ContractError,
build_threat_model_export,
diff --git a/plugins/codex-security/scripts/workbench_severity.py b/plugins/codex-security/scripts/workbench_severity.py
index 65a329fa5..07eecc8c0 100644
--- a/plugins/codex-security/scripts/workbench_severity.py
+++ b/plugins/codex-security/scripts/workbench_severity.py
@@ -3,11 +3,14 @@
import argparse
import json
import sqlite3
+import sys
from contextlib import closing
from pathlib import Path
from typing import Any
from urllib.parse import quote
+# Some plugin hosts launch Python with safe-path isolation enabled.
+sys.path.insert(0, str(Path(__file__).resolve().parent))
from workbench_finding_index import upsert_finding
FIELDS = {
diff --git a/plugins/codex-security/tests/test_cli_dry_runs.py b/plugins/codex-security/tests/test_cli_dry_runs.py
index 2713fe936..1a4cce6cc 100644
--- a/plugins/codex-security/tests/test_cli_dry_runs.py
+++ b/plugins/codex-security/tests/test_cli_dry_runs.py
@@ -5,6 +5,8 @@ import subprocess
import sys
from pathlib import Path
+import pytest
+
PLUGIN_ROOT = Path(__file__).resolve().parents[1]
SCRIPT_DIR = PLUGIN_ROOT / "scripts"
@@ -25,6 +27,19 @@ def test_all_scripts_support_help() -> None:
assert "usage:" in result.stdout.lower(), script.name
[email protected]("name", ("workbench_publication.py", "workbench_severity.py"))
+def test_workbench_helpers_support_help_with_safe_path(name: str) -> None:
+ result = subprocess.run(
+ [sys.executable, "-P", str(SCRIPT_DIR / name), "--help"],
+ check=False,
+ capture_output=True,
+ text=True,
+ )
+
+ assert result.returncode == 0, result.stderr
+ assert "usage:" in result.stdout.lower()
+
+
def test_recover_scan_results_help_describes_its_contract() -> None:
result = run_script("workbench_db.py", "recover-scan-results", "--help")