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

fix(release): sign macOS addons for packaged review items (#2331)

Michael D'Angelo61fc3a061f39
diff --git a/.github/scripts/test-macos-review-items.sh b/.github/scripts/test-macos-review-items.sh
new file mode 100755
index 000000000..ba36a50f4
--- /dev/null
+++ b/.github/scripts/test-macos-review-items.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# Exercise the npm archive under a released arm64 Node that enforces library validation.
+set -euo pipefail
+
+archive=${1:?expected a packed npm release}
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+tar -xzf "$archive" -C "$work"
+
+# Pin the host as well as the package under test. Only the Node executable is needed.
+curl --fail --location --retry 3 --output "$work/desktop.zip" \
+ https://persistent.oaistatic.com/codex-app-prod/ChatGPT-darwin-arm64-26.1029.61003.zip
+(cd "$work" && echo '43def98099e94837f07b976be98138251859ae58831d057d5483e8b20906a9a4 desktop.zip' | shasum -a 256 --check)
+unzip -p "$work/desktop.zip" 'ChatGPT.app/Contents/Resources/cua_node/bin/node' > "$work/node"
+chmod +x "$work/node"
+
+CODEX_MCP_NODE_PATH="$work/node" "$work/node" \
+ sdk/typescript/scripts/fixtures/package-review-items.mjs "$work/package"
+
+# The arm64 host exercises its own slice. Check the other shipped addon has
+# the same Developer ID signature before publishing the universal package.
+team=$(codesign -dv --verbose=4 "$work/node" 2>&1 | sed -n 's/^TeamIdentifier=//p')
+for arch in arm64 x64; do
+ codesign --verify --strict -R="anchor apple generic and certificate leaf[subject.OU] = \"$team\"" \
+ "$work/package/_bundled_plugin/mcp/native/darwin-$arch/unix.node"
+done
diff --git a/.github/workflows/native-artifacts.yml b/.github/workflows/native-artifacts.yml
index ae09d4b9b..94a90d814 100644
--- a/.github/workflows/native-artifacts.yml
+++ b/.github/workflows/native-artifacts.yml
@@ -15,6 +15,10 @@ on:
description: UTC ISO year and week selected by the source CI classifier; zero uses the current week.
type: number
default: 0
+ outputs:
+ artifact-id:
+ description: Artifact ID of the verified universal native payload.
+ value: ${{ jobs.prepare.outputs.artifact-id || jobs.bundle.outputs.artifact-id }}
workflow_dispatch:
permissions:
@@ -24,6 +28,7 @@ jobs:
prepare:
runs-on: ubuntu-24.04
outputs:
+ artifact-id: ${{ steps.upload.outputs.artifact-id }}
cache-key: ${{ steps.key.outputs.key }}
cache-hit: ${{ steps.restore.outputs.cache-hit }}
steps:
@@ -47,6 +52,7 @@ jobs:
path: native
key: ${{ steps.key.outputs.key }}
- name: Upload reused native payload for this commit
+ id: upload
if: steps.restore.outputs.cache-hit == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with: &upload-universal-native
@@ -77,6 +83,8 @@ jobs:
needs: [prepare, unix, windows, musl]
if: ${{ !cancelled() && (needs.prepare.result != 'success' || needs.prepare.outputs.cache-hit != 'true') }}
runs-on: ubuntu-24.04
+ outputs:
+ artifact-id: ${{ steps.upload.outputs.artifact-id }}
steps:
- name: Require every native build to pass
shell: bash
@@ -95,6 +103,7 @@ jobs:
merge-multiple: true
path: native
- name: Upload universal native payload
+ id: upload
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with: *upload-universal-native
- name: Save verified native payload from main
diff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.yml
index 246cc4e26..13887c2ed 100644
--- a/.github/workflows/node-release.yml
+++ b/.github/workflows/node-release.yml
@@ -17,10 +17,9 @@ jobs:
contents: read
uses: ./.github/workflows/native-artifacts.yml
- verify:
- needs: native
+ eligibility:
if: github.repository == 'openai/codex-security'
- name: verify
+ name: release tests / release eligibility
runs-on: ubuntu-latest
permissions:
contents: read
@@ -30,7 +29,6 @@ jobs:
COREPACK_NPM_REGISTRY: https://openai.firewall.socket.dev/npm/
BUN_CONFIG_REGISTRY: https://openai.firewall.socket.dev/npm/
outputs:
- artifact-id: ${{ steps.upload.outputs.artifact-id }}
mode: ${{ steps.release.outputs.mode }}
version: ${{ steps.release.outputs.version }}
@@ -41,10 +39,6 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- - &download-release-native
- name: Prepare native runtime
- uses: ./.github/actions/download-native
-
- &setup-release-firewall
name: Set up Socket Firewall
uses: SocketDev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
@@ -80,23 +74,16 @@ jobs:
printf 'PIP_INDEX_URL=%s\n' "$pypi_registry"
} >> "$GITHUB_ENV"
- - &setup-release-bun
- name: Set up Bun
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
- with:
- bun-version-file: .bun-version
- no-cache: true
-
- - &setup-release-pnpm
- name: Enable pnpm
- shell: bash
- run: corepack enable && corepack prepare "$(node -p 'require("./package.json").packageManager')" --activate
-
- name: Validate release tag
id: release
shell: bash
run: |
set -euo pipefail
+ git fetch origin main
+ if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
+ echo "npm release tags must point to a commit on main." >&2
+ exit 1
+ fi
version="$(
node sdk/typescript/scripts/release-automation.mjs release-tag \
"$GITHUB_REF_TYPE" \
@@ -104,11 +91,6 @@ jobs:
"$GITHUB_REF_NAME" \
sdk/typescript/package.json
)"
- git fetch origin main
- if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
- echo "npm release tags must point to a commit on main." >&2
- exit 1
- fi
if ! published_versions="$(
sfw npm view @openai/codex-security versions --json
)"; then
@@ -146,6 +128,175 @@ jobs:
node sdk/typescript/scripts/release-automation.mjs \
validate-release-notes "$RELEASE_VERSION" "$release_notes_file" >/dev/null
+ sign-darwin:
+ name: native / sign Darwin addons
+ needs: [eligibility, native]
+ if: needs.eligibility.outputs.mode == 'publish'
+ runs-on: ubuntu-24.04
+ environment: codesigning
+ permissions:
+ contents: read
+ id-token: write
+ outputs:
+ artifact-id: ${{ steps.upload.outputs.artifact-id }}
+ steps:
+ - &require-release-native
+ name: Require the verified native artifact ID
+ env:
+ NATIVE_ARTIFACT_ID: ${{ needs.native.outputs.artifact-id }}
+ run: test -n "$NATIVE_ARTIFACT_ID"
+ - &download-release-native
+ name: Download verified native payload
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ needs.native.outputs.artifact-id }}
+ path: plugins/codex-security/native/prebuilt
+ merge-multiple: true
+ digest-mismatch: error
+ - name: Revalidate tag before Developer ID signing
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: &revalidate-release-tag |
+ set -euo pipefail
+
+ invalid_tag() {
+ echo "Protected npm release tag must still point to the verified commit." >&2
+ exit 1
+ }
+
+ if [[ "$GITHUB_REF_TYPE" != "tag" ||
+ "$GITHUB_REF" != "refs/tags/$GITHUB_REF_NAME" ]]; then
+ invalid_tag
+ fi
+
+ if ! tag_fields="$(
+ gh api \
+ "repos/$GITHUB_REPOSITORY/git/ref/tags/$GITHUB_REF_NAME" \
+ --jq '[.object.type, .object.sha] | @tsv'
+ )"; then
+ invalid_tag
+ fi
+ IFS=$'\t' read -r tag_type tag_object <<< "$tag_fields"
+ if [[ ! "$tag_object" =~ ^[0-9a-f]{40}$ ]]; then
+ invalid_tag
+ fi
+
+ case "$tag_type" in
+ commit)
+ tag_commit="$tag_object"
+ ;;
+ tag)
+ if ! tag_commit="$(
+ gh api \
+ "repos/$GITHUB_REPOSITORY/git/tags/$tag_object" \
+ --jq 'if .object.type == "commit" then .object.sha else empty end'
+ )"; then
+ invalid_tag
+ fi
+ ;;
+ *)
+ invalid_tag
+ ;;
+ esac
+
+ if [[ ! "$tag_commit" =~ ^[0-9a-f]{40}$ ||
+ "$tag_commit" != "$GITHUB_SHA" ]]; then
+ invalid_tag
+ fi
+ echo "Protected npm release tag matches the verified commit."
+
+ - name: Set up Developer ID signing
+ id: signing-tools
+ uses: openai/codex/.github/actions/setup-akv-pkcs11-codesigning@9ff072db8ae43d413c8d205ebf22b54b83c72cef
+ with:
+ setup-mode: tools-only
+ rcodesign-blob-uri: ${{ secrets.AKV_CODESIGN_RCODESIGN_BLOB_URI }}
+ rcodesign-sha256: ${{ secrets.AKV_CODESIGN_RCODESIGN_SHA256 }}
+ akv-pkcs11-library-blob-uri: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI }}
+ akv-pkcs11-library-sha256: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_SHA256 }}
+ azure-client-id: ${{ secrets.AKV_CODESIGN_AZURE_CLIENT_ID }}
+ azure-tenant-id: ${{ secrets.AKV_CODESIGN_TENANT }}
+ azure-subscription-id: ${{ secrets.AKV_CODESIGN_SUBSCRIPTION }}
+ # Required action inputs, unused in tools-only mode.
+ key-vault-name: ""
+ key-name: ""
+ - name: Sign Darwin addons
+ shell: bash
+ env:
+ RCODESIGN: ${{ steps.signing-tools.outputs.rcodesign }}
+ PKCS11_LIBRARY: ${{ steps.signing-tools.outputs.pkcs11-library }}
+ AKV_PKCS11_BACKEND: signer-service
+ SIGNER_SERVICE_ENDPOINT: ${{ secrets.SIGNER_SERVICE_ENDPOINT }}
+ SIGNER_SERVICE_PURPOSE: ${{ secrets.SIGNER_SERVICE_PURPOSE }}
+ SIGNER_SERVICE_KEY_ID: ${{ secrets.SIGNER_SERVICE_KEY_ID }}
+ SIGNER_SERVICE_KEY_LABEL: Developer ID Application
+ SIGNER_SERVICE_CERTIFICATE_FILE: ${{ runner.temp }}/developer-id.pem
+ SIGNING_CERTIFICATE_PEM: ${{ secrets.SIGNING_CERTIFICATE_PEM }}
+ run: |
+ set -euo pipefail
+ printf '%s\n' "$SIGNING_CERTIFICATE_PEM" > "$SIGNER_SERVICE_CERTIFICATE_FILE"
+ for target in darwin-arm64 darwin-x64; do
+ mkdir -p "signed/$target"
+ cp "plugins/codex-security/native/prebuilt/$target/unix.node" "signed/$target/unix.node"
+ "$RCODESIGN" sign --config-file /dev/null --shallow --for-notarization \
+ --pkcs11-library "$PKCS11_LIBRARY" \
+ --pkcs11-certificate-file "$SIGNER_SERVICE_CERTIFICATE_FILE" \
+ --pkcs11-key-label "$SIGNER_SERVICE_KEY_LABEL" \
+ --code-signature-flags runtime --binary-identifier com.openai.codex-security.unix \
+ "signed/$target/unix.node"
+ done
+ - name: Upload signed Darwin addons
+ id: upload
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: signed-darwin-addons-${{ github.run_attempt }}
+ path: signed/
+ if-no-files-found: error
+
+ verify:
+ needs: [eligibility, native, sign-darwin]
+ if: >-
+ !cancelled() && needs.eligibility.result == 'success' && needs.native.result == 'success' &&
+ ((needs.eligibility.outputs.mode == 'publish' && needs.sign-darwin.result == 'success' &&
+ needs.sign-darwin.outputs.artifact-id != '') ||
+ (needs.eligibility.outputs.mode == 'recover' && needs.sign-darwin.result == 'skipped'))
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ env: *release-environment
+ outputs:
+ artifact-id: ${{ steps.upload.outputs.artifact-id }}
+ mode: ${{ needs.eligibility.outputs.mode }}
+ version: ${{ needs.eligibility.outputs.version }}
+ steps:
+ - *checkout-release
+ - *require-release-native
+ - *download-release-native
+
+ - name: Overlay signed Darwin addons for publication
+ if: needs.eligibility.outputs.mode == 'publish'
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ needs.sign-darwin.outputs.artifact-id }}
+ path: plugins/codex-security/native/prebuilt
+ merge-multiple: true
+ digest-mismatch: error
+ - *setup-release-firewall
+ - *setup-release-node
+ - *activate-release-firewall
+ - &setup-release-bun
+ name: Set up Bun
+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version-file: .bun-version
+ no-cache: true
+
+ - &setup-release-pnpm
+ name: Enable pnpm
+ shell: bash
+ run: corepack enable && corepack prepare "$(node -p 'require("./package.json").packageManager')" --activate
+
- &install-release-dependencies
name: Install dependencies
run: |
@@ -185,10 +336,10 @@ jobs:
run: pnpm run check:package ../../dist/*.tgz
- name: Recover the published npm release archive
- if: steps.release.outputs.mode == 'recover'
+ if: needs.eligibility.outputs.mode == 'recover'
shell: bash
env:
- RELEASE_VERSION: ${{ steps.release.outputs.version }}
+ RELEASE_VERSION: ${{ needs.eligibility.outputs.version }}
run: |
set -euo pipefail
shopt -s nullglob
@@ -268,6 +419,7 @@ jobs:
suite: [1, 2, 3, mcp]
steps:
- *checkout-release
+ - *require-release-native
- *download-release-native
- *setup-release-firewall
- *setup-release-node
@@ -303,10 +455,35 @@ jobs:
if-no-files-found: warn
retention-days: 14
+ macos-review-items:
+ name: release tests / packaged macOS review items
+ needs: verify
+ if: needs.verify.outputs.mode == 'publish' && needs.verify.outputs.artifact-id != ''
+ runs-on: macos-15
+ permissions:
+ contents: read
+ steps:
+ - *checkout-release
+ - &download-verified-package
+ name: Download verified package
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ needs.verify.outputs.artifact-id }}
+ path: dist
+ merge-multiple: true
+ digest-mismatch: error
+ - name: Exercise packaged review items on macOS arm64
+ shell: bash
+ run: .github/scripts/test-macos-review-items.sh dist/*.tgz
+
publish:
- if: github.repository == 'openai/codex-security'
+ needs: [verify, test, macos-review-items]
+ if: >-
+ !cancelled() && needs.verify.result == 'success' && needs.verify.outputs.artifact-id != '' &&
+ needs.test.result == 'success' &&
+ ((needs.verify.outputs.mode == 'publish' && needs.macos-review-items.result == 'success') ||
+ (needs.verify.outputs.mode == 'recover' && needs.macos-review-items.result == 'skipped'))
name: ${{ needs.verify.outputs.mode == 'recover' && 'Verify existing npm release' || 'Publish npm and container images' }}
- needs: [verify, test]
runs-on: ubuntu-latest
environment: npm
permissions:
@@ -323,13 +500,7 @@ jobs:
- name: Set up release npm
uses: ./.github/actions/setup-release-npm
- - name: Download verified package
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- artifact-ids: ${{ needs.verify.outputs.artifact-id }}
- path: dist
- merge-multiple: true
- digest-mismatch: error
+ - *download-verified-package
- name: Verify recovered npm release provenance
if: needs.verify.outputs.mode == 'recover'
@@ -385,61 +556,14 @@ jobs:
shell: bash
env:
GH_TOKEN: ${{ github.token }}
- run: |
- set -euo pipefail
-
- invalid_tag() {
- echo "Protected npm release tag must still point to the verified commit." >&2
- exit 1
- }
-
- if [[ "$GITHUB_REF_TYPE" != "tag" ||
- "$GITHUB_REF" != "refs/tags/$GITHUB_REF_NAME" ]]; then
- invalid_tag
- fi
-
- if ! tag_fields="$(
- gh api \
- "repos/$GITHUB_REPOSITORY/git/ref/tags/$GITHUB_REF_NAME" \
- --jq '[.object.type, .object.sha] | @tsv'
- )"; then
- invalid_tag
- fi
- IFS=$'\t' read -r tag_type tag_object <<< "$tag_fields"
- if [[ ! "$tag_object" =~ ^[0-9a-f]{40}$ ]]; then
- invalid_tag
- fi
-
- case "$tag_type" in
- commit)
- tag_commit="$tag_object"
- ;;
- tag)
- if ! tag_commit="$(
- gh api \
- "repos/$GITHUB_REPOSITORY/git/tags/$tag_object" \
- --jq 'if .object.type == "commit" then .object.sha else empty end'
- )"; then
- invalid_tag
- fi
- ;;
- *)
- invalid_tag
- ;;
- esac
-
- if [[ ! "$tag_commit" =~ ^[0-9a-f]{40}$ ||
- "$tag_commit" != "$GITHUB_SHA" ]]; then
- invalid_tag
- fi
- echo "Protected npm release tag matches the verified commit."
+ run: *revalidate-release-tag
- name: Publish to npm using trusted publishing
if: needs.verify.outputs.mode == 'publish'
run: npm publish ./dist/*.tgz --provenance --access public --tag latest
dispatch-github-release:
- if: github.repository == 'openai/codex-security'
+ if: ${{ !cancelled() && needs.publish.result == 'success' }}
name: dispatch GitHub release
needs: publish
runs-on: ubuntu-latest
diff --git a/RELEASING.md b/RELEASING.md
index fc41cb3c4..6884dcff9 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -293,9 +293,11 @@ for that exact commit:
1. `node-release-cut` verifies that the version increased, checks the reviewed
summary, and creates the exact `npm-vX.Y.Z` tag.
-2. `node-release` installs the committed dependency graph and packs the
- package. Three TypeScript test shards and the MCP tests run in parallel
- with package verification.
+2. For a new npm version, `node-release` signs the arm64 and x64 Darwin
+ addons before packing the package. An arm64 macOS runner extracts that
+ exact archive and prepares a diff inventory with a released desktop Node
+ that enforces library validation. Three TypeScript test shards and the MCP
+ tests also run before publication.
After every shard and package check passes, approve the **npm** deployment
for **Publish npm and container images**. This authorizes the npm archive
and the matching container images built from the tagged release. The job
@@ -320,6 +322,22 @@ for that exact commit:
distribution commit SHA. It is never marked Latest. A final status job
reports publication, installation smoke, Action, and container results.
+Before the first signed release, restrict the `codesigning` GitHub environment
+to `npm-v*` tags and configure its secrets for both steps:
+
+- **Download tools.** The `AKV_CODESIGN_*` inputs in `node-release.yml` select
+ a blob-reader identity and pin the downloads of `rcodesign` and a PKCS#11
+ provider that supports Signer Service. The identity needs read access to
+ those blobs only.
+- **Sign addons.** Authorize the tagged release workflow's GitHub OIDC
+ identity in Signer Service to read the public key and sign with the
+ Developer ID Application key for the desktop runtime's Apple Developer team.
+ Set `SIGNER_SERVICE_ENDPOINT`, `SIGNER_SERVICE_PURPOSE`, and
+ `SIGNER_SERVICE_KEY_ID` for that key. Set `SIGNING_CERTIFICATE_PEM` to the
+ matching public leaf certificate in PEM format.
+
+Recovery of an already published version uses the original npm archive.
+
The Action tag points to a generated distribution commit whose parent is the
CLI release commit. That additional commit contains the runnable Action bundle
and runtime lockfile. Its release manifest records both commits, both tags,
diff --git a/sdk/typescript/scripts/fixtures/package-review-items.mjs b/sdk/typescript/scripts/fixtures/package-review-items.mjs
new file mode 100644
index 000000000..cb6d8ff2f
--- /dev/null
+++ b/sdk/typescript/scripts/fixtures/package-review-items.mjs
@@ -0,0 +1,83 @@
+import assert from "node:assert/strict";
+import { execFileSync } from "node:child_process";
+import {
+ mkdir,
+ mkdtemp,
+ readFile,
+ realpath,
+ rm,
+ writeFile,
+} from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { pathToFileURL } from "node:url";
+import { startRpc } from "./package-rpc.mjs";
+
+const plugin = join(await realpath(process.argv[2]), "_bundled_plugin");
+const node = process.env.CODEX_MCP_NODE_PATH;
+assert.ok(node, "Set CODEX_MCP_NODE_PATH to the Node executable under test.");
+const root = await realpath(await mkdtemp(join(tmpdir(), "package-review-")));
+try {
+ const cwd = join(root, "repository");
+ await mkdir(cwd);
+ // Observe the actual MCP server process so a launcher fallback cannot pass.
+ const recordHost = join(root, "record-host.mjs");
+ await writeFile(
+ recordHost,
+ 'import { writeFileSync } from "node:fs";\n' +
+ 'writeFileSync(new URL("./host-path", import.meta.url), process.execPath);\n',
+ );
+ const env = {
+ PATH: process.env.PATH,
+ HOME: root,
+ CODEX_HOME: join(root, ".codex"),
+ CODEX_MCP_NODE_PATH: node,
+ NODE_OPTIONS: `--import=${pathToFileURL(recordHost).href}`,
+ CODEX_SECURITY_PLUGIN_ROOT: plugin,
+ CODEX_SECURITY_SCAN_ROOT: join(root, "scans"),
+ CODEX_SECURITY_STATE_DIR: join(root, "state"),
+ };
+ const git = (...args) =>
+ execFileSync("git", args, { cwd, env, encoding: "utf8" }).trim();
+ git("init", "-q");
+ git("config", "user.email", "[email protected]");
+ git("config", "user.name", "Fixture");
+ await writeFile(join(cwd, "unchanged.py"), "value = 1\n");
+ git("add", ".");
+ git("commit", "-qm", "base");
+ const baseRevision = git("rev-parse", "HEAD");
+ await writeFile(join(cwd, "handler.py"), "value = 2\n");
+ git("add", ".");
+ git("commit", "-qm", "head");
+ const headRevision = git("rev-parse", "HEAD");
+
+ const rpc = await startRpc(
+ join(plugin, "scripts", "launch_codex_security_mcp"),
+ ["--stdio"],
+ { cwd, env },
+ );
+ try {
+ assert.equal(
+ await realpath(await readFile(join(root, "host-path"), "utf8")),
+ await realpath(node),
+ "The packaged launcher must use the selected Node.",
+ );
+ const call = (name, args) =>
+ rpc.call(name, args, { "openai/threadId": "package-review-owner" });
+ const { scan } = await call("start_codex_security_prompt_only_scan", {
+ targetPath: cwd,
+ scope: ".",
+ mode: "diff",
+ diffTarget: { kind: "range", baseRevision, headRevision },
+ });
+ const bound = { scanId: scan.scanId };
+ const prepared = await call("prepare_codex_security_review_items", bound);
+ assert.equal(prepared.reviewItemsTotal, 1);
+ const inventory = await call("list_codex_security_review_items", bound);
+ assert.deepEqual(inventory.items, [{ path: "handler.py" }]);
+ } finally {
+ await rpc.close();
+ }
+} finally {
+ await rm(root, { recursive: true, force: true });
+}
diff --git a/sdk/typescript/scripts/smoke-package.mjs b/sdk/typescript/scripts/smoke-package.mjs
index 83859f513..4267b6d8a 100644
--- a/sdk/typescript/scripts/smoke-package.mjs
+++ b/sdk/typescript/scripts/smoke-package.mjs
@@ -883,6 +883,20 @@ try {
);
await smokeNestedDeepScanWorker(installedRoot, consumer);
+ if (process.platform === "darwin" && process.arch === "arm64") {
+ run(
+ process.execPath,
+ [
+ join(packageRoot, "scripts", "fixtures", "package-review-items.mjs"),
+ installedRoot,
+ ],
+ {
+ cwd: consumer,
+ env: { ...process.env, CODEX_MCP_NODE_PATH: process.execPath },
+ },
+ );
+ }
+
run(
process.execPath,
[
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index fafa1df95..647940891 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -14,7 +14,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
import { afterEach, describe, expect, spyOn, test } from "bun:test";
import { publishGitHubRelease } from "../scripts/publish-github-release.mjs";
import { createTemporaryDirectoriesSync } from "./support/temporary-directories.js";
-import { bashCommand, runCommand } from "./support/shell.js";
+import { bashCommand, runCommand, writeSource } from "./support/shell.js";
import {
type ReleaseMetadata,
@@ -2588,6 +2588,106 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}
},
);
+ test("binds signing and packaging to the verified native artifact and rechecks the live tag", () => {
+ const { jobs } = Bun.YAML.parse(
+ protectedReleaseWorkflow,
+ ) as WorkflowContract;
+ const check = workflowStepShell(
+ protectedReleaseWorkflow,
+ "Revalidate protected release tag",
+ );
+ for (const job of ["sign-darwin", "verify"]) {
+ const download = jobs[job]?.steps?.find(
+ (step) => step.name === "Download verified native payload",
+ );
+ expect(download?.with).toMatchObject({
+ "artifact-ids": "${{ needs.native.outputs.artifact-id }}",
+ "digest-mismatch": "error",
+ });
+ }
+ const signer = jobs["sign-darwin"]!.steps!;
+ const setup = signer.findIndex(
+ (step) => step.name === "Set up Developer ID signing",
+ );
+ expect(signer[setup]?.with?.["setup-mode"]).toBe("tools-only");
+ expect(signer[setup - 1]).toMatchObject({
+ name: "Revalidate tag before Developer ID signing",
+ run: check,
+ });
+ const publisher = jobs["publish"]!.steps!;
+ const publishIndex = publisher.findIndex(
+ (step) => step.name === "Publish to npm using trusted publishing",
+ );
+ expect(publisher[publishIndex - 1]).toMatchObject({
+ name: "Revalidate protected release tag",
+ if: "needs.verify.outputs.mode == 'publish'",
+ run: check,
+ });
+ });
+
+ test("signs both Darwin addons with the configured provider and certificate", async () => {
+ const { jobs } = Bun.YAML.parse(
+ protectedReleaseWorkflow,
+ ) as WorkflowContract;
+ const step = jobs["sign-darwin"]!.steps!.find(
+ (step) => step.name === "Sign Darwin addons",
+ )!;
+ expect(step.env).toMatchObject({
+ RCODESIGN: "${{ steps.signing-tools.outputs.rcodesign }}",
+ PKCS11_LIBRARY: "${{ steps.signing-tools.outputs.pkcs11-library }}",
+ AKV_PKCS11_BACKEND: "signer-service",
+ SIGNER_SERVICE_ENDPOINT: "${{ secrets.SIGNER_SERVICE_ENDPOINT }}",
+ SIGNER_SERVICE_PURPOSE: "${{ secrets.SIGNER_SERVICE_PURPOSE }}",
+ SIGNER_SERVICE_KEY_ID: "${{ secrets.SIGNER_SERVICE_KEY_ID }}",
+ SIGNER_SERVICE_KEY_LABEL: expect.stringMatching(/\S/),
+ SIGNING_CERTIFICATE_PEM: "${{ secrets.SIGNING_CERTIFICATE_PEM }}",
+ });
+
+ const cwd = directories.create("release signer ");
+ const targets = ["darwin-arm64", "darwin-x64"];
+ for (const target of targets) {
+ writeSource(
+ cwd,
+ `plugins/codex-security/native/prebuilt/${target}/unix.node`,
+ target,
+ );
+ }
+ const env = {
+ ...step.env,
+ RCODESIGN: "./fixture signer",
+ PKCS11_LIBRARY: "fixture provider.so",
+ SIGNER_SERVICE_CERTIFICATE_FILE: "fixture certificate.pem",
+ SIGNING_CERTIFICATE_PEM:
+ "-----BEGIN CERTIFICATE-----\nfixture\n-----END CERTIFICATE-----",
+ };
+ writeFileSync(
+ join(cwd, env.RCODESIGN),
+ '#!/usr/bin/env bash\nprintf "<%s>" "$@" >> "${!#}"\n',
+ { mode: 0o755 },
+ );
+ const result = await runShell(step.run!, env, { cwd });
+ expect(result.status).toBe(0);
+ const pem = readFileSync(
+ join(cwd, env.SIGNER_SERVICE_CERTIFICATE_FILE),
+ "utf8",
+ );
+ expect(pem.trimEnd()).toBe(env.SIGNING_CERTIFICATE_PEM);
+ for (const target of targets) {
+ const signed = readFileSync(
+ join(cwd, "signed", target, "unix.node"),
+ "utf8",
+ );
+ expect(signed).toStartWith(`${target}<sign>`);
+ expect(signed).toContain(`<--pkcs11-library><${env.PKCS11_LIBRARY}>`);
+ expect(signed).toContain(
+ `<--pkcs11-certificate-file><${env.SIGNER_SERVICE_CERTIFICATE_FILE}>`,
+ );
+ expect(signed).toContain(
+ `<--pkcs11-key-label><${step.env!["SIGNER_SERVICE_KEY_LABEL"]}>`,
+ );
+ }
+ });
+
test("rejects manually publishing a tag older than npm latest", async () => {
const script = workflowStepShell(
protectedReleaseWorkflow,
@@ -2672,7 +2772,16 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}
expect(jobs["test"]?.strategy?.["fail-fast"]).toBe(false);
expect(jobs["test"]?.permissions).toEqual({ contents: "read" });
expect(jobs["test"]?.env).toEqual(jobs["verify"]?.env);
- expect(jobs["publish"]?.needs).toEqual(["verify", "test"]);
+ expect(jobs["publish"]?.needs).toEqual([
+ "verify",
+ "test",
+ "macos-review-items",
+ ]);
+ expect(
+ jobs["macos-review-items"]?.steps?.find(
+ (step) => step.name === "Download verified package",
+ )?.with?.["artifact-ids"],
+ ).toBe("${{ needs.verify.outputs.artifact-id }}");
expect(jobs["publish"]?.name).toBe(
`\${{ needs.verify.outputs.mode == 'recover' && '${recoveryPublisher}' || '${combinedPublisher}' }}`,
);
@@ -2754,7 +2863,7 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}
expect(protectedReleaseWorkflow).toContain(
[
" dispatch-github-release:",
- " if: github.repository == 'openai/codex-security'",
+ " if: ${{ !cancelled() && needs.publish.result == 'success' }}",
" name: dispatch GitHub release",
" needs: publish",
" runs-on: ubuntu-latest",