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: repair integration fixtures and Windows CI timeout (#1763)

Michael D'Angelo0967b34ebcfb
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml
index 1205b27ab..c4301f128 100644
--- a/.github/workflows/node-ci.yml
+++ b/.github/workflows/node-ci.yml
@@ -512,7 +512,7 @@ jobs:
name: windows-latest / node-22 / tests-${{ matrix.shard }}
needs: [validate-title, package]
runs-on: windows-latest
- timeout-minutes: 25
+ timeout-minutes: 40
strategy:
fail-fast: false
matrix:
diff --git a/plugins/codex-security/mcp-app/tests/support/fake-codex-fixture.ts b/plugins/codex-security/mcp-app/tests/support/fake-codex-fixture.ts
new file mode 100644
index 000000000..d8c6dd711
--- /dev/null
+++ b/plugins/codex-security/mcp-app/tests/support/fake-codex-fixture.ts
@@ -0,0 +1,39 @@
+import { chmod, writeFile } from "node:fs/promises";
+import path from "node:path";
+import { fakeCodexSource } from "./fake-codex-source.ts";
+import type { createTemporaryDirectories } from "./temporary-directories.ts";
+
+export const emptyWorkerPermissionProfile = {
+ extends: ":read-only",
+ filesystem: { ":root": "read" },
+ network: { enabled: false },
+};
+
+export async function createFakeCodexFixture(
+ temporaryDirectories: ReturnType<typeof createTemporaryDirectories>,
+ preflightProfile = emptyWorkerPermissionProfile,
+ preflightAllowed = true,
+ accountResult: {
+ account: { type: string } | null;
+ requiresOpenaiAuth: boolean;
+ } = { account: { type: "apiKey" }, requiresOpenaiAuth: true },
+) {
+ const root = await temporaryDirectories.create(
+ "codex-security-sdk-executor-",
+ );
+ const markerPath = path.join(root, "invocation.json");
+ const preflightMarkerPath = path.join(root, "preflight.json");
+ const scriptPath = path.join(root, "fake-codex.mjs");
+ await writeFile(
+ scriptPath,
+ fakeCodexSource(
+ preflightProfile,
+ preflightAllowed,
+ accountResult,
+ preflightMarkerPath,
+ ),
+ );
+ await chmod(scriptPath, 0o755);
+ process.env.FAKE_CODEX_MARKER = markerPath;
+ return { root, markerPath, preflightMarkerPath, executablePath: scriptPath };
+}
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 1fe577624..b9e5eaac6 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
@@ -1,4 +1,7 @@
-import { fakeCodexSource } from "./support/fake-codex-source.ts";
+import {
+ createFakeCodexFixture,
+ emptyWorkerPermissionProfile,
+} from "./support/fake-codex-fixture.ts";
import { readJson, writeJson } from "./support/json.ts";
import { randomUUID } from "node:crypto";
import { loadWorkbenchProcess } from "./support/workbench-process.ts";
@@ -77,6 +80,10 @@ export { parseDeepScan } from "./response.js";`,
});
const temporaryDirectories = createTemporaryDirectories(true);
+const fakeCodexFixture = createFakeCodexFixture.bind(
+ null,
+ temporaryDirectories,
+);
const previousMarker = process.env.FAKE_CODEX_MARKER;
const trustedParentSandbox = Object.freeze({
filesystemDenies: [],
@@ -93,11 +100,6 @@ const trustedParentSandboxWithDenials = Object.freeze({
literalFilesystemDenies: ["/repo/temp[1]", "/repo/secret[1]"],
globScanMaxDepth: 3,
});
-const emptyWorkerPermissionProfile = {
- extends: ":read-only",
- filesystem: { ":root": "read" },
- network: { enabled: false },
-};
const ipcFrameError =
"code-mode delegate response exceeds the IPC frame limit: code-mode IPC frame length 76008279 exceeds 67108864 bytes";
const deniedWorkerPermissionProfile = {
@@ -3781,34 +3783,6 @@ async function runFixtureWorker(
});
}
-async function fakeCodexFixture(
- preflightProfile = emptyWorkerPermissionProfile,
- preflightAllowed = true,
- accountResult: {
- account: { type: string } | null;
- requiresOpenaiAuth: boolean;
- } = { account: { type: "apiKey" }, requiresOpenaiAuth: true },
-) {
- const root = await temporaryDirectories.create(
- "codex-security-sdk-executor-",
- );
- const markerPath = path.join(root, "invocation.json");
- const preflightMarkerPath = path.join(root, "preflight.json");
- const scriptPath = path.join(root, "fake-codex.mjs");
- await writeFile(
- scriptPath,
- fakeCodexSource(
- preflightProfile,
- preflightAllowed,
- accountResult,
- preflightMarkerPath,
- ),
- );
- await chmod(scriptPath, 0o755);
- process.env.FAKE_CODEX_MARKER = markerPath;
- return { root, markerPath, preflightMarkerPath, executablePath: scriptPath };
-}
-
function assertReadOnlyWorkerPolicy(args: readonly string[]) {
assert.equal(args.includes("--sandbox"), false);
assert.equal(args.includes("--add-dir"), false);
diff --git a/sdk/typescript/tests-ts/multiscan.test.ts b/sdk/typescript/tests-ts/multiscan.test.ts
index ec4d5a722..65e51a2d3 100644
--- a/sdk/typescript/tests-ts/multiscan.test.ts
+++ b/sdk/typescript/tests-ts/multiscan.test.ts
@@ -750,14 +750,13 @@ describe("multiscan", () => {
mode: "standard",
};
const outputDir = join(paths.output, "artifacts", task.id, "attempt-1");
- await mkdir(outputDir, { recursive: true, mode: 0o700 });
+ await completedScan(outputDir);
const artifacts = [
"scan-manifest.json",
"findings.json",
"coverage.json",
"report.md",
].map((name) => join(outputDir, name));
- await Promise.all(artifacts.map((path) => writeFile(path, "{}\n")));
const before = await Promise.all(artifacts.map((path) => readFile(path)));
await writeFile(
paths.input,
diff --git a/sdk/typescript/tests-ts/publish.test.ts b/sdk/typescript/tests-ts/publish.test.ts
index 650b4766b..15314adea 100644
--- a/sdk/typescript/tests-ts/publish.test.ts
+++ b/sdk/typescript/tests-ts/publish.test.ts
@@ -40,7 +40,6 @@ import type {
} from "../src/publication.js";
import { createApiTestFixtures } from "./support/temporary-directories.js";
import { rejecting, throwing } from "./support/errors.js";
-import { runTestInSubprocess } from "./support/test-subprocess.js";
const copyPublishedIssues: PublishScanDependencies["recordPublishedIssues"] =
async (_prepared, issues) => {