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

feat(container): release Debian and Wolfi from the verified scanner package (#2116)

Michael D'Angeloe3e688758e93
diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml
index 3734e1945..28c41f0c5 100644
--- a/.github/actionlint.yaml
+++ b/.github/actionlint.yaml
@@ -1,5 +1,5 @@
paths:
- .github/workflows/{container-release,node-github-release,node-ci,node-release-cut,node-release-pr,node-release,release-progress}.yml:
+ .github/workflows/{container-publish,node-github-release,node-ci,node-release-cut,node-release-pr,node-release,publish-wolfi,release-progress}.yml:
ignore:
# actionlint 1.7.12 predates GitHub's queue: max support. Keep the supported queue setting.
# https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency
diff --git a/.github/scripts/release-progress.mjs b/.github/scripts/release-progress.mjs
index e150803ba..76d30b492 100644
--- a/.github/scripts/release-progress.mjs
+++ b/.github/scripts/release-progress.mjs
@@ -80,14 +80,22 @@ export function renderProgress(
job.name.startsWith("publish matching container /"),
);
const containerState = jobStatus(containerJobs, github);
+ const containerJob = (name) =>
+ containerJobs.find(
+ (job) => job.name === `publish matching container / ${name}`,
+ );
+ const containerVerification = containerJob(
+ "verify required container publications",
+ );
+ // Historical runs skipped promotion after verifying an existing image.
const containerFinished =
github?.conclusion === "success" ||
- containerJobs.some(
- (job) =>
- job.name ===
- "publish matching container / promote-verified-and-attested-release" &&
- job.status === "completed",
- );
+ (containerVerification
+ ? containerVerification.conclusion === "success"
+ : github?.status === "completed" &&
+ containerJob("source")?.conclusion === "success" &&
+ containerJob("promote-verified-and-attested-release")?.status ===
+ "completed");
const complete = github?.conclusion === "success";
return [
marker,
diff --git a/.github/scripts/test_release_progress.mjs b/.github/scripts/test_release_progress.mjs
index 3c39db394..f3ff48b60 100644
--- a/.github/scripts/test_release_progress.mjs
+++ b/.github/scripts/test_release_progress.mjs
@@ -311,6 +311,9 @@ test("completed prerequisites do not claim that later checks or Action publicati
"node-github-release": [
job("verify matching Action"),
job("publish matching container / source"),
+ job(
+ "publish matching container / promote-verified-and-attested-release",
+ ),
],
},
false,
@@ -320,6 +323,31 @@ test("completed prerequisites do not claim that later checks or Action publicati
assert.match(body, /Container image \| Running/u);
});
+test("keeps the published container result on a historical failed release", () => {
+ for (const promotion of ["skipped", "success"]) {
+ const body = renderProgress(
+ {
+ "node-github-release": run(3, "node-github-release", {
+ status: "completed",
+ conclusion: "failure",
+ }),
+ },
+ {
+ "node-github-release": [
+ job("publish matching container / source"),
+ job(
+ "publish matching container / promote-verified-and-attested-release",
+ promotion,
+ ),
+ job("publish matching Action", "failure"),
+ ],
+ },
+ false,
+ );
+ assert.match(body, /Container image \| Passed/u);
+ }
+});
+
test("observer follows protected approval through completion without workflow events", async () => {
const f = fixture();
f.runs.set(2, run(2, "node-release"));
diff --git a/.github/workflows/action-ci.yml b/.github/workflows/action-ci.yml
index cec854c24..f33cd0fea 100644
--- a/.github/workflows/action-ci.yml
+++ b/.github/workflows/action-ci.yml
@@ -73,7 +73,7 @@ jobs:
- name: Test Action release contracts
if: inputs.sdk-contracts
working-directory: sdk/typescript
- run: bun test --timeout 30000 tests-ts/action-release-workflow.test.ts
+ run: bun test --timeout 30000 tests-ts/action-release-workflow.test.ts tests-ts/codex-dependency-pins.test.ts
- name: Install the pinned CLI for integration tests
run: npm ci --prefix runtime --ignore-scripts --no-audit --no-fund
- name: Published CLI result and SARIF compatibility (no model calls)
diff --git a/.github/workflows/container-publish.yml b/.github/workflows/container-publish.yml
new file mode 100644
index 000000000..a08c75ee7
--- /dev/null
+++ b/.github/workflows/container-publish.yml
@@ -0,0 +1,436 @@
+name: container-publish
+
+on:
+ workflow_call:
+ inputs:
+ release-sha:
+ required: true
+ type: string
+ release-version:
+ required: true
+ type: string
+ release-integrity:
+ type: string
+ release-tarball-artifact:
+ type: string
+ runtime-lock-artifact:
+ type: string
+ outputs:
+ debian-digest:
+ value: ${{ jobs.complete.outputs.debian-digest }}
+ wolfi-digest:
+ value: ${{ jobs.complete.outputs.wolfi-digest }}
+
+concurrency:
+ group: container-release-publish
+ queue: max
+
+permissions:
+ contents: read
+
+jobs:
+ source:
+ if: github.workflow_ref == 'openai/codex-security/.github/workflows/node-github-release.yml@refs/heads/main'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ permissions:
+ contents: read
+ packages: read
+ attestations: read
+ outputs:
+ sha: ${{ inputs.release-sha }}
+ image: ${{ steps.release.outputs.image }}
+ version: ${{ inputs.release-version }}
+ wolfi: ${{ steps.release.outputs.wolfi }}
+ labels: ${{ steps.metadata.outputs.labels }}
+ metadata: ${{ steps.metadata.outputs.json }}
+ existing-digest: ${{ steps.existing.outputs.digest }}
+ complete: ${{ steps.existing.outputs.complete }}
+ steps:
+ - name: Checkout release history
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+
+ - name: Validate protected release source and version
+ id: release
+ env:
+ RELEASE_SHA: ${{ inputs.release-sha }}
+ RELEASE_VERSION: ${{ inputs.release-version }}
+ CLI_INTEGRITY: ${{ inputs.release-integrity }}
+ TARBALL: ${{ inputs.release-tarball-artifact }}
+ RUNTIME_LOCK: ${{ inputs.runtime-lock-artifact }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ [[ $RELEASE_SHA =~ ^[0-9a-f]{40}$ && $RELEASE_VERSION =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] || exit 1
+ if [[ $GITHUB_REF != refs/heads/main ]]; then
+ echo 'Coordinated image releases must run on main with an exact release commit.' >&2
+ exit 1
+ fi
+ if [[ $(git rev-parse "refs/tags/npm-v$RELEASE_VERSION^{commit}") != "$RELEASE_SHA" ]]; then
+ echo 'The container source must match the immutable npm release tag.' >&2
+ exit 1
+ fi
+ if [[ $(git show "$RELEASE_SHA:sdk/typescript/package.json" | jq -r .version) != "$RELEASE_VERSION" ]]; then
+ echo 'The container version must match the CLI package version.' >&2
+ exit 1
+ fi
+ git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
+ if ! git merge-base --is-ancestor "$RELEASE_SHA" refs/remotes/origin/main; then
+ echo 'Container releases must be built from a commit on the protected main branch.' >&2
+ exit 1
+ fi
+ if git cat-file -e "$RELEASE_SHA:.github/workflows/wolfi-build.yml"; then
+ test "$GITHUB_REF_PROTECTED" = true
+ [[ ${TARBALL:-} =~ ^[0-9]+$ && ${RUNTIME_LOCK:-} =~ ^[0-9]+$ && ${CLI_INTEGRITY:-} == sha512-* ]] || exit 1
+ echo 'wolfi=true' >> "$GITHUB_OUTPUT"
+ fi
+ owner=$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')
+ printf 'image=ghcr.io/%s/codex-security\n' "$owner" >> "$GITHUB_OUTPUT"
+
+ - name: Generate release image metadata
+ id: metadata
+ uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
+ with:
+ images: ${{ steps.release.outputs.image }}
+ tags: type=raw,value=${{ inputs.release-version }}
+ labels: |
+ org.opencontainers.image.title=Codex Security
+ org.opencontainers.image.description=Codex Security scanner.
+ org.opencontainers.image.licenses=Apache-2.0
+ org.opencontainers.image.vendor=OpenAI
+ org.opencontainers.image.revision=${{ inputs.release-sha }}
+ org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/releases/tag/npm-v${{ inputs.release-version }}
+ org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/${{ inputs.release-sha }}/docker/README.md
+
+ - &buildx
+ name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
+
+ - name: Verify an existing immutable container release
+ id: existing
+ env:
+ GH_TOKEN: ${{ github.token }}
+ HAS_WOLFI: ${{ steps.release.outputs.wolfi == 'true' }}
+ IMAGE: ${{ steps.release.outputs.image }}
+ VERSION: ${{ inputs.release-version }}
+ RELEASE_SHA: ${{ inputs.release-sha }}
+ shell: bash
+ run: |
+ set -euo pipefail
+ owner=$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')
+ endpoint="orgs/$owner/packages/container/codex-security"
+ versions=$(gh api --paginate "$endpoint/versions?per_page=100" | jq -s .)
+ tag_digest() {
+ jq -r --arg tag "$1" '[.[][] | select(any(.metadata.container.tags[]?; . == $tag)) | .name] | unique[]' <<< "$versions"
+ }
+ version_digest=$(tag_digest "$VERSION")
+ sha_digest=$(tag_digest "sha-$RELEASE_SHA")
+ latest_digest=$(tag_digest latest)
+ digest=${version_digest:-${sha_digest:-$latest_digest}}
+ if [[ -z $digest ]]; then exit 0; fi
+ [[ $digest =~ ^sha256:[0-9a-f]{64}$ ]] || exit 1
+ [[ -z $sha_digest || $sha_digest == "$digest" ]] || exit 1
+ reference="$IMAGE@$digest"
+ manifest=$(docker buildx imagetools inspect "$reference" --raw)
+ if [[ -z $version_digest && -z $sha_digest ]] &&
+ [[ $(jq -r '.annotations["org.opencontainers.image.version"]' <<< "$manifest") != "$VERSION" ]]; then
+ exit 0
+ fi
+ jq -e --arg version "$VERSION" --arg sha "$RELEASE_SHA" '
+ .annotations["org.opencontainers.image.version"] == $version
+ and .annotations["org.opencontainers.image.revision"] == $sha
+ and ([.manifests[] | select(.platform.os == "linux") | .platform.architecture] | sort == ["amd64","arm64"])
+ ' <<< "$manifest" > /dev/null
+ verify_provenance() {
+ local workflow=$1 ref=$2
+ shift 2
+ gh attestation verify "oci://$reference" --repo "$GITHUB_REPOSITORY" \
+ --cert-identity "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/.github/workflows/$workflow.yml@$ref" \
+ --source-ref "$ref" "$@"
+ }
+ if ! verify_provenance container-publish refs/heads/main; then
+ [[ $HAS_WOLFI == false ]] || exit 1
+ verify_provenance container-release refs/heads/main ||
+ verify_provenance container-release "refs/tags/container-v$VERSION" --source-digest "$RELEASE_SHA"
+ fi
+ docker logout ghcr.io
+ # Classic Docker stores one local platform per index digest.
+ arm64_digest=$(jq -er '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "arm64") | .digest' <<< "$manifest")
+ docker pull --platform linux/arm64 "$IMAGE@$arm64_digest"
+ docker pull --platform linux/amd64 "$reference"
+ actual_version=$(docker run --rm --platform linux/amd64 "$reference" --version)
+ test "$actual_version" = "$VERSION"
+ GITHUB_OUTPUT="$RUNNER_TEMP/debian-version" sh docker/verify-container-release-version.sh "$endpoint" "$VERSION" "$digest"
+ complete=false
+ if [[ $version_digest == "$digest" && $sha_digest == "$digest" ]] && { grep -Fxq 'publish_latest=false' "$RUNNER_TEMP/debian-version" || [[ $latest_digest == "$digest" ]]; }; then
+ complete=true
+ fi
+ printf 'digest=%s\ncomplete=%s\n' "$digest" "$complete" >> "$GITHUB_OUTPUT"
+
+ native:
+ needs: source
+ if: needs.source.outputs.wolfi != 'true' && needs.source.outputs.existing-digest == ''
+ uses: ./.github/workflows/native-artifacts.yml
+ with:
+ ref: ${{ needs.source.outputs.sha }}
+
+ validate:
+ needs: [source, native]
+ if: >-
+ !cancelled() && needs.source.result == 'success' && needs.source.outputs.existing-digest == '' &&
+ (needs.source.outputs.wolfi == 'true' || needs.native.result == 'success')
+ uses: ./.github/workflows/container-validate.yml
+ with:
+ ref: ${{ needs.source.outputs.sha }}
+ release-version: ${{ needs.source.outputs.version }}
+ release-integrity: ${{ inputs.release-integrity }}
+ release-tarball-artifact: ${{ inputs.release-tarball-artifact }}
+ runtime-lock-artifact: ${{ inputs.runtime-lock-artifact }}
+ labels: ${{ needs.source.outputs.labels }}
+
+ debian:
+ needs: [source, validate]
+ if: ${{ !cancelled() && needs.validate.result == 'success' }}
+ runs-on: ubuntu-24.04
+ outputs:
+ digest: ${{ steps.index.outputs.digest }}
+ artifact: ${{ steps.upload.outputs.artifact-id }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ pattern: codex-security-oci-*
+ path: ${{ runner.temp }}/platforms
+ - name: Prepare the tested multiarchitecture index
+ id: index
+ env:
+ IMAGE_METADATA: ${{ needs.source.outputs.metadata }}
+ run: |
+ cd "$RUNNER_TEMP"
+ digest=$(bash "$GITHUB_WORKSPACE/docker/prepare-container-index.sh" \
+ platforms/codex-security-oci-amd64/image.tar platforms/codex-security-oci-arm64/image.tar debian)
+ printf 'digest=%s\n' "$digest" >> "$GITHUB_OUTPUT"
+ printf 'Debian amd64 and arm64: `%s`\n' "$digest" >> "$GITHUB_STEP_SUMMARY" || true
+ - name: Retain the Debian index and its tested platform images
+ id: upload
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: debian-index-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/debian
+ compression-level: 0
+ if-no-files-found: error
+ retention-days: 7
+
+ wolfi:
+ needs: source
+ if: needs.source.outputs.wolfi == 'true'
+ permissions:
+ contents: read
+ attestations: read
+ uses: ./.github/workflows/wolfi-build.yml
+ with:
+ release-sha: ${{ needs.source.outputs.sha }}
+ release-version: ${{ needs.source.outputs.version }}
+ release-integrity: ${{ inputs.release-integrity }}
+ release-tarball-artifact: ${{ inputs.release-tarball-artifact }}
+ runtime-lock-artifact: ${{ inputs.runtime-lock-artifact }}
+
+ authorize:
+ name: authorize-container-publication
+ needs: [source, debian, wolfi]
+ if: >-
+ !cancelled() && needs.source.result == 'success' &&
+ (needs.debian.result == 'success' || needs.source.outputs.existing-digest != '') &&
+ (needs.wolfi.result == 'success' || needs.source.outputs.wolfi != 'true') &&
+ (needs.source.outputs.complete != 'true' || (needs.source.outputs.wolfi == 'true' && needs.wolfi.outputs.existing != 'true'))
+ runs-on: ubuntu-24.04
+ environment: container
+ permissions:
+ contents: read
+ packages: read
+ steps:
+ - name: Require a public registry before uploading either image
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: gh api "orgs/${GITHUB_REPOSITORY_OWNER,,}/packages/container/codex-security" | jq -e '.visibility == "public"'
+
+ manifest:
+ name: publish-and-verify-multiarchitecture-candidate
+ needs: [source, debian, authorize]
+ if: ${{ !cancelled() && needs.authorize.result == 'success' && needs.debian.result == 'success' }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 30
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ needs.source.outputs.sha }}
+ persist-credentials: false
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ needs.debian.outputs.artifact }}
+ merge-multiple: true
+ path: ${{ runner.temp }}/debian
+ - &login
+ name: Sign in to GitHub Container Registry
+ uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ github.token }}
+ - name: Upload the approved index and verify its anonymous digest
+ env:
+ IMAGE: ${{ needs.source.outputs.image }}
+ DIGEST: ${{ needs.debian.outputs.digest }}
+ RELEASE_SHA: ${{ needs.source.outputs.sha }}
+ VERSION: ${{ needs.source.outputs.version }}
+ run: |
+ set -euo pipefail
+ [[ $DIGEST =~ ^sha256:[0-9a-f]{64}$ ]]
+ skopeo inspect --raw "oci:$RUNNER_TEMP/debian:scanner" | sha256sum | cut -d' ' -f1 | grep -Fxq "${DIGEST#sha256:}"
+ skopeo copy --all --preserve-digests --digestfile "$RUNNER_TEMP/registry-digest" \
+ "oci:$RUNNER_TEMP/debian:scanner" "docker://$IMAGE:release-candidate-$RELEASE_SHA"
+ [[ $(cat "$RUNNER_TEMP/registry-digest") == "$DIGEST" ]]
+ docker logout ghcr.io
+ skopeo copy --all --src-no-creds --preserve-digests --digestfile "$RUNNER_TEMP/public-digest" \
+ "docker://$IMAGE@$DIGEST" "oci:$RUNNER_TEMP/public:scanner"
+ test "$(cat "$RUNNER_TEMP/public-digest")" = "$DIGEST"
+ skopeo copy "oci:$RUNNER_TEMP/public:scanner" docker-daemon:codex-security:public-candidate
+ actual_version=$(docker run --rm --pull=never codex-security:public-candidate --version)
+ test "$actual_version" = "$VERSION"
+ - name: Verify hardened customer Compose against the public candidate
+ env:
+ CODEX_SECURITY_IMAGE: codex-security:public-candidate
+ run: source docker/verify-container-compose.sh
+
+ attest:
+ name: attest-verified-multiarchitecture-candidate
+ needs: [source, debian, manifest]
+ if: ${{ !cancelled() && needs.manifest.result == 'success' }}
+ runs-on: ubuntu-24.04
+ permissions:
+ attestations: write
+ artifact-metadata: write
+ contents: read
+ id-token: write
+ packages: write
+ steps:
+ - *login
+ - name: Sign verified multiarchitecture candidate provenance
+ uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
+ with:
+ push-to-registry: true
+ subject-name: ${{ needs.source.outputs.image }}
+ subject-digest: ${{ needs.debian.outputs.digest }}
+ - name: Verify the published provenance
+ env:
+ GH_TOKEN: ${{ github.token }}
+ IMAGE: ${{ needs.source.outputs.image }}
+ DIGEST: ${{ needs.debian.outputs.digest }}
+ run: |
+ gh attestation verify "oci://$IMAGE@$DIGEST" --repo "$GITHUB_REPOSITORY" \
+ --cert-identity "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/.github/workflows/container-publish.yml@refs/heads/main" \
+ --source-ref refs/heads/main
+
+ publish-wolfi:
+ needs: [source, authorize, attest, wolfi]
+ if: >-
+ !cancelled() && needs.authorize.result == 'success' && needs.wolfi.result == 'success' &&
+ needs.wolfi.outputs.existing != 'true' && (needs.attest.result == 'success' || needs.source.outputs.existing-digest != '')
+ permissions:
+ contents: read
+ packages: write
+ attestations: write
+ artifact-metadata: write
+ id-token: write
+ uses: ./.github/workflows/publish-wolfi.yml
+ with:
+ artifact: ${{ needs.wolfi.outputs.artifact }}
+ digest: ${{ needs.wolfi.outputs.digest }}
+ tag: ${{ needs.wolfi.outputs.tag }}
+ sbom-sha: ${{ needs.wolfi.outputs.sbom-sha }}
+
+ promote:
+ name: promote-verified-and-attested-release
+ needs: [source, authorize, debian, attest, wolfi, publish-wolfi]
+ if: >-
+ !cancelled() && needs.authorize.result == 'success' && needs.source.outputs.complete != 'true' &&
+ (needs.attest.result == 'success' || needs.source.outputs.existing-digest != '') &&
+ (needs.source.outputs.wolfi != 'true' || needs.wolfi.outputs.existing == 'true' || needs.publish-wolfi.result == 'success')
+ runs-on: ubuntu-24.04
+ permissions:
+ contents: read
+ packages: write
+ env:
+ IMAGE: ${{ needs.source.outputs.image }}
+ VERSION: ${{ needs.source.outputs.version }}
+ RELEASE_SHA: ${{ needs.source.outputs.sha }}
+ MANIFEST_DIGEST: ${{ needs.source.outputs.existing-digest || needs.debian.outputs.digest }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - *buildx
+ - *login
+ - name: Recheck immutable version and select the latest tag
+ id: version
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: sh docker/verify-container-release-version.sh "orgs/${GITHUB_REPOSITORY_OWNER,,}/packages/container/codex-security" "$VERSION" "$MANIFEST_DIGEST"
+ - name: Promote and verify each release tag
+ env:
+ PUBLISH_LATEST: ${{ steps.version.outputs.publish_latest }}
+ run: |
+ set -euo pipefail
+ tags=("$VERSION" "sha-$RELEASE_SHA")
+ if [[ $PUBLISH_LATEST == true ]]; then tags+=(latest); fi
+ for tag in "${tags[@]}"; do
+ docker buildx imagetools create --tag "$IMAGE:$tag" "$IMAGE@$MANIFEST_DIGEST"
+ actual=$(skopeo inspect --no-creds --raw "docker://$IMAGE:$tag" | sha256sum | cut -d' ' -f1)
+ [[ "sha256:$actual" == "$MANIFEST_DIGEST" ]]
+ done
+ docker logout ghcr.io
+ docker pull "$IMAGE:$VERSION"
+ actual_version=$(docker run --rm --entrypoint codex-security "$IMAGE:$VERSION" --version)
+ test "$actual_version" = "$VERSION"
+
+ complete:
+ name: verify required container publications
+ needs: [source, debian, wolfi, promote, publish-wolfi]
+ if: ${{ !cancelled() }}
+ runs-on: ubuntu-24.04
+ outputs:
+ debian-digest: ${{ steps.result.outputs.debian }}
+ wolfi-digest: ${{ steps.result.outputs.wolfi }}
+ steps:
+ - id: result
+ env:
+ DEBIAN: ${{ needs.source.outputs.existing-digest || needs.debian.outputs.digest }}
+ DEBIAN_OK: ${{ needs.source.outputs.complete == 'true' || needs.promote.result == 'success' }}
+ WOLFI_REQUIRED: ${{ needs.source.outputs.wolfi }}
+ WOLFI: ${{ needs.wolfi.outputs.digest }}
+ WOLFI_OK: ${{ needs.wolfi.outputs.existing == 'true' || needs.publish-wolfi.result == 'success' }}
+ SOURCE_OK: ${{ needs.source.result }}
+ IMAGE: ${{ needs.source.outputs.image }}
+ VERSION: ${{ needs.source.outputs.version }}
+ run: |
+ set -euo pipefail
+ [[ $SOURCE_OK == success && $DEBIAN_OK == true && $DEBIAN =~ ^sha256:[0-9a-f]{64}$ ]] || exit 1
+ verify_tag() {
+ skopeo inspect --no-creds --raw "docker://$IMAGE:$1" | sha256sum | cut -d' ' -f1 | grep -Fxq "${2#sha256:}"
+ }
+ verify_tag "$VERSION" "$DEBIAN"
+ if [[ $WOLFI_REQUIRED == true ]]; then
+ [[ $WOLFI_OK == true && $WOLFI =~ ^sha256:[0-9a-f]{64}$ ]] || exit 1
+ verify_tag "$VERSION-wolfi-amd64" "$WOLFI"
+ fi
+ printf 'debian=%s\nwolfi=%s\n' "$DEBIAN" "$WOLFI" >> "$GITHUB_OUTPUT"
diff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.yml
index ca6bc9e41..85ceb234e 100644
--- a/.github/workflows/container-release.yml
+++ b/.github/workflows/container-release.yml
@@ -5,20 +5,6 @@ on:
tags:
- "container-v*"
workflow_dispatch:
- workflow_call:
- inputs:
- release-sha:
- description: Verified npm release source commit.
- required: true
- type: string
- release-version:
- description: Verified stable npm version.
- required: true
- type: string
-
-concurrency:
- group: container-release-publish
- queue: max
permissions:
contents: read
@@ -27,537 +13,60 @@ jobs:
source:
if: github.repository == 'openai/codex-security'
runs-on: ubuntu-24.04
- timeout-minutes: 10
- permissions:
- contents: read
- packages: read
- attestations: read
outputs:
- sha: ${{ steps.release.outputs.sha }}
- image: ${{ steps.release.outputs.image }}
version: ${{ steps.release.outputs.version }}
- existing-digest: ${{ steps.existing.outputs.digest }}
steps:
- - name: Checkout release history
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
- ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
-
- - name: Validate protected release source and version
+ - name: Resolve the protected container release
id: release
- env:
- RELEASE_SHA: ${{ inputs.release-sha }}
- RELEASE_VERSION: ${{ inputs.release-version }}
shell: bash
run: |
set -euo pipefail
- source_sha="$GITHUB_SHA"
-
- if [[ -n "$RELEASE_SHA" ]]; then
- if [[ "$GITHUB_REF" != refs/heads/main || ! "$RELEASE_SHA" =~ ^[0-9a-f]{40}$ ]]; then
- echo 'Coordinated image releases must run on main with an exact release commit.' >&2
- exit 1
- fi
- source_sha="$RELEASE_SHA"
- version="$RELEASE_VERSION"
- if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] ||
- [[ "$(git rev-parse "refs/tags/npm-v$version^{commit}")" != "$source_sha" ]]; then
- echo 'The container source must match the immutable npm release tag.' >&2
- exit 1
- fi
- elif [[ "$GITHUB_EVENT_NAME" == workflow_dispatch ]]; then
- if [[ "$GITHUB_REF" != refs/heads/main ]]; then
- echo 'Manual image releases must use the protected main branch.' >&2
- exit 1
- fi
- version="$(git show "$source_sha:sdk/typescript/package.json" | jq -r .version)"
- elif [[ "$GITHUB_REF_NAME" =~ ^container-v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
- version="${GITHUB_REF_NAME#container-v}"
+ version=$(jq -er .version sdk/typescript/package.json)
+ [[ $version =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] || exit 1
+ if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
+ test "$GITHUB_REF" = refs/heads/main
else
- echo 'Container release tags must identify a stable version such as container-v0.1.0.' >&2
- exit 1
- fi
-
- package_version="$(git show "$source_sha:sdk/typescript/package.json" | jq -r .version)"
- if [[ "$version" != "$package_version" ]]; then
- echo "Container version $version must match the CLI package version $package_version." >&2
- exit 1
- fi
-
- git fetch --no-tags origin +refs/heads/main:refs/remotes/origin/main
- if ! git merge-base --is-ancestor "$source_sha" refs/remotes/origin/main; then
- echo 'Container releases must be built from a commit on the protected main branch.' >&2
- exit 1
- fi
-
- owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
- printf 'image=ghcr.io/%s/codex-security\n' "$owner" >> "$GITHUB_OUTPUT"
- printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
- printf 'sha=%s\n' "$source_sha" >> "$GITHUB_OUTPUT"
-
- - &set-up-docker-buildx
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
-
- - name: Verify an existing immutable container release
- id: existing
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- IMAGE: ${{ steps.release.outputs.image }}
- VERSION: ${{ steps.release.outputs.version }}
- RELEASE_SHA: ${{ steps.release.outputs.sha }}
- shell: bash
- run: |
- set -euo pipefail
- owner="$(printf '%s' "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
- endpoint="orgs/$owner/packages/container/codex-security"
- versions="$(gh api --paginate "$endpoint/versions?per_page=100")"
- digest="$(jq -r -s --arg version "$VERSION" '
- [.[][] | select(any(.metadata.container.tags[]?; . == $version)) | .name]
- | unique | .[]
- ' <<< "$versions")"
- if [[ -z "$digest" ]]; then
- exit 0
- fi
- if [[ ! "$digest" =~ ^sha256:[a-f0-9]{64}$ ]]; then
- echo 'The existing container version must resolve to one immutable digest.' >&2
- exit 1
+ test "$GITHUB_REF" = "refs/tags/container-v$version"
fi
- jq --exit-status --slurp --arg tag "sha-$RELEASE_SHA" --arg digest "$digest" '
- [.[][] | select(any(.metadata.container.tags[]?; . == $tag)) | .name]
- | unique == [$digest]
- ' <<< "$versions" > /dev/null
- reference="$IMAGE@$digest"
- docker buildx imagetools inspect "$reference" --raw |
- jq --exit-status --arg version "$VERSION" --arg sha "$RELEASE_SHA" '
- .annotations["org.opencontainers.image.version"] == $version
- and .annotations["org.opencontainers.image.revision"] == $sha
- and (
- [.manifests[] | select(.platform.os == "linux") | .platform.architecture]
- | (index("amd64") != null and index("arm64") != null)
- )
- ' > /dev/null
- gh attestation verify "oci://$reference" --repo "$GITHUB_REPOSITORY"
- docker pull "$reference"
- docker run --rm "$reference" --version
- sh docker/verify-container-release-version.sh "$endpoint" "$VERSION" "$digest"
- printf 'digest=%s\n' "$digest" >> "$GITHUB_OUTPUT"
-
- native:
+ git merge-base --is-ancestor "$GITHUB_SHA" refs/remotes/origin/main
+ # A manual request on main may follow the npm release commit.
+ npm_sha=$(git rev-parse --verify "refs/tags/npm-v$version^{commit}")
+ if [[ $GITHUB_EVENT_NAME == push ]]; then test "$npm_sha" = "$GITHUB_SHA"; fi
+ git merge-base --is-ancestor "$npm_sha" "$GITHUB_SHA"
+ echo "version=$version" >> "$GITHUB_OUTPUT"
+
+ dispatch:
+ name: Start the verified npm release backfill
needs: source
- if: github.repository == 'openai/codex-security' && needs.source.outputs.existing-digest == ''
- uses: ./.github/workflows/native-artifacts.yml
- with:
- ref: ${{ needs.source.outputs.sha }}
-
- validate:
- needs: [source, native]
- if: github.repository == 'openai/codex-security'
- uses: ./.github/workflows/container-validate.yml
- with:
- ref: ${{ needs.source.outputs.sha }}
-
- authorize:
- if: github.repository == 'openai/codex-security'
- name: authorize-container-publication
- needs: [source, validate]
runs-on: ubuntu-24.04
- timeout-minutes: 10
- environment: container
permissions:
- contents: read
- packages: read
- outputs:
- sha: ${{ needs.source.outputs.sha }}
- image: ${{ needs.source.outputs.image }}
- version: ${{ needs.source.outputs.version }}
- labels: ${{ steps.metadata.outputs.labels }}
- metadata: ${{ steps.metadata.outputs.json }}
+ actions: write
steps:
- - name: Checkout release automation
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.sha }}
- persist-credentials: false
-
- - name: Preflight public package and immutable release version
+ - name: Dispatch the coordinator on protected main
+ id: dispatch
env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.source.outputs.version }}
- shell: bash
- run: |
- set -euo pipefail
- owner="${GITHUB_REPOSITORY_OWNER,,}"
- endpoint="orgs/$owner/packages/container/codex-security"
-
- if ! metadata="$(gh api "$endpoint" 2>/dev/null)"; then
- echo "::error::A repository administrator must bootstrap ghcr.io/$owner/codex-security, make the package public, and grant this repository package access before approving publication."
- exit 1
- fi
-
- if [[ "$(jq -r '.visibility' <<< "$metadata")" != public ]]; then
- echo "::error::ghcr.io/$owner/codex-security must be public before any release image is pushed."
- exit 1
- fi
-
- sh docker/verify-container-release-version.sh "$endpoint" "$VERSION"
-
- - name: Generate release image metadata
- id: metadata
- uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
- with:
- images: ${{ needs.source.outputs.image }}
- # Use the release version for metadata; only promote publishes stable tags.
- tags: type=raw,value=${{ needs.source.outputs.version }}
- labels: |
- org.opencontainers.image.title=Codex Security
- org.opencontainers.image.description=Codex Security scanner.
- org.opencontainers.image.licenses=Apache-2.0
- org.opencontainers.image.vendor=OpenAI
- org.opencontainers.image.revision=${{ needs.source.outputs.sha }}
- org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}/releases/tag/npm-v${{ needs.source.outputs.version }}
- org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/${{ needs.source.outputs.sha }}/docker/README.md
-
- publish-platform:
- name: publish-linux-${{ matrix.architecture }}
- needs: authorize
- runs-on: ${{ matrix.runner }}
- timeout-minutes: 60
- permissions:
- contents: read
- packages: write
- strategy:
- fail-fast: false
- matrix:
- include:
- - architecture: amd64
- runner: ubuntu-24.04
- - architecture: arm64
- runner: ubuntu-24.04-arm
-
- steps:
- - name: Checkout approved release source
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ needs.authorize.outputs.sha }}
- persist-credentials: false
- - name: Prepare native runtime
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- name: native-universal-${{ needs.authorize.outputs.sha }}
- path: plugins/codex-security/native/prebuilt
-
- - *set-up-docker-buildx
-
- - &sign-in-to-github-container-registry
- name: Sign in to GitHub Container Registry
- uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Publish native image by immutable digest
- id: build
- uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
- with:
- context: .
- platforms: linux/${{ matrix.architecture }}
- outputs: type=image,name=${{ needs.authorize.outputs.image }},push-by-digest=true,name-canonical=true,push=true
- provenance: mode=max
- sbom: true
- cache-from: type=gha,scope=codex-security-${{ matrix.architecture }}
- cache-to: type=gha,mode=max,scope=codex-security-${{ matrix.architecture }}
- labels: ${{ needs.authorize.outputs.labels }}
-
- - name: Verify the exact published native image
- env:
- EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}
- IMAGE: ${{ needs.authorize.outputs.image }}
- IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
- IMAGE_METADATA: ${{ needs.authorize.outputs.metadata }}
- shell: bash
- run: |
- set -euo pipefail
- if [[ ! "$IMAGE_DIGEST" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
- echo 'The registry did not return a valid immutable platform digest.' >&2
- exit 1
- fi
-
- reference="$IMAGE@$IMAGE_DIGEST"
- docker logout ghcr.io
- docker pull "$reference"
-
- actual_architecture="$(docker image inspect --format '{{.Architecture}}' "$reference")"
- if [[ "$actual_architecture" != "$EXPECTED_ARCHITECTURE" ]]; then
- echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2
- exit 1
- fi
-
- docker image inspect --format '{{json .Config.Labels}}' "$reference" |
- jq --exit-status --argjson metadata "$IMAGE_METADATA" '
- . as $labels
- | all($metadata.labels | to_entries[]; $labels[.key] == .value)
- ' > /dev/null
-
- docker run --rm "$reference" --version
- docker run --rm "$reference" bulk-scan --help
- docker run --rm "$reference" info --json
- [[ "$(docker run --rm --entrypoint id "$reference" -u)" == 10001 ]]
-
- - name: Record verified platform digest
- env:
- IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
- shell: bash
- run: |
- set -euo pipefail
- mkdir -p "$RUNNER_TEMP/codex-security-platform-digests"
- touch "$RUNNER_TEMP/codex-security-platform-digests/${IMAGE_DIGEST#sha256:}"
-
- - name: Upload platform digest
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: codex-security-image-digest-${{ matrix.architecture }}
- path: ${{ runner.temp }}/codex-security-platform-digests/*
- if-no-files-found: error
- retention-days: 7
- compression-level: 0
-
- manifest:
- name: publish-and-verify-multiarchitecture-candidate
- needs:
- - authorize
- - publish-platform
- runs-on: ubuntu-24.04
- timeout-minutes: 30
- permissions:
- contents: read
- packages: write
- outputs:
- digest: ${{ steps.manifest.outputs.digest }}
- candidate: ${{ steps.manifest.outputs.candidate }}
-
- steps:
- - name: Checkout approved customer configuration
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ needs.authorize.outputs.sha }}
- persist-credentials: false
-
- - *set-up-docker-buildx
-
- - name: Download verified platform digests
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
- with:
- path: ${{ runner.temp }}/codex-security-platform-digests
- pattern: codex-security-image-digest-*
- merge-multiple: true
-
- - *sign-in-to-github-container-registry
-
- - name: Publish provisional multiarchitecture candidate
- id: manifest
- env:
- IMAGE: ${{ needs.authorize.outputs.image }}
- IMAGE_LABELS: ${{ needs.authorize.outputs.labels }}
- IMAGE_METADATA: ${{ needs.authorize.outputs.metadata }}
- RELEASE_SHA: ${{ needs.authorize.outputs.sha }}
- shell: bash
run: |
set -euo pipefail
- mapfile -t digest_files < <(
- find "$RUNNER_TEMP/codex-security-platform-digests" \
- -maxdepth 1 -type f -printf '%f\n' | sort
- )
-
- if [[ "${#digest_files[@]}" -ne 2 ]]; then
- echo 'A release must contain exactly one verified amd64 and arm64 image.' >&2
- exit 1
- fi
-
- references=()
- for digest in "${digest_files[@]}"; do
- if [[ ! "$digest" =~ ^[[:xdigit:]]{64}$ ]]; then
- echo 'The release contains an invalid platform digest.' >&2
- exit 1
- fi
- references+=("$IMAGE@sha256:$digest")
- done
-
- annotations=()
- while IFS= read -r label; do
- annotations+=(--annotation "index:$label")
- done <<< "$IMAGE_LABELS"
-
- candidate="$IMAGE:release-candidate-$RELEASE_SHA"
- docker buildx imagetools create \
- "${annotations[@]}" \
- --tag "$candidate" \
- "${references[@]}"
-
- manifest_digest="$(docker buildx imagetools inspect --format '{{.Manifest.Digest}}' "$candidate")"
- if [[ ! "$manifest_digest" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
- echo 'The registry did not return a valid multiarchitecture image digest.' >&2
- exit 1
- fi
- printf 'digest=%s\n' "$manifest_digest" >> "$GITHUB_OUTPUT"
- printf 'candidate=%s\n' "$candidate" >> "$GITHUB_OUTPUT"
-
- docker buildx imagetools inspect "$candidate" --raw |
- jq --exit-status --argjson metadata "$IMAGE_METADATA" '
- . as $index
- | all($metadata.labels | to_entries[]; $index.annotations[.key] == .value)
- and (
- [.manifests[] | select(.platform.os == "linux") | .platform.architecture]
- | (index("amd64") != null and index("arm64") != null)
- )
- ' > /dev/null
-
- - name: Verify customers can pull the candidate without GitHub credentials
- env:
- CANDIDATE: ${{ steps.manifest.outputs.candidate }}
- shell: bash
- run: |
- set -euo pipefail
- docker logout ghcr.io
- if ! docker pull "$CANDIDATE"; then
- echo '::error::The verified candidate cannot be pulled anonymously; no stable release tags have been published.'
- exit 1
- fi
- docker run --rm "$CANDIDATE" --version
- docker run --rm "$CANDIDATE" bulk-scan --help
- docker run --rm "$CANDIDATE" info --json
-
- - name: Verify hardened customer Compose against the public candidate
- env:
- CODEX_SECURITY_IMAGE: ${{ steps.manifest.outputs.candidate }}
- shell: bash
- run: source docker/verify-container-compose.sh
-
- attest:
- name: attest-verified-multiarchitecture-candidate
- needs:
- - authorize
- - manifest
- runs-on: ubuntu-24.04
- timeout-minutes: 10
- permissions:
- attestations: write
- artifact-metadata: write
- contents: read
- id-token: write
- packages: write
-
- steps:
- - *sign-in-to-github-container-registry
-
- - name: Sign verified multiarchitecture candidate provenance
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
- with:
- push-to-registry: true
- subject-name: ${{ needs.authorize.outputs.image }}
- subject-digest: ${{ needs.manifest.outputs.digest }}
-
- promote:
- name: promote-verified-and-attested-release
- needs:
- - authorize
- - manifest
- - attest
- runs-on: ubuntu-24.04
- timeout-minutes: 15
- permissions:
- contents: read
- packages: write
-
- steps:
- - name: Checkout approved immutable-version verifier
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- ref: ${{ github.sha }}
- persist-credentials: false
-
- - *set-up-docker-buildx
-
- - *sign-in-to-github-container-registry
-
- - name: Recheck immutable version and select the latest tag
- id: version
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- VERSION: ${{ needs.authorize.outputs.version }}
- MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}
- shell: bash
- run: |
- set -euo pipefail
- if [[ ! "$MANIFEST_DIGEST" =~ ^sha256:[[:xdigit:]]{64}$ ]]; then
- echo 'The verified release did not provide a valid immutable digest.' >&2
- exit 1
- fi
-
- owner="${GITHUB_REPOSITORY_OWNER,,}"
- endpoint="orgs/$owner/packages/container/codex-security"
- sh docker/verify-container-release-version.sh "$endpoint" "$VERSION" "$MANIFEST_DIGEST"
-
- - name: Promote the verified, attested, immutable image digest
- env:
- IMAGE: ${{ needs.authorize.outputs.image }}
- VERSION: ${{ needs.authorize.outputs.version }}
- PUBLISH_LATEST: ${{ steps.version.outputs.publish_latest }}
- MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}
- RELEASE_SHA: ${{ needs.authorize.outputs.sha }}
- shell: bash
- run: |
- set -euo pipefail
- tags=(--tag "$IMAGE:$VERSION" --tag "$IMAGE:sha-$RELEASE_SHA")
- if [[ "$PUBLISH_LATEST" == true ]]; then
- tags+=(--tag "$IMAGE:latest")
- fi
-
- docker buildx imagetools create \
- "${tags[@]}" \
- "$IMAGE@$MANIFEST_DIGEST"
-
- actual_digest="$(docker buildx imagetools inspect --format '{{.Manifest.Digest}}' "$IMAGE:$VERSION")"
- if [[ "$actual_digest" != "$MANIFEST_DIGEST" ]]; then
- echo '::error::The promoted stable tag does not reference the verified and attested candidate digest.'
- exit 1
- fi
-
- - name: Verify the stable release is publicly pullable
- env:
- IMAGE: ${{ needs.authorize.outputs.image }}
- VERSION: ${{ needs.authorize.outputs.version }}
- shell: bash
- run: |
- set -euo pipefail
- docker logout ghcr.io
- docker pull "$IMAGE:$VERSION"
- docker run --rm --entrypoint codex-security "$IMAGE:$VERSION" --version
-
- - name: Summarize published container release
+ id=$(gh api --method POST -H 'X-GitHub-Api-Version: 2026-03-10' \
+ "repos/$GITHUB_REPOSITORY/actions/workflows/node-github-release.yml/dispatches" \
+ -f ref=main -f "inputs[tag]=npm-v$VERSION" --jq .workflow_run_id)
+ [[ $id =~ ^[0-9]+$ ]] || exit 1
+ printf 'run-id=%s\n' "$id" >> "$GITHUB_OUTPUT"
+ printf 'Container publication for npm-v%s is tracked in the [release run](%s/%s/actions/runs/%s).\n' "$VERSION" "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$id" >> "$GITHUB_STEP_SUMMARY" || true
+
+ - name: Start release progress observer
+ if: steps.dispatch.outputs.run-id != ''
continue-on-error: true
env:
- IMAGE: ${{ needs.authorize.outputs.image }}
- VERSION: ${{ needs.authorize.outputs.version }}
- MANIFEST_DIGEST: ${{ needs.manifest.outputs.digest }}
- RELEASE_URL: ${{ fromJSON(needs.authorize.outputs.metadata).labels['org.opencontainers.image.url'] }}
- DOCUMENTATION_URL: ${{ fromJSON(needs.authorize.outputs.metadata).labels['org.opencontainers.image.documentation'] }}
- RELEASE_SHA: ${{ needs.authorize.outputs.sha }}
- shell: bash
+ GH_TOKEN: ${{ github.token }}
+ RELEASE_RUN_ID: ${{ steps.dispatch.outputs.run-id }}
run: |
- {
- printf '## Codex Security container %s\n\n' "$VERSION"
- printf 'Platforms: linux/amd64, linux/arm64.\n\n'
- printf 'Source: [%s](%s/%s/commit/%s)\n\n' \
- "$RELEASE_SHA" "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$RELEASE_SHA"
- printf '[Container guide](%s) | [Release notes](%s)\n\n' \
- "$DOCUMENTATION_URL" "$RELEASE_URL"
- printf '```bash\n'
- printf 'docker pull %s:%s@%s\n' "$IMAGE" "$VERSION" "$MANIFEST_DIGEST"
- printf 'gh attestation verify oci://%s@%s --repo %s\n' \
- "$IMAGE" "$MANIFEST_DIGEST" "$GITHUB_REPOSITORY"
- printf '```\n'
- } >> "$GITHUB_STEP_SUMMARY"
+ timeout --kill-after=5s 10s gh workflow run release-progress.yml \
+ --repo "$GITHUB_REPOSITORY" --ref main \
+ -f "run-id=$RELEASE_RUN_ID" -f watch=true
diff --git a/.github/workflows/container-validate.yml b/.github/workflows/container-validate.yml
index 89604abd9..4a65a3aab 100644
--- a/.github/workflows/container-validate.yml
+++ b/.github/workflows/container-validate.yml
@@ -7,6 +7,17 @@ on:
description: Source commit to validate; defaults to the calling workflow commit.
type: string
default: ""
+ release-version:
+ type: string
+ release-integrity:
+ type: string
+ release-tarball-artifact:
+ type: string
+ runtime-lock-artifact:
+ type: string
+ labels:
+ description: Release metadata for the OCI candidate. Omit for source validation.
+ type: string
permissions:
contents: read
@@ -32,11 +43,34 @@ jobs:
ref: ${{ inputs.ref || github.sha }}
persist-credentials: false
- name: Prepare native runtime
+ if: inputs.release-tarball-artifact == ''
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: native-universal-${{ inputs.ref || github.sha }}
path: plugins/codex-security/native/prebuilt
+ - name: Download the verified scanner and its runtime lock
+ if: inputs.release-tarball-artifact != ''
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ inputs.runtime-lock-artifact && format('{0},{1}', inputs.release-tarball-artifact, inputs.runtime-lock-artifact) || inputs.release-tarball-artifact }}
+ merge-multiple: true
+ path: ${{ runner.temp }}/scanner-artifacts
+
+ - name: Prepare the locked scanner package
+ if: inputs.release-tarball-artifact != ''
+ env:
+ RELEASE_VERSION: ${{ inputs.release-version }}
+ RELEASE_INTEGRITY: ${{ inputs.release-integrity }}
+ run: |
+ lock=$RUNNER_TEMP/scanner-artifacts/package-lock.json
+ jq -e --arg version "$RELEASE_VERSION" --arg integrity "$RELEASE_INTEGRITY" '
+ .packages["node_modules/@openai/codex-security"] |
+ .version == $version and .integrity == $integrity
+ ' "$lock" > /dev/null
+ mkdir "$RUNNER_TEMP/release-inputs"
+ node docker/prepare-release-package.mjs "$RUNNER_TEMP"/scanner-artifacts/*.tgz "$lock" "$RUNNER_TEMP/release-inputs"
+
- name: Verify customer build excludes secrets and scan data
shell: bash
run: |
@@ -74,24 +108,59 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
with:
- driver-opts: provenance-add-gha=false
+ driver-opts: ${{ !inputs.labels && 'provenance-add-gha=false' || '' }}
+
+ - name: Test release index assembly
+ if: matrix.architecture == 'amd64' && inputs.ref == '' && inputs.release-tarball-artifact == ''
+ run: bash docker/test-container-index.sh
- name: Build native customer image
+ if: inputs.labels == ''
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
env:
DOCKER_BUILD_RECORD_UPLOAD: "false"
with:
context: .
+ target: &target ${{ inputs.release-tarball-artifact && 'scanner-release' || '' }}
+ build-contexts: &release-inputs ${{ inputs.release-tarball-artifact && format('release-inputs={0}/release-inputs', runner.temp) || '' }}
load: true
platforms: linux/${{ matrix.architecture }}
push: false
tags: codex-security:release-candidate
- cache-from: type=gha,scope=codex-security-${{ matrix.architecture }}
+ cache-from: &cache-from type=gha,scope=${{ inputs.release-tarball-artifact && 'codex-security-release' || 'codex-security' }}-${{ matrix.architecture }}
cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,scope=codex-security-{0}', matrix.architecture) || '' }}
+ - name: Build the release candidate with provenance and SBOM
+ id: candidate
+ if: inputs.labels != ''
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
+ with:
+ context: .
+ target: *target
+ build-contexts: *release-inputs
+ platforms: linux/${{ matrix.architecture }}
+ labels: ${{ inputs.labels }}
+ outputs: type=oci,dest=${{ runner.temp }}/image.tar,name=ghcr.io/${{ github.repository }}:${{ inputs.release-version }}
+ provenance: mode=max
+ sbom: true
+ cache-from: *cache-from
+ cache-to: type=gha,mode=max,scope=${{ inputs.release-tarball-artifact && 'codex-security-release' || 'codex-security' }}-${{ matrix.architecture }}
+
+ - name: Load the native image from the release artifact
+ if: inputs.labels != ''
+ env:
+ DIGEST: ${{ steps.candidate.outputs.digest }}
+ run: |
+ archive="oci-archive:$RUNNER_TEMP/image.tar"
+ skopeo inspect --raw "$archive" | sha256sum | cut -d' ' -f1 | grep -Fxq "${DIGEST#sha256:}"
+ skopeo copy "$archive" docker-daemon:codex-security:release-candidate
+ printf '%s\n' "$DIGEST" > "$RUNNER_TEMP/digest"
+
- name: Verify native image
env:
EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}
+ EXPECTED_VERSION: ${{ inputs.release-version }}
+ EXPECTED_LABELS: ${{ inputs.labels }}
shell: bash
run: |
set -euo pipefail
@@ -100,7 +169,15 @@ jobs:
echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2
exit 1
fi
- docker run --rm codex-security:release-candidate --version
+ if [[ -n "$EXPECTED_LABELS" ]]; then
+ docker image inspect --format '{{json .Config.Labels}}' codex-security:release-candidate |
+ jq -e --arg labels "$EXPECTED_LABELS" '
+ . as $actual | all($labels | split("\n")[] | select(length > 0) |
+ capture("^(?<key>[^=]+)=(?<value>.*)$"); $actual[.key] == .value)
+ ' > /dev/null
+ fi
+ version=$(docker run --rm codex-security:release-candidate --version)
+ if [[ -n "$EXPECTED_VERSION" ]]; then test "$version" = "$EXPECTED_VERSION"; fi
docker run --rm codex-security:release-candidate bulk-scan --help
docker run --rm codex-security:release-candidate info --json
[[ "$(docker run --rm --entrypoint id codex-security:release-candidate -u)" == 10001 ]]
@@ -211,6 +288,20 @@ jobs:
fi
'
- "${compose[@]}" run --rm --entrypoint node codex-security \
- /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js \
- sandbox /usr/bin/true
+ "${compose[@]}" run --rm --entrypoint /bin/sh codex-security -ec '
+ cd "$(dirname "$(readlink -f /usr/local/bin/codex-security)")"
+ exec npm exec --offline -- codex sandbox /usr/bin/true
+ '
+
+ - name: Retain the tested release candidate
+ if: inputs.labels != ''
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: codex-security-oci-${{ matrix.architecture }}
+ path: |
+ ${{ runner.temp }}/image.tar
+ ${{ runner.temp }}/digest
+ if-no-files-found: error
+ retention-days: 7
+ compression-level: 0
+ overwrite: true
diff --git a/.github/workflows/node-github-release.yml b/.github/workflows/node-github-release.yml
index 19e183dad..d6dd4dcb8 100644
--- a/.github/workflows/node-github-release.yml
+++ b/.github/workflows/node-github-release.yml
@@ -36,6 +36,8 @@ jobs:
integrity: ${{ steps.artifact.outputs.integrity }}
has-action: ${{ steps.action.outputs.present }}
has-container: ${{ steps.container.outputs.present }}
+ has-wolfi: ${{ steps.container.outputs.wolfi }}
+ release-tarball-artifact: ${{ steps.container-tarball.outputs.artifact-id }}
steps:
- name: Checkout release automation
@@ -372,10 +374,23 @@ jobs:
if [[ "$RELEASE_VERSION" =~ ^0\.[0-4]\. ]]; then
exit 0
fi
- if git cat-file -e "$RELEASE_SHA:Dockerfile" 2>/dev/null; then
- echo 'present=true' >> "$GITHUB_OUTPUT"
+ git cat-file -e "$RELEASE_SHA:Dockerfile" 2>/dev/null || exit 0
+ echo 'present=true' >> "$GITHUB_OUTPUT"
+ if git cat-file -e "$RELEASE_SHA:.github/workflows/wolfi-build.yml" 2>/dev/null; then
+ echo 'wolfi=true' >> "$GITHUB_OUTPUT"
fi
+ - name: Save the verified scanner archive for both container builds
+ id: container-tarball
+ if: steps.container.outputs.wolfi == 'true'
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: container-scanner-tarball-${{ github.run_attempt }}
+ path: ${{ steps.artifact.outputs.archive }}
+ if-no-files-found: error
+ compression-level: 0
+ retention-days: 7
+
- name: Resolve published release history
id: history
shell: bash
@@ -715,18 +730,24 @@ jobs:
container:
name: publish matching container
- needs: [release, installed]
- if: needs.release.outputs.has-container == 'true'
+ needs: [release, installed, action-verify, action]
+ if: >-
+ !cancelled() && needs.release.result == 'success' && needs.installed.result == 'success' &&
+ needs.release.outputs.has-container == 'true' &&
+ (needs.release.outputs.has-wolfi != 'true' || needs.action.result == 'success')
permissions:
contents: read
packages: write
attestations: write
artifact-metadata: write
id-token: write
- uses: ./.github/workflows/container-release.yml
+ uses: ./.github/workflows/container-publish.yml
with:
release-sha: ${{ needs.release.outputs.sha }}
release-version: ${{ needs.release.outputs.version }}
+ release-integrity: ${{ needs.release.outputs.integrity }}
+ release-tarball-artifact: ${{ needs.release.outputs.release-tarball-artifact }}
+ runtime-lock-artifact: ${{ needs.action-verify.outputs.runtime-lock-artifact }}
complete:
name: release status
@@ -740,11 +761,15 @@ jobs:
HAS_ACTION: ${{ needs.release.outputs.has-action }}
CONTAINER_RESULT: ${{ needs.container.result }}
HAS_CONTAINER: ${{ needs.release.outputs.has-container }}
+ HAS_WOLFI: ${{ needs.release.outputs.has-wolfi }}
+ DEBIAN_DIGEST: ${{ needs.container.outputs.debian-digest }}
+ WOLFI_DIGEST: ${{ needs.container.outputs.wolfi-digest }}
steps:
- name: Summarize release channels
continue-on-error: true
env:
RELEASE_VERSION: ${{ needs.release.outputs.version }}
+ RELEASE_SHA: ${{ needs.release.outputs.sha }}
run: |
{
printf '## Release publication status\n\n'
@@ -753,7 +778,28 @@ jobs:
printf '| Published package installation checks | %s |\n' "$INSTALL_RESULT"
printf '| GitHub Action release | %s |\n' "$ACTION_RESULT"
printf '| GitHub Marketplace | Not checked; publish and verify separately |\n'
- printf '| Container image | %s |\n\n' "$CONTAINER_RESULT"
+ printf '| Container image | %s |\n' "$CONTAINER_RESULT"
+ if [[ -n "$DEBIAN_DIGEST" ]]; then printf '| Debian `%s` | `%s` |\n' "$RELEASE_VERSION" "$DEBIAN_DIGEST"; fi
+ if [[ -n "$WOLFI_DIGEST" ]]; then printf '| Wolfi `%s-wolfi-amd64` | `%s` |\n' "$RELEASE_VERSION" "$WOLFI_DIGEST"; fi
+ echo
+ if [[ -n "$DEBIAN_DIGEST" ]]; then
+ repo="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
+ printf '[Release source](%s/tree/%s) | [Container guide](%s/blob/%s/docker/README.md)\n\n' "$repo" "$RELEASE_SHA" "$repo" "$RELEASE_SHA"
+ printf '```bash\n'
+ for digest in "$DEBIAN_DIGEST" "$WOLFI_DIGEST"; do
+ if [[ -n "$digest" ]]; then
+ ref="ghcr.io/$GITHUB_REPOSITORY@$digest"
+ printf 'docker pull %s\ngh attestation verify oci://%s --repo %s' "$ref" "$ref" "$GITHUB_REPOSITORY"
+ if [[ -n "$WOLFI_DIGEST" ]]; then
+ signer=container-publish
+ if [[ $digest == "$WOLFI_DIGEST" ]]; then signer=publish-wolfi; fi
+ printf ' --cert-identity %s/.github/workflows/%s.yml@refs/heads/main --source-ref refs/heads/main' "$repo" "$signer"
+ fi
+ printf '\n'
+ fi
+ done
+ printf '```\n\n'
+ fi
if [[ "$HAS_ACTION" == true && "$ACTION_RESULT" == success ]]; then
printf 'Marketplace: [edit the Action release](%s/%s/releases/edit/action-v%s) to publish or verify its listing.\n\n' \
"$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$RELEASE_VERSION"
@@ -772,3 +818,7 @@ jobs:
if [[ "$HAS_CONTAINER" == true ]]; then
test "$CONTAINER_RESULT" = success
fi
+ if [[ "$HAS_WOLFI" == true ]]; then
+ test -n "$DEBIAN_DIGEST"
+ test -n "$WOLFI_DIGEST"
+ fi
diff --git a/.github/workflows/publish-wolfi.yml b/.github/workflows/publish-wolfi.yml
index ad8e5e2c1..29fdb80b4 100644
--- a/.github/workflows/publish-wolfi.yml
+++ b/.github/workflows/publish-wolfi.yml
@@ -2,19 +2,17 @@ name: Publish Wolfi scanner
on:
workflow_dispatch:
- pull_request:
- paths:
- - .github/workflows/publish-wolfi.yml
- - docker/wolfi/**
- - LICENSE
- - docker/entrypoint.sh
- - docker/git-credential.sh
- - docker/codex-security.apparmor
- - docker/codex-security-seccomp.json
- - github-action/scripts/setup-ubuntu-sandbox.sh
- - sdk/typescript/scripts/is-main.mjs
- - sdk/typescript/scripts/package-provenance.mjs
- - sdk/typescript/scripts/release-automation.mjs
+ inputs:
+ release-version:
+ description: Published scanner version receiving a Wolfi OS update.
+ type: string
+ required: true
+ workflow_call:
+ inputs:
+ artifact: {type: string, required: true}
+ digest: {type: string, required: true}
+ tag: {type: string, required: true}
+ sbom-sha: {type: string, required: true}
permissions: {}
@@ -22,76 +20,43 @@ env:
IMAGE: ghcr.io/openai/codex-security
jobs:
- build:
- name: Build and smoke-test Linux amd64
- runs-on: ubuntu-24.04
- timeout-minutes: 60
+ os-update:
+ if: >-
+ inputs.release-version != '' && github.event_name == 'workflow_dispatch' &&
+ github.repository == 'openai/codex-security' && github.ref == 'refs/heads/main' && github.ref_protected
+ uses: ./.github/workflows/wolfi-build.yml
permissions:
contents: read
- outputs:
- artifact: ${{ steps.upload.outputs.artifact-id }}
- digest: ${{ steps.prepare.outputs.digest }}
- tag: ${{ steps.prepare.outputs.tag }}
- sbom-sha: ${{ steps.prepare.outputs.sbom-sha }}
+ attestations: read
+ with:
+ release-version: ${{ inputs.release-version }}
+ os-update: true
+
+ authorize:
+ needs: os-update
+ if: needs.os-update.outputs.existing != 'true'
+ runs-on: ubuntu-24.04
+ environment: container
steps:
- - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- fetch-depth: 0
- persist-credentials: false
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
- with:
- node-version: "24.15.0"
- package-manager-cache: false
- - name: Build and test on native Linux
- run: bash docker/wolfi/ci-build.sh "$RUNNER_TEMP/wolfi"
- - name: Prepare the tested digest for publication
- id: prepare
- shell: bash
- run: |
- set -euo pipefail
- out=$RUNNER_TEMP/wolfi
- candidate=$RUNNER_TEMP/candidate
- mkdir "$candidate"
- digest=$(python3 docker/wolfi/to-oci.py "$out/image.tar" "$out/verification.json" "$candidate/layout")
- skopeo inspect --raw "oci:$candidate/layout:wolfi" | sha256sum | cut -d' ' -f1 | grep -Fxq "${digest#sha256:}"
- version=$(jq -er '.installed_npm[] | select(.path == "node_modules/@openai/codex-security") | .version' "$out/public-components.json")
- [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
- release_sha=$(git rev-parse --verify "refs/tags/npm-v$version^{commit}")
- bash docker/wolfi/verify-npm-release.sh "$out/public-components.json" "$version" "$release_sha"
- recorded_source=$(docker run --rm --network=none --pull=never --entrypoint /usr/bin/node \
- codex-security:wolfi-amd64 -p 'require("/usr/share/licenses/codex-security/SOURCES.json").scanner_source')
- [[ $recorded_source == "https://github.com/openai/codex-security/tree/$release_sha" ]]
- python3 docker/wolfi/release-sbom.py "$out/sbom/sbom-x86_64.spdx.json" "$out/public-components.json" "$candidate/sbom.spdx.json"
- pdfjs=$(jq -er '.installed_npm[] | select(.path == "node_modules/pdfjs-dist") | .version' "$out/public-components.json")
- jq -e --arg purl "pkg:npm/pdfjs-dist@$pdfjs" 'any(.packages[].externalRefs[]?; .referenceLocator == $purl)' \
- "$candidate/sbom.spdx.json" > /dev/null
- sbom_sha=$(sha256sum "$candidate/sbom.spdx.json" | cut -d' ' -f1)
- revision=$(jq -er '.image_revision | numbers | select(. >= 0 and . == floor)' "$out/build-inputs.json")
- tag=$version-wolfi-amd64
- if [[ $revision != 0 ]]; then tag+=-r$revision; fi
- printf 'digest=%s\ntag=%s\nsbom-sha=%s\n' "$digest" "$tag" "$sbom_sha" >> "$GITHUB_OUTPUT"
- printf 'Scanner source: %s\n\nRecipe commit: %s\n\nTested digest: %s\n' "$release_sha" "$GITHUB_SHA" "$digest" >> "$GITHUB_STEP_SUMMARY"
- - name: Retain the tested image and SBOM for the protected job
- if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' && github.ref_protected
- id: upload
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
- with:
- name: wolfi-amd64-${{ github.run_attempt }}
- path: ${{ runner.temp }}/candidate
- if-no-files-found: error
- compression-level: 0
- retention-days: 7
+ - name: Record approved Wolfi OS update
+ env:
+ TAG: ${{ needs.os-update.outputs.tag }}
+ DIGEST: ${{ needs.os-update.outputs.digest }}
+ run: printf 'Approved %s at %s\n' "$TAG" "$DIGEST"
publish:
- name: Approve and publish the Wolfi variant
- needs: build
- if: github.event_name == 'workflow_dispatch' && github.repository == 'openai/codex-security' && github.ref == 'refs/heads/main' && github.ref_protected
+ name: Publish verified Wolfi variant
+ needs: [os-update, authorize]
+ if: >-
+ always() && !cancelled() && github.repository == 'openai/codex-security' &&
+ github.ref == 'refs/heads/main' && github.ref_protected &&
+ (needs.authorize.result == 'success' ||
+ (inputs.artifact != '' && github.workflow_ref == 'openai/codex-security/.github/workflows/node-github-release.yml@refs/heads/main'))
runs-on: ubuntu-24.04
timeout-minutes: 30
- environment: container
concurrency:
group: publish-wolfi-amd64
- cancel-in-progress: false
+ queue: max
permissions:
contents: read
packages: write
@@ -99,13 +64,13 @@ jobs:
id-token: write
artifact-metadata: write
env:
- DIGEST: ${{ needs.build.outputs.digest }}
- TAG: ${{ needs.build.outputs.tag }}
- SBOM_SHA: ${{ needs.build.outputs.sbom-sha }}
+ DIGEST: ${{ inputs.digest || needs.os-update.outputs.digest }}
+ TAG: ${{ inputs.tag || needs.os-update.outputs.tag }}
+ SBOM_SHA: ${{ inputs.sbom-sha || needs.os-update.outputs.sbom-sha }}
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
- artifact-ids: ${{ needs.build.outputs.artifact }}
+ artifact-ids: ${{ inputs.artifact || needs.os-update.outputs.artifact }}
merge-multiple: true
path: ${{ runner.temp }}/candidate
- name: Check the public package, immutable tag and local artifacts
@@ -116,7 +81,10 @@ jobs:
set -euo pipefail
[[ $TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+-wolfi-amd64(-r[1-9][0-9]*)?$ && $DIGEST =~ ^sha256:[0-9a-f]{64}$ ]]
printf '%s %s\n' "$SBOM_SHA" "$RUNNER_TEMP/candidate/sbom.spdx.json" | sha256sum -c -
- skopeo inspect --raw "oci:$RUNNER_TEMP/candidate/layout:wolfi" | sha256sum | cut -d' ' -f1 | grep -Fxq "${DIGEST#sha256:}"
+ manifest=$RUNNER_TEMP/wolfi-manifest.json
+ skopeo inspect --raw "oci:$RUNNER_TEMP/candidate/layout:wolfi" > "$manifest"
+ printf '%s %s\n' "${DIGEST#sha256:}" "$manifest" | sha256sum -c -
+ jq -e --arg tag "$TAG" '.annotations["io.openai.codex-security.release-tag"] == $tag' "$manifest" >/dev/null
package=orgs/openai/packages/container/codex-security
gh api "$package" | jq -e '.visibility == "public"' > /dev/null
existing=$(gh api --paginate --slurp "$package/versions?per_page=100" |
@@ -168,4 +136,4 @@ jobs:
skopeo copy --preserve-digests --src-no-creds "docker://$IMAGE@$DIGEST" "docker://$IMAGE:$TAG"
fi
skopeo inspect --no-creds --raw "docker://$IMAGE:$TAG" | sha256sum | cut -d' ' -f1 | grep -Fxq "${DIGEST#sha256:}"
- printf 'Published \x60%s:%s\x60 at \x60%s\x60.\n' "$IMAGE" "$TAG" "$DIGEST" >> "$GITHUB_STEP_SUMMARY"
+ printf 'Published \x60%s:%s\x60 at \x60%s\x60.\n' "$IMAGE" "$TAG" "$DIGEST" >> "$GITHUB_STEP_SUMMARY" || true
diff --git a/.github/workflows/wolfi-build.yml b/.github/workflows/wolfi-build.yml
new file mode 100644
index 000000000..18883a9f8
--- /dev/null
+++ b/.github/workflows/wolfi-build.yml
@@ -0,0 +1,203 @@
+name: Build Wolfi scanner
+
+on:
+ workflow_call:
+ inputs:
+ release-version: {type: string, required: true}
+ release-sha: {type: string}
+ release-integrity: {type: string}
+ release-tarball-artifact: {type: string}
+ runtime-lock-artifact: {type: string}
+ os-update: {type: boolean, default: false}
+ outputs:
+ artifact: {value: "${{ jobs.build.outputs.artifact }}"}
+ digest: {value: "${{ jobs.build.outputs.digest }}"}
+ tag: {value: "${{ jobs.build.outputs.tag }}"}
+ sbom-sha: {value: "${{ jobs.build.outputs.sbom-sha }}"}
+ existing: {value: "${{ jobs.build.outputs.existing }}"}
+ pull_request:
+ paths:
+ - Dockerfile
+ - .dockerignore
+ - Dockerfile.dockerignore
+ - .github/workflows/container-validate.yml
+ - docker/verify-container-sandbox.sh
+ - .github/workflows/publish-wolfi.yml
+ - .github/workflows/wolfi-build.yml
+ - docker/wolfi/**
+ - LICENSE
+ - docker/prepare-release-package.mjs
+ - docker/entrypoint.sh
+ - docker/git-credential.sh
+ - docker/codex-security.apparmor
+ - docker/codex-security-seccomp.json
+ - github-action/scripts/setup-ubuntu-sandbox.sh
+ - sdk/typescript/scripts/is-main.mjs
+ - sdk/typescript/scripts/package-provenance.mjs
+ - sdk/typescript/scripts/release-automation.mjs
+
+permissions:
+ contents: read
+
+jobs:
+ fixture:
+ name: Verify the PR scanner fixture
+ if: github.event_name == 'pull_request'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 10
+ outputs:
+ artifact: ${{ steps.fixture.outputs.artifact-id }}
+ version: ${{ steps.known.outputs.version }}
+ sha: ${{ steps.known.outputs.sha }}
+ integrity: ${{ steps.known.outputs.integrity }}
+ steps:
+ - &checkout
+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+ - &setup-node
+ uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ with:
+ node-version: "24.15.0"
+ package-manager-cache: false
+ - name: Exercise release staging on a known published scanner
+ id: known
+ shell: bash
+ run: |
+ set -euo pipefail
+ jq -e '.image_revision | numbers | . >= 0 and . == floor' docker/wolfi/build-inputs.json > /dev/null
+ fixture=$RUNNER_TEMP/scanner-fixture
+ mkdir "$fixture"
+ cp docker/wolfi/payload/package-lock.json "$fixture/"
+ lock=$fixture/package-lock.json
+ version=$(jq -er '.packages["node_modules/@openai/codex-security"].version' "$lock")
+ git fetch --no-tags https://github.com/openai/codex-security.git "+refs/tags/npm-v$version:refs/tags/npm-v$version"
+ sha=$(git rev-parse --verify "refs/tags/npm-v$version^{commit}")
+ archive=$fixture/$(npm pack --ignore-scripts --silent --pack-destination "$fixture" \
+ --registry=https://registry.npmjs.org "@openai/codex-security@$version")
+ bash docker/wolfi/verify-npm-release.sh "$lock" "$version" "$sha" "$archive"
+ integrity=$(jq -er '.packages["node_modules/@openai/codex-security"].integrity' "$lock")
+ mv "$archive" "$fixture/scanner.tgz"
+ printf 'version=%s\nsha=%s\nintegrity=%s\n' "$version" "$sha" "$integrity" >> "$GITHUB_OUTPUT"
+ - name: Share the verified scanner fixture
+ id: fixture
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: verified-scanner-fixture-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/scanner-fixture
+ if-no-files-found: error
+ retention-days: 1
+
+ build:
+ name: Build and smoke-test Linux amd64
+ needs: fixture
+ if: ${{ !cancelled() && (github.event_name != 'pull_request' || needs.fixture.result == 'success') }}
+ runs-on: ubuntu-24.04
+ timeout-minutes: 60
+ permissions:
+ contents: read
+ attestations: read
+ outputs:
+ artifact: ${{ steps.upload.outputs.artifact-id }}
+ digest: ${{ steps.prepare.outputs.digest || steps.release.outputs.digest }}
+ tag: ${{ steps.release.outputs.tag }}
+ existing: ${{ steps.release.outputs.existing }}
+ sbom-sha: ${{ steps.prepare.outputs.sbom-sha }}
+ steps:
+ - *checkout
+ - *setup-node
+ - name: Download the verified npm archive
+ if: needs.fixture.outputs.artifact != '' || inputs.release-tarball-artifact != ''
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ needs.fixture.outputs.artifact || inputs.release-tarball-artifact }}
+ merge-multiple: true
+ path: ${{ runner.temp }}/scanner
+ - name: Download the verified runtime lock
+ if: inputs.runtime-lock-artifact != ''
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
+ with:
+ artifact-ids: ${{ inputs.runtime-lock-artifact }}
+ merge-multiple: true
+ path: ${{ runner.temp }}/scanner
+ - name: Use the verified PR fixture
+ if: github.event_name == 'pull_request'
+ env:
+ VERSION: ${{ needs.fixture.outputs.version }}
+ SHA: ${{ needs.fixture.outputs.sha }}
+ INTEGRITY: ${{ needs.fixture.outputs.integrity }}
+ run: |
+ # The Wolfi build uses the scanner commit's timestamp even on forks without upstream tags.
+ git cat-file -e "$SHA^{commit}" || git fetch --no-tags https://github.com/openai/codex-security.git "$SHA"
+ printf 'SCANNER_TARBALL=%s\nSCANNER_RUNTIME_LOCK=%s\nSCANNER_VERSION=%s\nSCANNER_SHA=%s\nSCANNER_INTEGRITY=%s\n' \
+ "$RUNNER_TEMP/scanner/scanner.tgz" "$RUNNER_TEMP/scanner/package-lock.json" "$VERSION" "$SHA" "$INTEGRITY" >> "$GITHUB_ENV"
+ - name: Resolve immutable release inputs
+ if: inputs.release-version != ''
+ id: release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RELEASE_VERSION: ${{ inputs.release-version }}
+ RELEASE_SHA: ${{ inputs.release-sha }}
+ RELEASE_INTEGRITY: ${{ inputs.release-integrity }}
+ OS_UPDATE: ${{ inputs.os-update }}
+ run: bash docker/wolfi/resolve-release.sh
+ - name: Build and test on native Linux
+ if: steps.release.outputs.existing != 'true'
+ run: bash docker/wolfi/ci-build.sh "$RUNNER_TEMP/wolfi"
+ - name: Prepare the tested digest for publication
+ if: steps.release.outputs.existing != 'true'
+ id: prepare
+ shell: bash
+ run: |
+ set -euo pipefail
+ out=$RUNNER_TEMP/wolfi
+ if [[ $GITHUB_EVENT_NAME == pull_request ]]; then
+ expected=$(jq -er .payload_sha256 docker/wolfi/build-inputs.json)
+ jq -e --arg sha "$expected" '.payload_sha256 == $sha' "$out/build-inputs.json" >/dev/null
+ fi
+ candidate=$RUNNER_TEMP/candidate
+ mkdir "$candidate"
+ digest=$(python3 docker/wolfi/to-oci.py "$out/image.tar" "$out/verification.json" "$candidate/layout")
+ manifest=$RUNNER_TEMP/wolfi-manifest.json
+ skopeo inspect --raw "oci:$candidate/layout:wolfi" > "$manifest"
+ printf '%s %s\n' "${digest#sha256:}" "$manifest" | sha256sum -c -
+ jq -e --arg tag "${SCANNER_RELEASE_TAG:-$SCANNER_VERSION-wolfi-amd64}" \
+ '.annotations["io.openai.codex-security.release-tag"] == $tag' "$manifest" >/dev/null
+ version=$(jq -er '.installed_npm[] | select(.path == "node_modules/@openai/codex-security") | .version' "$out/public-components.json")
+ [[ $version == "$SCANNER_VERSION" ]]
+ jq -e --arg sri "$SCANNER_INTEGRITY" 'any(.installed_npm[]; .path == "node_modules/@openai/codex-security" and .integrity == $sri)' "$out/public-components.json" >/dev/null
+ docker run --rm --network=none --pull=never --entrypoint /usr/bin/node codex-security:wolfi-amd64 \
+ -p 'require("/usr/share/licenses/codex-security/SOURCES.json").scanner_source' | grep -Fxq "https://github.com/openai/codex-security/tree/$SCANNER_SHA"
+ if [[ -f "$RUNNER_TEMP/scanner/base-sources.json" ]]; then
+ docker run --rm --network=none --pull=never --entrypoint cat codex-security:wolfi-amd64 \
+ /usr/share/licenses/codex-security/SOURCES.json | cmp - "$RUNNER_TEMP/scanner/base-sources.json"
+ if [[ -n ${BASE_PAYLOAD_SHA:-} ]]; then
+ jq -e --arg sha "$BASE_PAYLOAD_SHA" '.payload_sha256 == $sha' "$out/build-inputs.json" >/dev/null
+ fi
+ fi
+ python3 docker/wolfi/release-sbom.py "$out/sbom/sbom-x86_64.spdx.json" "$out/public-components.json" "$candidate/sbom.spdx.json"
+ pdfjs=$(jq -er '.installed_npm[] | select(.path == "node_modules/pdfjs-dist") | .version' "$out/public-components.json")
+ jq -e --arg purl "pkg:npm/pdfjs-dist@$pdfjs" 'any(.packages[].externalRefs[]?; .referenceLocator == $purl)' "$candidate/sbom.spdx.json" >/dev/null
+ printf 'digest=%s\nsbom-sha=%s\n' "$digest" "$(sha256sum "$candidate/sbom.spdx.json" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
+ printf 'Scanner source: %s\n\nRecipe commit: %s\n\nWolfi digest: %s\n' "$SCANNER_SHA" "$(git rev-parse HEAD)" "$digest" >> "$GITHUB_STEP_SUMMARY" || true
+ - name: Retain the tested image and SBOM for the protected job
+ if: inputs.release-version != '' && steps.release.outputs.existing != 'true'
+ id: upload
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
+ with:
+ name: wolfi-amd64-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate
+ if-no-files-found: error
+ compression-level: 0
+ retention-days: 7
+
+ debian-pr:
+ name: Smoke-test the Debian release target
+ if: github.event_name == 'pull_request'
+ needs: fixture
+ uses: ./.github/workflows/container-validate.yml
+ with:
+ release-version: ${{ needs.fixture.outputs.version }}
+ release-integrity: ${{ needs.fixture.outputs.integrity }}
+ release-tarball-artifact: ${{ needs.fixture.outputs.artifact }}
diff --git a/Dockerfile b/Dockerfile
index 6201e67c1..36dfcfb7f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -25,7 +25,7 @@ RUN pnpm run types \
&& pnpm pack --pack-destination /build/package \
&& node scripts/check-package.mjs /build/package/*.tgz
-FROM node:26.12.1-bookworm-slim@sha256:28147155d47dc31abe0a46e0d12b59b2fb3d0a2dcc5dc65fce76a074180b16fe AS scanner
+FROM node:26.12.1-bookworm-slim@sha256:28147155d47dc31abe0a46e0d12b59b2fb3d0a2dcc5dc65fce76a074180b16fe AS runtime
LABEL org.opencontainers.image.title="Codex Security" \
org.opencontainers.image.description="Codex Security scanner" \
@@ -39,16 +39,6 @@ RUN apt-get update \
python3 \
&& rm -rf /var/lib/apt/lists/*
-COPY --from=package /build/package/ /tmp/codex-security-package/
-
-RUN npm install --global --include=optional --no-audit --no-fund \
- /tmp/codex-security-package/*.tgz \
- && node /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js --version \
- && codex-security --version \
- && codex-security bulk-scan --help \
- && rm -rf /tmp/codex-security-package \
- && npm cache clean --force
-
COPY --chmod=0555 docker/entrypoint.sh /usr/local/bin/codex-security-entrypoint
COPY --chmod=0555 docker/git-credential.sh /usr/local/bin/codex-security-git-credential
@@ -57,14 +47,39 @@ RUN groupadd --gid 10001 codex-security \
&& mkdir -p /input /output /state \
&& chown 10001:10001 /output /state
-ENV CODEX_HOME=/state \
- CODEX_SECURITY_STATE_DIR=/output/.codex-security-state \
+ENV CODEX_SECURITY_STATE_DIR=/output/.codex-security-state \
GIT_TERMINAL_PROMPT=0 \
- HOME=/state \
PYTHON=/usr/bin/python3
-USER 10001:10001
WORKDIR /state
ENTRYPOINT ["/usr/local/bin/codex-security-entrypoint"]
CMD ["--help"]
+
+# Release builds supply a verified npm tarball and a frozen runtime lock.
+FROM runtime AS scanner-release
+RUN --mount=type=bind,from=release-inputs,target=/tmp/scanner,rw \
+ cd /tmp/scanner \
+ && npm ci --ignore-scripts --include=optional --no-audit --no-fund \
+ && node node_modules/@openai/codex/bin/codex.js --version \
+ && mkdir /opt/codex-security \
+ && mv node_modules /opt/codex-security/ \
+ && ln -s /opt/codex-security/node_modules/.bin/codex-security /usr/local/bin/codex-security \
+ && ln -s /opt/codex-security/node_modules/.bin/cs /usr/local/bin/cs \
+ && npm cache clean --force
+ENV HOME=/state CODEX_HOME=/state
+USER 10001:10001
+
+# Local and pull request builds package the current checkout.
+FROM runtime AS scanner
+COPY --from=package /build/package/ /tmp/codex-security-package/
+
+RUN npm install --global --include=optional --no-audit --no-fund \
+ /tmp/codex-security-package/*.tgz \
+ && node /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js --version \
+ && codex-security --version \
+ && codex-security bulk-scan --help \
+ && rm -rf /tmp/codex-security-package \
+ && npm cache clean --force
+ENV HOME=/state CODEX_HOME=/state
+USER 10001:10001
diff --git a/RELEASING.md b/RELEASING.md
index 2f9eafac7..75135fdb0 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -366,25 +366,19 @@ The npm package and CLI GitHub release become public before the installation and
Action and container checks finish. Use the final workflow result before
announcing that the automated release is complete.
-After the installed-package checks pass, `node-github-release` calls
-`container-release` with the verified npm version and source commit. Native
-binaries, Docker builds, OCI revision labels, and image tags all use that commit,
-including when the release is older than `main`. Publication still requires
-approval in the protected `container` environment. The final status waits for
-both architectures, public pulls, attestation, and stable tag promotion.
-Coordinated container publication starts at 0.5.0. Earlier releases use older
-container and native build contracts, so their recovery runs continue to publish
-npm and the Action without requiring this container pipeline. Sources without a
-Dockerfile also skip container publication.
-
-To publish a missing container for an existing npm release, dispatch
-`node-github-release` on `main` with its `npm-vX.Y.Z` tag and approve the container
-deployment after validation. Recovery verifies and reuses an existing container
-only when its version, source commit, architectures, attestation, public pull, and
-immutable tag checks pass. It does not rebuild or overwrite that version.
-Standalone `container-vX.Y.Z` and manual `container-release` triggers remain
-available.
-See [Container releases](docker/README.md) for publication and verification.
+For new scanner releases, `node-github-release` publishes the matching Action
+before starting the Debian and Wolfi builders. The Action distribution records
+the runtime dependency lock used by both images with the verified npm tarball. Review the native
+build results for Debian (amd64 and arm64) and Wolfi (amd64), then approve one
+`container` deployment for both. The coordinated release requires both public
+version tags to pass verification.
+
+To recover a missing image, dispatch `node-github-release` on `main` with the
+original `npm-vX.Y.Z` tag. Recovery follows the capabilities of the tagged
+source. Releases from 0.5.0 with a Dockerfile but without coordinated Wolfi
+builds require only Debian. Earlier releases or releases without a Dockerfile
+skip containers. For retry instructions and independent Wolfi OS revisions, see
+[Container releases](docker/README.md#publishing).
## Publish to GitHub Marketplace
@@ -424,6 +418,8 @@ Check the published state before announcing the release:
- The exact-version published installation checks succeeded.
- For releases at or after 0.5.0 with a Dockerfile, container publication
succeeded and the version tag is publicly pullable on Linux `amd64` and `arm64`.
+ For coordinated Wolfi releases, verify `X.Y.Z-wolfi-amd64` is publicly
+ pullable on Linux `amd64` as well.
- For releases with the Action, `action-vX.Y.Z` points to the distribution
commit recorded in its manifest, whose parent is the CLI release commit.
Its companion GitHub Release contains the manifest and SBOM, links to the
diff --git a/docker/README.md b/docker/README.md
index 8adc454ae..8e9a12095 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -1,19 +1,20 @@
# Container releases
-`container-release` publishes `ghcr.io/openai/codex-security` from the default
-`scanner` Docker target. The image runs the scanner CLI; saved-scan
-deduplication uses the runner's local SQLite database directly.
+Each scanner release publishes two images to `ghcr.io/openai/codex-security`
+from the same verified npm tarball and runtime dependency lock. Both run the
+scanner CLI and use the runner's local SQLite database for saved-scan deduplication.
-Releases use the SDK package version, native Linux `amd64`/`arm64` builds,
-BuildKit SBOMs and maximum-mode provenance, and a GitHub provenance attestation.
-Each native image passes scanner checks before
-publishing the multiarchitecture manifest. Anonymous
-pulls and attestation must succeed before promoting version, `sha-<commit>`, and
-`latest` tags. Stable version tags cannot be overwritten.
+| Tag | Image | Platforms |
+| ----------------------------------------- | --------------------------------- | --------------------- |
+| `X.Y.Z`, `sha-<scanner-commit>`, `latest` | Debian | Linux amd64 and arm64 |
+| `X.Y.Z-wolfi-amd64` | Wolfi | Linux amd64 |
+| `X.Y.Z-wolfi-amd64-rN` | Wolfi OS update for scanner X.Y.Z | Linux amd64 |
+
+Version tags are immutable. Only the newest stable Debian release gets `latest`.
## Image metadata and verification
-Release images include OCI metadata in each platform's image labels and in the
+Debian release images include OCI metadata in each platform's image labels and in the
final multiarchitecture index: title, description, source, license, vendor,
version, source commit, build timestamp, release notes, and documentation pinned
to that commit. GHCR reads the multiarchitecture description from the index,
@@ -35,10 +36,17 @@ digest="$(docker buildx imagetools inspect "$image:$version" --format '{{.Manife
reference="$image@$digest"
docker buildx imagetools inspect "$reference" --raw | jq '.annotations'
-gh attestation verify "oci://$reference" --repo openai/codex-security
+gh attestation verify "oci://$reference" --repo openai/codex-security \
+ --cert-identity 'https://github.com/openai/codex-security/.github/workflows/container-publish.yml@refs/heads/main' \
+ --source-ref refs/heads/main
docker pull "$reference"
```
+Older Debian releases were signed by `container-release.yml`. For those releases,
+use that filename in the certificate identity. For an older image published from
+a `container-vVERSION` tag, use `refs/tags/container-vVERSION` for both refs
+and pass `--source-digest` with the release commit.
+
Set `CODEX_SECURITY_IMAGE` to the verified
`reference` when using Compose. The index selects the native `amd64` or `arm64`
image. Its `unknown/unknown` entries contain the per-platform SBOM and build
@@ -82,35 +90,37 @@ and [package access settings](https://docs.github.com/en/packages/learn-github-p
## Publishing
-Starting with 0.5.0, the coordinated `node-github-release` workflow calls
-`container-release` after verifying the published npm package and its installation. It supplies the npm
-release version and exact source commit; native binaries and Docker images are
-built from that source even when `main` has advanced. Approve the `container`
-environment deployment after validation. The coordinated release cannot finish
-successfully until the container has been published and verified.
-
-To backfill a missing image, dispatch `node-github-release` on `main` with the
-existing `npm-v<version>` tag for version 0.5.0 or later. Earlier release recovery
-skips the new container pipeline because those source trees use older build
-contracts. Standalone publication also supports pushing
-`container-v<version>` matching the SDK package version, or running
-`container-release` manually on `main`. Releases require a commit on protected
-`main`; pull requests only build and test.
-
-BuildKit provenance and OCI revision labels identify the source checkout. The
-GitHub attestation identifies the workflow run that built and promoted the image;
-for a coordinated backfill, that automation can be newer than the release source.
-
-If the version already exists, the workflow verifies its source revision,
-architectures, GitHub attestation, anonymous pull, and immutable tags, then reuses
-it without approval or publication. A mismatched image fails recovery.
-
-If a release fails, fix the cause and rerun failed jobs, or dispatch recovery on
-`main` to use updated automation. Promotion retries
-require the existing stable version to reference the verified digest. If a newer
-stable version exists, promotion leaves `latest` untouched; otherwise a retry
-also requires `latest` to reference that digest. `bootstrap` and
-`release-candidate-<commit>` tags are not consumer releases.
+After verifying the published npm tarball and installation, `node-github-release`
+publishes the matching Action. Its immutable `action-vX.Y.Z` tag preserves the
+runtime lock for future backfills. The workflow passes the verified archive and
+lock to `container-publish`. Debian builds on amd64 and arm64 using the
+Dockerfile at the scanner release commit. Wolfi builds on amd64 using the
+recipe at the protected `main` commit selected for the run. Review the build summaries, then
+approve one deployment to the protected `container` environment for both
+images. Publication uses the tested digests, verifies anonymous pulls, and
+attests the images before promoting their version tags. Debian carries BuildKit
+SBOMs and maximum-mode provenance. Wolfi carries build provenance and an SPDX
+inventory of its OS packages, installed npm packages, and native components.
+
+To backfill a release, dispatch `node-github-release` on protected `main` with
+the original `npm-vX.Y.Z` tag. A manual `container-release` run on `main`
+requests the coordinated release for the current package version. Pushing a
+`container-vX.Y.Z` tag runs the container workflow at the tagged commit.
+The release source determines which images are required.
+Sources from 0.5.0 onward with a Dockerfile but predating coordinated Wolfi
+builds use the original Debian release path. Earlier releases skip image
+publication. On a backfill, Wolfi can use refreshed OS pins from protected
+`main` with the original scanner tarball and runtime lock. If the original Wolfi
+tag already passes the source, lock, and attestation checks, the workflow
+reuses its digest.
+
+Promotion updates tags separately. If publication stops partway through, rerun
+the failed jobs to reuse the retained artifacts. The publisher verifies existing
+version tags and refuses to replace a different digest. The `release status`
+summary lists both digests when the coordinated release finishes. For a Wolfi
+OS update between scanner releases, see [Wolfi-only OS updates](wolfi/README.md#wolfi-only-os-updates).
+The `bootstrap` and `release-candidate-<commit>` tags are for registry setup
+and release validation.
## Workflow runner
@@ -150,7 +160,7 @@ docker build --target scanner -t codex-security:local .
export CODEX_SECURITY_IMAGE=codex-security:local
```
-For a local Linux amd64 build of the pinned npm release on Wolfi, see the
+To build the Linux amd64 Wolfi image locally, see the
[melange and apko recipe](wolfi/README.md).
The existing `CODEX_SECURITY_RESULTS` and `CODEX_SECURITY_STATE` settings select
diff --git a/docker/prepare-container-index.sh b/docker/prepare-container-index.sh
new file mode 100644
index 000000000..4ad475e6d
--- /dev/null
+++ b/docker/prepare-container-index.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+# Combine the tested BuildKit archives into a release index without rewriting
+# their runnable manifests, attestation manifests, or layers.
+set -euo pipefail
+
+amd64=$1 arm64=$2 layout=$3
+mkdir "$layout"
+indexes=()
+for arch in amd64 arm64; do
+ archive=$amd64
+ if [[ $arch == arm64 ]]; then archive=$arm64; fi
+ tar -xf "$archive" -C "$layout" blobs oci-layout index.json
+ # BuildKit's layout index points to its build result. That inner index contains
+ # both the native manifest and its SBOM/provenance attestation descriptor.
+ digest=$(jq -er '.manifests | select(length == 1) | .[0].digest' "$layout/index.json")
+ [[ $digest =~ ^sha256:[0-9a-f]{64}$ ]]
+ index="$layout/blobs/sha256/${digest#sha256:}"
+ jq -e --arg arch "$arch" '
+ [.manifests[] | select(.platform.os == "linux") | .platform.architecture] == [$arch]
+ ' "$index" > /dev/null
+ indexes+=("$index")
+done
+
+index="$layout/release-index.json"
+jq -cs --argjson metadata "$IMAGE_METADATA" '
+ .[0] + {manifests: map(.manifests[]), annotations: $metadata.labels}
+' "${indexes[@]}" > "$index"
+digest=$(sha256sum "$index" | cut -d' ' -f1)
+size=$(wc -c < "$index")
+mv "$index" "$layout/blobs/sha256/$digest"
+jq -n --arg digest "sha256:$digest" --argjson size "$size" '{
+ schemaVersion: 2,
+ manifests: [{
+ mediaType: "application/vnd.oci.image.index.v1+json", digest: $digest, size: $size,
+ annotations: {"org.opencontainers.image.ref.name": "scanner"}
+ }]
+}' > "$layout/index.json"
+printf 'sha256:%s\n' "$digest"
diff --git a/docker/prepare-release-package.mjs b/docker/prepare-release-package.mjs
new file mode 100644
index 000000000..79e680643
--- /dev/null
+++ b/docker/prepare-release-package.mjs
@@ -0,0 +1,28 @@
+// Prepare an npm ci consumer that reads the scanner from the verified archive.
+// Keep every dependency and integrity from the release runtime lock.
+import assert from "node:assert/strict";
+import { createHash } from "node:crypto";
+import { copyFileSync, readFileSync, writeFileSync } from "node:fs";
+import { join, resolve } from "node:path";
+
+const [archive, runtimeLock, directory] = process.argv.slice(2);
+const lock = JSON.parse(readFileSync(runtimeLock, "utf8"));
+const scanner = lock.packages["node_modules/@openai/codex-security"];
+const integrity =
+ "sha512-" +
+ createHash("sha512").update(readFileSync(archive)).digest("base64");
+assert.equal(
+ scanner.integrity,
+ integrity,
+ "Scanner archive differs from the release runtime lock",
+);
+
+const localArchive = join(directory, "scanner.tgz");
+if (resolve(archive) !== resolve(localArchive))
+ copyFileSync(archive, localArchive);
+scanner.resolved = "file:scanner.tgz";
+writeFileSync(
+ join(directory, "package.json"),
+ JSON.stringify(lock.packages[""]),
+);
+writeFileSync(join(directory, "package-lock.json"), JSON.stringify(lock));
diff --git a/docker/test-container-index.sh b/docker/test-container-index.sh
new file mode 100644
index 000000000..c3774c342
--- /dev/null
+++ b/docker/test-container-index.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+# Exercise the release index with BuildKit's OCI layout and attestation manifests.
+set -euo pipefail
+
+prepare=$(realpath "$(dirname "$0")/prepare-container-index.sh")
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+cd "$work"
+mkdir context
+printf 'FROM scratch\nCOPY platform /platform\n' > context/Dockerfile
+for arch in amd64 arm64; do
+ echo "$arch" > context/platform
+ docker buildx build --platform "linux/$arch" --provenance=mode=max \
+ --output "type=oci,dest=$arch.tar,name=ghcr.io/openai/codex-security:1.2.3" context
+ skopeo inspect --raw "oci-archive:$arch.tar" > "$arch.json"
+done
+
+export IMAGE_METADATA='{"labels":{"org.opencontainers.image.version":"1.2.3"}}'
+digest=$(bash "$prepare" amd64.tar arm64.tar release)
+skopeo copy --all --preserve-digests --digestfile copied.digest oci:release:scanner oci:copied:scanner
+[[ $(cat copied.digest) == "$digest" ]]
+skopeo inspect --raw oci:copied:scanner > copied.json
+jq -es --argjson metadata "$IMAGE_METADATA" '
+ .[2].annotations == $metadata.labels and
+ .[2].manifests == (.[0].manifests + .[1].manifests)
+' amd64.json arm64.json copied.json > /dev/null
+for arch in amd64 arm64; do
+ platform=$(jq -er --arg arch "$arch" '.manifests[] | select(.platform.os == "linux" and .platform.architecture == $arch).digest' "$arch.json")
+ attachment=$(jq -er --arg platform "$platform" '.manifests[] | select(.annotations["vnd.docker.reference.digest"] == $platform).digest' "$arch.json")
+ statement=$(jq -er '.layers[] | select(.annotations["in-toto.io/predicate-type"] | startswith("https://slsa.dev/provenance/")).digest' \
+ "copied/blobs/sha256/${attachment#sha256:}")
+ jq -e --arg digest "${platform#sha256:}" --arg name "pkg:docker/ghcr.io/openai/[email protected]?platform=linux%2F$arch" \
+ 'any(.subject[]; .digest.sha256 == $digest and .name == $name)' "copied/blobs/sha256/${statement#sha256:}" > /dev/null
+done
+
+if bash "$prepare" amd64.tar amd64.tar duplicate; then
+ echo 'Two amd64 archives must not form a release index.' >&2
+ exit 1
+fi
diff --git a/docker/verify-container-release-version.sh b/docker/verify-container-release-version.sh
index ac12fc134..c394be096 100644
--- a/docker/verify-container-release-version.sh
+++ b/docker/verify-container-release-version.sh
@@ -10,6 +10,7 @@ fi
endpoint=$1
version=$2
verified_digest=${3:-}
+stable='^(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)$'
if ! versions="$(gh api --paginate "$endpoint/versions?per_page=100")"; then
printf '%s\n' "::error::Unable to verify whether container version $version already exists; refusing to publish." >&2
@@ -18,26 +19,28 @@ fi
if ! version_status="$(
printf '%s\n' "$versions" |
- jq --raw-output --slurp --arg version "$version" --arg digest "$verified_digest" '
+ jq --raw-output --slurp --arg version "$version" --arg digest "$verified_digest" --arg sha "${RELEASE_SHA:-}" --arg stable "$stable" '
def stable_version:
- select(test("^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$")) |
+ select(test($stable)) |
split(".") | map(tonumber);
if length == 0 or any(.[]; type != "array") then
error("Container package versions must contain at least one JSON array.")
else
[.[][] | select(any(.metadata.container.tags[]?; . == $version))] as $existing |
- [.[][] | select(any(.metadata.container.tags[]?; . == "latest"))] as $latest |
+ [.[][] | select(any(.metadata.container.tags[]?; . == ("sha-" + $sha)))] as $source |
any(.[][]; any(.metadata.container.tags[]?;
stable_version > ($version | stable_version))) as $backfill |
- if ($existing | length) > 0 and (
+ if (($existing + $source) | length) > 0 and (
($digest | test("^sha256:[a-fA-F0-9]{64}$") | not) or
- any($existing[]; .name != $digest) or
- ($backfill | not) and (
- ($latest | length) == 0 or any($latest[]; .name != $digest)
- )
+ any(($existing + $source)[]; .name != $digest)
) then "published"
elif $backfill then "backfill"
- else "latest"
+ else
+ # An index can lose its numeric alias while it still owns latest.
+ [.[][] | .metadata.container.tags as $tags |
+ select(.name != $digest and any($tags[]?; . == "latest") and
+ (any($tags[]?; stable_version) | not))] |
+ if length == 0 then "latest" else .[].name end
end
end
'
@@ -46,6 +49,20 @@ if ! version_status="$(
exit 1
fi
+case "$version_status" in
+ sha256:*)
+ if ! manifest="$(docker buildx imagetools inspect "$IMAGE@$version_status" --raw)" ||
+ ! version_status="$(printf '%s\n' "$manifest" | jq -er --arg version "$version" --arg stable "$stable" '
+ .annotations["org.opencontainers.image.version"] | select(test($stable)) |
+ (split(".") | map(tonumber)) as $latest | ($version | split(".") | map(tonumber)) as $target |
+ if $latest > $target then "backfill" elif $latest < $target then "latest" else "published" end
+ ')"; then
+ printf '%s\n' "::error::Unable to verify the current latest image version; refusing to promote." >&2
+ exit 1
+ fi
+ ;;
+esac
+
case "$version_status" in
latest|backfill)
if [ -n "${GITHUB_OUTPUT:-}" ]; then
@@ -58,7 +75,7 @@ case "$version_status" in
exit 0
;;
published)
- printf '%s\n' "::error::Container version $version already exists; retries require a matching verified digest and, unless a newer stable version exists, a matching latest tag." >&2
+ printf '%s\n' "::error::Container version $version or its source tag already exists; retries require a matching verified digest." >&2
exit 1
;;
*)
diff --git a/docker/verify-container-sandbox.sh b/docker/verify-container-sandbox.sh
index de59c343d..f8e24ba75 100644
--- a/docker/verify-container-sandbox.sh
+++ b/docker/verify-container-sandbox.sh
@@ -13,7 +13,9 @@ if docker info --format '{{json .SecurityOptions}}' | grep -Fq '"name=apparmor"'
sudo grep -Fxq 'codex-security-container (enforce)' \
/sys/kernel/security/apparmor/profiles
apparmor_options=(--security-opt apparmor=codex-security-container)
- printf '%s\n' 'COMPOSE_FILE=compose.yaml:compose.apparmor.yaml' >> "$GITHUB_ENV"
+ if [[ -n ${GITHUB_ENV:-} ]]; then
+ printf '%s\n' 'COMPOSE_FILE=compose.yaml:compose.apparmor.yaml' >> "$GITHUB_ENV"
+ fi
fi
docker run --rm \
@@ -21,7 +23,7 @@ docker run --rm \
--security-opt no-new-privileges \
--security-opt "seccomp=$repository_root/docker/codex-security-seccomp.json" \
"${apparmor_options[@]}" \
- --entrypoint node \
- "$image" \
- /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js \
- sandbox /usr/bin/true
+ --entrypoint /bin/sh "$image" -ec '
+ cd "$(dirname "$(readlink -f /usr/local/bin/codex-security)")"
+ exec npm exec --offline -- codex sandbox /usr/bin/true
+ '
diff --git a/docker/wolfi/README.md b/docker/wolfi/README.md
index 1c028591d..823212594 100644
--- a/docker/wolfi/README.md
+++ b/docker/wolfi/README.md
@@ -1,13 +1,12 @@
-# Build a local Wolfi scanner image
+# Wolfi scanner image
-This recipe packages the published `@openai/[email protected]` for
-Linux amd64. [melange](https://github.com/chainguard-dev/melange) creates
-the scanner APK; [apko](https://github.com/chainguard-dev/apko) assembles it
+Each new scanner release includes a Linux amd64 Wolfi image.
+[melange](https://github.com/chainguard-dev/melange) creates the scanner APK.
+[apko](https://github.com/chainguard-dev/apko) assembles it
with packages from the [public Wolfi repository](https://github.com/wolfi-dev/os).
The image uses the same entrypoint, UID/GID 10001, and `/input`, `/output`, and
-`/state` directories as the [published scanner](../README.md). The local build
-packages the pinned npm release. To publish it, use the separate
-[amd64 release workflow](#publish-the-amd64-variant).
+`/state` directories as the [Debian image](../README.md). The local build below
+uses the scanner version pinned in [payload/package.json](payload/package.json).
## Build and inspect
@@ -69,32 +68,33 @@ does not include a model.
## Publish the amd64 variant
-Pull requests that change this recipe or its shared inputs run the native build
-and smoke test. The build also verifies that the scanner archive in the image's
-npm inventory matches the signed provenance for its upstream release tag.
-Publishing is a separate manual run. After the workflow is on protected
-`main`, a maintainer can start it with:
+For a scanner release, `container-publish` supplies the same verified npm tarball
+and runtime lock used for Debian. The builder records the scanner commit from
+`npm-vX.Y.Z` and the recipe commit from protected `main`. One protected
+`container` approval covers both images after the native tests pass. The Wolfi publisher verifies an anonymous
+pull and attests build provenance and the SPDX inventory before promoting
+`ghcr.io/openai/codex-security:X.Y.Z-wolfi-amd64`.
+
+### Wolfi-only OS updates
+
+Choose an existing `X.Y.Z-wolfi-amd64` release. Update the OS pins and increment
+`image_revision` in [build-inputs.json](build-inputs.json) in the same PR. After
+it merges, run the following on protected `main`, substituting the scanner version
+for `X.Y.Z`.
```sh
-gh workflow run publish-wolfi.yml --repo openai/codex-security --ref main
+gh workflow run publish-wolfi.yml --repo openai/codex-security --ref main -f release-version=X.Y.Z
```
-Approve the pending `container` deployment in GitHub Actions after the build
-and smoke test pass. The workflow publishes the tested platform digest, checks
-an anonymous pull, and attaches build provenance and an SPDX inventory covering
-OS packages, installed npm packages, and bundled native components. The run
-summary includes the digest for a pinned pull.
-
-The first Wolfi image for a scanner version uses a tag such as
-`ghcr.io/openai/codex-security:0.7.0-wolfi-amd64`. To ship a Wolfi OS fix
-without changing the scanner version, update the OS pins and increment
-`image_revision` in [build-inputs.json](build-inputs.json) in the same PR.
-Revision 1 publishes `0.7.0-wolfi-amd64-r1` and leaves the first tag in place.
-Reset the revision to 0 for a new scanner version.
+The build verifies the original scanner tarball against its signed npm provenance.
+It uses the base image's lock and staging recipe to reproduce the scanner payload
+and verifies its digest before packaging it with the updated OS pins. Approve the
+pending `container` deployment to publish `X.Y.Z-wolfi-amd64-rN` for the reviewed
+revision `N`. New scanner versions begin with the unsuffixed tag.
-Retries cannot replace a versioned tag with a different digest. To retry a
-failed publication using the same build, rerun the failed job within the
-seven-day artifact retention period.
+To retry publication, rerun the failed jobs within the seven-day artifact
+retention period. A fresh build generates a new APK signing key and a different
+image digest.
## Inputs and updates
@@ -102,8 +102,8 @@ seven-day artifact retention period.
and runtime packages. [build-inputs.json](build-inputs.json) pins their resolved
lock identities and Wolfi's signing key. The build downloads the locked builder
APKs, verifies their bytes, and gives melange only a local, signed index of those
-files. The
-[npm lock](payload/package-lock.json) pins the scanner and dependencies.
+files. For a local build, [the recipe's npm lock](payload/package-lock.json) pins
+the scanner and dependencies. Coordinated builds use the release runtime lock.
[stage.py](payload/stage.py) checks the target dependency graph, skips npm
lifecycle scripts, and stages the Linux scanner. [melange.yaml](melange.yaml)
checks the normalized tar hash before installing it. The APK omits the optional
@@ -117,10 +117,7 @@ Components keep their upstream licenses.
If the public Wolfi index moves past a pinned version, refresh the affected
package pins and review the resulting apko locks and component inventory before
-updating the lock digests. For a new scanner release, update the npm dependency
-and lock, the native source and notice pins, the APK version in the
-[package](melange.yaml) and [image](apko.yaml) recipes and build inputs, and the
-smoke test's expected versions. Regenerate the payload with
-`python3 docker/wolfi/payload/stage.py /tmp/wolfi-stage` and update the normalized
-tar hash after reviewing what changed. Build the image and repeat the native
-smoke test for either kind of update.
+updating the lock digests. Review native source and notice pins when scanner
+dependencies change. Coordinated builds take the scanner version, source commit,
+and integrity from the verified release. Run the native smoke test after
+changing either the scanner payload or OS packages.
diff --git a/docker/wolfi/apko.yaml b/docker/wolfi/apko.yaml
index 8c0fdf288..fd9d055e5 100644
--- a/docker/wolfi/apko.yaml
+++ b/docker/wolfi/apko.yaml
@@ -11,7 +11,7 @@ contents:
- busybox=1.38.0-r3
- c-ares=1.34.9-r0
- ca-certificates-bundle=20261020-r0
- - codex-security=0.7.0-r1
+ - "@LOCAL_PACKAGE@"
- cyrus-sasl-heimdal-libs=2.1.28-r58
- gdbm=1.26-r8
- git=2.56.0-r3
@@ -95,3 +95,6 @@ work-dir: /state
entrypoint:
command: /usr/local/bin/codex-security-entrypoint
cmd: --help
+annotations:
+ # @RECIPE_REVISION@
+ io.openai.codex-security.payload-sha256: "@PAYLOAD_SHA256@"
diff --git a/docker/wolfi/build-inputs.json b/docker/wolfi/build-inputs.json
index 7aed7b519..9bca3a944 100644
--- a/docker/wolfi/build-inputs.json
+++ b/docker/wolfi/build-inputs.json
@@ -3,6 +3,7 @@
"wolfi_key_sha256": "f0031424cf46f7db780ce63a45f0fd6aa6f85f601e6bb3b7a91fe3d4d5b7d2cc",
"repository": "https://packages.wolfi.dev/os",
"local_package": "codex-security=0.7.0-r1",
+ "payload_sha256": "db42f7b5b4d0bfc79975e38778ece88d02d31887a262f8a5c0e5bdfdbbe3563d",
"image_revision": 0,
"snapshots": {
"builder": {
diff --git a/docker/wolfi/build.sh b/docker/wolfi/build.sh
index 92249cf5d..0fae7251b 100755
--- a/docker/wolfi/build.sh
+++ b/docker/wolfi/build.sh
@@ -9,7 +9,7 @@ Requires Linux with an x86_64-capable melange/bubblewrap runner, melange 0.61.1,
apko 1.4.13, Python 3.9+, OpenSSL, and npm 11 for payload staging.
APKO and MELANGE optionally name the installed tool executables.
STAGED_PAYLOAD optionally names an absolute path to an already staged payload
-matching the hash in melange.yaml. All OS packages come from packages.wolfi.dev.
+matching the payload_sha256 in build-inputs.json. All OS packages come from packages.wolfi.dev.
Each run generates a new local signing key and removes the private key at exit.
EOF
}
@@ -39,6 +39,14 @@ cp "$root"/{wolfi-signing.rsa.pub,builder.yaml,apko.yaml,melange.yaml,build-inpu
(cd "$scratch"; "$melange" keygen melange.rsa)
cp "$scratch/melange.rsa.pub" .
stamp=2026-10-26T11:30:14Z
+if [[ -n ${SCANNER_TARBALL:-} ]]; then
+ : "${SCANNER_SHA:?}" "${SCANNER_VERSION:?}" "${SCANNER_RUNTIME_LOCK:?}"
+ if [[ -n ${STAGED_PAYLOAD:-} ]]; then
+ [[ ${BASE_PAYLOAD_SHA:-} =~ ^[0-9a-f]{64}$ ]] || die 'OS updates require the original scanner payload hash'
+ fi
+ [[ $SCANNER_SHA =~ ^[0-9a-f]{40}$ && $SCANNER_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || die 'Invalid scanner release'
+ stamp=$(git -C "$root" show -s --format=%cI "$SCANNER_SHA")
+fi
# Authenticate the upstream indexes with the reviewed Wolfi key.
python3 -c 'import hashlib, json, pathlib, sys
actual = hashlib.sha256(pathlib.Path("wolfi-signing.rsa.pub").read_bytes()).hexdigest()
@@ -81,6 +89,37 @@ if [[ -n ${STAGED_PAYLOAD:-} ]]; then
else
python3 "$root/payload/stage.py" "$out/src"
fi
+# Render only the scanner-specific fields. The reviewed OS locks stay fixed.
+python3 - "$root" <<'RECIPE'
+import gzip, hashlib, json, os, subprocess, sys
+from pathlib import Path
+inputs_path = Path("build-inputs.json")
+inputs = json.loads(inputs_path.read_text())
+if os.environ.get("SCANNER_TARBALL"):
+ version = os.environ["SCANNER_VERSION"]
+ epoch = inputs["local_package"].rsplit("-r", 1)[1]
+ inputs["local_package"] = f"codex-security={version}-r{epoch}"
+ if os.environ.get("STAGED_PAYLOAD"):
+ inputs["payload_sha256"] = os.environ["BASE_PAYLOAD_SHA"]
+ else:
+ digest = hashlib.sha256()
+ with gzip.open("src/payload.tar.gz", "rb") as data:
+ for chunk in iter(lambda: data.read(1024 * 1024), b""):
+ digest.update(chunk)
+ inputs["payload_sha256"] = digest.hexdigest()
+ inputs_path.write_text(json.dumps(inputs, indent=2) + "\n")
+ revision = subprocess.check_output(["git", "-C", sys.argv[1], "rev-parse", "HEAD"], text=True).strip()
+ tag = os.environ.get("SCANNER_RELEASE_TAG", f"{version}-wolfi-amd64")
+ recipe = f'org.opencontainers.image.revision: "{revision}"\n io.openai.codex-security.release-tag: "{tag}"'
+else:
+ version = inputs["local_package"].split("=")[1].split("-r")[0]
+ recipe = ""
+for path in (Path("melange.yaml"), Path("apko.yaml")):
+ path.write_text(path.read_text().replace("@SCANNER_VERSION@", version)
+ .replace("@LOCAL_PACKAGE@", inputs["local_package"])
+ .replace("@PAYLOAD_SHA256@", inputs["payload_sha256"])
+ .replace("# @RECIPE_REVISION@", recipe))
+RECIPE
pins=$(python3 -c 'import json; print(",".join(p["name"]+"="+p["version"] for p in json.load(open("builder.lock.json"))["contents"]["packages"]))')
"$melange" build melange.yaml --source-dir "$out/src" --arch x86_64 --runner bubblewrap \
--signing-key "$scratch/melange.rsa" --generate-index --out-dir "$out/packages" \
diff --git a/docker/wolfi/melange.yaml b/docker/wolfi/melange.yaml
index 8d92f3444..7ff61e8ee 100644
--- a/docker/wolfi/melange.yaml
+++ b/docker/wolfi/melange.yaml
@@ -2,7 +2,7 @@
# build.sh supplies the signed local repository prepared from builder.lock.json.
package:
name: codex-security
- version: "0.7.0"
+ version: "@SCANNER_VERSION@"
epoch: 1
description: Codex Security repository scanner and bundled Linux amd64 Codex runtime
target-architecture: [x86_64]
@@ -33,7 +33,7 @@ pipeline:
- name: Verify and install the locked Linux scanner payload
runs: |
set -eu
- expected=db42f7b5b4d0bfc79975e38778ece88d02d31887a262f8a5c0e5bdfdbbe3563d
+ expected=@PAYLOAD_SHA256@
actual=$(gzip -dc payload.tar.gz | sha256sum)
test "${actual%% *}" = "$expected"
mkdir -p "${{targets.destdir}}"
diff --git a/docker/wolfi/payload/native-sources.json b/docker/wolfi/payload/native-sources.json
new file mode 100644
index 000000000..071d75f03
--- /dev/null
+++ b/docker/wolfi/payload/native-sources.json
@@ -0,0 +1,6 @@
+{
+ "@openai/[email protected]": "https://github.com/openai/codex/tree/6aaac694803004a63c6f393d153c96d22521a6b9",
+ "@openai/[email protected]": "https://github.com/openai/codex/tree/360319d8dee62d87e2d59fc0c21805d79519cfed",
+ "@napi-rs/[email protected]": "https://github.com/Brooooooklyn/canvas/tree/7d19abed029287e7c26b14eaa6e67d560a37d853",
+ "@napi-rs/[email protected]": "https://github.com/Brooooooklyn/canvas/tree/00a115d9903647f116daf86eccd2c6ba36128371"
+}
diff --git a/docker/wolfi/payload/stage.py b/docker/wolfi/payload/stage.py
index 1b03003ed..c8ed6f8da 100644
--- a/docker/wolfi/payload/stage.py
+++ b/docker/wolfi/payload/stage.py
@@ -27,8 +27,6 @@ VENDOR = "node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl"
TARGET = {"os": "linux", "cpu": "x64", "libc": "glibc"}
LICENSE_DIR = Path("usr/share/licenses/codex-security")
REVIEWED_NPM_LICENSES = {"Apache-2.0", "BSD-3-Clause", "ISC", "MIT", "(MIT OR CC0-1.0)"}
-CODEX_SOURCE = "https://github.com/openai/codex/tree/6aaac694803004a63c6f393d153c96d22521a6b9"
-SCANNER_SOURCE = "https://github.com/openai/codex-security/tree/f05a0b096cc881242ddf34a4d6b3ce0f322f3cf9"
OFF_TARGET_PLUGIN_TARGETS = {
"darwin-arm64", "darwin-x64", "linux-arm64-gnu", "linux-arm64-musl",
"linux-x64-musl", "win32-arm64", "win32-x64",
@@ -103,13 +101,26 @@ def write_attributions(root, app, wanted):
raise ValueError(f"Review license for {key}: {pkg.get('license')}")
npm.append({"path": key, "name": pkg["name"], "version": pkg["version"], "license": pkg["license"],
"repository": source_url(pkg), "input_archive": lock_record["resolved"], "integrity": lock_record["integrity"]})
+ scanner_sha = os.environ.get("SCANNER_SHA") or "f05a0b096cc881242ddf34a4d6b3ce0f322f3cf9"
+ scanner_source = f"https://github.com/openai/codex-security/tree/{scanner_sha}"
+ # Identify the native archive actually installed, including npm's alias for Codex.
+ native_sources = read_json(HERE / "native-sources.json")
+
+ def native_source(package):
+ pkg = wanted["node_modules/" + package]
+ spec = f"{pkg.get('name', package)}@{pkg['version']}"
+ if spec not in native_sources:
+ raise ValueError(f"Review the native source and notices for {spec} in payload/native-sources.json")
+ return native_sources[spec]
+
+ codex_source = native_source("@openai/codex-linux-x64")
codex_native = {
- VENDOR + "/bin/codex": CODEX_SOURCE + "/codex-rs/cli",
- VENDOR + "/bin/codex-code-mode-host": CODEX_SOURCE + "/codex-rs/code-mode-host",
- VENDOR + "/codex-resources/bwrap": CODEX_SOURCE + "/codex-rs/vendor/bubblewrap",
+ VENDOR + "/bin/codex": codex_source + "/codex-rs/cli",
+ VENDOR + "/bin/codex-code-mode-host": codex_source + "/codex-rs/code-mode-host",
+ VENDOR + "/codex-resources/bwrap": codex_source + "/codex-rs/vendor/bubblewrap",
VENDOR + "/codex-path/rg": "https://github.com/BurntSushi/ripgrep/tree/e89fff89ac9af12e8d4ce9d5fd07beb408ca730f",
- SDK + "/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node": SCANNER_SOURCE + "/plugins/codex-security/native",
- "node_modules/@napi-rs/canvas-linux-x64-gnu/skia.linux-x64-gnu.node": "https://github.com/Brooooooklyn/canvas/tree/00a115d9903647f116daf86eccd2c6ba36128371",
+ SDK + "/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node": scanner_source + "/plugins/codex-security/native",
+ "node_modules/@napi-rs/canvas-linux-x64-gnu/skia.linux-x64-gnu.node": native_source("@napi-rs/canvas-linux-x64-gnu"),
}
native_records = []
for file, source in codex_native.items():
@@ -118,7 +129,7 @@ def write_attributions(root, app, wanted):
while chunk := f.read(1 << 20):
hasher.update(chunk)
native_records.append({"path": file, "source": source, "sha256": hasher.hexdigest()})
- manifest = {"scanner_source": SCANNER_SOURCE, "codex_source": CODEX_SOURCE, "npm": npm,
+ manifest = {"scanner_source": scanner_source, "codex_source": codex_source, "npm": npm,
"native_executables_and_addons": native_records,
"omitted": [VENDOR + "/codex-resources/voice"] +
[SDK + "/_bundled_plugin/mcp/native/" + target for target in sorted(OFF_TARGET_PLUGIN_TARGETS)]}
@@ -128,9 +139,14 @@ def write_attributions(root, app, wanted):
def stage_root(root):
app = root / INSTALL
app.mkdir(parents=True)
- for name in ("package.json", "package-lock.json"):
- shutil.copyfile(HERE / name, app / name)
- lock = read_json(app / "package-lock.json")
+ lock_path = Path(os.environ.get("SCANNER_RUNTIME_LOCK") or HERE / "package-lock.json")
+ if os.environ.get("SCANNER_TARBALL"):
+ subprocess.run(["node", DOCKER / "prepare-release-package.mjs", os.environ["SCANNER_TARBALL"],
+ lock_path, app], check=True)
+ else:
+ for name in ("package.json", "package-lock.json"):
+ shutil.copyfile(HERE / name, app / name)
+ lock = read_json(lock_path)
packages = {k: v for k, v in lock["packages"].items() if k}
# An unexpected package manager script or nonregistry artifact requires review.
for name, pkg in packages.items():
@@ -153,8 +169,13 @@ def stage_root(root):
for key, pkg in wanted.items():
if installed[key]["integrity"] != pkg["integrity"] or read_json(app / key / "package.json")["version"] != pkg["version"]:
raise ValueError(f"Installed version/integrity differs for {key}")
- # Keep the original lock usable by npm ci. SOURCES.json records the subset
- # installed for this platform.
+ if os.environ.get("SCANNER_TARBALL"):
+ # Retain the registry lock, without the temporary archive or its local URL.
+ (app / "scanner.tgz").unlink()
+ shutil.copyfile(lock_path, app / "package-lock.json")
+ # The pinned recipe includes this manifest's original bytes in its reviewed tar hash.
+ if lock_path.read_bytes() == (HERE / "package-lock.json").read_bytes():
+ shutil.copyfile(HERE / "package.json", app / "package.json")
(app / "node_modules/.package-lock.json").unlink() # transient local npm cache
select_scanner_payload(app)
for name in ("bin/codex", "bin/codex-code-mode-host", "codex-resources/bwrap", "codex-path/rg"):
diff --git a/docker/wolfi/resolve-release.sh b/docker/wolfi/resolve-release.sh
new file mode 100644
index 000000000..360cff09d
--- /dev/null
+++ b/docker/wolfi/resolve-release.sh
@@ -0,0 +1,134 @@
+#!/usr/bin/env bash
+# Resolve the scanner bytes and the immutable tag before building a new Wolfi image.
+set -euo pipefail
+image=ghcr.io/openai/codex-security
+version=$RELEASE_VERSION
+[[ $version =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]
+sha=$(git rev-parse --verify "refs/tags/npm-v$version^{commit}")
+recipe=$(git rev-parse HEAD)
+dir=$RUNNER_TEMP/scanner
+mkdir -p "$dir"
+lock=$dir/package-lock.json
+base=$version-wolfi-amd64
+tag=$base
+if [[ $OS_UPDATE == true ]]; then
+ revision=$(jq -er '.image_revision | numbers | select(. > 0 and . == floor)' docker/wolfi/build-inputs.json)
+ tag=$base-r$revision
+else
+ [[ $sha == "$RELEASE_SHA" && -n $RELEASE_INTEGRITY ]]
+fi
+printf 'tag=%s\n' "$tag" >> "$GITHUB_OUTPUT"
+
+# Work by immutable digest, including when obtaining the frozen runtime lock of an older release.
+read_public_image() {
+ local release_tag=$1 prefix=$2 ref container predicate signed_tag commit revision
+ digest=sha256:$(skopeo inspect --no-creds --raw "docker://$image:$release_tag" | tee "$dir/$prefix-manifest.json" | sha256sum | cut -d' ' -f1)
+ ref=$image@$digest
+ for predicate in https://slsa.dev/provenance/v1 https://spdx.dev/Document/v2.3; do
+ gh attestation verify "oci://$ref" --repo "$GITHUB_REPOSITORY" --predicate-type "$predicate" \
+ --signer-workflow "$GITHUB_REPOSITORY/.github/workflows/publish-wolfi.yml" --source-ref refs/heads/main \
+ --format json > "$dir/$prefix-${predicate##*/}.json"
+ done
+ signed_tag=$(jq -r '.annotations["io.openai.codex-security.release-tag"] // empty' "$dir/$prefix-manifest.json")
+ if [[ -z $signed_tag ]]; then
+ # The original publisher tagged the scanner version with the revision in its signed main commit.
+ commit=$(image_recipe "$prefix")
+ revision=$(git show "$commit:docker/wolfi/build-inputs.json" | jq -er '.image_revision | numbers | select(. >= 0 and . == floor)')
+ signed_tag=$base
+ if [[ $revision != 0 ]]; then signed_tag+=-r$revision; fi
+ fi
+ if [[ $signed_tag != "$release_tag" ]]; then
+ echo "::error::$release_tag resolves to an image built for $signed_tag."
+ exit 1
+ fi
+ docker pull "$ref"
+ container=$(docker create "$ref")
+ docker cp "$container:/usr/lib/codex-security/package-lock.json" "$dir/$prefix-lock.json"
+ docker cp "$container:/usr/share/licenses/codex-security/SOURCES.json" "$dir/$prefix-sources.json"
+ docker rm "$container" >/dev/null
+ jq -e --arg sha "$sha" '.scanner_source == ("https://github.com/openai/codex-security/tree/" + $sha)' \
+ "$dir/$prefix-sources.json" >/dev/null
+}
+
+image_recipe() {
+ local prefix=$1 commit
+ commit=$(jq -r '.annotations["org.opencontainers.image.revision"] // empty' "$dir/$prefix-manifest.json")
+ if [[ -z $commit ]]; then
+ # The original standalone publisher signed the protected-main recipe but did not annotate it.
+ commit=$(jq -er --arg uri "git+https://github.com/$GITHUB_REPOSITORY@refs/heads/main" \
+ '.[0].verificationResult.statement.predicate.buildDefinition.resolvedDependencies[] | select(.uri == $uri) | .digest.gitCommit' "$dir/$prefix-v1.json")
+ fi
+ [[ $commit =~ ^[0-9a-f]{40}$ ]] || return 1
+ printf '%s\n' "$commit"
+}
+
+image_payload_sha() {
+ local prefix=$1 commit=$2 hash
+ hash=$(jq -r '.annotations["io.openai.codex-security.payload-sha256"] // empty' "$dir/$prefix-manifest.json")
+ if [[ -z $hash ]]; then
+ # Unannotated releases pinned the payload directly in their signed recipe.
+ hash=$(git show "$commit:docker/wolfi/melange.yaml" | sed -nE 's/^[[:space:]]+expected=([0-9a-f]{64})$/\1/p')
+ fi
+ [[ $hash =~ ^[0-9a-f]{64}$ ]] || return 1
+ printf '%s\n' "$hash"
+}
+
+if [[ $OS_UPDATE == true ]]; then
+ read_public_image "$base" base
+ cp "$dir/base-lock.json" "$lock"
+ npm pack --ignore-scripts --pack-destination "$dir" --registry=https://registry.npmjs.org \
+ "@openai/codex-security@$version"
+ base_recipe=$(image_recipe base)
+ git merge-base --is-ancestor "$base_recipe" "$recipe"
+ mkdir "$dir/base-recipe"
+ git archive "$base_recipe" LICENSE docker | tar -x -C "$dir/base-recipe"
+ base_payload=$(image_payload_sha base "$base_recipe")
+fi
+archives=("$dir"/*.tgz)
+[[ ${#archives[@]} == 1 && -f ${archives[0]} ]]
+archive=${archives[0]}
+integrity=$(jq -er --arg version "$version" '.packages["node_modules/@openai/codex-security"] | select(.version == $version) | .integrity' "$lock")
+[[ $integrity == "sha512-$(openssl dgst -sha512 -binary "$archive" | openssl base64 -A)" ]]
+if [[ $OS_UPDATE == true ]]; then
+ bash docker/wolfi/verify-npm-release.sh "$lock" "$version" "$sha" "$archive"
+else
+ [[ $integrity == "$RELEASE_INTEGRITY" ]]
+fi
+
+# A new melange key changes the digest. Reuse an already attested matching release on recovery.
+skopeo list-tags --no-creds "docker://$image" > "$dir/tags.json"
+if jq -e --arg tag "$tag" '.Tags | index($tag) != null' "$dir/tags.json" >/dev/null; then
+ read_public_image "$tag" published
+ cmp "$lock" "$dir/published-lock.json"
+ if [[ $OS_UPDATE == true ]]; then
+ # The scanner payload is frozen at the base tag. Compare what builds the OS around it.
+ published_recipe=$(image_recipe published)
+ git merge-base --is-ancestor "$published_recipe" "$recipe"
+ published_payload=$(image_payload_sha published "$published_recipe")
+ inputs=docker/wolfi/build-inputs.json
+ git show "$published_recipe:$inputs" > "$dir/published-inputs.json"
+ # The release tag supplies the scanner version and payload hash. Only the APK epoch carries over.
+ if [[ $published_payload != "$base_payload" ]] ||
+ ! jq -es 'map(del(.payload_sha256) | .local_package |= (split("-r") | last)) | .[0] == .[1]' \
+ "$dir/published-inputs.json" "$inputs" >/dev/null ||
+ ! git diff --quiet "$published_recipe" "$recipe" -- \
+ docker/wolfi/{apko.yaml,builder.yaml,melange.yaml,wolfi-signing.rsa.pub} \
+ docker/wolfi/{build.sh,ci-build.sh,snapshot-builder.py}; then
+ echo "::error::$tag already exists with different Wolfi build inputs. Increment image_revision."
+ exit 1
+ fi
+ fi
+ printf 'existing=true\ndigest=%s\n' "$digest" >> "$GITHUB_OUTPUT"
+ printf 'Verified previously published %s:%s at %s.\n' "$image" "$tag" "$digest" >> "$GITHUB_STEP_SUMMARY" || true
+ exit 0
+fi
+
+if [[ $OS_UPDATE == true ]]; then
+ # Use the original entrypoint, notices and scanner staging code; only the OS recipe advances.
+ SCANNER_TARBALL="$archive" SCANNER_RUNTIME_LOCK="$lock" SCANNER_VERSION="$version" SCANNER_SHA="$sha" \
+ python3 "$dir/base-recipe/docker/wolfi/payload/stage.py" "$dir/base-payload"
+ printf 'BASE_PAYLOAD_SHA=%s\nSTAGED_PAYLOAD=%s\n' "$base_payload" "$dir/base-payload/payload.tar.gz" >> "$GITHUB_ENV"
+fi
+printf 'SCANNER_RELEASE_TAG=%s\nSCANNER_VERSION=%s\nSCANNER_SHA=%s\nSCANNER_RECIPE_SHA=%s\nSCANNER_TARBALL=%s\nSCANNER_RUNTIME_LOCK=%s\nSCANNER_INTEGRITY=%s\n' \
+ "$tag" "$version" "$sha" "$recipe" "$archive" "$lock" "$integrity" >> "$GITHUB_ENV"
+printf 'existing=false\n' >> "$GITHUB_OUTPUT"
diff --git a/docker/wolfi/tests/runtime.mjs b/docker/wolfi/tests/runtime.mjs
index 4db0f265b..a61633417 100644
--- a/docker/wolfi/tests/runtime.mjs
+++ b/docker/wolfi/tests/runtime.mjs
@@ -33,11 +33,12 @@ run(process.env.PYTHON, ["-c",
console.log("PASS non-root account, state directories, Python SQLite and CA trust");
const info = cli("info");
-assert.equal(info.cliVersion, "0.7.0");
-assert.equal(info.codexVersion, "0.164.0");
const launcher = realpathSync(run("/bin/sh", ["-c", "command -v codex-security"]));
const pkg = dirname(dirname(launcher));
-assert.equal(read(join(pkg, "package.json")).name, "@openai/codex-security");
+const manifest = read(join(pkg, "package.json"));
+assert.equal(manifest.name, "@openai/codex-security");
+assert.equal(info.cliVersion, manifest.version);
+assert.equal(info.codexVersion, manifest.dependencies["@openai/codex"]);
const { resolveCodexCommand } = await import(pathToFileURL(join(pkg, "dist/index.js")));
const { command: codex } = resolveCodexCommand({});
assert.equal(run(codex, ["--version"]), `codex-cli ${info.codexVersion}`);
diff --git a/docker/wolfi/tests/smoke.sh b/docker/wolfi/tests/smoke.sh
index 821381a80..5a4414494 100755
--- a/docker/wolfi/tests/smoke.sh
+++ b/docker/wolfi/tests/smoke.sh
@@ -27,7 +27,9 @@ flags=(--rm --pull=never --network=none --read-only --cap-drop=ALL
help=$(docker run "${flags[@]}" "$image")
[[ $help == *'Usage: codex-security'* ]]
version=$(docker run "${flags[@]}" "$image" --version)
-[[ $version == 0.7.0 ]]
+expected=${SCANNER_VERSION:-$(docker run "${flags[@]}" --entrypoint /usr/bin/node "$image" \
+ -p 'require("/usr/lib/codex-security/node_modules/@openai/codex-security/package.json").version')}
+[[ $version == "$expected" ]]
status=0
reason=$(docker run "${flags[@]}" "$image" bulk-scan 2>&1) || status=$?
[[ $status == 2 && $reason == *'bulk-scan requires a repository CSV'* ]]
diff --git a/docker/wolfi/verify-npm-release.sh b/docker/wolfi/verify-npm-release.sh
index 2dd2863c6..00513c2b5 100644
--- a/docker/wolfi/verify-npm-release.sh
+++ b/docker/wolfi/verify-npm-release.sh
@@ -1,21 +1,20 @@
#!/usr/bin/env bash
-# Run from the repo root with the verified image inventory, scanner version and tagged commit.
+# Verify the release lock's scanner archive against the signed npm provenance.
set -euo pipefail
-inventory=$1 version=$2 release_sha=$3
+lock=$1 version=$2 release_sha=$3 archive=${4:-}
verifier=$PWD/sdk/typescript/scripts/release-automation.mjs
work=$(mktemp -d)
trap 'rm -rf -- "$work"' EXIT
export npm_config_registry=https://registry.npmjs.org/
-
-# npm ci checked this lock integrity while staging the image. Verify the very
-# same archive against the signed provenance of the upstream scanner release.
-integrity=$(jq -er --arg version "$version" '.installed_npm[] |
- select(.path == "node_modules/@openai/codex-security" and .version == $version) | .integrity' "$inventory")
-cp docker/wolfi/payload/{package.json,package-lock.json} "$work/"
+integrity=$(jq -er --arg version "$version" '.packages["node_modules/@openai/codex-security"] | select(.version == $version) | .integrity' "$lock")
+cp "$lock" "$work/package-lock.json"
+jq '.packages[""]' "$lock" > "$work/package.json"
+if [[ -n $archive && $archive != /* ]]; then archive=$PWD/$archive; fi
cd "$work"
npm ci --omit=optional --ignore-scripts --no-audit --no-fund
-archive=$(npm pack --ignore-scripts --json "@openai/codex-security@$version" |
- jq -er --arg integrity "$integrity" '.[0] | if .integrity == $integrity then .filename
- else error("npm archive SHA-512 differs from the verified image inventory") end')
+if [[ -z $archive ]]; then
+ archive=$(npm pack --ignore-scripts --json "@openai/codex-security@$version" |
+ jq -er --arg integrity "$integrity" '.[0] | select(.integrity == $integrity) | .filename')
+fi
npm audit signatures --json --include-attestations |
node "$verifier" verify-recovered-provenance "$archive" "$version" "$release_sha" openai/codex-security
diff --git a/sdk/typescript/tests-ts/action-release-workflow.test.ts b/sdk/typescript/tests-ts/action-release-workflow.test.ts
index ce19a98fc..8388359b9 100644
--- a/sdk/typescript/tests-ts/action-release-workflow.test.ts
+++ b/sdk/typescript/tests-ts/action-release-workflow.test.ts
@@ -893,6 +893,16 @@ const channelCases: Array<[Record<string, string>, boolean]> = [
[{ CONTAINER_RESULT: "failure" }, false],
[{ CONTAINER_RESULT: "cancelled" }, false],
[{ CONTAINER_RESULT: "skipped" }, false],
+ [{ HAS_WOLFI: "true", DEBIAN_DIGEST: "debian-digest" }, false],
+ [{ HAS_WOLFI: "true", WOLFI_DIGEST: "wolfi-digest" }, false],
+ [
+ {
+ HAS_WOLFI: "true",
+ DEBIAN_DIGEST: "debian-digest",
+ WOLFI_DIGEST: "wolfi-digest",
+ },
+ true,
+ ],
[{ CONTAINER_RESULT: "skipped", HAS_CONTAINER: "" }, true],
];
@@ -911,12 +921,17 @@ test.each(channelCases)(
test("detects container support from the release commit, not the automation checkout", () => {
const release = fixture();
+ release.write(".github/workflows/wolfi-build.yml", "name: Wolfi\n");
+ const withoutContainer = release.commit("Add Wolfi workflow");
+ expect(
+ release.run(detectContainer, { RELEASE_SHA: withoutContainer }).output,
+ ).toBe("");
release.write("Dockerfile", "FROM scratch\n");
const containerSource = release.commit("Add container");
expect(release.run(detectContainer).output).toBe("");
expect(
release.run(detectContainer, { RELEASE_SHA: containerSource }).output,
- ).toBe("present=true\n");
+ ).toBe("present=true\nwolfi=true\n");
});
test.each([
@@ -959,11 +974,26 @@ test.each(["success", "failure", "cancelled", "skipped"])(
GITHUB_SERVER_URL: "https://github.com",
GITHUB_REPOSITORY: "example/project",
CONTAINER_RESULT: containerResult,
+ RELEASE_SHA: "a".repeat(40),
+ DEBIAN_DIGEST:
+ containerResult === "success" ? `sha256:${"a".repeat(64)}` : "",
+ WOLFI_DIGEST:
+ containerResult === "success" ? `sha256:${"b".repeat(64)}` : "",
},
["-e", "-o", "pipefail"],
);
expect(result.status, result.stderr).toBe(0);
- const rows = readFileSync(summary, "utf8")
+ const text = readFileSync(summary, "utf8");
+ if (containerResult === "success") {
+ for (const digit of ["a", "b"]) {
+ const ref = `ghcr.io/example/project@sha256:${digit.repeat(64)}`;
+ expect(text).toContain(`docker pull ${ref}`);
+ expect(text).toContain(
+ `gh attestation verify oci://${ref} --repo example/project`,
+ );
+ }
+ }
+ const rows = text
.split("\n")
.filter((line) => line.startsWith("|"))
.map((line) => line.split("|").map((cell) => cell.trim()));
diff --git a/sdk/typescript/tests-ts/codex-dependency-pins.test.ts b/sdk/typescript/tests-ts/codex-dependency-pins.test.ts
index d68141a7e..30a5c9d65 100644
--- a/sdk/typescript/tests-ts/codex-dependency-pins.test.ts
+++ b/sdk/typescript/tests-ts/codex-dependency-pins.test.ts
@@ -45,3 +45,31 @@ test("pins one Codex version across the CLI, MCP app, and evals", async () => {
}
}
});
+
+test("the Wolfi recipe records sources for its pinned Linux amd64 binaries", async () => {
+ const repo = new URL("../../../", import.meta.url);
+ const [sources, sdk, wolfi, action] = await Promise.all(
+ [
+ "docker/wolfi/payload/native-sources.json",
+ "sdk/typescript/package.json",
+ "docker/wolfi/payload/package-lock.json",
+ "github-action/runtime/package-lock.json",
+ ].map((path) => Bun.file(new URL(path, repo)).json()),
+ );
+ const codex = wolfi.packages["node_modules/@openai/codex-linux-x64"];
+ const canvas = "@napi-rs/canvas-linux-x64-gnu";
+ // Action release preparation replaces the scanner and its exact Codex dependency.
+ // It can retain the transitive Canvas resolution from its existing npm lock.
+ for (const name of [
+ `@openai/codex@${sdk.dependencies["@openai/codex"]}-linux-x64`,
+ `${codex.name}@${codex.version}`,
+ ...[wolfi, action].map(
+ (lock) => `${canvas}@${lock.packages[`node_modules/${canvas}`].version}`,
+ ),
+ ]) {
+ expect(
+ sources[name] ?? "",
+ `Review Wolfi source and notices for ${name}`,
+ ).toMatch(/\/tree\/[a-f0-9]{40}$/);
+ }
+});
diff --git a/sdk/typescript/tests-ts/container-ci-workflow.test.ts b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
index 7037a3389..13972985f 100644
--- a/sdk/typescript/tests-ts/container-ci-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-ci-workflow.test.ts
@@ -1,4 +1,9 @@
-import { readFileSync } from "node:fs";
+import { execFileSync } from "node:child_process";
+import { createHash } from "node:crypto";
+import { readFileSync, writeFileSync } from "node:fs";
+import { join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { createTemporaryDirectoriesSync } from "./support/temporary-directories.js";
import { expect, test } from "bun:test";
type Job = {
@@ -62,17 +67,75 @@ test("shares one native build and container matrix in automatic CI", () => {
test("keeps container validation available to forks and publication upstream-only", () => {
const container = workflow("container-ci");
const validation = workflow("container-validate");
- const release = workflow("container-release");
+ const release = workflow("container-publish");
expect(container.jobs["native"]).not.toHaveProperty("if");
expect(container.jobs["container"]).not.toHaveProperty("if");
expect(validation.jobs["validate"]).not.toHaveProperty("if");
- for (const name of ["source", "validate", "authorize"]) {
- expect(release.jobs[name]?.if).toBe(
- "github.repository == 'openai/codex-security'",
+ expect(Object.keys(release.on)).toEqual(["workflow_call"]);
+ expect(release.jobs["source"]?.if).toBe(
+ "github.workflow_ref == 'openai/codex-security/.github/workflows/node-github-release.yml@refs/heads/main'",
+ );
+ expect(release.jobs["authorize"]?.needs).toContain("source");
+ expect(release.jobs["manifest"]?.needs).toContain("authorize");
+});
+
+test("stages the verified scanner archive and retains its locked dependencies", () => {
+ const directories = createTemporaryDirectoriesSync();
+ try {
+ const root = directories.create("release image inputs ");
+ const archive = join(root, "release.tgz");
+ const runtimeLock = join(root, "runtime-lock.json");
+ const bytes = Buffer.from("verified npm archive");
+ const integrity =
+ "sha512-" + createHash("sha512").update(bytes).digest("base64");
+ const scanner = {
+ version: "1.2.3",
+ resolved: "https://registry.npmjs.org/scanner.tgz",
+ integrity,
+ };
+ const packages = {
+ "": { dependencies: { "@openai/codex-security": "1.2.3" } },
+ "node_modules/@openai/codex-security": scanner,
+ "node_modules/dependency": { version: "3.2.1", integrity: "unchanged" },
+ };
+ writeFileSync(archive, bytes);
+ writeFileSync(
+ runtimeLock,
+ JSON.stringify({ lockfileVersion: 3, packages }),
);
+ const prepare = () =>
+ execFileSync(
+ process.execPath,
+ [
+ fileURLToPath(
+ new URL(
+ "../../../docker/prepare-release-package.mjs",
+ import.meta.url,
+ ),
+ ),
+ archive,
+ runtimeLock,
+ root,
+ ],
+ { stdio: "pipe" },
+ );
+ prepare();
+ expect(readFileSync(join(root, "scanner.tgz"))).toEqual(bytes);
+ expect(
+ JSON.parse(readFileSync(join(root, "package-lock.json"), "utf8"))
+ .packages,
+ ).toEqual({
+ ...packages,
+ "node_modules/@openai/codex-security": {
+ ...scanner,
+ resolved: "file:scanner.tgz",
+ },
+ });
+ writeFileSync(archive, "changed scanner bytes");
+ expect(prepare).toThrow(
+ "Scanner archive differs from the release runtime lock",
+ );
+ } finally {
+ directories.cleanup();
}
- expect(release.jobs["native"]?.if).toBe(
- "github.repository == 'openai/codex-security' && needs.source.outputs.existing-digest == ''",
- );
- expect(release.jobs["publish-platform"]?.needs).toBe("authorize");
});
diff --git a/sdk/typescript/tests-ts/container-entrypoint.test.ts b/sdk/typescript/tests-ts/container-entrypoint.test.ts
index 14e87b7eb..536a67ddd 100644
--- a/sdk/typescript/tests-ts/container-entrypoint.test.ts
+++ b/sdk/typescript/tests-ts/container-entrypoint.test.ts
@@ -49,6 +49,7 @@ async function runVersionVerifier(
response: string,
failure = false,
expectedDigest?: string,
+ latestVersion: string | null = "0.1.3",
): Promise<SpawnSyncReturns<string> & { workflowOutput: string }> {
const root = await realpath(
await mkdtemp(join(tmpdir(), "codex-security-container-version-")),
@@ -74,6 +75,16 @@ async function runVersionVerifier(
{ mode: 0o755 },
);
+ await writeFile(
+ join(root, "docker"),
+ `#!/bin/sh
+[ "$*" = "buildx imagetools inspect $IMAGE@$LATEST_DIGEST --raw" ] || exit 64
+[ -n "$LATEST_MANIFEST" ] || exit 1
+printf '%s\\n' "$LATEST_MANIFEST"
+`,
+ { mode: 0o755 },
+ );
+
const endpoint = "orgs/openai/packages/container/codex-security";
const output = join(root, "output");
await writeFile(output, "");
@@ -90,8 +101,19 @@ async function runVersionVerifier(
env: {
...process.env,
EXPECTED_ENDPOINT: endpoint,
+ IMAGE: "ghcr.io/openai/codex-security",
+ LATEST_DIGEST: `sha256:${"b".repeat(64)}`,
+ LATEST_MANIFEST:
+ latestVersion === null
+ ? ""
+ : JSON.stringify({
+ annotations: {
+ "org.opencontainers.image.version": latestVersion,
+ },
+ }),
GH_FIXTURE_FAILURE: failure ? "1" : "0",
GH_FIXTURE_RESPONSE: response,
+ RELEASE_SHA: "1".repeat(40),
GITHUB_OUTPUT: output,
PATH: `${root}${delimiter}${process.env["PATH"] ?? ""}`,
},
@@ -374,10 +396,35 @@ describe("immutable customer container releases", () => {
);
expect(result.status).toBe(1);
- expect(result.stderr).toContain("Container version 0.1.4 already exists");
+ expect(result.stderr).toContain(
+ "retries require a matching verified digest",
+ );
expect(result.workflowOutput).toBe("");
});
+ testPosix(
+ "checks the immutable source tag before the version exists",
+ async () => {
+ const approved = `sha256:${"a".repeat(64)}`;
+ for (const tagDigest of [approved, `sha256:${"b".repeat(64)}`]) {
+ const result = await runVersionVerifier(
+ JSON.stringify([
+ {
+ name: tagDigest,
+ metadata: { container: { tags: [`sha-${"1".repeat(40)}`] } },
+ },
+ ]),
+ false,
+ approved,
+ );
+ expect(result.status).toBe(tagDigest === approved ? 0 : 1);
+ expect(result.workflowOutput).toBe(
+ tagDigest === approved ? "publish_latest=true\n" : "",
+ );
+ }
+ },
+ );
+
testPosix(
"retries the verified digest without moving latest backwards",
async () => {
@@ -410,14 +457,51 @@ describe("immutable customer container releases", () => {
false,
digest,
);
- const allowed = newer || latest === "same";
- expect(result.status, JSON.stringify({ newer, latest })).toBe(
- allowed ? 0 : 1,
- );
- expect(result.workflowOutput).toBe(
- allowed ? `publish_latest=${!newer}\n` : "",
+ expect(result.status, JSON.stringify({ newer, latest })).toBe(0);
+ expect(result.workflowOutput).toBe(`publish_latest=${!newer}\n`);
+ expect(result.stderr).toBe("");
+ }
+ }
+ },
+ );
+
+ testPosix(
+ "checks the public index when latest has lost its numeric tag",
+ async () => {
+ const candidate = `sha256:${"a".repeat(64)}`;
+ for (const alreadyPublished of [false, true]) {
+ const versions = JSON.stringify([
+ {
+ name: candidate,
+ metadata: {
+ container: { tags: alreadyPublished ? ["0.1.4"] : [] },
+ },
+ },
+ {
+ name: `sha256:${"b".repeat(64)}`,
+ metadata: {
+ container: { tags: ["latest", `sha-${"2".repeat(40)}`] },
+ },
+ },
+ ]);
+ for (const [version, output] of [
+ ["0.1.3", "publish_latest=true\n"],
+ ["0.1.10", "publish_latest=false\n"],
+ ["0.1.4", ""],
+ ["invalid", ""],
+ [null, ""],
+ ] as const) {
+ const result = await runVersionVerifier(
+ versions,
+ false,
+ candidate,
+ version,
);
- if (allowed) expect(result.stderr).toBe("");
+ expect(
+ result.status === 0,
+ JSON.stringify({ alreadyPublished, version }),
+ ).toBe(output !== "");
+ expect(result.workflowOutput).toBe(output);
}
}
},
@@ -446,7 +530,7 @@ describe("immutable customer container releases", () => {
);
expect(result.status).toBe(1);
expect(result.stderr).toContain(
- "Container version 0.1.4 already exists",
+ "retries require a matching verified digest",
);
expect(result.workflowOutput).toBe("");
}
diff --git a/sdk/typescript/tests-ts/container-release-workflow.test.ts b/sdk/typescript/tests-ts/container-release-workflow.test.ts
index 23b3f3d73..977448f57 100644
--- a/sdk/typescript/tests-ts/container-release-workflow.test.ts
+++ b/sdk/typescript/tests-ts/container-release-workflow.test.ts
@@ -1,5 +1,6 @@
import { afterEach, expect, test } from "bun:test";
import { execFileSync } from "node:child_process";
+import { createHash } from "node:crypto";
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import { delimiter, join } from "node:path";
import { createTemporaryDirectoriesSync } from "./support/temporary-directories.js";
@@ -34,7 +35,8 @@ function workflow(name: string) {
jobs: Record<string, Job>;
};
}
-const release = workflow("container-release");
+const release = workflow("container-publish");
+const parent = workflow("node-github-release");
const directories = createTemporaryDirectoriesSync();
afterEach(directories.cleanup);
@@ -72,11 +74,11 @@ function fixture() {
git("tag", "npm-v99.1.2");
const automation = commit("99.2.0");
git("remote", "add", "origin", repository);
- function run(env: Record<string, string> = {}) {
+ function run(env: Record<string, string> = {}, selected = release) {
writeFileSync(output, "");
const result = runWorkflowScript(
repository,
- release.jobs["source"]!.steps![1]!.run,
+ selected.jobs["source"]!.steps![1]!.run,
{
GITHUB_OUTPUT: output.replaceAll("\\", "/"),
GITHUB_REPOSITORY_OWNER: "Example",
@@ -91,15 +93,14 @@ function fixture() {
);
return { ...result, output: readFileSync(output, "utf8") };
}
- return { source, automation, git, commit, run };
+ return { source, automation, git, commit, run, repository };
}
test("backfills the tagged release after main has advanced", () => {
- const { run, source } = fixture();
+ const { run } = fixture();
const result = run();
expect(result.status, result.stderr).toBe(0);
- expect(result.output).toContain(`sha=${source}\n`);
- expect(result.output).toContain("version=99.1.2\n");
+ expect(result.output).toBe("image=ghcr.io/example/codex-security\n");
});
test("rejects a different commit with the same package version", () => {
@@ -141,64 +142,134 @@ test.each(["refs/heads/feature", "refs/tags/npm-v99.1.2"])(
},
);
-test("preserves standalone manual and container tag source selection", () => {
+test("routes new manual and tagged requests through the verified release coordinator", () => {
const source = fixture();
- const manual = source.run({ RELEASE_SHA: "", RELEASE_VERSION: "" });
+ const wrapper = workflow("container-release");
+ const released = source.commit("99.3.0");
+ source.git("tag", "npm-v99.3.0");
+ source.git("fetch", "origin", "main");
+ const manual = source.run({ GITHUB_SHA: released }, wrapper);
expect(manual.status, manual.stderr).toBe(0);
- expect(manual.output).toContain(`sha=${source.automation}\n`);
- expect(manual.output).toContain("version=99.2.0\n");
- const tagged = source.run({
- RELEASE_SHA: "",
- RELEASE_VERSION: "",
- GITHUB_SHA: source.source,
+ expect(manual.output).toBe("version=99.3.0\n");
+ const push = {
GITHUB_EVENT_NAME: "push",
- GITHUB_REF: "refs/tags/container-v99.1.2",
- GITHUB_REF_NAME: "container-v99.1.2",
- });
- expect(tagged.status, tagged.stderr).toBe(0);
- expect(tagged.output).toContain(`sha=${source.source}\n`);
+ GITHUB_REF: "refs/tags/container-v99.3.0",
+ GITHUB_SHA: released,
+ };
+ expect(source.run(push, wrapper).status).toBe(0);
+ expect(
+ source.run({ ...push, GITHUB_REF: "refs/tags/container-v99.3.1" }, wrapper)
+ .status,
+ ).not.toBe(0);
});
-test("coordinates publication, approval, and completion with the verified npm source", () => {
- const parent = workflow("node-github-release");
- expect(parent.jobs["container"]).toMatchObject({
- needs: ["release", "installed"],
- if: "needs.release.outputs.has-container == 'true'",
- uses: "./.github/workflows/container-release.yml",
- with: {
- "release-sha": "${{ needs.release.outputs.sha }}",
- "release-version": "${{ needs.release.outputs.version }}",
- },
- permissions: {
- contents: "read",
- packages: "write",
- attestations: "write",
- "artifact-metadata": "write",
- "id-token": "write",
- },
+test("requires both verified artifacts for a scanner release with the Wolfi builder", () => {
+ const source = fixture();
+ mkdirSync(join(source.repository, ".github/workflows"), { recursive: true });
+ writeFileSync(
+ join(source.repository, ".github/workflows/wolfi-build.yml"),
+ "",
+ );
+ const sha = source.commit("99.3.0");
+ source.git("tag", "npm-v99.3.0");
+ const inputs = {
+ RELEASE_SHA: sha,
+ RELEASE_VERSION: "99.3.0",
+ GITHUB_SHA: sha,
+ GITHUB_REF_PROTECTED: "true",
+ TARBALL: "123",
+ RUNTIME_LOCK: "456",
+ CLI_INTEGRITY: "sha512-test",
+ };
+ expect(source.run(inputs).output).toContain("wolfi=true\n");
+ for (const artifact of ["TARBALL", "RUNTIME_LOCK"]) {
+ expect(source.run({ ...inputs, [artifact]: "" }).status).not.toBe(0);
+ }
+});
+
+test("approves both tested container candidates in one deployment", () => {
+ const container = parent.jobs["container"]!;
+ expect(container.uses).toBe("./.github/workflows/container-publish.yml");
+ expect(container.needs).toContain("action-verify");
+ expect(container.needs).toContain("action");
+ expect(container.with).toMatchObject({
+ "release-sha": "${{ needs.release.outputs.sha }}",
+ "release-version": "${{ needs.release.outputs.version }}",
+ "release-integrity": "${{ needs.release.outputs.integrity }}",
+ "release-tarball-artifact":
+ "${{ needs.release.outputs.release-tarball-artifact }}",
+ "runtime-lock-artifact":
+ "${{ needs.action-verify.outputs.runtime-lock-artifact }}",
});
expect(parent.jobs["complete"]?.needs).toContain("container");
- expect(release.jobs["authorize"]).toMatchObject({
- needs: ["source", "validate"],
- environment: "container",
- permissions: { contents: "read", packages: "read" },
- });
- expect(release.jobs["publish-platform"]?.needs).toBe("authorize");
- expect(release.jobs["promote"]?.needs).toContain("attest");
- expect(release.jobs["attest"]?.permissions?.["artifact-metadata"]).toBe(
- "write",
+
+ expect(
+ Object.keys(release.jobs).filter(
+ (key) => release.jobs[key]!.environment === "container",
+ ),
+ ).toEqual(["authorize"]);
+ for (const candidate of ["debian", "wolfi"]) {
+ expect(release.jobs["authorize"]?.needs).toContain(candidate);
+ }
+ expect(release.jobs["manifest"]?.needs).toContain("authorize");
+ const upload = release.jobs["manifest"]!.steps!.find(
+ ({ name }) =>
+ name === "Upload the approved index and verify its anonymous digest",
+ )!.run!;
+ expect(upload).toContain(
+ "skopeo copy --all --src-no-creds --preserve-digests",
+ );
+ expect(upload).toContain(
+ '"docker://$IMAGE@$DIGEST" "oci:$RUNNER_TEMP/public:scanner"',
);
+
+ expect(release.jobs["publish-wolfi"]?.needs).toContain("authorize");
+ expect(release.jobs["promote"]?.needs).toContain("attest");
+ expect(release.jobs["promote"]?.needs).toContain("publish-wolfi");
expect(release.concurrency).toEqual({
group: "container-release-publish",
queue: "max",
});
});
-test("builds and downloads native payloads from the same source as the image", () => {
- expect(release.jobs["native"]?.with?.["ref"]).toBe(
- "${{ needs.source.outputs.sha }}",
+test("routes a Wolfi-only OS update through its own approval", () => {
+ const publisher = workflow("publish-wolfi");
+ const update = publisher.jobs["os-update"]!;
+ expect(update.uses).toBe("./.github/workflows/wolfi-build.yml");
+ expect(update.if).toContain("github.event_name == 'workflow_dispatch'");
+ expect(update.if).toContain("github.ref_protected");
+ expect(update.with).toMatchObject({
+ "release-version": "${{ inputs.release-version }}",
+ "os-update": true,
+ });
+ expect(publisher.jobs["authorize"]).toMatchObject({
+ environment: "container",
+ needs: "os-update",
+ });
+ const publish = publisher.jobs["publish"]!;
+ expect(publish.if).toContain("needs.authorize.result == 'success'");
+ expect(publish.if).toContain(
+ "inputs.artifact != '' && github.workflow_ref == 'openai/codex-security/.github/workflows/node-github-release.yml@refs/heads/main'",
);
- expect(release.jobs["validate"]?.with?.["ref"]).toBe(
+});
+
+test("passes the same verified npm tarball and runtime lock to both image builders", () => {
+ const debian = release.jobs["validate"]!;
+ const wolfi = release.jobs["wolfi"]!;
+ for (const key of [
+ "release-integrity",
+ "release-tarball-artifact",
+ "runtime-lock-artifact",
+ ]) {
+ expect(debian.with?.[key]).toBeTruthy();
+ expect(wolfi.with?.[key]).toBe(debian.with?.[key]);
+ }
+ expect(debian.with?.["ref"]).toBe("${{ needs.source.outputs.sha }}");
+ expect(wolfi.with?.["release-sha"]).toBe("${{ needs.source.outputs.sha }}");
+});
+
+test("keeps historical native payloads tied to the release checkout", () => {
+ expect(release.jobs["native"]?.with?.["ref"]).toBe(
"${{ needs.source.outputs.sha }}",
);
const native = workflow("native-artifacts");
@@ -222,30 +293,53 @@ test("builds and downloads native payloads from the same source as the image", (
(step) => step.name === "Upload universal native payload",
)?.with?.["name"],
).toBe("native-universal-${{ inputs.ref || github.sha }}");
- for (const job of ["publish-platform", "manifest"]) {
- expect(release.jobs[job]!.steps![0]?.with?.["ref"]).toBe(
- "${{ needs.authorize.outputs.sha }}",
- );
- }
- for (const job of ["authorize", "promote"]) {
- expect(release.jobs[job]!.steps![0]?.with?.["ref"]).toBe(
- "${{ github.sha }}",
- );
- }
- const buildSteps = release.jobs["publish-platform"]!.steps!;
- expect(
- buildSteps.find((step) => step.name === "Prepare native runtime")?.with?.[
- "name"
- ],
- ).toBe("native-universal-${{ needs.authorize.outputs.sha }}");
- const validation = workflow("container-validate").jobs["validate"]!.steps!;
- expect(validation[0]?.with?.["ref"]).toBe("${{ inputs.ref || github.sha }}");
- expect(validation[1]?.with?.["name"]).toBe(
- "native-universal-${{ inputs.ref || github.sha }}",
- );
});
const digest = `sha256:${"a".repeat(64)}`;
+const arm64Digest = `sha256:${"c".repeat(64)}`;
+test.each([
+ ["historical Debian", false, "", true],
+ ["missing Wolfi", true, "", false],
+ ["published Wolfi", true, "99.1.2-wolfi-amd64", true],
+ ["different Wolfi tag digest", true, "unexpected", false],
+] as const)(
+ "verifies the public digests before completing publication: %s",
+ (_case, required, approvedWolfi, succeeds) => {
+ const directory = directories.create("container completion ");
+ const image = "ghcr.io/example/scanner";
+ const version = "99.1.2";
+ const tagDigest = (tag: string) =>
+ `sha256:${createHash("sha256").update(`docker://${image}:${tag}`).digest("hex")}`;
+ writeFileSync(join(directory, "skopeo"), `#!/bin/sh\nprintf '%s' "$4"\n`, {
+ mode: 0o755,
+ });
+ if (process.platform === "darwin" && !Bun.which("sha256sum")) {
+ writeFileSync(
+ join(directory, "sha256sum"),
+ '#!/bin/sh\nexec shasum -a 256 "$@"\n',
+ { mode: 0o755 },
+ );
+ }
+ const result = runWorkflowScript(
+ directory,
+ release.jobs["complete"]!.steps![0]!.run,
+ {
+ GITHUB_OUTPUT: join(directory, "output").replaceAll("\\", "/"),
+ PATH: `${directory}${delimiter}${process.env["PATH"]}`,
+ IMAGE: image,
+ VERSION: version,
+ SOURCE_OK: "success",
+ DEBIAN: tagDigest(version),
+ DEBIAN_OK: "true",
+ WOLFI: approvedWolfi && tagDigest(approvedWolfi),
+ WOLFI_OK: String(Boolean(approvedWolfi)),
+ WOLFI_REQUIRED: String(required),
+ },
+ );
+ expect(result.status === 0, result.stderr).toBe(succeeds);
+ },
+);
+
function existingFixture() {
const directory = directories.create("container release ");
const source = "1".repeat(40);
@@ -267,7 +361,20 @@ function existingFixture() {
`#!/bin/sh
case "$1" in
api) printf '%s\\n' "$MOCK_VERSIONS"; exit "$MOCK_API_STATUS" ;;
- attestation) printf '%s\\n' "$*" >> "$EVENTS"; exit "$MOCK_ATTESTATION_STATUS" ;;
+ attestation)
+ printf '%s\\n' "$*" >> "$EVENTS"
+ shift 3
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --repo) [ "$2" = "example/project" ] || exit 1 ;;
+ --cert-identity) [ "$2" = "https://github.com/example/project/.github/workflows/$MOCK_SIGNER.yml@$MOCK_SIGNER_REF" ] || exit 1 ;;
+ --source-ref) [ "$2" = "$MOCK_SOURCE_REF" ] || exit 1 ;;
+ --source-digest) [ "$2" = "$MOCK_SOURCE_SHA" ] || exit 1 ;;
+ *) exit 99 ;;
+ esac
+ shift 2
+ done
+ exit "$MOCK_ATTESTATION_STATUS" ;;
*) exit 99 ;;
esac
`,
@@ -279,7 +386,11 @@ esac
printf '%s\\n' "$*" >> "$EVENTS"
case "$1" in
buildx) printf '%s\\n' "$MOCK_MANIFEST" ;;
- pull|run) exit "$MOCK_DOCKER_STATUS" ;;
+ logout) exit 0 ;;
+ pull)
+ if [ "$3" = linux/arm64 ] && [ "$MOCK_ARM64_PULL_STATUS" != 0 ]; then exit "$MOCK_ARM64_PULL_STATUS"; fi
+ exit "$MOCK_DOCKER_STATUS" ;;
+ run) printf '%s\\n' "$MOCK_CLI_VERSION"; exit "$MOCK_DOCKER_STATUS" ;;
*) exit 99 ;;
esac
`,
@@ -290,25 +401,37 @@ esac
"org.opencontainers.image.version": "99.1.2",
"org.opencontainers.image.revision": source,
},
- manifests: ["amd64", "arm64"].map((architecture) => ({
- platform: { os: "linux", architecture },
- })),
+ manifests: [
+ {
+ digest: `sha256:${"d".repeat(64)}`,
+ platform: { os: "linux", architecture: "amd64" },
+ },
+ { digest: arm64Digest, platform: { os: "linux", architecture: "arm64" } },
+ ],
};
const script = release.jobs["source"]!.steps!.find(
(step) => step.name === "Verify an existing immutable container release",
)!.run;
- function run(env: Record<string, string> = {}) {
+ function run(env: Record<string, string> = {}, command = script) {
writeFileSync(events, "");
writeFileSync(output, "");
- const result = runWorkflowScript(repository, script, {
+ const result = runWorkflowScript(repository, command, {
PATH: `${bin}${delimiter}${process.env["PATH"]}`,
EVENTS: events.replaceAll("\\", "/"),
GITHUB_OUTPUT: output.replaceAll("\\", "/"),
GITHUB_REPOSITORY: "example/project",
+ GITHUB_SERVER_URL: "https://github.com",
GITHUB_REPOSITORY_OWNER: "Example",
IMAGE: "ghcr.io/example/codex-security",
VERSION: "99.1.2",
RELEASE_SHA: source,
+ DIGEST: digest,
+ HAS_WOLFI: "true",
+ MOCK_SIGNER: "container-publish",
+ MOCK_SIGNER_REF: "refs/heads/main",
+ MOCK_SOURCE_REF: "refs/heads/main",
+ MOCK_SOURCE_SHA: source,
+ RUNNER_TEMP: directory.replaceAll("\\", "/"),
MOCK_VERSIONS: JSON.stringify([
{
name: digest,
@@ -321,6 +444,8 @@ esac
MOCK_API_STATUS: "0",
MOCK_ATTESTATION_STATUS: "0",
MOCK_DOCKER_STATUS: "0",
+ MOCK_ARM64_PULL_STATUS: "0",
+ MOCK_CLI_VERSION: "99.1.2",
...env,
});
return {
@@ -337,14 +462,93 @@ test("verifies and reuses the published source without a registry write", () =>
const result = run();
expect(result.status, result.stderr).toBe(0);
expect(result.output).toContain(`digest=${digest}\n`);
+ expect(result.output).toContain("complete=true\n");
expect(result.events.trim().split("\n")).toEqual([
`buildx imagetools inspect ghcr.io/example/codex-security@${digest} --raw`,
- `attestation verify oci://ghcr.io/example/codex-security@${digest} --repo example/project`,
- `pull ghcr.io/example/codex-security@${digest}`,
- `run --rm ghcr.io/example/codex-security@${digest} --version`,
+ `attestation verify oci://ghcr.io/example/codex-security@${digest} --repo example/project --cert-identity https://github.com/example/project/.github/workflows/container-publish.yml@refs/heads/main --source-ref refs/heads/main`,
+ "logout ghcr.io",
+ `pull --platform linux/arm64 ghcr.io/example/codex-security@${arm64Digest}`,
+ `pull --platform linux/amd64 ghcr.io/example/codex-security@${digest}`,
+ `run --rm --platform linux/amd64 ghcr.io/example/codex-security@${digest} --version`,
]);
});
+const historicalTag = "refs/tags/container-v99.1.2";
+const historicalSigner = {
+ HAS_WOLFI: "false",
+ MOCK_SIGNER: "container-release",
+};
+const historicalTagSigner = {
+ ...historicalSigner,
+ MOCK_SIGNER_REF: historicalTag,
+ MOCK_SOURCE_REF: historicalTag,
+};
+const signerCases: [string, Record<string, string>, boolean][] = [
+ ["historical main", historicalSigner, true],
+ ["historical release tag", historicalTagSigner, true],
+ [
+ "wrong historical source commit",
+ { ...historicalTagSigner, MOCK_SOURCE_SHA: "2".repeat(40) },
+ false,
+ ],
+ [
+ "historical signer on a coordinated release",
+ { ...historicalSigner, HAS_WOLFI: "true" },
+ false,
+ ],
+ ["another repository workflow", { MOCK_SIGNER: "container-ci" }, false],
+ [
+ "unprotected signing branch",
+ { MOCK_SIGNER_REF: "refs/heads/feature" },
+ false,
+ ],
+ [
+ "unprotected caller branch",
+ { MOCK_SOURCE_REF: "refs/heads/feature" },
+ false,
+ ],
+];
+
+test.each(signerCases)(
+ "checks recovered image attestation: %s",
+ (_name, claims, allowed) => {
+ const result = existingFixture().run(claims);
+ expect(result.status === 0, result.stderr).toBe(allowed);
+ expect(result.output.includes(`digest=${digest}`)).toBe(allowed);
+ },
+);
+
+test("verifies newly signed images with the protected publisher", () => {
+ const script = release.jobs["attest"]!.steps!.find(
+ ({ name }) => name === "Verify the published provenance",
+ )!.run!;
+ const { run } = existingFixture();
+ expect(run({}, script).status).toBe(0);
+ const untrusted: Record<string, string>[] = [
+ historicalSigner,
+ { MOCK_SIGNER_REF: "refs/heads/feature" },
+ { MOCK_SOURCE_REF: "refs/heads/feature" },
+ ];
+ for (const claims of untrusted) {
+ expect(run(claims, script).status).not.toBe(0);
+ }
+});
+
+test("stops recovery when the existing arm64 image cannot be pulled anonymously", () => {
+ const result = existingFixture().run({ MOCK_ARM64_PULL_STATUS: "1" });
+ expect(result.status).not.toBe(0);
+ expect(result.output).toBe("");
+ expect(result.events.trim().split("\n").at(-1)).toBe(
+ `pull --platform linux/arm64 ghcr.io/example/codex-security@${arm64Digest}`,
+ );
+});
+
+test("rejects an existing index when the scanner version differs from its label", () => {
+ const result = existingFixture().run({ MOCK_CLI_VERSION: "99.1.1" });
+ expect(result.status).not.toBe(0);
+ expect(result.output).not.toContain("digest=");
+});
+
test("leaves an unpublished version on the build and approval path", () => {
const result = existingFixture().run({ MOCK_VERSIONS: "[]" });
expect(result.status, result.stderr).toBe(0);
@@ -378,27 +582,64 @@ test.each(["source", "version", "architecture"] as const)(
},
);
-test("does not reuse a version whose latest tag is incomplete", () => {
+test.each(["latest", "sha", "version", "version and sha"] as const)(
+ "resumes an attested index with a missing %s tag",
+ (missing) => {
+ const { run, source } = existingFixture();
+ const tags = { latest: "latest", sha: `sha-${source}`, version: "99.1.2" };
+ const result = run({
+ MOCK_VERSIONS: JSON.stringify([
+ {
+ name: digest,
+ metadata: {
+ container: {
+ tags:
+ missing === "version and sha"
+ ? [tags.latest]
+ : Object.values(tags).filter((tag) => tag !== tags[missing]),
+ },
+ },
+ },
+ ]),
+ });
+ expect(result.status, result.stderr).toBe(0);
+ expect(result.output).toContain(`digest=${digest}\n`);
+ expect(result.output).toContain("complete=false\n");
+ expect(result.events).toContain(
+ `attestation verify oci://ghcr.io/example/codex-security@${digest}`,
+ );
+ },
+);
+
+test.each(["version", "revision"] as const)(
+ "checks the %s of a latest-only index",
+ (different) => {
+ const { run, manifest } = existingFixture();
+ if (different === "version")
+ manifest.annotations["org.opencontainers.image.version"] = "99.1.1";
+ manifest.annotations["org.opencontainers.image.revision"] = "b".repeat(40);
+ const result = run({
+ MOCK_VERSIONS: JSON.stringify([
+ { name: digest, metadata: { container: { tags: ["latest"] } } },
+ ]),
+ MOCK_MANIFEST: JSON.stringify(manifest),
+ });
+ expect(result.status, result.stderr).toBe(different === "version" ? 0 : 1);
+ expect(result.output).toBe("");
+ },
+);
+
+test("refuses to replace a source tag pointing at another index", () => {
const { run, source } = existingFixture();
const result = run({
MOCK_VERSIONS: JSON.stringify([
+ { name: digest, metadata: { container: { tags: ["99.1.2", "latest"] } } },
{
- name: digest,
- metadata: { container: { tags: ["99.1.2", `sha-${source}`] } },
+ name: `sha256:${"b".repeat(64)}`,
+ metadata: { container: { tags: [`sha-${source}`] } },
},
]),
});
expect(result.status).not.toBe(0);
- expect(result.stderr).toContain("matching latest tag");
expect(result.output).not.toContain("digest=");
});
-
-test("does not reuse a version missing its source commit tag", () => {
- const result = existingFixture().run({
- MOCK_VERSIONS: JSON.stringify([
- { name: digest, metadata: { container: { tags: ["99.1.2", "latest"] } } },
- ]),
- });
- expect(result.status).not.toBe(0);
- expect(result.output).toBe("");
-});
diff --git a/sdk/typescript/tests-ts/native-artifact-cache.test.ts b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
index 5b24f9d70..889510ad1 100644
--- a/sdk/typescript/tests-ts/native-artifact-cache.test.ts
+++ b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
@@ -222,7 +222,7 @@ test("source CI opts in to native artifact reuse", () => {
expect(workflow("node-ci").jobs["native"]?.with?.["reuse-verified"]).toBe(
true,
);
- for (const caller of ["node-release", "container-release", "container-ci"]) {
+ for (const caller of ["node-release", "container-publish", "container-ci"]) {
expect(
workflow(caller).jobs["native"]?.with?.["reuse-verified"],
).toBeUndefined();
diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts
index 98f1aacba..3f80f9292 100644
--- a/sdk/typescript/tests-ts/release-automation.test.ts
+++ b/sdk/typescript/tests-ts/release-automation.test.ts
@@ -2847,6 +2847,18 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}
);
test.each([
+ {
+ workflow: readFileSync(
+ new URL(
+ "../../../.github/workflows/container-release.yml",
+ import.meta.url,
+ ),
+ "utf8",
+ ),
+ step: "Dispatch the coordinator on protected main",
+ target: "node-github-release.yml",
+ fields: ["-f", "ref=main", "-f", "inputs[tag]=npm-v0.1.2"],
+ },
{
workflow: releaseCutWorkflow,
step: "Dispatch the protected npm release",
@@ -2875,6 +2887,12 @@ ${workflowStepShell(releaseCutWorkflow, "Resolve the stable package version")}
const mock = "gh() { printf '%s\\n' \"$@\" >&2; printf '12345\\n'; }";
const env = {
GITHUB_REPOSITORY: releaseRepository,
+ GITHUB_SERVER_URL: "https://github.com",
+ GITHUB_STEP_SUMMARY: join(
+ directories.create("release-summary-"),
+ "summary",
+ ),
+ VERSION: "0.1.2",
RELEASE_RUN_ID: releaseRun,
RELEASE_TAG: "npm-v0.1.2",
GITHUB_OUTPUT: output,