OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
test(mcp): resolve the Python fixture interpreter on Windows (#2367)
Michael D'Angelo4f8aeb51d1f8
diff --git a/plugins/codex-security/mcp-app/tests/deep_scan_context_snapshot_cases.ts b/plugins/codex-security/mcp-app/tests/deep_scan_context_snapshot_cases.tsindex b2422d4df..ce064cbdb 100644--- a/plugins/codex-security/mcp-app/tests/deep_scan_context_snapshot_cases.ts+++ b/plugins/codex-security/mcp-app/tests/deep_scan_context_snapshot_cases.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import {CodexSdkWorkerExecutor,fakeCodexFixture,@@ -77,7 +78,7 @@ export async function testDeepScanContextSnapshots() {await writeFile(deepConfig, `[deep_scan]\nmax_time_hours = 48\n`);const command = async (args: string[], input?: string) => {const execution = promisify(execFile)(- process.env.PYTHON?.trim() || "python3",+ fixturePython,[path.join(pluginRoot, "scripts/workbench_db.py"), ...args],{env: {diff --git a/plugins/codex-security/mcp-app/tests/deep_scan_coverage_fixture.ts b/plugins/codex-security/mcp-app/tests/deep_scan_coverage_fixture.tsindex 42db23250..010666b49 100644--- a/plugins/codex-security/mcp-app/tests/deep_scan_coverage_fixture.ts+++ b/plugins/codex-security/mcp-app/tests/deep_scan_coverage_fixture.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";import { randomUUID } from "node:crypto";@@ -70,7 +71,7 @@ export async function readFixtureCoverage(scanDir: string,stateDir = path.resolve(scanDir, "../../../state"),): Promise<PublishedCoverage> {- const { stdout } = await exec(process.env.PYTHON || "python3", [+ const { stdout } = await exec(fixturePython, ["-c",`import json,sysfrom pathlib import Path@@ -187,7 +188,7 @@ runpy.run_path(sys.argv[0], run_name="__main__")`,);}- const { stdout } = await exec(process.env.PYTHON || "python3", command, {+ const { stdout } = await exec(fixturePython, command, {signal: workbenchAbort.signal,env: {...process.env,diff --git a/plugins/codex-security/mcp-app/tests/deep_scan_lifecycle_cases.ts b/plugins/codex-security/mcp-app/tests/deep_scan_lifecycle_cases.tsindex adfeb0d41..686ae510c 100644--- a/plugins/codex-security/mcp-app/tests/deep_scan_lifecycle_cases.ts+++ b/plugins/codex-security/mcp-app/tests/deep_scan_lifecycle_cases.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import type { TestContext } from "node:test";import { readJson, writeJson } from "./support/json.ts";import type { ScanDraftInput } from "../src/artifact-scan-draft.js";@@ -112,7 +113,7 @@ export async function testDeepScanLifecycle(context: TestContext) {async function lateCancellationWaitsForPersistence(context: TestContext) {const completedParentStatus: string = JSON.parse(execFileSync(- process.env.PYTHON || "python3",+ fixturePython,["-I","-B",diff --git a/plugins/codex-security/mcp-app/tests/scan-identity-recovery-fixture.ts b/plugins/codex-security/mcp-app/tests/scan-identity-recovery-fixture.tsindex 229d36ee8..6723b3e05 100644--- a/plugins/codex-security/mcp-app/tests/scan-identity-recovery-fixture.ts+++ b/plugins/codex-security/mcp-app/tests/scan-identity-recovery-fixture.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { execFile } from "node:child_process";import { readdir, utimes } from "node:fs/promises";import path from "node:path";@@ -92,11 +93,9 @@ export async function recoverAndFinalize(normalCoverage: Record<string, unknown>;recoveredCoverage: Record<string, unknown>;}> {- const { stdout } = await execFileAsync(- process.env.PYTHON?.trim() || "python3",- [- "-c",- `import json,sys+ const { stdout } = await execFileAsync(fixturePython, [+ "-c",+ `import json,sysfrom pathlib import Pathsys.path.insert(0,sys.argv[1])from workbench_saved_results import merge_saved_results@@ -128,18 +127,17 @@ for root,documents in [(normal,ordinary),(recovered,recovery)]:preserved_identities.append([row.get('provenance',{}).get('preservedIdentity') for row in prepared.findings['findings']])results.append([{'title':row['title'],'identity':row['identity'],'fingerprints':row['fingerprints'],'findingId':row['findingId'],'occurrenceId':row['occurrenceId'],'workerMetadata':row.get('provenance',{}).get('workerId'),**({'evidenceProvenance':{key:row.get('provenance',{}).get(key,[]) for key in ['sourceFindingIds','sourceFindings','previousFindings','originalCandidates']}} if json.loads(sys.argv[8]) else {}),**({'summary':row['summary'],'locations':row['locations'],'severity':row['severity'],'candidateMetadata':{'provenance':row.get('provenance',{}).get('candidateId'),'extensions':row.get('extensions')}} if json.loads(sys.argv[6]) else {})} for row in prepared.findings['findings']])print(json.dumps({'normal':results[0],'recovered':results[1],'warnings':warnings,'normalCoverage':ordinary[2],'recoveredCoverage':recovery[2],'preservedIdentities':preserved_identities,'historySummaries':[previous.get('summary') for row in recovery[1]['findings'] for previous in row.get('provenance',{}).get('previousFindings',[]) if isinstance(previous,dict)]}))`,- fileURLToPath(new URL("../../scripts", import.meta.url)),- normal.root,- recovered.root,- normal.context.scanId!,- JSON.stringify(workers),- JSON.stringify(details),- JSON.stringify(replay),- JSON.stringify(provenanceDetails),- source,- normal.context.mode!,- ],- );+ fileURLToPath(new URL("../../scripts", import.meta.url)),+ normal.root,+ recovered.root,+ normal.context.scanId!,+ JSON.stringify(workers),+ JSON.stringify(details),+ JSON.stringify(replay),+ JSON.stringify(provenanceDetails),+ source,+ normal.context.mode!,+ ]);return JSON.parse(stdout);}diff --git a/plugins/codex-security/mcp-app/tests/support/python.ts b/plugins/codex-security/mcp-app/tests/support/python.tsnew file mode 100644index 000000000..47682d32e--- /dev/null+++ b/plugins/codex-security/mcp-app/tests/support/python.ts@@ -0,0 +1,5 @@+import { resolvePythonCommand } from "../../src/python_command.ts";++export const fixturePython =+ process.env.PYTHON?.trim() ||+ (process.platform === "win32" ? await resolvePythonCommand() : "python3");diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_contracts.ts b/plugins/codex-security/mcp-app/tests/test_artifact_contracts.tsindex f6aa8b475..088af164e 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_contracts.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_contracts.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import path from "node:path";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";@@ -113,7 +114,7 @@ const commonJson = await readJson();const pythonTextResults = JSON.parse(execFileSync(- process.env.PYTHON || "python3",+ fixturePython,["-c","import json, re, sys; values, pattern = json.load(sys.stdin.buffer); print(json.dumps([[bool(value.strip()), bool(re.search(pattern, value))] for value in values]))",diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_inventory.ts b/plugins/codex-security/mcp-app/tests/test_artifact_inventory.tsindex a4469b422..bd171620b 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_inventory.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_inventory.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { after, test } from "node:test";import { createTemporaryDirectories } from "./support/temporary-directories.ts";import assert from "node:assert/strict";@@ -98,7 +99,7 @@ test(async function testPrepareUsesTheExistingStandardGenerator() {const result = await inventory.prepareCodexSecurityReviewItems({...fixture.scan,pluginRoot,- pythonCommand: process.env.PYTHON ?? "python3",+ pythonCommand: fixturePython,});const scripts = await readdir(path.join(pluginRoot, "scripts"), {recursive: true,diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.tsindex 2b4928512..8424f4282 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { readJson, writeJson } from "./support/json.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";@@ -79,7 +80,7 @@ async function finalizeParentFindings({document.scanId = context.scanId;await writeJson(filePath, document);}- await execFileAsync(process.env.PYTHON?.trim() || "python3", [+ await execFileAsync(fixturePython, [fileURLToPath(new URL("../../scripts/finalize_scan_contract.py", import.meta.url),),@@ -201,11 +202,9 @@ for (const [layout, status] of [saved.findings[1].identity.instance = "saved-distinct-location";await writeFile(file, JSON.stringify(saved));}- const { stdout } = await execFileAsync(- process.env.PYTHON?.trim() || "python3",- [- "-c",- `import sys,json+ const { stdout } = await execFileAsync(fixturePython, [+ "-c",+ `import sys,jsonfrom pathlib import Pathsys.path.insert(0,sys.argv[1])from workbench_saved_results import merge_saved_results@@ -223,12 +222,11 @@ prepared=_prepare_scan_finalization(root,completion_binding=binding,recover_unsewarnings.extend(prepared.warnings)published=_write_prepared_scan_finalization(prepared)print(json.dumps({'count':len(published[1]['findings']),'status':published[0]['scan']['status'],'sealed':bool(published[0]['scan'].get('sealedAt')),'warnings':warnings,'assessments':sorted([row['title'],row['severity']['level']] for row in published[1]['findings'])}))`,- fileURLToPath(new URL("../../scripts", import.meta.url)),- f.root,- f.context.scanId!,- status,- ],- );+ fileURLToPath(new URL("../../scripts", import.meta.url)),+ f.root,+ f.context.scanId!,+ status,+ ]);assert.deepEqual(JSON.parse(stdout), {count,status,@@ -630,11 +628,9 @@ for (const headTime of [1, 2, 3]) {]) {originals.set(filename, await readFile(filename));}- const { stdout } = await execFileAsync(- process.env.PYTHON?.trim() || "python3",- [- "-c",- `import json,sys+ const { stdout } = await execFileAsync(fixturePython, [+ "-c",+ `import json,sysfrom pathlib import Pathsys.path.insert(0,sys.argv[1])from workbench_saved_results import merge_saved_results@@ -644,12 +640,11 @@ binding={"status":"interrupted","allowedTargetKinds":["git_revision"],"target":{first=merge_saved_results(root,sys.argv[4],binding,[worker],[],stopped=True,reason="interrupted")replay=merge_saved_results(root,sys.argv[4],binding,[worker],[],stopped=True,reason="interrupted",frozen_source_digests=first[0]["scan"]["preservedSources"])print(json.dumps([first[2],replay[2]]))`,- path.join(import.meta.dirname, "../../scripts"),- path.dirname(f.root),- f.root,- f.context.scanId!,- ],- );+ path.join(import.meta.dirname, "../../scripts"),+ path.dirname(f.root),+ f.root,+ f.context.scanId!,+ ]);const [reviewState, replay] = JSON.parse(stdout);assert.deepEqual(replay, reviewState);for (const [field, rows] of Object.entries(added)) {diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_scan_identity.ts b/plugins/codex-security/mcp-app/tests/test_artifact_scan_identity.tsindex 1c3d8a63e..241ab9f5c 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_scan_identity.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_scan_identity.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { readJson } from "./support/json.ts";import assert from "node:assert/strict";import { createHash } from "node:crypto";@@ -1185,11 +1186,9 @@ for (const layout of ["standard", "diff"] as const) {[{ ...first, summary: "Revised evidence." }, second],{ complete: true },);- const { stdout } = await execFileAsync(- process.env.PYTHON?.trim() || "python3",- [- "-c",- `import json,sys+ const { stdout } = await execFileAsync(fixturePython, [+ "-c",+ `import json,sysfrom pathlib import Pathsys.path.insert(0,sys.argv[1])from finalize_scan_contract import _prepare_scan_finalization@@ -1199,11 +1198,10 @@ documents[0]['scan'].update(id=sys.argv[3],status='completed',producer={'name':'for document in documents[1:]: document['scanId']=sys.argv[3]prepared=_prepare_scan_finalization(root,draft_documents=documents)print(len(prepared.findings['findings']))`,- fileURLToPath(new URL("../../scripts", import.meta.url)),- f.root,- f.context.scanId!,- ],- );+ fileURLToPath(new URL("../../scripts", import.meta.url)),+ f.root,+ f.context.scanId!,+ ]);assert.equal(stdout.trim(), "2");});}diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_storage.ts b/plugins/codex-security/mcp-app/tests/test_artifact_storage.tsindex 4e29bc76b..6d545cd5a 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_storage.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_storage.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { temporaryDirectory } from "./support/temporary-directories.ts";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";@@ -328,7 +329,7 @@ try {});assert.equal(projectedModel.content.slice(0, content.length), content);execFileSync(- process.env.PYTHON || "python3",+ fixturePython,[path.resolve(applicationRoot, "../scripts/workbench_db.py"),"prepare-scan-completion",diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_storage_regressions.ts b/plugins/codex-security/mcp-app/tests/test_artifact_storage_regressions.tsindex 990f287d4..1d0040f30 100644--- a/plugins/codex-security/mcp-app/tests/test_artifact_storage_regressions.ts+++ b/plugins/codex-security/mcp-app/tests/test_artifact_storage_regressions.ts@@ -1,3 +1,4 @@+import { fixturePython as python } from "./support/python.ts";interface ArtifactToolResults {save_codex_security_artifact: {directory: string;@@ -26,7 +27,6 @@ import { importModule } from "./import-module.ts";import { applicationRoot, buildServer } from "./build-server.ts";const pluginRoot = path.dirname(applicationRoot);-const python = process.env.PYTHON || "python3";const exec = promisify(execFile);const fixture = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), "codex-security-storage-regressions-")),diff --git a/plugins/codex-security/mcp-app/tests/test_compact_artifact_server.ts b/plugins/codex-security/mcp-app/tests/test_compact_artifact_server.tsindex a026a165c..1d5e558b5 100644--- a/plugins/codex-security/mcp-app/tests/test_compact_artifact_server.ts+++ b/plugins/codex-security/mcp-app/tests/test_compact_artifact_server.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { readJson, snapshotScanDraft, writeJson } from "./support/json.ts";import { workerDraft, finding } from "./scan-draft-fixture.ts";import { gitText } from "../scripts/git.mjs";@@ -1197,7 +1198,7 @@ async function testClaimedParentArtifactOperations(assert.equal(await readFile(inventoryPath, "utf8"), originalInventory);}- execFileSync(process.env.PYTHON ?? "python3", [+ execFileSync(fixturePython, ["-c","import sqlite3,sys; c=sqlite3.connect(sys.argv[1]); " +"c.execute('UPDATE scans SET handoff_claim_token = ? WHERE id = ?', " +diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_cancel_response.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_cancel_response.tsindex 38988259a..2348a38b1 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_cancel_response.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_cancel_response.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { randomUUID } from "node:crypto";import { mkdir, rm, writeFile } from "node:fs/promises";@@ -141,17 +142,13 @@ try {);const run = (args: string[]): WorkbenchScanRecord & { scanId: string } =>JSON.parse(- execFileSync(- process.env.PYTHON || "python3",- ["-I", "-B", workbenchPath, ...args],- {- encoding: "utf8",- env: {- ...process.env,- CODEX_SECURITY_STATE_DIR: join(fixtureRoot!, "state"),- },+ execFileSync(fixturePython, ["-I", "-B", workbenchPath, ...args], {+ encoding: "utf8",+ env: {+ ...process.env,+ CODEX_SECURITY_STATE_DIR: join(fixtureRoot!, "state"),},- ),+ }),);const registered = run(["register-cli-scan",diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_empty_target.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_empty_target.tsindex 2f436cce7..22bcd008a 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_empty_target.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_empty_target.ts@@ -1,3 +1,4 @@+import { fixturePython as python } from "./support/python.ts";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";import { chmod, mkdir, rm, symlink, watch, writeFile } from "node:fs/promises";@@ -15,7 +16,6 @@ import {} from "./deep_scan_coordinator_fixture.ts";import { importSource } from "./import-module.ts";-const python = process.env.PYTHON?.trim() || "python3";const pluginRoot = resolve(import.meta.dirname, "../..");const { checkFreshTarget } = await importSource("src/deep-scan/engine.ts", {loader: { ".md": "text" },diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_publication_integration.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_publication_integration.tsindex 865c9b1be..e515566af 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_publication_integration.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_publication_integration.ts@@ -1,3 +1,4 @@+import { fixturePython as python } from "./support/python.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";import {@@ -69,7 +70,6 @@ const testsRoot = path.dirname(fileURLToPath(import.meta.url));const mcpAppRoot = path.resolve(testsRoot, "..");const pluginRoot = path.resolve(mcpAppRoot, "..");const workbenchPath = path.join(pluginRoot, "scripts", "workbench_db.py");-const python = process.env.PYTHON?.trim() || "python3";const owner = "publication-test-owner";const reviewState: ScanDraftInput["reviewState"] = {surfaces: [],diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_store_integration.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_store_integration.tsindex 62fabce4c..809f7367d 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_store_integration.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_store_integration.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { readJson, writeJsonLine } from "./support/json.ts";import { readFixtureCoverage } from "./deep_scan_coverage_fixture.ts";import { finding } from "./scan-draft-fixture.ts";@@ -119,7 +120,7 @@ async function testJoiningCallerAdmission(registry,runWorkbench,pluginRoot,- pythonCommand: process.env.PYTHON?.trim() || "python3",+ pythonCommand: fixturePython,parentSandbox: { filesystemDenies: [] },threadId,});@@ -156,7 +157,7 @@ async function testJoiningCallerAdmission(}async function expireLease(environment: NodeJS.ProcessEnv, scanId: string) {- await execFileAsync(process.env.PYTHON?.trim() || "python3", [+ await execFileAsync(fixturePython, ["-c",`import sqlite3, syswith sqlite3.connect(sys.argv[1]) as connection:@@ -331,13 +332,16 @@ async function createWorkbenchFixture(prefix: string) {}function createWorkbenchRunner(environment: NodeJS.ProcessEnv, bounded = true) {- const python = process.env.PYTHON?.trim() || "python3";return async (args: string[]) => {- const { stdout } = await execFileAsync(python, [workbenchPath, ...args], {- cwd: pluginRoot,- env: environment,- ...(bounded ? { timeout: 30_000, maxBuffer: 4 * 1024 * 1024 } : {}),- });+ const { stdout } = await execFileAsync(+ fixturePython,+ [workbenchPath, ...args],+ {+ cwd: pluginRoot,+ env: environment,+ ...(bounded ? { timeout: 30_000, maxBuffer: 4 * 1024 * 1024 } : {}),+ },+ );return JSON.parse(stdout);};}@@ -790,7 +794,6 @@ async function testReducerCommitAndFinishAgainstRealWorkbench() {const scanRoot = path.join(fixtureRoot, "scans");const codexHome = path.join(fixtureRoot, "codex-home");const threadId = "deep-scan-store-integration-thread";- const python = process.env.PYTHON?.trim() || "python3";const runWorkbench = mock.fn(createWorkbenchRunner(environment));const store = new WorkbenchDeepScanStore(runWorkbench);@@ -840,7 +843,7 @@ max_time_hours = 2.5observer.fail(run.scanId, "observer cannot fail its owner"),/current coordinator lease/,);- const writer = spawn(python, [+ const writer = spawn(fixturePython, ["-c",`import sqlite3, sysconnection = sqlite3.connect(sys.argv[1])@@ -1418,7 +1421,7 @@ async function testDeadlinePreservesValidWorkerCheckpoints() {);const runSql = async (sql: string) =>execFileAsync(- process.env.PYTHON?.trim() || "python3",+ fixturePython,["-c","import sqlite3,sys; connection=sqlite3.connect(sys.argv[1]); connection.executescript(sys.argv[2]); connection.close()",diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_terminal_race.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_terminal_race.tsindex 892e7874e..1055ade7a 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_terminal_race.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_terminal_race.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";import { mkdir, rm, writeFile } from "node:fs/promises";@@ -93,7 +94,7 @@ for (const ordering of [);const runWorkbench = async (args: string[]) => {const { stdout } = await execFileAsync(- process.env.PYTHON || "python3",+ fixturePython,[join(pluginRoot, "scripts", "workbench_db.py"), ...args],{ cwd: pluginRoot, env: environment },);diff --git a/plugins/codex-security/mcp-app/tests/test_large_findings_page.ts b/plugins/codex-security/mcp-app/tests/test_large_findings_page.tsindex 8e51b1fdd..fa7a084e6 100644--- a/plugins/codex-security/mcp-app/tests/test_large_findings_page.ts+++ b/plugins/codex-security/mcp-app/tests/test_large_findings_page.ts@@ -1,3 +1,4 @@+import { fixturePython as python } from "./support/python.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";import { rm } from "node:fs/promises";@@ -11,7 +12,6 @@ import { temporaryDirectory } from "./support/temporary-directories.ts";const exec = promisify(execFile);const pluginRoot = path.dirname(applicationRoot);-const python = process.env.PYTHON || "python3";await test("returns an accepted 50-finding Unicode page through the MCP subprocess", async () => {const root = await temporaryDirectory("codex-security-large-findings-");diff --git a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.tsindex 421550095..c5078ef20 100644--- a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts+++ b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { temporaryDirectory } from "./support/temporary-directories.ts";import { readJson, writeJson } from "./support/json.ts";import { gitText } from "../scripts/git.mjs";@@ -753,7 +754,7 @@ async function assertDeepScanPersistsRetryableWorkerStartupError() {assert.equal(scan.progress.status, "running");const { deepScan } = JSON.parse(execFileSync(- process.env.PYTHON?.trim() || "python3",+ fixturePython,[path.join(pluginRoot, "scripts", "workbench_db.py"),"get-deep-scan",@@ -808,7 +809,7 @@ async function assertDeepScanPersistsRetryableWorkerStartupError() {const publicationFailure ="Saved result publication failed: fixture retained result publication failure";- execFileSync(process.env.PYTHON?.trim() || "python3", [+ execFileSync(fixturePython, ["-c",`import sqlite3, syswith sqlite3.connect(sys.argv[1]) as connection:@@ -3068,7 +3069,7 @@ try {"delivered",);const rotatedFallbackClaimToken = `recovery_${randomUUID()}`;- execFileSync(process.env.PYTHON?.trim() || "python3", [+ execFileSync(fixturePython, ["-c",`import sqlite3, syswith sqlite3.connect(sys.argv[1]) as connection:diff --git a/plugins/codex-security/mcp-app/tests/test_parent_candidate_followup.ts b/plugins/codex-security/mcp-app/tests/test_parent_candidate_followup.tsindex de4fb12d8..623bf25eb 100644--- a/plugins/codex-security/mcp-app/tests/test_parent_candidate_followup.ts+++ b/plugins/codex-security/mcp-app/tests/test_parent_candidate_followup.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { execFile } from "node:child_process";import { mkdir, readFile, rm, writeFile } from "node:fs/promises";@@ -39,11 +40,9 @@ for (const newerTask of [false, true]) {};const script = path.join(pluginRoot, "scripts/workbench_db.py");const runWorkbench = async (args: string[]) => {- const { stdout } = await exec(- process.env.PYTHON || "python3",- [script, ...args],- { env: environment },- );+ const { stdout } = await exec(fixturePython, [script, ...args], {+ env: environment,+ });return JSON.parse(stdout);};const registered = await runWorkbench([@@ -124,7 +123,7 @@ for (const newerTask of [false, true]) {`import sys\nsys.path.insert(0, ${JSON.stringify(path.join(pluginRoot, "scripts"))})\nimport workbench_db, workbench_saved_results\ndef fail(*args, **kwargs):\n raise OSError("Synthetic publication interruption.")\nworkbench_saved_results._write_prepared_scan_finalization = fail\nworkbench_db.main()\n`,);const { stdout } = await exec(- process.env.PYTHON || "python3",+ fixturePython,[fault,"fail-scan",diff --git a/plugins/codex-security/mcp-app/tests/test_receipt_ownership.ts b/plugins/codex-security/mcp-app/tests/test_receipt_ownership.tsindex b32ef84f9..d1ac9767c 100644--- a/plugins/codex-security/mcp-app/tests/test_receipt_ownership.ts+++ b/plugins/codex-security/mcp-app/tests/test_receipt_ownership.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";import {@@ -126,7 +127,7 @@ function recoverCoverage() {return JSON.parse(execFileSync(- process.env.PYTHON || "python3",+ fixturePython,["-B","-c",diff --git a/plugins/codex-security/mcp-app/tests/test_threat_model_render.ts b/plugins/codex-security/mcp-app/tests/test_threat_model_render.tsindex 719dec236..48fef47d9 100644--- a/plugins/codex-security/mcp-app/tests/test_threat_model_render.ts+++ b/plugins/codex-security/mcp-app/tests/test_threat_model_render.ts@@ -1,3 +1,4 @@+import { fixturePython as python } from "./support/python.ts";import assert from "node:assert/strict";import { execFileSync } from "node:child_process";import { join } from "node:path";@@ -9,7 +10,6 @@ const pluginRoot = join(import.meta.dirname, "../..");const { renderThreatModel } = await importSource(join(pluginRoot, "mcp-app/src/threat-model-render.ts"),);-const python = process.env.PYTHON?.trim() || "python3";function pythonRender(input: Input): string {return execFileSync(python,diff --git a/plugins/codex-security/mcp-app/tests/test_workbench_process.ts b/plugins/codex-security/mcp-app/tests/test_workbench_process.tsindex 0fa009fec..0b9856cb2 100644--- a/plugins/codex-security/mcp-app/tests/test_workbench_process.ts+++ b/plugins/codex-security/mcp-app/tests/test_workbench_process.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import assert from "node:assert/strict";import { test } from "node:test";import { randomUUID } from "node:crypto";@@ -24,10 +25,14 @@ const { workbenchArgs } = await importSource();async function userSitePython(): Promise<string> {// A caller's virtualenv may intentionally disable user-site imports.- const { stdout } = await promisify(execFile)(- process.env.PYTHON?.trim() || "python3",- ["-I", "-X", "utf8", "-B", "-c", "import sys; print(sys._base_executable)"],- );+ const { stdout } = await promisify(execFile)(fixturePython, [+ "-I",+ "-X",+ "utf8",+ "-B",+ "-c",+ "import sys; print(sys._base_executable)",+ ]);return stdout.trim();}@@ -120,7 +125,7 @@ def main():"--help",];const result = await executeParser(- process.env.PYTHON?.trim() || "python3",+ fixturePython,workbenchArgs("record-deep-scan-iteration", {scanId: randomUUID(),workerId: randomUUID(),@@ -245,7 +250,7 @@ try {);for (const stdin of [true, false]) {const result = await executeWorkbench(- process.env.PYTHON?.trim() || "python3",+ fixturePython,workbenchArgs("create-workspace", {workspaceId: randomUUID(),targetPath: target,@@ -272,17 +277,17 @@ try {"raw.bin",];await executeWorkbench(- process.env.PYTHON?.trim() || "python3",+ fixturePython,["save-artifact", ...artifactArgs],binary,);- const saved = await executeWorkbench(- process.env.PYTHON?.trim() || "python3",- ["read-artifact", ...artifactArgs],- );+ const saved = await executeWorkbench(fixturePython, [+ "read-artifact",+ ...artifactArgs,+ ]);assert.deepEqual(Buffer.from(saved.content, "base64"), binary);await assert.rejects(- executeWorkbench(process.env.PYTHON?.trim() || "python3", [+ executeWorkbench(fixturePython, ["read-artifact","--artifact-root",artifactRoot,@@ -314,10 +319,11 @@ try {]),);}- const inspected = await executeWorkbench(- process.env.PYTHON?.trim() || "python3",- ["inspect-target", "--target-path", path.join(root, "target-\udcff")],- );+ const inspected = await executeWorkbench(fixturePython, [+ "inspect-target",+ "--target-path",+ path.join(root, "target-\udcff"),+ ]);assert.equal(inspected.targetPath, replacementTarget);},);@@ -338,10 +344,9 @@ await test("large saved context retains cancellation results and diagnostics", aawait writeFile(path.join(target, "example.py"), "value = 1\n");const state = path.join(root, "state");process.env.CODEX_SECURITY_STATE_DIR = state;- const python = process.env.PYTHON || "python3";const userContext = "x".repeat(1_500_000);const begun = (await executeWorkbench(- python,+ fixturePython,["begin-deep-scan","--target-path",@@ -358,7 +363,11 @@ await test("large saved context retains cancellation results and diagnostics", a)) as { deepScan: { scanId: string } };const scanId = begun.deepScan.scanId;const readScan = async () =>- (await executeWorkbench(python, ["get-scan", "--scan-id", scanId])) as {+ (await executeWorkbench(fixturePython, [+ "get-scan",+ "--scan-id",+ scanId,+ ])) as {workspace: {results: { userContext: string; progress: { status: string } };};@@ -366,7 +375,7 @@ await test("large saved context retains cancellation results and diagnostics", aconst current = await readScan();assert.equal(current.workspace.results.userContext, userContext);assert.equal(current.workspace.results.progress.status, "running");- await executeWorkbench(python, ["cancel-scan", "--scan-id", scanId]);+ await executeWorkbench(fixturePython, ["cancel-scan", "--scan-id", scanId]);assert.equal((await readScan()).workspace.results.progress.status,"canceled",diff --git a/plugins/codex-security/mcp-app/tests/test_workbench_state.ts b/plugins/codex-security/mcp-app/tests/test_workbench_state.tsindex ef700cbdc..e3c2b2730 100644--- a/plugins/codex-security/mcp-app/tests/test_workbench_state.ts+++ b/plugins/codex-security/mcp-app/tests/test_workbench_state.ts@@ -1,3 +1,4 @@+import { fixturePython } from "./support/python.ts";import { assertNoError } from "./assertions.ts";import { WORKBENCH_PYTHON } from "../src/server/workbench-process.ts";import assert from "node:assert/strict";@@ -30,8 +31,8 @@ const serverBundlePath = path.join();const script = path.join(pluginRoot, "scripts/workbench_db.py");const python = execFileSync(- process.env.PYTHON?.trim() || "python3",- ["-c", "import sys; print(sys.executable)"],+ fixturePython,+ ["-I", "-X", "utf8", "-c", "import sys; print(sys.executable)"],{ encoding: "utf8" },).trim();const codexHome = path.join(fixtureRoot, "home");