Skip to content

Commit 75730e9

Browse files
committed
ci: attest the Codex Security package bootstrap
1 parent 904c7f1 commit 75730e9

1 file changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: attest-container-package-bootstrap
2+
3+
on:
4+
push:
5+
branches:
6+
- mdangelo/codex/bootstrap-ghcr-8d9eb30
7+
paths:
8+
- .github/workflows/container-registry-bootstrap-attest.yml
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: codex-security-container-registry-bootstrap-attestation
15+
queue: max
16+
17+
env:
18+
IMAGE: ghcr.io/openai/codex-security
19+
SOURCE_SHA: 8d9eb30dcf71853d9e55da517404d4aef6c74f64
20+
BOOTSTRAP_TAG: bootstrap-8d9eb30
21+
22+
jobs:
23+
verify-and-attest:
24+
if: >-
25+
github.repository == 'openai/codex-security' &&
26+
github.ref == 'refs/heads/mdangelo/codex/bootstrap-ghcr-8d9eb30'
27+
name: verify and attest the existing bootstrap
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 20
30+
permissions:
31+
attestations: write
32+
contents: read
33+
id-token: write
34+
packages: write
35+
36+
steps:
37+
- name: Authenticate only to the linked repository package
38+
shell: bash
39+
env:
40+
GH_TOKEN: ${{ github.token }}
41+
run: |
42+
set -euo pipefail
43+
printf '%s' "$GH_TOKEN" |
44+
docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
45+
46+
- name: Verify both architectures, source, package access, and visibility
47+
id: bootstrap
48+
shell: bash
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
run: |
52+
set -euo pipefail
53+
reference="$IMAGE:$BOOTSTRAP_TAG"
54+
manifest="$(docker buildx imagetools inspect "$reference" --format '{{json .Manifest}}')"
55+
56+
if ! jq --exit-status '
57+
(.digest | type == "string" and startswith("sha256:")) and
58+
([.manifests[] | select(.platform.os == "linux") | .platform.architecture] | sort) ==
59+
["amd64", "arm64"]
60+
' <<< "$manifest" > /dev/null; then
61+
echo 'The bootstrap must contain the exact native amd64 and arm64 images.' >&2
62+
exit 1
63+
fi
64+
printf 'digest=%s\n' "$(jq --raw-output '.digest' <<< "$manifest")" >> "$GITHUB_OUTPUT"
65+
66+
metadata="$(gh api orgs/openai/packages/container/codex-security)"
67+
if [[ "$(jq --exit-status --raw-output '.name' <<< "$metadata")" != codex-security ]]; then
68+
echo 'The repository token cannot access its Codex Security package.' >&2
69+
exit 1
70+
fi
71+
72+
repository="$(jq --raw-output '.repository.full_name // empty' <<< "$metadata")"
73+
if [[ -n "$repository" && "$repository" != openai/codex-security ]]; then
74+
echo "The package is linked to $repository instead of openai/codex-security." >&2
75+
exit 1
76+
fi
77+
78+
visibility="$(jq --exit-status --raw-output '.visibility' <<< "$metadata")"
79+
printf 'visibility=%s\n' "$visibility" >> "$GITHUB_OUTPUT"
80+
case "$visibility" in
81+
public)
82+
echo 'The Codex Security package is publicly available.'
83+
;;
84+
private)
85+
echo '::warning::The package is correctly bootstrapped and repository-linked, but OpenAI organization policy disables public package visibility. An organization owner must enable public package creation before customers can pull it anonymously.'
86+
;;
87+
*)
88+
echo "Unexpected package visibility: $visibility" >&2
89+
exit 1
90+
;;
91+
esac
92+
93+
docker pull --platform linux/amd64 "$reference"
94+
source="$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.source" }}' "$reference")"
95+
revision="$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' "$reference")"
96+
if [[ "$source" != https://github.com/openai/codex-security || "$revision" != "$SOURCE_SHA" ]]; then
97+
echo 'The bootstrap image does not identify the audited repository and source commit.' >&2
98+
exit 1
99+
fi
100+
if [[ "$(docker run --rm "$reference" --version)" != 0.1.3 ]]; then
101+
echo 'The verified bootstrap image reports an unexpected CLI version.' >&2
102+
exit 1
103+
fi
104+
if [[ "$(docker run --rm --entrypoint id "$reference" -u)" != 10001 ]]; then
105+
echo 'The verified bootstrap image must remain nonroot.' >&2
106+
exit 1
107+
fi
108+
109+
- name: Attest the exact verified bootstrap manifest
110+
uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2
111+
with:
112+
subject-name: ghcr.io/openai/codex-security
113+
subject-digest: ${{ steps.bootstrap.outputs.digest }}
114+
push-to-registry: true

0 commit comments

Comments
 (0)