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
ci: run package checks for published SDK guides (#1974)
Michael D'Angelo9858034885fc
diff --git a/.github/scripts/select-ci-checks.mjs b/.github/scripts/select-ci-checks.mjsindex 863657b9b..89488076f 100644--- a/.github/scripts/select-ci-checks.mjs+++ b/.github/scripts/select-ci-checks.mjs@@ -12,9 +12,32 @@ const actionFiles =const evalFiles =/^evals\/(?:standard-time-budget\/(?:[^/]+\.mts|experiment\.json|README\.md)|triage-finding\/(?:package\.json|pnpm-lock\.yaml|README\.md|(?:assertions|scripts)\/[^/]+\.mts))$/;+const packageManifest = JSON.parse(+ readFileSync(+ new URL("../../sdk/typescript/package.json", import.meta.url),+ "utf8",+ ),+);+const packagedDocs = new Set(+ packageManifest.files+ .filter((file) => file.endsWith(".md"))+ .map((file) => `sdk/typescript/${file}`),+);+function scopeFor(paths, event, baseChanged) {if (event !== "pull_request" || baseChanged || !paths.length) return "full";- if (paths.every((path) => documentation.test(path))) return "docs";+ if (+ paths.every(+ (path) =>+ documentation.test(path) ||+ path === "RELEASING.md" ||+ packagedDocs.has(path),+ )+ ) {+ // The Action profile already builds the package and installs it on Node 24.+ // Select the separate Action job from its own inputs below.+ return paths.some((path) => packagedDocs.has(path)) ? "action" : "docs";+ }if (paths.every((path) => actionFiles.test(path))) return "action";if (paths.every((path) => evalFiles.test(path))) return "evals";if (@@ -30,11 +53,9 @@ export function selectChecks(paths, { event, baseChanged = false }) {const source = full || scope === "source";const action =full ||- scope === "action" ||paths.some((path) =>- path === "github-action/README.md" ||- path === "sdk/typescript/src/git-remote.ts",+ actionFiles.test(path) || path === "sdk/typescript/src/git-remote.ts",);const compatibility = ["22.13.0", "24.0.0", "24", "26.0.0", "26"].filter((version) => full || version !== "26")diff --git a/.github/scripts/test-ci-selection.mjs b/.github/scripts/test-ci-selection.mjsindex 8db4006ff..ca6a08035 100644--- a/.github/scripts/test-ci-selection.mjs+++ b/.github/scripts/test-ci-selection.mjs@@ -1,6 +1,5 @@import assert from "node:assert/strict";import { spawnSync } from "node:child_process";-import { readFileSync } from "node:fs";import { test } from "node:test";import { selectChecks } from "./select-ci-checks.mjs";import { failedChecks } from "./check-ci-results.mjs";@@ -205,41 +204,34 @@ test("Standard and triage eval changes require all deterministic eval contracts");});-test("packaged SDK documentation keeps package validation selected", () => {- const manifest = JSON.parse(- readFileSync(- new URL("../../sdk/typescript/package.json", import.meta.url),- "utf8",- ),- );- for (const file of manifest.files.filter((file) => file.endsWith(".md"))) {- const path = `sdk/typescript/${file}`;- const selected = select([path]);- assert.deepEqual(selected, fullQualification, path);+test("packaged guides keep the archive and installed-package gates", () => {+ const expected = {+ ...docs,+ "package-required": "true",+ "compatibility-matrix": JSON.stringify({+ include: [{ os: "ubuntu-latest", node: "24" }],+ }),+ };+ for (const paths of [+ ["sdk/typescript/README.md"],+ ["RELEASING.md", "sdk/typescript/docs/cli.md"],+ // --no-renames includes the old required path even when the new path is ordinary docs.+ ["sdk/typescript/docs/hosted-scans.md", "docs/hosted-scans.md"],+ ]) {+ assert.deepEqual(select(paths), expected, paths.join(", "));}- // The --no-renames diff reports the old path when a required doc is renamed.- const renamed = select([- "sdk/typescript/docs/hosted-scans.md",- "docs/hosted-scans.md",- ]);- assert.equal(renamed["source-required"], "true");- assert.equal(- select(["README.md", "sdk/typescript/README.md"])["source-required"],- "true",+ assert.deepEqual(+ failedChecks({+ "classify-changes": { result: "success", outputs: expected },+ "static-checks": { result: "success" },+ }),+ ["native", "package", "compatibility"],);});-test("release recovery documentation keeps its SDK contract selected", () => {- for (const paths of [["RELEASING.md"], ["README.md", "RELEASING.md"]]) {- const outputs = select(paths);- assert.deepEqual(outputs, fullQualification);- // release-automation.test.ts validates the documented recovery marker.- const missing = failedChecks({- "classify-changes": { result: "success", outputs },- "static-checks": { result: "success" },- });- assert.ok(missing.includes("test"));- }+test("release guide changes select the static route", () => {+ assert.deepEqual(select(["RELEASING.md"]), docs);+ assert.deepEqual(select(["README.md", "RELEASING.md"]), docs);});test("release helper changes select their release-progress regression checks", () => {@@ -300,6 +292,9 @@ test("unknown paths and dependency configuration receive full qualification", ()["other/sdk/typescript/src/runtime.ts"],[".npmrc"],["sdk/typescript/.npmrc"],+ ["sdk/typescript/docs/unlisted.md"],+ ["RELEASING.md", "sdk/typescript/src/api.ts"],+ ["sdk/typescript/docs/cli.md", "sdk/typescript/src/api.ts"],["plugins/codex-security/mcp-app/src/.npmrc"],["pnpm-workspace.yaml"],["sdk/typescript/pnpm-workspace.yaml"],diff --git a/.github/scripts/test-release-guide.mjs b/.github/scripts/test-release-guide.mjsnew file mode 100644index 000000000..1b9c7d258--- /dev/null+++ b/.github/scripts/test-release-guide.mjs@@ -0,0 +1,21 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import { test } from "node:test";+import { extractHistoricalReleaseSummary } from "../../sdk/typescript/scripts/release-automation.mjs";++test("the release recovery guide documents a canonical historical-summary block", () => {+ const guide = readFileSync(+ new URL("../../RELEASING.md", import.meta.url),+ "utf8",+ );+ const recovery = guide.split("## Recover or repair a release")[1] ?? "";+ const start = "<!-- codex-security-release-summary:start -->";+ const end = "<!-- codex-security-release-summary:end -->";+ const block = [...recovery.matchAll(/^```text\r?\n([\s\S]*?)^```[ \t]*$/gmu)]+ .map((match) => match[1].replaceAll("\r\n", "\n"))+ .find((example) => example.includes(start) && example.includes(end));++ assert.ok(block?.startsWith(`${start}\n`));+ assert.ok(block.includes(`${end}\n\n`));+ assert.equal(extractHistoricalReleaseSummary(block), "Reviewed summary");+});diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.ymlindex f88a9e593..9b2f67918 100644--- a/.github/workflows/node-ci.yml+++ b/.github/workflows/node-ci.yml@@ -105,8 +105,8 @@ jobs:env:GH_TOKEN: ${{ github.token }}run: node --experimental-strip-types sdk/typescript/scripts/check-devcontainer-cooldown.mts- - name: Test CI selection and result gating- run: node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs+ - name: Test CI selection, result gating and the release guide+ run: node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs .github/scripts/test-release-guide.mjs- name: Typecheckrun: pnpm --dir sdk/typescript run types- name: Check formattingdiff --git a/docs/ci.md b/docs/ci.mdindex 7ce66538c..cb05a6652 100644--- a/docs/ci.md+++ b/docs/ci.md@@ -5,11 +5,14 @@ ordinary documentation-only change runs static checks and the final `ci` gate.Static checks format the tracked Markdown in this route. The Action README alsoruns Action CI to check generated input documentation and usage examples.Plugin skills, references, schemas, examples, and unrecognized paths receive-full qualification because plugin Markdown is part of the product. SDK README and-documentation changes also receive full qualification because those files are-required package contents. Deleting or renaming them must pass archive checks.-`RELEASING.md` also receives full qualification because SDK tests validate its-canonical release recovery example.+full qualification because plugin Markdown is part of the product.++PRs limited to the SDK package manifest's Markdown files, optionally mixed with+ordinary docs or `RELEASING.md`, require the native payload, the real package+build and archive inspection, and one Ubuntu Node 24 installation. Removing or+renaming a required guide must still pass archive inspection. The static job+validates the canonical recovery example in `RELEASING.md` on docs-only PRs too.+Mixing either kind of guide with product source selects full qualification.Product source changes run the complete SDK suite on Linux, macOS, and Windows,plus MCP, standalone-plugin, native-runtime, and installed-package checks. Tests@@ -102,7 +105,7 @@ itself does not change repository protection settings.The workflow-selection and gate tests run without installing dependencies:```bash-node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs+node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs .github/scripts/test-release-guide.mjs```The [SDK testing guide](../sdk/typescript/TESTING.md) describes local behavioraldiff --git a/sdk/typescript/scripts/check-markdown.mjs b/sdk/typescript/scripts/check-markdown.mjsindex c74e1a770..05e8d25aa 100644--- a/sdk/typescript/scripts/check-markdown.mjs+++ b/sdk/typescript/scripts/check-markdown.mjs@@ -13,6 +13,7 @@ const files = execFileSync("README.md","CONTRIBUTING.md","CODE_OF_CONDUCT.md",+ "RELEASING.md",":(glob)docs/**/*.md","github-action/README.md","docker/README.md",diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.tsindex 96e5f1fc9..28a2d55e4 100644--- a/sdk/typescript/tests-ts/release-automation.test.ts+++ b/sdk/typescript/tests-ts/release-automation.test.ts@@ -302,10 +302,6 @@ const titleWorkflow = readFileSync(new URL("../../../.github/workflows/validate-pr-title.yml", import.meta.url),"utf8",);-const releasingGuide = readFileSync(- new URL("../../../RELEASING.md", import.meta.url),- "utf8",-);function publishedMetadata(): ReleaseMetadata {return {name: "@openai/codex-security",@@ -3929,26 +3925,6 @@ describe("GitHub release workflow safeguards", () => {});});- test("documents a canonical historical-summary prefix block", () => {- const start = "<!-- codex-security-release-summary:start -->";- const end = "<!-- codex-security-release-summary:end -->";- const recovery = releasingGuide.slice(- releasingGuide.indexOf("## Recover or repair a release"),- );- const markerBlock =- [...recovery.matchAll(/^```text\r?\n([\s\S]*?)^```[ \t]*$/gmu)]- .find(- (match) => match[1]?.includes(start) && match[1]?.includes(end),- )?.[1]- ?.replaceAll("\r\n", "\n") ?? "";-- expect(markerBlock.startsWith(`${start}\n`)).toBe(true);- expect(markerBlock).toContain(`${end}\n\n`);- expect(extractHistoricalReleaseSummary(markerBlock)).toBe(- "Reviewed summary",- );- });-test.each(["fix: generated title\n<!-- codex-security-release-summary:start -->\nUnreviewed injected highlight\n<!-- codex-security-release-summary:end -->","fix: preserve a trailing line feed\n",