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(release): bind Darwin signing to builds from protected main (#2495)
Michael D'Angeloc40e2cba18a9
diff --git a/.github/actionlint.yaml b/.github/actionlint.yamlindex 28c41f0c5..33b852b8b 100644--- a/.github/actionlint.yaml+++ b/.github/actionlint.yaml@@ -9,7 +9,12 @@ paths:# actionlint 1.7.12 predates GitHub’s reference to the defining workflow's commit.# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsuses- '^specifying action "\$/\.github/actions/native-cache-key" in invalid format because ref is missing\.'- .github/workflows/invoice-desk-scan.yml:+ .github/workflows/{node-release,sign-darwin-release}.yml:+ ignore:+ # actionlint 1.7.12 predates GitHub’s reference to the defining workflow's commit.+ # https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsuses+ - '^specifying action "\$/\.github/actions/revalidate-release-tag" in invalid format because ref is missing\.'+ .github/workflows/{invoice-desk-scan,sign-darwin-release}.yml:ignore:# actionlint 1.7.12 predates GitHub's job-level cache permissions.# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcache-modediff --git a/.github/actions/revalidate-release-tag/action.yml b/.github/actions/revalidate-release-tag/action.ymlnew file mode 100644index 000000000..4466777bc--- /dev/null+++ b/.github/actions/revalidate-release-tag/action.yml@@ -0,0 +1,56 @@+name: Revalidate release tag+description: Check that the live npm release tag still points to the triggering commit.+runs:+ using: composite+ steps:+ - 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."diff --git a/.github/workflows/native-artifacts.yml b/.github/workflows/native-artifacts.ymlindex 94a90d814..d6a061bc9 100644--- a/.github/workflows/native-artifacts.yml+++ b/.github/workflows/native-artifacts.yml@@ -19,6 +19,18 @@ on:artifact-id:description: Artifact ID of the verified universal native payload.value: ${{ jobs.prepare.outputs.artifact-id || jobs.bundle.outputs.artifact-id }}+ darwin-arm64-artifact-id:+ description: Artifact ID of the verified macOS arm64 build.+ value: ${{ jobs.unix.outputs.darwin-arm64-artifact-id }}+ darwin-arm64-sha256:+ description: SHA-256 of the addon of the verified macOS arm64 build.+ value: ${{ jobs.unix.outputs.darwin-arm64-sha256 }}+ darwin-x64-artifact-id:+ description: Artifact ID of the verified macOS x64 build.+ value: ${{ jobs.unix.outputs.darwin-x64-artifact-id }}+ darwin-x64-sha256:+ description: SHA-256 of the addon of the verified macOS x64 build.+ value: ${{ jobs.unix.outputs.darwin-x64-sha256 }}workflow_dispatch:permissions:diff --git a/.github/workflows/native-unix.yml b/.github/workflows/native-unix.ymlindex 50a79e4e8..c247089a2 100644--- a/.github/workflows/native-unix.yml+++ b/.github/workflows/native-unix.yml@@ -7,6 +7,19 @@ on:description: Source commit to build; defaults to the calling workflow commit.type: stringdefault: ""+ outputs:+ darwin-arm64-artifact-id:+ description: Artifact ID of the verified macOS arm64 build.+ value: ${{ jobs.primitives.outputs.darwin-arm64-artifact-id }}+ darwin-arm64-sha256:+ description: SHA-256 of the addon of the verified macOS arm64 build.+ value: ${{ jobs.primitives.outputs.darwin-arm64-sha256 }}+ darwin-x64-artifact-id:+ description: Artifact ID of the verified macOS x64 build.+ value: ${{ jobs.primitives.outputs.darwin-x64-artifact-id }}+ darwin-x64-sha256:+ description: SHA-256 of the addon of the verified macOS x64 build.+ value: ${{ jobs.primitives.outputs.darwin-x64-sha256 }}permissions:contents: read@@ -16,6 +29,11 @@ jobs:name: primitives / ${{ matrix.artifact }}runs-on: ${{ matrix.runner }}timeout-minutes: 30+ outputs:+ darwin-arm64-artifact-id: ${{ steps.darwin.outputs.darwin-arm64-artifact-id }}+ darwin-arm64-sha256: ${{ steps.darwin.outputs.darwin-arm64-sha256 }}+ darwin-x64-artifact-id: ${{ steps.darwin.outputs.darwin-x64-artifact-id }}+ darwin-x64-sha256: ${{ steps.darwin.outputs.darwin-x64-sha256 }}strategy:fail-fast: falsematrix:@@ -133,6 +151,7 @@ jobs:native_node="$(command -v node)"PATH='' "$native_node" proof.mjs- name: Upload verified native artifact+ id: uploaduses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:name: native-platform-${{ matrix.artifact }}-${{ inputs.ref || github.sha }}@@ -144,3 +163,15 @@ jobs:if-no-files-found: erroroverwrite: trueretention-days: 7+ - name: Record Darwin build outputs+ if: matrix.platform == 'darwin'+ id: darwin+ env:+ DARWIN_TARGET: ${{ matrix.artifact }}+ ARTIFACT_ID: ${{ steps.upload.outputs.artifact-id }}+ run: |+ digest="$(shasum -a 256 "dist/$DARWIN_TARGET/unix.node")"+ {+ echo "$DARWIN_TARGET-artifact-id=$ARTIFACT_ID"+ echo "$DARWIN_TARGET-sha256=${digest%% *}"+ } >> "$GITHUB_OUTPUT"diff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.ymlindex 13887c2ed..f06ba3211 100644--- a/.github/workflows/node-release.yml+++ b/.github/workflows/node-release.yml@@ -11,8 +11,10 @@ concurrency:queue: maxjobs:- native:- if: github.repository == 'openai/codex-security'+ recover-native:+ name: native / recover verified artifacts+ needs: eligibility+ if: needs.eligibility.outputs.mode == 'recover'permissions:contents: readuses: ./.github/workflows/native-artifacts.yml@@ -22,6 +24,7 @@ jobs:name: release tests / release eligibilityruns-on: ubuntu-latestpermissions:+ actions: readcontents: readenv: &release-environmentNPM_CONFIG_REGISTRY: https://openai.firewall.socket.dev/npm/@@ -110,6 +113,23 @@ jobs:printf 'mode=%s\n' "$mode"} >> "$GITHUB_OUTPUT"+ - name: Verify reusable signing workflow ref before signing+ if: steps.release.outputs.mode == 'publish'+ shell: bash+ env:+ GH_TOKEN: ${{ github.token }}+ run: &verify-signing-workflow-ref |+ set -euo pipefail+ # A tag named main takes precedence over the branch in a workflow call.+ if ! gh api "repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT" |+ jq -e --arg workflow "$GITHUB_REPOSITORY/.github/workflows/sign-darwin-release.yml@" '+ [.referenced_workflows[] | select(.path | startswith($workflow)) | .ref]+ == ["refs/heads/main"]+ ' >/dev/null; then+ echo "The signed addons must come from the signing workflow on protected main." >&2+ exit 1+ fi+- name: Validate reviewed release notesif: steps.release.outputs.mode == 'publish'shell: bash@@ -130,137 +150,72 @@ jobs:sign-darwin:name: native / sign Darwin addons- needs: [eligibility, native]+ needs: eligibilityif: needs.eligibility.outputs.mode == 'publish'- runs-on: ubuntu-24.04- environment: codesigningpermissions:contents: readid-token: write+ uses: openai/codex-security/.github/workflows/sign-darwin-release.yml@main # zizmor: ignore[unpinned-uses] -- The signing policy requires this protected branch in job_workflow_ref.+ secrets:+ AKV_CODESIGN_RCODESIGN_BLOB_URI: ${{ secrets.AKV_CODESIGN_RCODESIGN_BLOB_URI }}+ AKV_CODESIGN_RCODESIGN_SHA256: ${{ secrets.AKV_CODESIGN_RCODESIGN_SHA256 }}+ AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI }}+ AKV_CODESIGN_PKCS11_LIBRARY_SHA256: ${{ secrets.AKV_CODESIGN_PKCS11_LIBRARY_SHA256 }}+ AKV_CODESIGN_AZURE_CLIENT_ID: ${{ secrets.AKV_CODESIGN_AZURE_CLIENT_ID }}+ AKV_CODESIGN_TENANT: ${{ secrets.AKV_CODESIGN_TENANT }}+ AKV_CODESIGN_SUBSCRIPTION: ${{ secrets.AKV_CODESIGN_SUBSCRIPTION }}+ SIGNER_SERVICE_ENDPOINT: ${{ secrets.SIGNER_SERVICE_ENDPOINT }}+ SIGNER_SERVICE_PURPOSE: ${{ secrets.SIGNER_SERVICE_PURPOSE }}+ SIGNER_SERVICE_KEY_ID: ${{ secrets.SIGNER_SERVICE_KEY_ID }}+ SIGNING_CERTIFICATE_PEM: ${{ secrets.SIGNING_CERTIFICATE_PEM }}++ native:+ name: native / select verified artifacts+ needs: [eligibility, recover-native, sign-darwin]+ if: >-+ !cancelled() && needs.eligibility.result == 'success' &&+ ((needs.eligibility.outputs.mode == 'publish' && needs.sign-darwin.result == 'success' &&+ needs.recover-native.result == 'skipped') ||+ (needs.eligibility.outputs.mode == 'recover' && needs.recover-native.result == 'success' &&+ needs.sign-darwin.result == 'skipped'))+ runs-on: ubuntu-latest+ permissions:+ actions: readoutputs:- artifact-id: ${{ steps.upload.outputs.artifact-id }}+ artifact-id: ${{ steps.select.outputs.native-id }}+ signed-darwin-id: ${{ steps.select.outputs.signed-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+ - name: Verify reusable signing workflow ref+ if: needs.eligibility.outputs.mode == 'publish'shell: bashenv: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+ run: *verify-signing-workflow-ref- 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+ - name: Select the native artifact IDs for this release mode+ id: selectenv:- 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 }}+ RELEASE_MODE: ${{ needs.eligibility.outputs.mode }}+ PUBLISH_NATIVE_ID: ${{ needs.sign-darwin.outputs.native-artifact-id }}+ SIGNED_ID: ${{ needs.sign-darwin.outputs.artifact-id }}+ RECOVER_NATIVE_ID: ${{ needs.recover-native.outputs.artifact-id }}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+ if [[ "$RELEASE_MODE" == publish ]]; then+ test -n "$PUBLISH_NATIVE_ID"+ test -n "$SIGNED_ID"+ echo "native-id=$PUBLISH_NATIVE_ID" >> "$GITHUB_OUTPUT"+ echo "signed-id=$SIGNED_ID" >> "$GITHUB_OUTPUT"+ else+ test -n "$RECOVER_NATIVE_ID"+ echo "native-id=$RECOVER_NATIVE_ID" >> "$GITHUB_OUTPUT"+ fiverify:- needs: [eligibility, native, sign-darwin]+ needs: [eligibility, native]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'))+ (needs.eligibility.outputs.mode == 'recover' || needs.native.outputs.signed-darwin-id != '')runs-on: ubuntu-latestpermissions:contents: read@@ -271,14 +226,25 @@ jobs:version: ${{ needs.eligibility.outputs.version }}steps:- *checkout-release- - *require-release-native- - *download-release-native+ - &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: Overlay signed Darwin addons for publicationif: needs.eligibility.outputs.mode == 'publish'uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2with:- artifact-ids: ${{ needs.sign-darwin.outputs.artifact-id }}+ artifact-ids: ${{ needs.native.outputs.signed-darwin-id }}path: plugins/codex-security/native/prebuiltmerge-multiple: truedigest-mismatch: error@@ -407,7 +373,7 @@ jobs:test:needs: native- if: github.repository == 'openai/codex-security'+ if: ${{ !cancelled() && needs.native.result == 'success' }}name: release tests / ${{ matrix.suite }}runs-on: ubuntu-latestpermissions:@@ -458,7 +424,9 @@ jobs:macos-review-items:name: release tests / packaged macOS review itemsneeds: verify- if: needs.verify.outputs.mode == 'publish' && needs.verify.outputs.artifact-id != ''+ if: >-+ !cancelled() && needs.verify.result == 'success' &&+ needs.verify.outputs.mode == 'publish' && needs.verify.outputs.artifact-id != ''runs-on: macos-15permissions:contents: read@@ -553,10 +521,7 @@ jobs:- name: Revalidate protected release tagif: needs.verify.outputs.mode == 'publish'- shell: bash- env:- GH_TOKEN: ${{ github.token }}- run: *revalidate-release-tag+ uses: $/.github/actions/revalidate-release-tag- name: Publish to npm using trusted publishingif: needs.verify.outputs.mode == 'publish'diff --git a/.github/workflows/sign-darwin-release.yml b/.github/workflows/sign-darwin-release.ymlnew file mode 100644index 000000000..512a74efa--- /dev/null+++ b/.github/workflows/sign-darwin-release.yml@@ -0,0 +1,159 @@+name: Sign Darwin release addons++on:+ workflow_call:+ secrets:+ AKV_CODESIGN_RCODESIGN_BLOB_URI:+ required: true+ AKV_CODESIGN_RCODESIGN_SHA256:+ required: true+ AKV_CODESIGN_PKCS11_LIBRARY_BLOB_URI:+ required: true+ AKV_CODESIGN_PKCS11_LIBRARY_SHA256:+ required: true+ AKV_CODESIGN_AZURE_CLIENT_ID:+ required: true+ AKV_CODESIGN_TENANT:+ required: true+ AKV_CODESIGN_SUBSCRIPTION:+ required: true+ SIGNER_SERVICE_ENDPOINT:+ required: true+ SIGNER_SERVICE_PURPOSE:+ required: true+ SIGNER_SERVICE_KEY_ID:+ required: true+ SIGNING_CERTIFICATE_PEM:+ required: true+ outputs:+ native-artifact-id:+ description: Artifact ID of the verified universal native payload.+ value: ${{ jobs.build.outputs.artifact-id }}+ artifact-id:+ description: Artifact ID of the signed Darwin addons.+ value: ${{ jobs.sign.outputs.artifact-id }}++permissions:+ contents: read++jobs:+ validate:+ if: github.repository == 'openai/codex-security'+ runs-on: ubuntu-latest+ steps:+ - name: Checkout protected main and its history+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1+ with:+ ref: refs/heads/main+ fetch-depth: 0+ persist-credentials: false+ - name: Verify the release tag is on main+ shell: bash+ run: |+ set -euo pipefail+ if [[ "$GITHUB_REF_TYPE" != tag || "$GITHUB_REF" != refs/tags/npm-v?* ]] ||+ [[ "$(git rev-parse --verify "$GITHUB_REF^{commit}")" != "$GITHUB_SHA" ]] ||+ ! git merge-base --is-ancestor "$GITHUB_SHA" HEAD; then+ echo "The npm release tag must point to the triggering commit on main." >&2+ exit 1+ fi++ build:+ needs: validate+ cache-mode: none+ uses: ./.github/workflows/native-artifacts.yml+ with:+ ref: ${{ github.sha }}+ reuse-verified: false++ sign:+ needs: build+ runs-on: ubuntu-24.04+ environment: codesigning+ permissions:+ contents: read+ id-token: write+ outputs:+ artifact-id: ${{ steps.upload.outputs.artifact-id }}+ steps:+ - name: Require both build artifact IDs+ env:+ ARM64_ID: ${{ needs.build.outputs.darwin-arm64-artifact-id }}+ X64_ID: ${{ needs.build.outputs.darwin-x64-artifact-id }}+ run: test -n "$ARM64_ID" && test -n "$X64_ID"+ - name: Download the arm64 build+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ artifact-ids: ${{ needs.build.outputs.darwin-arm64-artifact-id }}+ path: arm64-build+ merge-multiple: true+ digest-mismatch: error+ - name: Download the x64 build+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ artifact-ids: ${{ needs.build.outputs.darwin-x64-artifact-id }}+ path: x64-build+ merge-multiple: true+ digest-mismatch: error+ - name: Verify both addon digests+ shell: bash+ env:+ ARM64_SHA256: ${{ needs.build.outputs.darwin-arm64-sha256 }}+ X64_SHA256: ${{ needs.build.outputs.darwin-x64-sha256 }}+ run: |+ set -euo pipefail+ printf '%s %s\n' "$ARM64_SHA256" arm64-build/darwin-arm64/unix.node \+ "$X64_SHA256" x64-build/darwin-x64/unix.node | sha256sum --strict --check -+ - name: Revalidate tag before Developer ID signing+ uses: $/.github/actions/revalidate-release-tag++ - 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 arch in arm64 x64; do+ target="darwin-$arch"+ mkdir -p "signed/$target"+ cp "$arch-build/$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/darwin-arm64/unix.node+ signed/darwin-x64/unix.node+ if-no-files-found: errordiff --git a/RELEASING.md b/RELEASING.mdindex 6884dcff9..c76d4c25b 100644--- a/RELEASING.md+++ b/RELEASING.md@@ -293,11 +293,14 @@ for that exact commit:1. `node-release-cut` verifies that the version increased, checks the reviewedsummary, and creates the exact `npm-vX.Y.Z` tag.-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.+2. For a new npm version, `node-release` calls+ `sign-darwin-release.yml` on protected `main`. That workflow verifies+ the tag points to a commit in `main`'s history and runs the native build+ at that commit. It signs the arm64 and x64 addons selected by their+ platform build IDs after checking their SHA-256 digests.+ An arm64 macOS runner extracts the packed npm 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** deploymentfor **Publish npm and container images**. This authorizes the npm archiveand the matching container images built from the tagged release. The job@@ -325,18 +328,25 @@ for that exact commit:Before the first signed release, restrict the `codesigning` GitHub environmentto `npm-v*` tags and configure its secrets for both steps:-- **Download tools.** The `AKV_CODESIGN_*` inputs in `node-release.yml` select+- **Download tools.** The `AKV_CODESIGN_*` inputs in `sign-darwin-release.yml` selecta blob-reader identity and pin the downloads of `rcodesign` and a PKCS#11provider that supports Signer Service. The identity needs read access tothose blobs only.- **Sign addons.** Authorize the tagged release workflow's GitHub OIDCidentity in Signer Service to read the public key and sign with theDeveloper ID Application key for the desktop runtime's Apple Developer team.+ For both tag pushes and manual dispatches on release tags, require the+ tagged `node-release.yml` caller and the exact OIDC claim+ `job_workflow_ref: openai/codex-security/.github/workflows/sign-darwin-release.yml@refs/heads/main`.+ Land the reusable workflow on `main` before enabling this authorization.Set `SIGNER_SERVICE_ENDPOINT`, `SIGNER_SERVICE_PURPOSE`, and`SIGNER_SERVICE_KEY_ID` for that key. Set `SIGNING_CERTIFICATE_PEM` to thematching public leaf certificate in PEM format.-Recovery of an already published version uses the original npm archive.+The first tag to use this policy must include the updated caller. If an+unpublished tag still uses inline signing, cut a new version tag from a+commit containing the updated caller. Recovery of an already published+version uses the original npm archive.The Action tag points to a generated distribution commit whose parent is theCLI release commit. That additional commit contains the runnable Action bundlediff --git a/sdk/typescript/tests-ts/container-release-workflow.test.ts b/sdk/typescript/tests-ts/container-release-workflow.test.tsindex eff43f40c..75b4e13fa 100644--- a/sdk/typescript/tests-ts/container-release-workflow.test.ts+++ b/sdk/typescript/tests-ts/container-release-workflow.test.ts@@ -307,9 +307,10 @@ test("keeps historical native payloads tied to the release checkout", () => {);const steps = workflow(`native-${platform}`).jobs["primitives"]!.steps!;expect(steps[0]?.with?.["ref"]).toBe("${{ inputs.ref || github.sha }}");- expect(steps.at(-1)?.with?.["name"]).toContain(- "${{ inputs.ref || github.sha }}",- );+ expect(+ steps.find((step) => step.uses?.startsWith("actions/upload-artifact@"))+ ?.with?.["name"],+ ).toContain("${{ inputs.ref || github.sha }}");}expect(native.jobs["bundle"]!.steps!.find(diff --git a/sdk/typescript/tests-ts/native-artifact-cache.test.ts b/sdk/typescript/tests-ts/native-artifact-cache.test.tsindex be50b9672..6ed84125d 100644--- a/sdk/typescript/tests-ts/native-artifact-cache.test.ts+++ b/sdk/typescript/tests-ts/native-artifact-cache.test.ts@@ -194,8 +194,10 @@ test("source CI opts in to native artifact reuse", () => {true,);for (const caller of ["node-release", "container-publish", "container-ci"]) {- expect(- workflow(caller).jobs["native"]?.with?.["reuse-verified"],- ).toBeUndefined();+ const build = Object.values(workflow(caller).jobs).find(+ (job) => job.uses === "./.github/workflows/native-artifacts.yml",+ );+ expect(build).toBeDefined();+ expect(build!.with?.["reuse-verified"]).toBeUndefined();}});diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.tsindex 647940891..7fba4f3c9 100644--- a/sdk/typescript/tests-ts/release-automation.test.ts+++ b/sdk/typescript/tests-ts/release-automation.test.ts@@ -9,12 +9,13 @@ import {writeFileSync,} from "node:fs";import { tmpdir } from "node:os";-import { join } from "node:path";+import { delimiter, join } from "node:path";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, writeSource } from "./support/shell.js";+import { workflow } from "./support/workflow.js";import {type ReleaseMetadata,@@ -308,6 +309,13 @@ const protectedReleaseWorkflow = readFileSync(new URL("../../../.github/workflows/node-release.yml", import.meta.url),"utf8",);+const darwinSigningWorkflow = readFileSync(+ new URL(+ "../../../.github/workflows/sign-darwin-release.yml",+ import.meta.url,+ ),+ "utf8",+);const releaseCutWorkflow = readFileSync(new URL("../../../.github/workflows/node-release-cut.yml", import.meta.url),"utf8",@@ -522,11 +530,17 @@ function verifySignatureFixture(options: SignatureAuditFixture = {}) {}type WorkflowContract = {+ on?: { workflow_call?: { secrets?: Record<string, { required?: boolean }> } };concurrency?: Record<string, unknown>;jobs: Record<string,{name?: string;+ uses?: string;+ with?: Record<string, unknown>;+ secrets?: Record<string, string>;+ "cache-mode"?: string;+ outputs?: Record<string, string>;permissions?: Record<string, string>;env?: Record<string, string>;needs?: string | string[];@@ -1895,8 +1909,8 @@ describe("GitHub release workflow safeguards", () => {).toBe(scenario.expected);});- test("only consults release metadata for a CI commit on main", async () => {- const cwd = directories.create("release-cut-ancestry-");+ async function createReleaseAncestryFixture() {+ const cwd = directories.create("release-ancestry-");// A maintainer may be running with GIT_DIR, a custom template or global hooks.const env = {PATH: process.env["PATH"],@@ -1920,6 +1934,7 @@ tree=$(git mktree </dev/null)qualified=$(git commit-tree "$tree" -m qualified)main=$(git commit-tree "$tree" -p "$qualified" -m main)candidate=$(git commit-tree "$tree" -p "$qualified" -m off-main)+git update-ref refs/heads/main "$main"git push --quiet ./remote.git "$main:refs/heads/main"git remote add origin ./remote.gitprintf '%s\\n%s\\n%s\\n' "$qualified" "$main" "$candidate"@@ -1929,6 +1944,12 @@ printf '%s\\n%s\\n%s\\n' "$qualified" "$main" "$candidate");expect(setup.status, setup.stderr).toBe(0);const [qualified, main, candidate] = setup.stdout.trim().split(/\r?\n/u);+ return { cwd, env, qualified, main, candidate };+ }++ test("only consults release metadata for a CI commit on main", async () => {+ const { cwd, env, qualified, main, candidate } =+ await createReleaseAncestryFixture();const script = `# actions/checkout detaches HEAD at the selected release SHA.git update-ref --no-deref HEAD "$RELEASE_SHA" || exit 1@@ -1967,6 +1988,48 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}}});+ test("only builds a release tag whose exact commit is on protected main", async () => {+ const { cwd, env, qualified, candidate } =+ await createReleaseAncestryFixture();+ const { jobs } = Bun.YAML.parse(darwinSigningWorkflow) as WorkflowContract;+ const validation = jobs["validate"]!.steps!;+ expect(validation[0]?.with?.["ref"]).toBe("refs/heads/main");+ const validate = workflowStepShell(+ darwinSigningWorkflow,+ "Verify the release tag is on main",+ );+ for (const [tag, commit, eventSha, allowed] of [+ ["npm-v1", qualified, qualified, true],+ ["npm-v2", candidate, candidate, false],+ ["npm-v3", candidate, qualified, false],+ ] as const) {+ const result = await runCommand(+ bash,+ [+ "--noprofile",+ "--norc",+ "-c",+ `set -eu+git tag -a "$GITHUB_REF_NAME" "$TAG_COMMIT" -m fixture+${validate}`,+ ],+ {+ cwd,+ env: {+ ...env,+ GITHUB_SHA: eventSha,+ GITHUB_REF_TYPE: "tag",+ GITHUB_REF_NAME: tag,+ GITHUB_REF: `refs/tags/${tag}`,+ GITHUB_OUTPUT: "/dev/null",+ TAG_COMMIT: commit,+ },+ },+ );+ expect(result.status, result.stderr).toBe(allowed ? 0 : 1);+ }+ });+test("executes the manual release cut against all published versions", async () => {const script = workflowStepShell(releaseCutWorkflow,@@ -2542,12 +2605,18 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}status: 0,},])(- "revalidates the authoritative $kind immediately before npm publication",+ "revalidates the authoritative $kind before signing and publication",async ({ tagType, tagObject, peeledCommit = "", status }) => {- const script = workflowStepShell(- protectedReleaseWorkflow,- "Revalidate protected release tag",- );+ const action = Bun.YAML.parse(+ readFileSync(+ new URL(+ "../../../.github/actions/revalidate-release-tag/action.yml",+ import.meta.url,+ ),+ "utf8",+ ),+ ) as { runs: { steps: { run: string }[] } };+ const script = action.runs.steps[0]!.run;const mock = ["gh() {",' if [[ "$1" != "api" ]]; then return 64; fi',@@ -2588,31 +2657,89 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}},);- test("binds signing and packaging to the verified native artifact and rechecks the live tag", () => {+ test("binds signing to both verified Darwin builds and packaging to the signed artifact", () => {const { jobs } = Bun.YAML.parse(protectedReleaseWorkflow,) as WorkflowContract;- const check = workflowStepShell(- protectedReleaseWorkflow,- "Revalidate protected release tag",+ const signing = Bun.YAML.parse(darwinSigningWorkflow) as WorkflowContract;+ expect(jobs["sign-darwin"]?.needs).toBe("eligibility");+ expect(jobs["sign-darwin"]?.if).toBe(+ "needs.eligibility.outputs.mode == 'publish'",+ );+ expect(jobs["recover-native"]).toMatchObject({+ needs: "eligibility",+ if: "needs.eligibility.outputs.mode == 'recover'",+ uses: "./.github/workflows/native-artifacts.yml",+ });+ expect(jobs["sign-darwin"]?.uses).toBe(+ "openai/codex-security/.github/workflows/sign-darwin-release.yml@main",+ );+ const sign = signing.jobs["sign"]!;+ expect(signing.jobs["build"]).toMatchObject({+ needs: "validate",+ uses: "./.github/workflows/native-artifacts.yml",+ "cache-mode": "none",+ with: { ref: "${{ github.sha }}", "reuse-verified": false },+ });+ expect(sign.needs).toBe("build");+ expect(sign.environment).toBe("codesigning");+ const signer = sign.steps!;+ const usedSecrets = [+ ...JSON.stringify(signer).matchAll(/\$\{\{ secrets\.(\w+) \}\}/gu),+ ].map(([reference, name]) => [name!, reference] as const);+ expect(jobs["sign-darwin"]?.secrets).toEqual(+ Object.fromEntries(usedSecrets),+ );+ for (const [name] of usedSecrets) {+ expect(signing.on?.workflow_call?.secrets?.[name]?.required).toBe(true);+ }+ const requireIds = signer.find(+ (step) => step.name === "Require both build artifact IDs",+ )!;+ const digestCheck = signer.find(+ (step) => step.name === "Verify both addon digests",);- for (const job of ["sign-darwin", "verify"]) {- const download = jobs[job]?.steps?.find(- (step) => step.name === "Download verified native payload",+ for (const arch of ["arm64", "x64"]) {+ const download = signer.find(+ (step) => step.name === `Download the ${arch} build`,+ );+ const artifactId = `\${{ needs.build.outputs.darwin-${arch}-artifact-id }}`;+ expect(requireIds.env?.[arch.toUpperCase() + "_ID"]).toBe(artifactId);+ expect(signer.indexOf(requireIds)).toBeLessThan(+ signer.indexOf(download!),);expect(download?.with).toMatchObject({- "artifact-ids": "${{ needs.native.outputs.artifact-id }}",+ "artifact-ids": artifactId,"digest-mismatch": "error",+ path: `${arch}-build`,});+ expect(digestCheck?.env?.[arch.toUpperCase() + "_SHA256"]).toBe(+ `\${{ needs.build.outputs.darwin-${arch}-sha256 }}`,+ );}- const signer = jobs["sign-darwin"]!.steps!;+ const verify = jobs["verify"]!.steps!;+ expect(+ verify.find((step) => step.name === "Download verified native payload")+ ?.with,+ ).toMatchObject({+ "artifact-ids": "${{ needs.native.outputs.artifact-id }}",+ "digest-mismatch": "error",+ });+ expect(+ verify.find(+ (step) => step.name === "Overlay signed Darwin addons for publication",+ )?.with,+ ).toMatchObject({+ "artifact-ids": "${{ needs.native.outputs.signed-darwin-id }}",+ "digest-mismatch": "error",+ });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,+ uses: "$/.github/actions/revalidate-release-tag",});const publisher = jobs["publish"]!.steps!;const publishIndex = publisher.findIndex(@@ -2621,73 +2748,298 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}expect(publisher[publishIndex - 1]).toMatchObject({name: "Revalidate protected release tag",if: "needs.verify.outputs.mode == 'publish'",- run: check,+ uses: "$/.github/actions/revalidate-release-tag",});});- test("signs both Darwin addons with the configured provider and certificate", async () => {+ test("publication and recovery select only their own successful native build", async () => {const { jobs } = Bun.YAML.parse(protectedReleaseWorkflow,) as WorkflowContract;- const step = jobs["sign-darwin"]!.steps!.find(- (step) => step.name === "Sign Darwin addons",+ const native = jobs["native"]!;+ const select = native.steps!.find(+ (step) =>+ step.name === "Select the native artifact IDs for this release mode",)!;- 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 }}",+ expect(select.env).toMatchObject({+ PUBLISH_NATIVE_ID: "${{ needs.sign-darwin.outputs.native-artifact-id }}",+ SIGNED_ID: "${{ needs.sign-darwin.outputs.artifact-id }}",+ RECOVER_NATIVE_ID: "${{ needs.recover-native.outputs.artifact-id }}",});-- 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,+ for (const mode of ["publish", "recover"]) {+ const publish = mode === "publish";+ const context = {+ "!cancelled()": "true",+ "needs.eligibility.result": "success",+ "needs.eligibility.outputs.mode": mode,+ "needs.sign-darwin.result": publish ? "success" : "skipped",+ "needs.recover-native.result": publish ? "skipped" : "success",+ };+ expect(await evaluateWorkflowCondition(native.if!, context)).toBe(true);+ const requiredJob = publish ? "sign-darwin" : "recover-native";+ expect(+ await evaluateWorkflowCondition(native.if!, {+ ...context,+ [`needs.${requiredJob}.result`]: "failure",+ }),+ ).toBe(false);+ const output = join(+ directories.create("release-native-"),+ "outputs",+ ).replaceAll("\\", "/");+ const result = await runShell(select.run!, {+ RELEASE_MODE: mode,+ PUBLISH_NATIVE_ID: "101",+ SIGNED_ID: "102",+ RECOVER_NATIVE_ID: "201",+ GITHUB_OUTPUT: output,+ });+ expect(result.status, result.stderr).toBe(0);+ expect(readFileSync(output, "utf8").trim().split(/\r?\n/u)).toEqual(+ publish ? ["native-id=101", "signed-id=102"] : ["native-id=201"],);}- 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 },+ });++ test("requires the protected signing workflow before signing and consuming addons from this attempt", async () => {+ const { jobs } = Bun.YAML.parse(+ protectedReleaseWorkflow,+ ) as WorkflowContract;+ const steps = jobs["native"]!.steps!;+ const select = steps.findIndex(+ (step) =>+ step.name === "Select the native artifact IDs for this release mode",);- const result = await runShell(step.run!, env, { cwd });- expect(result.status).toBe(0);- const pem = readFileSync(- join(cwd, env.SIGNER_SERVICE_CERTIFICATE_FILE),- "utf8",+ const guard = steps[select - 1]!;+ expect(guard.name).toBe("Verify reusable signing workflow ref");+ expect(guard.if).toBe("needs.eligibility.outputs.mode == 'publish'");+ const eligibility = jobs["eligibility"]!;+ const early = eligibility.steps!.find(+ (step) =>+ step.name === "Verify reusable signing workflow ref before signing",);- 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(early).toMatchObject({+ if: "steps.release.outputs.mode == 'publish'",+ run: guard.run,+ });+ expect(eligibility.permissions).toEqual({+ actions: "read",+ contents: "read",+ });+ expect(jobs["sign-darwin"]?.needs).toBe("eligibility");+ expect(jobs["verify"]?.needs).toContain("native");+ expect(+ jobs["verify"]?.steps?.find(+ (step) => step.name === "Overlay signed Darwin addons for publication",+ )?.if,+ ).toBe(guard.if);+ const workflow = `${releaseRepository}/.github/workflows/sign-darwin-release.yml`;+ const branch = {+ path: `${workflow}@main`,+ ref: "refs/heads/main",+ sha: releaseCommit,+ };+ const tag = { ...branch, ref: "refs/tags/main" };+ const other = {+ ...branch,+ path: `${releaseRepository}/.github/workflows/other.yml@main`,+ };+ const script = `set -e+gh() {+ [[ "$*" == "api repos/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID/attempts/$GITHUB_RUN_ATTEMPT" ]] || return 64+ printf '%s\\n' "$MOCK_ATTEMPT"+}+${guard.run}+echo 'overlay reached'`;+ for (const [refs, allowed] of [+ [[other, branch], true],+ [[{ ...branch, path: `${workflow}@${releaseCommit}` }], true],+ [[tag], false],+ [[other, branch, tag], false],+ [[{ ...branch, ref: "refs/heads/feature" }], false],+ [[{ path: branch.path, sha: releaseCommit }], false],+ [[other], false],+ [[], false],+ ] as const) {+ const result = await runShell(script, {+ GITHUB_REPOSITORY: releaseRepository,+ GITHUB_RUN_ID: releaseRun,+ GITHUB_RUN_ATTEMPT: "3",+ MOCK_ATTEMPT: JSON.stringify({ referenced_workflows: refs }),+ });+ expect(result.status, JSON.stringify(refs) + result.stderr).toBe(+ allowed ? 0 : 1,);- expect(signed).toContain(- `<--pkcs11-key-label><${step.env!["SIGNER_SERVICE_KEY_LABEL"]}>`,+ expect(result.stdout.includes("overlay reached")).toBe(allowed);+ }+ });++ test("each verified Darwin matrix leg forwards its own upload ID and addon digest", async () => {+ const unix = workflow("native-unix");+ const native = workflow("native-artifacts");+ const build = unix.jobs["primitives"]!;+ const steps = build.steps!;+ const upload = steps.findIndex((step) => step.id === "upload");+ const record = steps.findIndex((step) => step.id === "darwin");+ const node20 = steps.findIndex(+ (step) => step.with?.["node-version"] === "20.0.0",+ );+ expect(node20).toBeGreaterThan(0);+ expect(+ steps+ .slice(node20 + 1, upload)+ .some(+ (step) =>+ step.run?.includes("check.mjs") && step.run.includes("proof.mjs"),+ ),+ ).toBe(true);+ expect(record).toBeGreaterThan(upload);+ expect(steps[record]).toMatchObject({+ if: "matrix.platform == 'darwin'",+ env: {+ DARWIN_TARGET: "${{ matrix.artifact }}",+ ARTIFACT_ID: "${{ steps.upload.outputs.artifact-id }}",+ },+ });+ for (const [target, id] of [+ ["darwin-arm64", "101"],+ ["darwin-x64", "202"],+ ] as const) {+ const cwd = directories.create("native-matrix-");+ const output = join(cwd, "outputs").replaceAll("\\", "/");+ writeSource(cwd, `dist/${target}/unix.node`, target);+ const script = `if ! command -v shasum >/dev/null; then+ shasum() { [[ "$1 $2" == "-a 256" ]] || return 64; shift 2; sha256sum "$@"; }+fi+${steps[record]!.run}`;+ const result = await runShell(+ script,+ { DARWIN_TARGET: target, ARTIFACT_ID: id, GITHUB_OUTPUT: output },+ { cwd },);+ expect(result.status, result.stderr).toBe(0);+ expect(readFileSync(output, "utf8").trim().split(/\r?\n/u)).toEqual([+ `${target}-artifact-id=${id}`,+ `${target}-sha256=${createHash("sha256").update(target).digest("hex")}`,+ ]);+ for (const key of [`${target}-artifact-id`, `${target}-sha256`]) {+ expect(build.outputs?.[key]).toBe(+ `\${{ steps.darwin.outputs.${key} }}`,+ );+ expect(unix.on["workflow_call"]).toMatchObject({+ outputs: {+ [key]: { value: `\${{ jobs.primitives.outputs.${key} }}` },+ },+ });+ expect(native.on["workflow_call"]).toMatchObject({+ outputs: { [key]: { value: `\${{ jobs.unix.outputs.${key} }}` } },+ });+ }}});+ test.each([+ { scenario: "both verified builds" },+ { scenario: "substituted arm64 addon", replaced: "darwin-arm64" },+ { scenario: "substituted x64 addon", replaced: "darwin-x64" },+ { scenario: "missing arm64 artifact ID", missingId: "ARM64_ID" },+ { scenario: "missing x64 artifact ID", missingId: "X64_ID" },+ ])(+ "gates the Developer ID signer on $scenario",+ async ({ replaced, missingId }) => {+ const { jobs } = Bun.YAML.parse(+ darwinSigningWorkflow,+ ) as WorkflowContract;+ const steps = jobs["sign"]!.steps!;+ const step = 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 ");+ if (process.platform === "darwin" && !Bun.which("sha256sum")) {+ writeFileSync(+ join(cwd, "sha256sum"),+ '#!/bin/sh\nexec shasum -a 256 "$@"\n',+ { mode: 0o755 },+ );+ }+ const architectures = ["arm64", "x64"];+ for (const arch of architectures) {+ const target = `darwin-${arch}`;+ writeSource(+ cwd,+ `${arch}-build/${target}/unix.node`,+ target === replaced ? "substituted artifact" : target,+ );+ }+ const env = {+ ...step.env,+ PATH: `${cwd}${delimiter}${process.env["PATH"]}`,+ ARM64_ID: missingId === "ARM64_ID" ? "" : "11",+ X64_ID: missingId === "X64_ID" ? "" : "12",+ ARM64_SHA256: createHash("sha256").update("darwin-arm64").digest("hex"),+ X64_SHA256: createHash("sha256").update("darwin-x64").digest("hex"),+ 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 script = steps+ .filter((s) =>+ [+ "Require both build artifact IDs",+ "Verify both addon digests",+ "Sign Darwin addons",+ ].includes(s.name!),+ )+ .map((s) => `(\n${s.run!}\n)`)+ .join("\n");+ const result = await runShell(`set -e\n${script}`, env, { cwd });+ if (replaced || missingId) {+ expect(result.status, result.stderr).toBe(1);+ expect(existsSync(join(cwd, env.SIGNER_SERVICE_CERTIFICATE_FILE))).toBe(+ false,+ );+ return;+ }+ expect(result.status, result.stderr).toBe(0);+ const pem = readFileSync(+ join(cwd, env.SIGNER_SERVICE_CERTIFICATE_FILE),+ "utf8",+ );+ expect(pem.trimEnd()).toBe(env.SIGNING_CERTIFICATE_PEM);+ for (const arch of architectures) {+ const target = `darwin-${arch}`;+ 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,@@ -2821,6 +3173,7 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}),) as WorkflowContract;expect(jobs["verify"]?.permissions).toEqual({ contents: "read" });+ expect(jobs["native"]?.permissions).toEqual({ actions: "read" });expect(progress.jobs["report"]?.["continue-on-error"]).toBe(true);expect(progress.jobs["report"]?.permissions).toEqual({actions: "read",diff --git a/sdk/typescript/tests-ts/release-progress-workflow.test.ts b/sdk/typescript/tests-ts/release-progress-workflow.test.tsindex 6bd7b630d..7f9bf7012 100644--- a/sdk/typescript/tests-ts/release-progress-workflow.test.ts+++ b/sdk/typescript/tests-ts/release-progress-workflow.test.ts@@ -1,5 +1,6 @@import { readFileSync } from "node:fs";import { expect, test } from "bun:test";+import { renderProgress } from "../../../.github/scripts/release-progress.mjs";const workflow = Bun.YAML.parse(readFileSync(@@ -81,6 +82,39 @@ function identify(return { output: output.join(""), calls };}+test("release verification reports a failed Darwin signer when publication is skipped", () => {+ const release = Bun.YAML.parse(+ readFileSync(+ new URL("../../../.github/workflows/node-release.yml", import.meta.url),+ "utf8",+ ),+ ) as {+ jobs: Record<string, { name?: string }>;+ };+ const jobName = release.jobs["sign-darwin"]?.name ?? "sign-darwin";+ const progress = renderProgress(+ { "node-release": { status: "completed", conclusion: "failure" } },+ {+ "node-release": [+ { name: "native / bundle", status: "completed", conclusion: "success" },+ {+ name: `${jobName} / sign`,+ status: "completed",+ conclusion: "failure",+ },+ { name: "verify", status: "completed", conclusion: "skipped" },+ {+ name: "Publish npm and container images",+ status: "completed",+ conclusion: "skipped",+ },+ ],+ },+ false,+ );+ expect(progress).toContain("| Release verification | Failed |");+});+test("main CI completions report independently of cutting a release", () => {expect(workflow.on).toHaveProperty("workflow_call");expect(workflow.on.workflow_run).toEqual({