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

test(plugin): keep executor tests portable and verify MCP versions

Alan DeLong18ba17e38e19
diff --git a/plugins/codex-security/mcp-app/tests/assertions.ts b/plugins/codex-security/mcp-app/tests/assertions.ts
index 6a027a643..d9460ea38 100644
--- a/plugins/codex-security/mcp-app/tests/assertions.ts
+++ b/plugins/codex-security/mcp-app/tests/assertions.ts
@@ -1,4 +1,5 @@
import assert from "node:assert/strict";
+import { parse as parseToml } from "smol-toml";
interface ToolResponse {
error?: { message?: string };
@@ -24,3 +25,34 @@ export function assertFlagPair(
assert.notEqual(index, -1, `missing ${flag}`);
assert.equal(args[index + 1], value);
}
+
+export function nativeConfigOverrides(args: readonly string[]) {
+ return args.flatMap((arg, index) =>
+ arg === "--config" || arg === "-c" ? [args[index + 1]] : [],
+ );
+}
+
+export function assertConfigOverrides(
+ args: readonly string[],
+ values: Record<string, string | number | boolean | undefined>,
+) {
+ const overrides = nativeConfigOverrides(args).map((value) =>
+ parseToml(value),
+ );
+ for (const [key, value] of Object.entries(values)) {
+ const supplied = overrides.map((config) =>
+ key
+ .split(".")
+ .reduce<unknown>(
+ (current, part) =>
+ (current as Record<string, unknown> | undefined)?.[part],
+ config,
+ ),
+ );
+ assert.deepEqual(
+ supplied.findLast((item) => item !== undefined),
+ value,
+ key,
+ );
+ }
+}
diff --git a/plugins/codex-security/mcp-app/tests/deep_scan_executable_alias_cases.ts b/plugins/codex-security/mcp-app/tests/deep_scan_executable_alias_cases.ts
index c15a08826..916b328bf 100644
--- a/plugins/codex-security/mcp-app/tests/deep_scan_executable_alias_cases.ts
+++ b/plugins/codex-security/mcp-app/tests/deep_scan_executable_alias_cases.ts
@@ -4,13 +4,13 @@ import path from "node:path";
import type { DeepWorkerParentSandbox } from "../src/deep-scan/parent-sandbox.js";
import type { CodexSdkWorkerExecutor as WorkerExecutor } from "../src/deep-scan/executor.js";
import { readJson } from "./support/json.ts";
+import { assertConfigOverrides } from "./assertions.ts";
export async function testConcurrentWorkerExecutableAliases({
CodexSdkWorkerExecutor,
fakeCodexFixture,
parentSandbox,
bundledCodexSdkEnvironment,
- assertConfigOverrides,
assertReadOnlyWorkerPolicy,
}: {
CodexSdkWorkerExecutor: typeof WorkerExecutor;
@@ -25,10 +25,6 @@ export async function testConcurrentWorkerExecutableAliases({
command: string,
environment: Record<string, string>,
) => Record<string, string>;
- assertConfigOverrides: (
- args: readonly string[],
- values: Record<string, string>,
- ) => void;
assertReadOnlyWorkerPolicy: (args: readonly string[]) => void;
}) {
const saved = [
diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts
index ba5a107f9..6e806112d 100644
--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts
+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts
@@ -10,7 +10,11 @@ import { readJson, writeJson } from "./support/json.ts";
import { randomUUID } from "node:crypto";
import { loadWorkbenchProcess } from "./support/workbench-process.ts";
import { finding, workerDraft } from "./scan-draft-fixture.ts";
-import { assertFlagPair } from "./assertions.ts";
+import {
+ assertConfigOverrides,
+ assertFlagPair,
+ nativeConfigOverrides,
+} from "./assertions.ts";
import { createTemporaryDirectories } from "./support/temporary-directories.ts";
import { mock } from "node:test";
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
@@ -48,16 +52,19 @@ import { workerTelemetryFixture } from "./deep_scan_worker_telemetry_fixture.ts"
import { testWorkerCyberAccessSettings } from "./deep_scan_worker_settings_cases.ts";
const executorSource = new URL("../src/deep-scan/executor.ts", import.meta.url);
-const { bundledCodexSdkEnvironment } = await importModule({
- entryPoints: [
- fileURLToPath(
- new URL(
- "../../../../sdk/typescript/src/codex-sdk-environment.ts",
- import.meta.url,
- ),
- ),
- ],
-});
+const { bundledCodexSdkEnvironment } =
+ process.platform === "win32"
+ ? {}
+ : await importModule({
+ entryPoints: [
+ fileURLToPath(
+ new URL(
+ "../../../../sdk/typescript/src/codex-sdk-environment.ts",
+ import.meta.url,
+ ),
+ ),
+ ],
+ });
const {
CodexSdkWorkerExecutor,
@@ -130,7 +137,6 @@ try {
fakeCodexFixture,
parentSandbox: trustedParentSandbox,
bundledCodexSdkEnvironment,
- assertConfigOverrides,
assertReadOnlyWorkerPolicy,
});
await testSdkInvocationAndThreadCapture();
@@ -3658,37 +3664,6 @@ function restoreEnv(name: string, value: string | undefined) {
else process.env[name] = value;
}
-function nativeConfigOverrides(args: readonly string[]) {
- return args.flatMap((arg, index) =>
- arg === "--config" || arg === "-c" ? [args[index + 1]] : [],
- );
-}
-
-function assertConfigOverrides(
- args: readonly string[],
- values: Record<string, string | number | boolean | undefined>,
-) {
- const overrides = nativeConfigOverrides(args).map((value) =>
- parseToml(value),
- );
- for (const [key, value] of Object.entries(values)) {
- const supplied = overrides.map((config) =>
- key
- .split(".")
- .reduce<unknown>(
- (current, part) =>
- (current as Record<string, unknown> | undefined)?.[part],
- config,
- ),
- );
- assert.deepEqual(
- supplied.findLast((item) => item !== undefined),
- value,
- key,
- );
- }
-}
-
async function withWorkerFixture<Result>(
action: (
fixture: Awaited<ReturnType<typeof fakeCodexFixture>>,
diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_scope.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_scope.ts
index a0d79074e..144fa66da 100644
--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_scope.ts
+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_scope.ts
@@ -141,6 +141,10 @@ for (const legacy of [false, true]) {
await server.connect(serverTransport);
await client.connect(clientTransport);
try {
+ assert.equal(
+ client.getServerVersion()?.version,
+ (await readJson(import.meta.dirname, "../package.json")).version,
+ );
const response = await client.callTool({
name: "record_codex_security_scan_draft",
arguments: {
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.ts
index 6bcb1932c..19b7be05d 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
@@ -1094,6 +1094,10 @@ try {
assertNoError(initialized);
assert.equal(initialized.result.serverInfo.name, "codex-security");
assert.equal(initialized.result.serverInfo.title, "Codex Security");
+ assert.equal(
+ initialized.result.serverInfo.version,
+ (await readJson(mcpAppRoot, "package.json")).version,
+ );
assert.equal(initialized.result.capabilities.resources, undefined);
assert.deepEqual(
initialized.result.capabilities.experimental["codex/sandbox-state-meta"],
diff --git a/plugins/codex-security/native/Cargo.toml b/plugins/codex-security/native/Cargo.toml
index aa372dbe8..d6e1aa9ed 100644
--- a/plugins/codex-security/native/Cargo.toml
+++ b/plugins/codex-security/native/Cargo.toml
@@ -10,6 +10,7 @@ publish = false
crate-type = ["cdylib"]
[dependencies]
+# Keep N-API pins in sync with the version-specific license fallbacks in notices.mts.
napi = { version = "=3.14.2", default-features = false, features = ["napi8"] }
napi-derive = "=3.6.12"
@@ -20,6 +21,7 @@ libc = "=0.2.190"
windows-sys = { version = "=0.61.2", features = ["Win32_Foundation", "Win32_Security", "Win32_Security_Authorization", "Win32_Storage_FileSystem", "Win32_System_Environment", "Win32_System_Threading", "Win32_System_JobObjects"] }
[build-dependencies]
+# Keep this pin in sync with the version-specific license fallback in notices.mts.
napi-build = "=2.6.0"
[profile.release]