OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
refactor(container): share one image for scanner and findings service (#701)
Kyle Brownd4877e4e493a
diff --git a/.github/workflows/container-ci.yml b/.github/workflows/container-ci.ymlindex ee0d244aa..d55e90871 100644--- a/.github/workflows/container-ci.yml+++ b/.github/workflows/container-ci.yml@@ -111,9 +111,7 @@ jobs:bun-version: "1.3.14"- name: Verify findings service and persistent SQLite storage- env:- CODEX_SECURITY_IMAGE: codex-security:ci- run: bun sdk/typescript/scripts/smoke-findings-service.ts+ run: bun sdk/typescript/scripts/smoke-findings-service.ts codex-security:ci- name: Validate hardened customer Compose configurationenv:diff --git a/.github/workflows/container-release-image.yml b/.github/workflows/container-release-image.ymldeleted file mode 100644index 054bbe770..000000000--- a/.github/workflows/container-release-image.yml+++ /dev/null@@ -1,653 +0,0 @@-name: container-release-image--on:- workflow_call:- inputs:- target:- required: true- type: string- package:- required: true- type: string--permissions:- contents: read--jobs:- validate:- name: validate-linux-${{ matrix.architecture }}- runs-on: ${{ matrix.runner }}- timeout-minutes: 45- strategy:- fail-fast: false- matrix:- include:- - architecture: amd64- runner: ubuntu-24.04- - architecture: arm64- runner: ubuntu-24.04-arm-- steps:- - name: Checkout repository- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- persist-credentials: false-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0-- - name: Build native customer image- uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0- env:- DOCKER_BUILD_RECORD_UPLOAD: "false"- with:- context: .- target: ${{ inputs.target }}- load: true- platforms: linux/${{ matrix.architecture }}- push: false- tags: codex-security:release-candidate- cache-from: type=gha,scope=${{ inputs.package }}-${{ matrix.architecture }}- cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,scope={0}-{1}', inputs.package, matrix.architecture) || '' }}-- - name: Verify native image- env:- EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}- TARGET: ${{ inputs.target }}- shell: bash- run: |- set -euo pipefail- actual_architecture="$(docker image inspect --format '{{.Architecture}}' codex-security:release-candidate)"- if [[ "$actual_architecture" != "$EXPECTED_ARCHITECTURE" ]]; then- echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2- exit 1- fi- if [[ "$TARGET" == scanner ]]; then- docker run --rm codex-security:release-candidate --version- docker run --rm codex-security:release-candidate bulk-scan --help- docker run --rm codex-security:release-candidate info --json- fi- [[ "$(docker run --rm --entrypoint id codex-security:release-candidate -u)" == 10001 ]]-- - name: Verify host-aware AppArmor sandbox selection- if: inputs.target == 'scanner'- shell: bash- run: |- set -euo pipefail- docker run --rm --entrypoint /bin/sh codex-security:release-candidate -ec '- command_directory="$(mktemp -d)"- trap '\''rm -rf "$command_directory"'\'' EXIT- printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' > "$command_directory/codex-security"- chmod 755 "$command_directory/codex-security"-- actual="$(- PATH="$command_directory:$PATH" \- /usr/local/bin/codex-security-entrypoint \- bulk-scan /input/repositories.csv --output-dir /output- )"- restricted_user_namespaces=- if [ -r /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then- IFS= read -r restricted_user_namespaces \- < /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true- fi-- apparmor_profile=- if [ -r /proc/self/attr/current ]; then- IFS= read -r apparmor_profile < /proc/self/attr/current || true- fi-- if [ "$restricted_user_namespaces" = 1 ] &&- [ "$apparmor_profile" != "codex-security-container (enforce)" ]; then- printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true- elif printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true; then- printf "%s\\n" "Landlock must not be forced when the preferred sandbox is available." >&2- exit 1- fi- '-- - name: Verify hardened Codex command sandbox- if: inputs.target == 'scanner'- shell: bash- run: |- set -euo pipefail- command=(- docker run --rm- --cap-drop ALL- --security-opt no-new-privileges- --security-opt "seccomp=$GITHUB_WORKSPACE/docker/codex-security-seccomp.json"- --entrypoint node- codex-security:release-candidate- /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js- )-- if output="$("${command[@]}" sandbox /usr/bin/true 2>&1)"; then- printf '%s\n' "$output"- elif grep -Eq 'bwrap: (Failed to make / slave: Permission denied|loopback: Failed RTM_NEW(ADDR|LINK): Operation not permitted|setting up uid map: Permission denied|No permissions to create a new namespace)' <<< "$output"; then- echo '::notice::This Docker host blocks nested Bubblewrap namespaces; verifying the supported Landlock fallback.'- "${command[@]}" sandbox --enable use_legacy_landlock /usr/bin/true- else- printf 'The hardened Codex sandbox failed unexpectedly:\n%s\n' "$output" >&2- exit 1- fi-- - name: Verify host-scoped Git credentials- if: inputs.target == 'scanner'- shell: bash- run: |- set -euo pipefail- docker run --rm \- --entrypoint /bin/sh \- --env GH_TOKEN=SYNTHETIC_GITHUB_TOKEN \- codex-security:release-candidate \- -ec 'actual="$(printf "protocol=https\nhost=github.com\n\n" | /usr/local/bin/codex-security-git-credential get)"; test "$actual" = "$(printf "username=x-access-token\npassword=SYNTHETIC_GITHUB_TOKEN")"; test -z "$(printf "protocol=https\nhost=untrusted.example\n\n" | /usr/local/bin/codex-security-git-credential get)"'-- - name: Verify hardened customer Compose configuration- if: inputs.target == 'scanner'- env:- CODEX_SECURITY_IMAGE: codex-security:release-candidate- shell: bash- run: |- set -euo pipefail- mkdir -p results state- chmod 700 results state- printf 'id,repository,revision\n' > repositories.csv- CODEX_SECURITY_USER="$(id -u):$(id -g)"- export CODEX_SECURITY_USER- docker compose config --quiet- docker compose run --rm codex-security --version- if output="$(docker compose run --rm codex-security 2>&1)"; then- echo 'An empty repository CSV must not start a security scan.' >&2- exit 1- else- status=$?- fi- if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then- printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2- exit 1- fi-- - name: Verify optional hardened AppArmor Compose override- if: inputs.target == 'scanner'- env:- CODEX_SECURITY_IMAGE: codex-security:release-candidate- shell: bash- run: |- set -euo pipefail- CODEX_SECURITY_USER="$(id -u):$(id -g)"- export CODEX_SECURITY_USER- compose=(docker compose -f compose.yaml -f compose.apparmor.yaml)-- "${compose[@]}" config --format json |- jq --exit-status '- .services["codex-security"].security_opt as $options |- ($options | index("apparmor=codex-security-container")) != null and- ($options | index("no-new-privileges:true")) != null and- any($options[]; startswith("seccomp="))- ' > /dev/null-- if ! docker info --format '{{json .SecurityOptions}}' |- grep -Fq '"name=apparmor"'; then- echo '::notice::This Docker host does not expose AppArmor; the default customer workflow remains available.'- exit 0- fi-- sudo install -m 0644 docker/codex-security.apparmor \- /etc/apparmor.d/codex-security-container- sudo apparmor_parser -r -W /etc/apparmor.d/codex-security-container- sudo grep -Fxq 'codex-security-container (enforce)' \- /sys/kernel/security/apparmor/profiles-- # The single-quoted program is evaluated inside the customer container.- # shellcheck disable=SC2016- "${compose[@]}" run --rm --entrypoint /bin/sh codex-security -ec '- test "$(cat /proc/self/attr/current)" = "codex-security-container (enforce)"- command_directory="$(mktemp -d)"- trap '\''rm -rf "$command_directory"'\'' EXIT- printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' \- > "$command_directory/codex-security"- chmod 755 "$command_directory/codex-security"- actual="$(- PATH="$command_directory:$PATH" \- /usr/local/bin/codex-security-entrypoint \- bulk-scan /input/repositories.csv --output-dir /output- )"- if printf "%s\\n" "$actual" |- grep -Fxq features.use_legacy_landlock=true; then- printf "%s\\n" "The AppArmor profile must retain the preferred Codex sandbox." >&2- exit 1- 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-- - name: Set up Bun for findings service verification- if: inputs.target == 'findings-service'- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2- with:- bun-version: "1.3.14"-- - name: Verify findings API and persistent storage through consumer Compose- if: inputs.target == 'findings-service'- env:- IMAGE: codex-security:release-candidate- run: bun sdk/typescript/scripts/smoke-findings-service.ts "$IMAGE"-- authorize:- if: github.event_name != 'pull_request'- name: authorize-container-publication- needs: validate- runs-on: ubuntu-24.04- timeout-minutes: 10- environment: container- permissions:- contents: read- packages: read- outputs:- image: ${{ steps.release.outputs.image }}- version: ${{ steps.release.outputs.version }}-- steps:- - name: Checkout release source- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- fetch-depth: 0- persist-credentials: false-- - name: Validate protected release source and version- id: release- env:- PACKAGE: ${{ inputs.package }}- shell: bash- run: |- set -euo pipefail- package_version="$(node -p 'require("./sdk/typescript/package.json").version')"-- if [[ "$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="$package_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}"- else- echo 'Container release tags must identify a stable version such as container-v0.1.0.' >&2- exit 1- fi-- 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 "$GITHUB_SHA" refs/remotes/origin/main; then- echo 'Container releases must be built from a commit on the protected main branch.' >&2- exit 1- fi-- printf 'image=ghcr.io/%s\n' "${GITHUB_REPOSITORY_OWNER,,}/$PACKAGE" >> "$GITHUB_OUTPUT"- printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"-- - name: Preflight public package and immutable release version- env:- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}- PACKAGE: ${{ inputs.package }}- VERSION: ${{ steps.release.outputs.version }}- shell: bash- run: |- set -euo pipefail- owner="${GITHUB_REPOSITORY_OWNER,,}"- endpoint="orgs/$owner/packages/container/$PACKAGE"-- if ! metadata="$(gh api "$endpoint" 2>/dev/null)"; then- echo "::error::A repository administrator must bootstrap ghcr.io/$owner/$PACKAGE, 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/$PACKAGE must be public before any release image is pushed."- exit 1- fi-- sh docker/verify-container-release-version.sh "$endpoint" "$VERSION"-- 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- persist-credentials: false-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0-- - 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@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0- with:- context: .- target: ${{ inputs.target }}- 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=${{ inputs.package }}-${{ matrix.architecture }}- cache-to: type=gha,mode=max,scope=${{ inputs.package }}-${{ matrix.architecture }}- labels: |- org.opencontainers.image.source=https://github.com/${{ github.repository }}- org.opencontainers.image.version=${{ needs.authorize.outputs.version }}- org.opencontainers.image.revision=${{ github.sha }}-- - name: Verify the exact published native image- env:- EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}- TARGET: ${{ inputs.target }}- IMAGE: ${{ needs.authorize.outputs.image }}- IMAGE_DIGEST: ${{ steps.build.outputs.digest }}- 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-- if [[ "$TARGET" == scanner ]]; then- docker run --rm "$reference" --version- docker run --rm "$reference" bulk-scan --help- docker run --rm "$reference" info --json- fi- [[ "$(docker run --rm --entrypoint id "$reference" -u)" == 10001 ]]-- - name: Set up Bun for findings service verification- if: inputs.target == 'findings-service'- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2- with:- bun-version: "1.3.14"-- - name: Verify findings API and persistent storage through consumer Compose- if: inputs.target == 'findings-service'- env:- IMAGE: ${{ needs.authorize.outputs.image }}@${{ steps.build.outputs.digest }}- run: bun sdk/typescript/scripts/smoke-findings-service.ts "$IMAGE"-- - name: Record verified platform digest- env:- IMAGE_DIGEST: ${{ steps.build.outputs.digest }}- 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- mkdir -p "$RUNNER_TEMP/${{ inputs.package }}-platform-digests"- touch "$RUNNER_TEMP/${{ inputs.package }}-platform-digests/${IMAGE_DIGEST#sha256:}"-- - name: Upload platform digest- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1- with:- name: ${{ inputs.package }}-image-digest-${{ matrix.architecture }}- path: ${{ runner.temp }}/${{ inputs.package }}-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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- persist-credentials: false-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0-- - name: Download verified platform digests- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1- with:- path: ${{ runner.temp }}/${{ inputs.package }}-platform-digests- pattern: ${{ inputs.package }}-image-digest-*- merge-multiple: true-- - 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 provisional multiarchitecture candidate- id: manifest- env:- IMAGE: ${{ needs.authorize.outputs.image }}- shell: bash- run: |- set -euo pipefail- mapfile -t digest_files < <(- find "$RUNNER_TEMP/${{ inputs.package }}-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-- candidate="$IMAGE:release-candidate-$GITHUB_SHA"- docker buildx imagetools create \- --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 '- [.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 }}- TARGET: ${{ inputs.target }}- 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- if [[ "$TARGET" == scanner ]]; then- docker run --rm "$CANDIDATE" --version- docker run --rm "$CANDIDATE" bulk-scan --help- docker run --rm "$CANDIDATE" info --json- fi-- - name: Verify hardened customer Compose against the public candidate- if: inputs.target == 'scanner'- env:- CODEX_SECURITY_IMAGE: ${{ steps.manifest.outputs.candidate }}- shell: bash- run: |- set -euo pipefail- mkdir -p results state- chmod 700 results state- printf 'id,repository,revision\n' > repositories.csv- CODEX_SECURITY_USER="$(id -u):$(id -g)"- export CODEX_SECURITY_USER- docker compose config --quiet- docker compose run --rm codex-security --version- if output="$(docker compose run --rm codex-security 2>&1)"; then- echo 'An empty repository CSV must not start a security scan.' >&2- exit 1- else- status=$?- fi- if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then- printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2- exit 1- fi-- attest:- name: attest-verified-multiarchitecture-candidate- needs:- - authorize- - manifest- runs-on: ubuntu-24.04- timeout-minutes: 10- permissions:- attestations: write- contents: read- id-token: write- packages: write-- steps:- - 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: Sign verified multiarchitecture candidate provenance- uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1- 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- persist-credentials: false-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0-- - 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: Promote the verified, attested, immutable image digest- env:- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}- PACKAGE: ${{ inputs.package }}- IMAGE: ${{ needs.authorize.outputs.image }}- 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/$PACKAGE"- sh docker/verify-container-release-version.sh "$endpoint" "$VERSION"-- docker buildx imagetools create \- --tag "$IMAGE:$VERSION" \- --tag "$IMAGE:sha-$GITHUB_SHA" \- --tag "$IMAGE:latest" \- "$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" --versiondiff --git a/.github/workflows/container-release.yml b/.github/workflows/container-release.ymlindex 20c573e43..a651ef487 100644--- a/.github/workflows/container-release.yml+++ b/.github/workflows/container-release.yml@@ -4,7 +4,7 @@ on:pull_request:paths:- .dockerignore- - .github/workflows/container-release*.yml+ - .github/workflows/container-release.yml- Dockerfile- Dockerfile.dockerignore- compose.yaml@@ -27,22 +27,616 @@ permissions:contents: readjobs:- release:+ validate:if: github.repository == 'openai/codex-security'+ name: validate-linux-${{ matrix.architecture }}+ runs-on: ${{ matrix.runner }}+ timeout-minutes: 45strategy:fail-fast: falsematrix:include:- - target: scanner- package: codex-security- - target: findings-service- package: codex-security-findings+ - architecture: amd64+ runner: ubuntu-24.04+ - architecture: arm64+ runner: ubuntu-24.04-arm++ steps:+ - name: Checkout repository+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0++ - name: Build native customer image+ uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0+ env:+ DOCKER_BUILD_RECORD_UPLOAD: "false"+ with:+ context: .+ load: true+ platforms: linux/${{ matrix.architecture }}+ push: false+ tags: codex-security:release-candidate+ cache-from: type=gha,scope=codex-security-${{ matrix.architecture }}+ cache-to: ${{ github.event_name != 'pull_request' && format('type=gha,mode=max,scope=codex-security-{0}', matrix.architecture) || '' }}++ - name: Verify native image+ env:+ EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}+ shell: bash+ run: |+ set -euo pipefail+ actual_architecture="$(docker image inspect --format '{{.Architecture}}' codex-security:release-candidate)"+ if [[ "$actual_architecture" != "$EXPECTED_ARCHITECTURE" ]]; then+ echo "Expected a native $EXPECTED_ARCHITECTURE image; found $actual_architecture." >&2+ exit 1+ fi+ docker run --rm codex-security:release-candidate --version+ 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 ]]++ - name: Verify host-aware AppArmor sandbox selection+ shell: bash+ run: |+ set -euo pipefail+ docker run --rm --entrypoint /bin/sh codex-security:release-candidate -ec '+ command_directory="$(mktemp -d)"+ trap '\''rm -rf "$command_directory"'\'' EXIT+ printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' > "$command_directory/codex-security"+ chmod 755 "$command_directory/codex-security"++ actual="$(+ PATH="$command_directory:$PATH" \+ /usr/local/bin/codex-security-entrypoint \+ bulk-scan /input/repositories.csv --output-dir /output+ )"+ restricted_user_namespaces=+ if [ -r /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then+ IFS= read -r restricted_user_namespaces \+ < /proc/sys/kernel/apparmor_restrict_unprivileged_userns || true+ fi++ apparmor_profile=+ if [ -r /proc/self/attr/current ]; then+ IFS= read -r apparmor_profile < /proc/self/attr/current || true+ fi++ if [ "$restricted_user_namespaces" = 1 ] &&+ [ "$apparmor_profile" != "codex-security-container (enforce)" ]; then+ printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true+ elif printf "%s\\n" "$actual" | grep -Fxq features.use_legacy_landlock=true; then+ printf "%s\\n" "Landlock must not be forced when the preferred sandbox is available." >&2+ exit 1+ fi+ '++ - name: Verify hardened Codex command sandbox+ shell: bash+ run: |+ set -euo pipefail+ command=(+ docker run --rm+ --cap-drop ALL+ --security-opt no-new-privileges+ --security-opt "seccomp=$GITHUB_WORKSPACE/docker/codex-security-seccomp.json"+ --entrypoint node+ codex-security:release-candidate+ /usr/local/lib/node_modules/@openai/codex-security/node_modules/@openai/codex/bin/codex.js+ )++ if output="$("${command[@]}" sandbox /usr/bin/true 2>&1)"; then+ printf '%s\n' "$output"+ elif grep -Eq 'bwrap: (Failed to make / slave: Permission denied|loopback: Failed RTM_NEW(ADDR|LINK): Operation not permitted|setting up uid map: Permission denied|No permissions to create a new namespace)' <<< "$output"; then+ echo '::notice::This Docker host blocks nested Bubblewrap namespaces; verifying the supported Landlock fallback.'+ "${command[@]}" sandbox --enable use_legacy_landlock /usr/bin/true+ else+ printf 'The hardened Codex sandbox failed unexpectedly:\n%s\n' "$output" >&2+ exit 1+ fi++ - name: Verify host-scoped Git credentials+ shell: bash+ run: |+ set -euo pipefail+ docker run --rm \+ --entrypoint /bin/sh \+ --env GH_TOKEN=SYNTHETIC_GITHUB_TOKEN \+ codex-security:release-candidate \+ -ec 'actual="$(printf "protocol=https\nhost=github.com\n\n" | /usr/local/bin/codex-security-git-credential get)"; test "$actual" = "$(printf "username=x-access-token\npassword=SYNTHETIC_GITHUB_TOKEN")"; test -z "$(printf "protocol=https\nhost=untrusted.example\n\n" | /usr/local/bin/codex-security-git-credential get)"'++ - name: Verify hardened customer Compose configuration+ env:+ CODEX_SECURITY_IMAGE: codex-security:release-candidate+ shell: bash+ run: |+ set -euo pipefail+ mkdir -p results state+ chmod 700 results state+ printf 'id,repository,revision\n' > repositories.csv+ CODEX_SECURITY_USER="$(id -u):$(id -g)"+ export CODEX_SECURITY_USER+ docker compose config --quiet+ docker compose run --rm codex-security --version+ if output="$(docker compose run --rm codex-security 2>&1)"; then+ echo 'An empty repository CSV must not start a security scan.' >&2+ exit 1+ else+ status=$?+ fi+ if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then+ printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2+ exit 1+ fi++ - name: Verify optional hardened AppArmor Compose override+ env:+ CODEX_SECURITY_IMAGE: codex-security:release-candidate+ shell: bash+ run: |+ set -euo pipefail+ CODEX_SECURITY_USER="$(id -u):$(id -g)"+ export CODEX_SECURITY_USER+ compose=(docker compose -f compose.yaml -f compose.apparmor.yaml)++ "${compose[@]}" config --format json |+ jq --exit-status '+ .services["codex-security"].security_opt as $options |+ ($options | index("apparmor=codex-security-container")) != null and+ ($options | index("no-new-privileges:true")) != null and+ any($options[]; startswith("seccomp="))+ ' > /dev/null++ if ! docker info --format '{{json .SecurityOptions}}' |+ grep -Fq '"name=apparmor"'; then+ echo '::notice::This Docker host does not expose AppArmor; the default customer workflow remains available.'+ exit 0+ fi++ sudo install -m 0644 docker/codex-security.apparmor \+ /etc/apparmor.d/codex-security-container+ sudo apparmor_parser -r -W /etc/apparmor.d/codex-security-container+ sudo grep -Fxq 'codex-security-container (enforce)' \+ /sys/kernel/security/apparmor/profiles++ # The single-quoted program is evaluated inside the customer container.+ # shellcheck disable=SC2016+ "${compose[@]}" run --rm --entrypoint /bin/sh codex-security -ec '+ test "$(cat /proc/self/attr/current)" = "codex-security-container (enforce)"+ command_directory="$(mktemp -d)"+ trap '\''rm -rf "$command_directory"'\'' EXIT+ printf "%s\\n" "#!/bin/sh" '\''printf "%s\\n" "$@"'\'' \+ > "$command_directory/codex-security"+ chmod 755 "$command_directory/codex-security"+ actual="$(+ PATH="$command_directory:$PATH" \+ /usr/local/bin/codex-security-entrypoint \+ bulk-scan /input/repositories.csv --output-dir /output+ )"+ if printf "%s\\n" "$actual" |+ grep -Fxq features.use_legacy_landlock=true; then+ printf "%s\\n" "The AppArmor profile must retain the preferred Codex sandbox." >&2+ exit 1+ 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++ - name: Set up Bun for findings service verification+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ with:+ bun-version: "1.3.14"++ - name: Verify findings API and persistent storage through consumer Compose+ env:+ IMAGE: codex-security:release-candidate+ run: bun sdk/typescript/scripts/smoke-findings-service.ts "$IMAGE"++ authorize:+ if: github.repository == 'openai/codex-security' && github.event_name != 'pull_request'+ name: authorize-container-publication+ needs: validate+ runs-on: ubuntu-24.04+ timeout-minutes: 10+ environment: container+ permissions:+ contents: read+ packages: read+ outputs:+ image: ${{ steps.release.outputs.image }}+ version: ${{ steps.release.outputs.version }}++ steps:+ - name: Checkout release source+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ fetch-depth: 0+ persist-credentials: false++ - name: Validate protected release source and version+ id: release+ shell: bash+ run: |+ set -euo pipefail+ package_version="$(node -p 'require("./sdk/typescript/package.json").version')"++ if [[ "$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="$package_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}"+ else+ echo 'Container release tags must identify a stable version such as container-v0.1.0.' >&2+ exit 1+ fi++ 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 "$GITHUB_SHA" refs/remotes/origin/main; then+ echo 'Container releases must be built from a commit on the protected main branch.' >&2+ exit 1+ fi++ printf 'image=ghcr.io/%s\n' "${GITHUB_REPOSITORY_OWNER,,}/codex-security" >> "$GITHUB_OUTPUT"+ printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"++ - name: Preflight public package and immutable release version+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ VERSION: ${{ steps.release.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"++ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0++ - 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@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.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: |+ org.opencontainers.image.source=https://github.com/${{ github.repository }}+ org.opencontainers.image.version=${{ needs.authorize.outputs.version }}+ org.opencontainers.image.revision=${{ github.sha }}++ - name: Verify the exact published native image+ env:+ EXPECTED_ARCHITECTURE: ${{ matrix.architecture }}+ IMAGE: ${{ needs.authorize.outputs.image }}+ IMAGE_DIGEST: ${{ steps.build.outputs.digest }}+ 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 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: Set up Bun for findings service verification+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2+ with:+ bun-version: "1.3.14"++ - name: Verify findings API and persistent storage through consumer Compose+ env:+ IMAGE: ${{ needs.authorize.outputs.image }}@${{ steps.build.outputs.digest }}+ run: bun sdk/typescript/scripts/smoke-findings-service.ts "$IMAGE"++ - name: Record verified platform digest+ env:+ IMAGE_DIGEST: ${{ steps.build.outputs.digest }}+ 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+ 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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1+ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0++ - name: Download verified platform digests+ uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1+ with:+ path: ${{ runner.temp }}/codex-security-platform-digests+ pattern: codex-security-image-digest-*+ merge-multiple: true++ - 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 provisional multiarchitecture candidate+ id: manifest+ env:+ IMAGE: ${{ needs.authorize.outputs.image }}+ 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++ candidate="$IMAGE:release-candidate-$GITHUB_SHA"+ docker buildx imagetools create \+ --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 '+ [.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: |+ set -euo pipefail+ mkdir -p results state+ chmod 700 results state+ printf 'id,repository,revision\n' > repositories.csv+ CODEX_SECURITY_USER="$(id -u):$(id -g)"+ export CODEX_SECURITY_USER+ docker compose config --quiet+ docker compose run --rm codex-security --version+ if output="$(docker compose run --rm codex-security 2>&1)"; then+ echo 'An empty repository CSV must not start a security scan.' >&2+ exit 1+ else+ status=$?+ fi+ if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then+ printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2+ exit 1+ fi++ attest:+ name: attest-verified-multiarchitecture-candidate+ needs:+ - authorize+ - manifest+ runs-on: ubuntu-24.04+ timeout-minutes: 10permissions:attestations: writecontents: readid-token: writepackages: write- uses: ./.github/workflows/container-release-image.yml- with:- target: ${{ matrix.target }}- package: ${{ matrix.package }}++ steps:+ - 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: Sign verified multiarchitecture candidate provenance+ uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1+ 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0++ - 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: Promote the verified, attested, immutable image digest+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ IMAGE: ${{ needs.authorize.outputs.image }}+ 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"++ docker buildx imagetools create \+ --tag "$IMAGE:$VERSION" \+ --tag "$IMAGE:sha-$GITHUB_SHA" \+ --tag "$IMAGE:latest" \+ "$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" --versiondiff --git a/Dockerfile b/Dockerfileindex b8cd633e7..796706a55 100644--- a/Dockerfile+++ b/Dockerfile@@ -19,10 +19,10 @@ RUN pnpm run types \&& pnpm pack --pack-destination /build/package \&& node scripts/check-package.mjs /build/package/*.tgz-FROM node:22-bookworm-slim@sha256:6c74791e557ce11fc957704f6d4fe134a7bc8d6f5ca4403205b2966bd488f6b3 AS runtime+FROM node:22-bookworm-slim@sha256:6c74791e557ce11fc957704f6d4fe134a7bc8d6f5ca4403205b2966bd488f6b3 AS scannerLABEL org.opencontainers.image.title="Codex Security" \- org.opencontainers.image.description="Noninteractive, resumable Codex Security CSV repository scans" \+ org.opencontainers.image.description="Codex Security scanner and findings API" \org.opencontainers.image.source="https://github.com/openai/codex-security"RUN apt-get update \@@ -59,21 +59,5 @@ ENV CODEX_HOME=/state \USER 10001:10001WORKDIR /state-FROM runtime AS findings-service--LABEL org.opencontainers.image.description="Codex Security findings API"--ENV HOST=0.0.0.0 \- PORT=3000 \- CODEX_SECURITY_STATE_DIR=/state--WORKDIR /usr/local/lib/node_modules/@openai/codex-security-EXPOSE 3000--ENTRYPOINT ["node"]-CMD ["dist/server/index.js"]--FROM runtime AS scanner-ENTRYPOINT ["/usr/local/bin/codex-security-entrypoint"]CMD ["--help"]diff --git a/README.md b/README.mdindex f97bd07de..8b3a61936 100644--- a/README.md+++ b/README.md@@ -53,8 +53,9 @@ findings service, use the same scanner image with the## Findings service (preview)The [findings service](sdk/typescript/README.md#findings-service-preview) runs-from the separate `ghcr.io/openai/codex-security-findings` image (or a local-source build), stores findings and embeddings in SQLite, and lists+from the same `ghcr.io/openai/codex-security` image as the scanner (or a local+source build), with a separate container and state volume configured by+`compose.findings.yaml`. It stores findings and embeddings in SQLite and listsfindings with pagination. Its read-only dashboard at `/dashboard` refreshes everyfive seconds and shows stored findings and duplicate groups from the service'sdatabase. It also returns potential duplicates by embedding similarity within adiff --git a/compose.findings.yaml b/compose.findings.yamlindex d9da02eef..9903964cb 100644--- a/compose.findings.yaml+++ b/compose.findings.yaml@@ -1,8 +1,14 @@services:findings:- image: ${CODEX_SECURITY_FINDINGS_IMAGE:-ghcr.io/openai/codex-security-findings:latest}+ image: ${CODEX_SECURITY_FINDINGS_IMAGE:-ghcr.io/openai/codex-security:latest}init: true+ entrypoint: ["node"]+ command: ["dist/server/index.js"]+ working_dir: /usr/local/lib/node_modules/@openai/codex-securityenvironment:+ HOST: "0.0.0.0"+ PORT: "3000"+ CODEX_SECURITY_STATE_DIR: /stateOPENAI_API_KEY:CODEX_API_KEY:ports:diff --git a/docker/README.md b/docker/README.mdindex 5f075b538..60e405df5 100644--- a/docker/README.md+++ b/docker/README.md@@ -1,37 +1,36 @@# Container releases-`container-release` uses one release pipeline for both images:--| Docker target | GHCR image |-| ------------------- | ---------------------------------------- |-| `scanner` (default) | `ghcr.io/openai/codex-security` |-| `findings-service` | `ghcr.io/openai/codex-security-findings` |--Both use the SDK package version, native Linux `amd64`/`arm64` builds, BuildKit-SBOMs and maximum-mode provenance, and a GitHub provenance attestation. Native-images are tested before publishing the multiarchitecture manifest. Anonymous+`container-release` publishes `ghcr.io/openai/codex-security` from the default+`scanner` Docker target. The scanner and findings service use this same image+in separate containers with separate state. `compose.findings.yaml` supplies+the Node server command, working directory, and service environment; the image's+default command remains the scanner CLI.++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 and findings API/persistence checks before+publishing the multiarchitecture manifest. Anonymouspulls and attestation must succeed before promoting version, `sha-<commit>`, and`latest` tags. Stable version tags cannot be overwritten.## GHCR administrator setup-Before the first release, an administrator must prepare each package:+Before the first release, an administrator must prepare the package:-1. Allow organization package creation and bootstrap missing packages with a- reviewed image and a non-release tag. For the findings image:+1. Allow organization package creation and, if the package is missing, bootstrap+ it with a reviewed image and a non-release tag:```bash- docker build --target findings-service -t ghcr.io/openai/codex-security-findings:bootstrap .+ docker build --target scanner -t ghcr.io/openai/codex-security:bootstrap .printf '%s' "$CR_PAT" | docker login ghcr.io --username YOUR_GITHUB_USER --password-stdin- docker push ghcr.io/openai/codex-security-findings:bootstrap+ docker push ghcr.io/openai/codex-security:bootstrapdocker logout ghcr.io```Use a personal access token (classic) with `write:packages`, authorized for SSO- if required; never commit it or pass it into the build. For the scanner, use- target `scanner` and image `ghcr.io/openai/codex-security:bootstrap`.+ if required; never commit it or pass it into the build.-2. In each package's settings, link `openai/codex-security`, set visibility to+2. In the package's settings, link `openai/codex-security`, set visibility to**Public**, and grant the repository **Write** under **Manage Actions access**.The workflow uses `GITHUB_TOKEN` and refuses missing, private, or unreadablepackages. Verify `docker pull` works after logging out of GHCR.@@ -49,19 +48,35 @@ After merging to `main`, push `container-v<version>` matching the SDK packageversion or run `container-release` manually on `main`. Releases require a commiton protected `main`; pull requests only build and test.-The images release independently. If one fails, fix the cause and rerun only-failed jobs; do not overwrite an existing stable version. `bootstrap` and+If a release fails, fix the cause and rerun only failed jobs; do not overwrite+an existing stable version. `bootstrap` and`release-candidate-<commit>` tags are not consumer releases.See the [findings service guide](../sdk/typescript/README.md#findings-service-preview)for image selection, source builds, storage, backups, and upgrades.+## Migrating the findings service++The `findings-service` build target and separate+`ghcr.io/openai/codex-security-findings` release are replaced by the shared+image. For source builds, use `--target scanner` (or omit `--target`). Update+`compose.findings.yaml` and set `CODEX_SECURITY_FINDINGS_IMAGE` to a published+`ghcr.io/openai/codex-security` version or digest before pulling and starting+the service. Custom deployments must also carry over the Compose file's Node+entrypoint, server command, package working directory, and service environment.++Back up the service as described in the [upgrade guide](../sdk/typescript/README.md#upgrades-and-backups).+Keep the same Compose project name and `findings-state` volume mounted at+`/state`; do not run `down --volumes`. This packaging change does not migrate or+move the database, and the runner must keep its own state. Existing published+images and tags are unchanged.+## Workflow runner`compose.runner.yaml` runs the packaged CLI from the **scanner** image. It doesnot start a findings service or implement another workflow engine. It passescommands, output, and exit codes through the existing scanner entrypoint.-The shared Dockerfile and the two image releases above are unchanged.+The findings service uses the same image with the configuration described above.Run these commands from the repository root. After the selected scanner releaseis available, prepare private directories and choose the host user's UID/GID sodiff --git a/sdk/typescript/README.md b/sdk/typescript/README.mdindex aa23bc506..7b71e940d 100644--- a/sdk/typescript/README.md+++ b/sdk/typescript/README.md@@ -912,8 +912,9 @@ cancel active scans.## Findings service (preview)-The findings API is distributed separately from the scanner as-`ghcr.io/openai/codex-security-findings`, for Linux `amd64` and `arm64`.+The findings API uses the same `ghcr.io/openai/codex-security` image as the+scanner, for Linux `amd64` and `arm64`. `compose.findings.yaml` starts the API+in a separate container with its own state volume and server configuration.Once a release is published, it can be pulled without a GitHub login. See[container release setup](../../docker/README.md) for the required maintainersetup and publication process.@@ -934,17 +935,20 @@ curl -i http://127.0.0.1:3000/v1/findingsYou can deploy with just `compose.findings.yaml` and a private `.env`; no sourcecheckout or Node.js installation is required. `CODEX_SECURITY_FINDINGS_IMAGE`-defaults to `ghcr.io/openai/codex-security-findings:latest`. Set it to a published+defaults to `ghcr.io/openai/codex-security:latest`. Set it to a publishedversion, `sha-<commit>` tag, or digest for repeatable deployments.To build from a source checkout instead:```bash-docker build --target findings-service -t codex-security-findings:local .-export CODEX_SECURITY_FINDINGS_IMAGE=codex-security-findings:local+docker build --target scanner -t codex-security:local .+export CODEX_SECURITY_FINDINGS_IMAGE=codex-security:localdocker compose -f compose.findings.yaml up --no-build -d```+For an existing deployment using the separate findings image or+`--target findings-service`, follow the [single-image migration guide](../../docker/README.md#migrating-the-findings-service).+### Read-only dashboardOpen `http://localhost:3000/dashboard` on the running findings service. The UI@@ -1368,7 +1372,7 @@ Stop the service with`docker compose -f compose.findings.yaml down`; add `--volumes` only when youintend to delete the stored data.-The image defaults to `HOST=0.0.0.0`, `PORT=3000`, and+The findings Compose configuration sets `HOST=0.0.0.0`, `PORT=3000`, and`CODEX_SECURITY_STATE_DIR=/state`. Keep port and volume mappings aligned ifchanging these settings. Compose binds only to host loopback; the API has noauthentication. Use an authenticated TLS proxy before sharing access. Findingdiff --git a/sdk/typescript/scripts/smoke-findings-service.ts b/sdk/typescript/scripts/smoke-findings-service.tsindex 80a83bd1f..d40d9cd83 100644--- a/sdk/typescript/scripts/smoke-findings-service.ts+++ b/sdk/typescript/scripts/smoke-findings-service.ts@@ -13,9 +13,7 @@ import type { DashboardSnapshot } from "../src/server/dashboard-types.js";const repositoryRoot = fileURLToPath(new URL("../../../", import.meta.url));const container = `findings-ci-${process.pid}`;-const image = process.argv[2] ?? "codex-security-findings:local";-const runnerImage =- process.env["CODEX_SECURITY_IMAGE"] ?? "codex-security:runner-smoke";+const image = process.argv[2] ?? "codex-security:local";const compose = ["compose", "-p", container, "-f", "compose.findings.yaml"];const runnerRoot = await mkdtemp(join(tmpdir(), "codex-security-runner-"));const runnerCompose = [@@ -80,7 +78,7 @@ function docker(args: string[], { check = true, status = 0 } = {}): string {env: {...process.env,CODEX_SECURITY_FINDINGS_IMAGE: image,- CODEX_SECURITY_IMAGE: runnerImage,+ CODEX_SECURITY_IMAGE: image,CODEX_SECURITY_USER: `${process.getuid!()}:${process.getgid!()}`,CODEX_SECURITY_RESULTS: join(runnerRoot, "results"),CODEX_SECURITY_STATE: join(runnerRoot, "state"),@@ -358,9 +356,7 @@ try {}),);if (!process.argv[2])- docker(["build", "--target", "findings-service", "--tag", image, "."]);- if (!process.env["CODEX_SECURITY_IMAGE"])- docker(["build", "--target", "scanner", "--tag", runnerImage, "."]);+ docker(["build", "--target", "scanner", "--tag", image, "."]);await startService();docker([...runnerCompose, "config", "--quiet"]);docker([