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
fix: harden Node CI and Windows package smoke (#84)
mldangelo-oai4357b1edd7b0
diff --git a/.github/workflows/container-ci.yml b/.github/workflows/container-ci.ymlindex ccf8bf1a6..8d4dc10f3 100644--- a/.github/workflows/container-ci.yml+++ b/.github/workflows/container-ci.yml@@ -25,6 +25,10 @@ on:permissions:contents: read+concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+jobs:container:name: linux-amd64@@ -96,7 +100,8 @@ jobs:mkdir -p results statechmod 700 results stateprintf 'id,repository,revision\n' > repositories.csv- export CODEX_SECURITY_USER="$(id -u):$(id -g)"+ CODEX_SECURITY_USER="$(id -u):$(id -g)"+ export CODEX_SECURITY_USERdocker compose config --quietdocker compose run --rm codex-security --versiondiff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.ymlindex fb5273406..091389d8d 100644--- a/.github/workflows/node-ci.yml+++ b/.github/workflows/node-ci.yml@@ -8,14 +8,25 @@ on:permissions:contents: read+concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}+jobs:test:- name: ${{ matrix.os }} / node-22+ name: ${{ matrix.os }} / node-${{ matrix.node }}runs-on: ${{ matrix.os }}+ timeout-minutes: 20strategy:fail-fast: falsematrix:os: [ubuntu-latest, macos-latest, windows-latest]+ node: ["22"]+ include:+ - os: ubuntu-latest+ node: "24"+ - os: ubuntu-latest+ node: "26"steps:- name: Checkout repository@@ -23,20 +34,25 @@ jobs:with:persist-credentials: false+ - name: Set up pnpm+ uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9+ with:+ package_json_file: sdk/typescript/package.json+ cache: true+ cache_dependency_path: sdk/typescript/pnpm-lock.yaml+- name: Set up Node.jsuses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6with:- node-version: "22"+ node-version: ${{ matrix.node }}+ cache: npm+ cache-dependency-path: sdk/typescript/pnpm-lock.yaml- name: Set up Bunuses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2with:bun-version: "1.3.14"- - name: Enable pnpm- shell: bash- run: corepack enable && corepack prepare "$(node -p 'require("./sdk/typescript/package.json").packageManager')" --activate-- name: Install dependenciesrun: pnpm --dir sdk/typescript install --frozen-lockfile@@ -65,3 +81,18 @@ jobs:working-directory: sdk/typescriptshell: bashrun: pnpm run check:package ../../dist/*.tgz++ - name: Smoke-test Node.js runtime+ working-directory: sdk/typescript+ shell: bash+ run: |+ set -euo pipefail+ node --input-type=module --eval '+ import { CodexSecurity } from "@openai/codex-security";++ if (typeof CodexSecurity !== "function") {+ throw new Error("The SDK does not export CodexSecurity.");+ }+ '+ node bin/codex-security.mjs --version+ node bin/codex-security.mjs --helpdiff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.ymlindex 828b19941..4aef8108c 100644--- a/.github/workflows/node-release.yml+++ b/.github/workflows/node-release.yml@@ -67,6 +67,7 @@ jobs:uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2with:bun-version: "1.3.14"+ no-cache: true- name: Enable pnpmshell: bashdiff --git a/sdk/typescript/scripts/check-package.mjs b/sdk/typescript/scripts/check-package.mjsindex 28f4a2b5b..430da8050 100644--- a/sdk/typescript/scripts/check-package.mjs+++ b/sdk/typescript/scripts/check-package.mjs@@ -4,6 +4,10 @@ import { readFileSync } from "node:fs";import { fileURLToPath } from "node:url";import { brotliDecompressSync, gunzipSync } from "node:zlib";import { assertExpectedGitHead } from "./package-provenance.mjs";+import { packageSmokeTimeouts } from "./package-smoke-timeouts.mjs";++const PACKAGE_SMOKE_PROCESS_TIMEOUT_MS =+ packageSmokeTimeouts().processTimeoutMs;const args = process.argv.slice(2);if (args[0] === "--") args.shift();@@ -279,15 +283,16 @@ if (args.length === 1) {[fileURLToPath(new URL("./smoke-package.mjs", import.meta.url)), archive],{stdio: "inherit",- timeout: 150_000,+ timeout: PACKAGE_SMOKE_PROCESS_TIMEOUT_MS,killSignal: "SIGKILL",windowsHide: true,},);if (smoke.error?.code === "ETIMEDOUT") {- throw new Error("Installed npm package smoke timed out after 150000 ms.", {- cause: smoke.error,- });+ throw new Error(+ `Installed npm package smoke timed out after ${PACKAGE_SMOKE_PROCESS_TIMEOUT_MS} ms.`,+ { cause: smoke.error },+ );}if (smoke.error !== undefined) throw smoke.error;if (smoke.status !== 0) {diff --git a/sdk/typescript/scripts/package-smoke-timeouts.mjs b/sdk/typescript/scripts/package-smoke-timeouts.mjsnew file mode 100644index 000000000..148d38a46--- /dev/null+++ b/sdk/typescript/scripts/package-smoke-timeouts.mjs@@ -0,0 +1,8 @@+export function packageSmokeTimeouts(platform = process.platform) {+ const commandTimeoutMs = platform === "win32" ? 180_000 : 120_000;++ return {+ commandTimeoutMs,+ processTimeoutMs: commandTimeoutMs + 30_000,+ };+}diff --git a/sdk/typescript/scripts/smoke-package.mjs b/sdk/typescript/scripts/smoke-package.mjsindex dc6d9cc6b..3e0d3702b 100644--- a/sdk/typescript/scripts/smoke-package.mjs+++ b/sdk/typescript/scripts/smoke-package.mjs@@ -11,8 +11,9 @@ import {import { tmpdir } from "node:os";import { basename, dirname, join, relative, resolve, sep } from "node:path";import { fileURLToPath } from "node:url";+import { packageSmokeTimeouts } from "./package-smoke-timeouts.mjs";-const PACKAGE_SMOKE_TIMEOUT_MS = 120_000;+const PACKAGE_SMOKE_TIMEOUT_MS = packageSmokeTimeouts().commandTimeoutMs;const packageRoot = fileURLToPath(new URL("../", import.meta.url));const packageManifest = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"),@@ -191,12 +192,11 @@ try {[...npm.args,"install",+ "--prefer-offline","--include=optional","--ignore-scripts","--no-audit","--no-fund",- "--cache",- join(consumer, ".npm-cache"),archive,],{ cwd: consumer },diff --git a/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts b/sdk/typescript/tests-ts/package-smoke-timeouts.test.tsnew file mode 100644index 000000000..631b77735--- /dev/null+++ b/sdk/typescript/tests-ts/package-smoke-timeouts.test.ts@@ -0,0 +1,45 @@+import { describe, expect, test } from "bun:test";++type PackageSmokeTimeouts = {+ packageSmokeTimeouts: (platform?: NodeJS.Platform) => {+ commandTimeoutMs: number;+ processTimeoutMs: number;+ };+};++const { packageSmokeTimeouts } = (await import(+ new URL("../scripts/package-smoke-timeouts.mjs", import.meta.url).href+)) as PackageSmokeTimeouts;++describe("npm package smoke timeouts", () => {+ test("preserves the existing timeout on Linux and macOS", () => {+ for (const platform of ["linux", "darwin"] as const) {+ expect(packageSmokeTimeouts(platform)).toEqual({+ commandTimeoutMs: 120_000,+ processTimeoutMs: 150_000,+ });+ }+ });++ test("allows the Windows npm install to complete", () => {+ expect(packageSmokeTimeouts("win32")).toEqual({+ commandTimeoutMs: 180_000,+ processTimeoutMs: 210_000,+ });+ });++ test("keeps the parent smoke timeout above the command timeout", () => {+ for (const platform of ["linux", "darwin", "win32"] as const) {+ const { commandTimeoutMs, processTimeoutMs } =+ packageSmokeTimeouts(platform);++ expect(processTimeoutMs).toBe(commandTimeoutMs + 30_000);+ }+ });++ test("uses the active runtime platform by default", () => {+ expect(packageSmokeTimeouts()).toEqual(+ packageSmokeTimeouts(process.platform),+ );+ });+});