Skip to content

Commit 6ef6c0f

Browse files
authored
ci: make Codex security advisory (#5246)
- Encrypt bounded diagnostics for private review - Run scans during prerelease qualification without gating
1 parent 29bcc97 commit 6ef6c0f

6 files changed

Lines changed: 202 additions & 101 deletions

File tree

‎.agents/skills/watch-github-actions/SKILL.md‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,32 @@ For tmachine Kubernetes conformance failures, inspect the `e2e-results-conforman
135135

136136
For the `e2e-suites` lane (`.github/workflows/e2e-suites.yml`), the last lines of the job log give the runner's result: PASS, FAIL (exit 1) after the end of the nextest log (which names the failed tests), or ERROR (exit 2) with the step that broke. FAIL and ERROR also appear as annotations on the run's summary page. Then inspect the `e2e-results-<family>-<package>-<environment>-<installer>` artifact, which holds `junit.xml`, `nextest.log` and, after a failure, the guest's `diagnostics/`.
137137

138-
`Pre-release` temporarily omits Codex Security from its `Security Scan` job.
139-
`Release` uses the passing prerelease qualification result. Other scanners and
140-
qualification gates still run. Use the standalone
141-
`Codex Security Release Qualification` workflow for manual investigation.
142-
143-
For `Codex Security`, an exit code of 2 with partial coverage is an incomplete
144-
scan, not a HIGH/CRITICAL threshold failure. Check the execution diagnostics in
145-
the job summary and the `codex-security-diagnostics-<run>-<attempt>` artifact on
138+
`Pre-release` runs Codex Security as a separate advisory qualification job.
139+
It scans the exact prerelease tag against the previous stable release. Findings
140+
and scanner execution failures do not affect qualification or publication;
141+
failed steps and warnings remain visible. `Release` uses the passing prerelease
142+
qualification result. Codex Security has no schedule or manual trigger.
143+
144+
For Codex Security `0.8.3`, exit code 2 means an execution or required-output
145+
failure. Deferred investigations no longer cause that exit code. Check the
146+
execution diagnostics in the job summary and the
147+
`codex-security-diagnostics-<run>-<attempt>` artifact on
146148
scan failure. It contains fixed status values, aggregate coverage counts, and
147149
disk space before, after, and the minimum sampled every five seconds. Missing
148150
coverage or manifest documents indicate no readable final report was available;
149-
deferred items or surfaces needing follow-up can explain partial coverage.
151+
deferred items or surfaces needing follow-up describe coverage limitations.
152+
Current reports omit the legacy completeness field, so the diagnostic's
153+
`coverage` value is `unknown`; use `scan_status` and the exit code for execution.
150154
Sampling cannot rule out a disk spike between samples.
151155

152156
Artifacts and logs in this public repository are public. Never upload the raw
153157
scan directory, `report.md`, `coverage.json`, findings, agent state, or scanner
154158
logs. Coverage reasons and notes are free text and may disclose vulnerabilities.
155159
The public diagnostic intentionally omits them; detailed review needs an
156-
approved private destination. Helpers must come from the workflow revision,
160+
approved private destination. Setting the repository variable
161+
`CODEX_SECURITY_DIAGNOSTICS_PUBLIC_KEY` enables bounded scanner logging and
162+
encrypted report retention. Only ciphertext is uploaded; the private key stays
163+
local. See `CI.md` for decryption. Helpers must come from the workflow revision,
157164
not from the candidate under scan.
158165

159166
`setup-nix` retries development-shell preparation once when `prepare-shell`

‎.github/workflows/codex-security.yml‎

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ on:
2020
required: false
2121
default: false
2222
type: boolean
23-
fail-on-findings:
24-
description: Fail on HIGH/CRITICAL security findings
25-
default: false
26-
type: boolean
27-
upload_sarif:
28-
description: Upload results to Code Scanning when called from a manual workflow
29-
default: true
30-
type: boolean
23+
diagnostics_public_key:
24+
description: Optional armored GPG public key for encrypted reports and scanner output
25+
default: ""
26+
type: string
3127
outputs:
3228
base_sha:
3329
description: Previous stable commit, empty for a full bootstrap scan
@@ -44,32 +40,13 @@ on:
4440
secrets:
4541
CODEX_SECURITY_API_KEY:
4642
required: true
47-
workflow_dispatch:
48-
inputs:
49-
candidate_ref:
50-
description: Pre-release tag to scan (vMAJOR.MINOR.PATCH-pre.N)
51-
required: true
52-
type: string
53-
stable_ref:
54-
description: Optional previous stable tag override
55-
required: false
56-
type: string
57-
upload_sarif:
58-
description: Upload manual-run results to Code Scanning
59-
required: false
60-
default: false
61-
type: boolean
62-
allow_full_bootstrap:
63-
description: Allow a full scan when no previous stable tag exists
64-
required: false
65-
default: false
66-
type: boolean
6743

6844
permissions:
6945
actions: read
7046
contents: read
7147
security-events: write
7248

49+
# Shared with codex-compatibility.yml to serialize inference requests.
7350
concurrency:
7451
group: codex-release-review
7552
cancel-in-progress: false
@@ -83,11 +60,13 @@ env:
8360

8461
jobs:
8562
analyze:
86-
name: Codex Security (${{ inputs.candidate_ref || github.ref_name }})
63+
name: Codex Security (${{ inputs.candidate_ref }})
8764
# The agent executes no shell commands on the repository self-hosted runner,
8865
# so its preflight never scopes the diff and it seals no draft.
8966
runs-on: ubuntu-latest
9067
timeout-minutes: 120
68+
# Keep scanner failures visible without blocking prerelease qualification.
69+
continue-on-error: true
9170
outputs:
9271
base_sha: ${{ steps.range.outputs.base_sha }}
9372
candidate_sha: ${{ steps.range.outputs.candidate_sha }}
@@ -126,7 +105,7 @@ jobs:
126105
--ignore-scripts \
127106
--no-audit \
128107
--no-fund \
129-
@openai/codex-security@0.1.24
108+
@openai/codex-security@0.8.3
130109
131110
- name: Verify Codex Security
132111
env:
@@ -136,12 +115,28 @@ jobs:
136115
test -x "$CODEX_SECURITY_BIN"
137116
"$CODEX_SECURITY_BIN" --version
138117
118+
- name: Prepare encrypted diagnostics recipient
119+
if: inputs.diagnostics_public_key != ''
120+
id: private
121+
env:
122+
DIAGNOSTICS_PUBLIC_KEY: ${{ inputs.diagnostics_public_key }}
123+
run: |
124+
set -euo pipefail
125+
umask 077
126+
mkdir "$RUNNER_TEMP/codex-security-gpg"
127+
printf '%s\n' "$DIAGNOSTICS_PUBLIC_KEY" > "$RUNNER_TEMP/codex-security-recipient.asc"
128+
gpg --batch --homedir "$RUNNER_TEMP/codex-security-gpg" \
129+
--trust-model always --recipient-file "$RUNNER_TEMP/codex-security-recipient.asc" \
130+
--encrypt --output "$RUNNER_TEMP/codex-security-recipient-check.gpg" /dev/null
131+
echo 'enabled=true' >> "$GITHUB_OUTPUT"
132+
139133
# The range resolver has to come from the workflow's own revision. A
140134
# scanned candidate predates it, and running the resolver from the
141135
# revision under scan would let that revision pick its own scan range.
142136
- name: Check out the workflow revision
143137
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
144138
with:
139+
ref: ${{ github.workflow_sha }}
145140
path: workflow-revision
146141
sparse-checkout: tasks/scripts
147142
persist-credentials: false
@@ -159,15 +154,15 @@ jobs:
159154
- name: Check out the pre-release
160155
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
161156
with:
162-
ref: ${{ inputs.candidate_ref || github.ref }}
157+
ref: ${{ inputs.candidate_ref }}
163158
fetch-depth: 0
164159
persist-credentials: false
165160

166161
- name: Resolve release range
167162
id: range
168163
env:
169164
ALLOW_FULL_BOOTSTRAP: ${{ inputs.allow_full_bootstrap || false }}
170-
CANDIDATE_REF: ${{ inputs.candidate_ref || github.ref_name }}
165+
CANDIDATE_REF: ${{ inputs.candidate_ref }}
171166
STABLE_REF: ${{ inputs.stable_ref || '' }}
172167
run: |
173168
set -euo pipefail
@@ -197,9 +192,14 @@ jobs:
197192
OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
198193
SCAN_DIR: ${{ runner.temp }}/codex-security-results-${{ github.run_id }}-${{ github.run_attempt }}
199194
SCAN_SCOPE: ${{ steps.range.outputs.scan_scope }}
195+
PRIVATE_DIAGNOSTICS: ${{ steps.private.outputs.enabled }}
200196
run: |
201197
set -euo pipefail
202198
install -d -m 700 "$CODEX_SECURITY_STATE_DIR" "$SCAN_DIR"
199+
diagnostic_args=()
200+
if [ "$PRIVATE_DIAGNOSTICS" = true ]; then
201+
diagnostic_args=(--private-log "$RUNNER_TEMP/codex-security-private.log")
202+
fi
203203
204204
target_args=()
205205
if [ "$SCAN_SCOPE" = "diff" ]; then
@@ -212,6 +212,7 @@ jobs:
212212
python3 "$RUNNER_TEMP/range-resolver/codex_security_diagnostics.py" \
213213
--scan-dir "$SCAN_DIR" \
214214
--output "$RUNNER_TEMP/codex-security-diagnostics.json" \
215+
"${diagnostic_args[@]}" \
215216
-- "$CODEX_SECURITY_BIN" scan . \
216217
"${target_args[@]}" \
217218
--auth api-key \
@@ -229,7 +230,38 @@ jobs:
229230
--headless
230231
231232
# Actions artifacts in this public repository are publicly downloadable.
232-
# Publish only the helper's allowlisted projection, never SCAN_DIR or state.
233+
# Raw reports and logs may only be retained inside the encrypted archive.
234+
- name: Encrypt private diagnostics
235+
if: ${{ !cancelled() && steps.private.outputs.enabled == 'true' && (steps.scan.outcome == 'success' || steps.scan.outcome == 'failure') }}
236+
id: encrypted
237+
env:
238+
SCAN_DIR: ${{ runner.temp }}/codex-security-results-${{ github.run_id }}-${{ github.run_attempt }}
239+
run: |
240+
set -euo pipefail
241+
umask 077
242+
reports=()
243+
for report in coverage.json scan-manifest.json report.md findings.json; do
244+
if [ -f "$SCAN_DIR/$report" ] && [ ! -L "$SCAN_DIR/$report" ]; then
245+
reports+=("$report")
246+
fi
247+
done
248+
tar -cz \
249+
-C "$SCAN_DIR" "${reports[@]}" \
250+
-C "$RUNNER_TEMP" codex-security-private.log |
251+
gpg --batch --homedir "$RUNNER_TEMP/codex-security-gpg" \
252+
--trust-model always --recipient-file "$RUNNER_TEMP/codex-security-recipient.asc" \
253+
--cipher-algo AES256 --encrypt \
254+
--output "$RUNNER_TEMP/codex-security-private.tar.gz.gpg"
255+
256+
- name: Retain encrypted private diagnostics
257+
if: ${{ !cancelled() && steps.encrypted.outcome == 'success' }}
258+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
259+
with:
260+
name: codex-security-encrypted-${{ github.run_id }}-${{ github.run_attempt }}
261+
path: ${{ runner.temp }}/codex-security-private.tar.gz.gpg
262+
if-no-files-found: error
263+
retention-days: 7
264+
233265
- name: Upload public execution diagnostics on failure
234266
if: ${{ failure() && steps.scan.outcome == 'failure' }}
235267
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
@@ -252,15 +284,13 @@ jobs:
252284
--output "$SARIF_FILE"
253285
254286
- name: Summarize findings
255-
id: findings
256287
env:
257288
BASE_TAG: ${{ steps.range.outputs.base_tag }}
258289
CANDIDATE_TAG: ${{ steps.range.outputs.candidate_tag }}
259290
COMMIT_COUNT: ${{ steps.range.outputs.commit_count }}
260291
SARIF_FILE: ${{ runner.temp }}/codex-security.sarif
261292
SCAN_SCOPE: ${{ steps.range.outputs.scan_scope }}
262293
TRAIN: ${{ steps.range.outputs.train }}
263-
FAIL_ON_FINDINGS: ${{ inputs.fail-on-findings || false }}
264294
run: |
265295
set -euo pipefail
266296
finding_count=$(jq '[.runs[].results[]] | length' "$SARIF_FILE")
@@ -270,7 +300,6 @@ jobs:
270300
| select(.properties.severity | ascii_downcase | IN("high", "critical"))
271301
] | length
272302
' "$SARIF_FILE")
273-
echo "high_count=$high_count" >> "$GITHUB_OUTPUT"
274303
{
275304
echo "### Codex Security release qualification"
276305
echo
@@ -283,50 +312,22 @@ jobs:
283312
else
284313
echo "- Scope: approved full bootstrap scan"
285314
fi
286-
echo "- Coverage: complete"
315+
echo "- Scanner execution: completed"
316+
echo "- Scope limitations and deferred investigations may remain."
287317
echo "- Findings: $finding_count"
288318
echo "- HIGH/CRITICAL: $high_count"
289-
echo
290-
echo "Fail on HIGH/CRITICAL: $FAIL_ON_FINDINGS"
291319
} >> "$GITHUB_STEP_SUMMARY"
292320
293321
- name: Upload SARIF to Code Scanning
294-
if: ${{ github.event_name != 'workflow_dispatch' || inputs.upload_sarif }}
295322
uses: github/codeql-action/upload-sarif@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3
296323
with:
297324
sarif_file: ${{ runner.temp }}/codex-security.sarif
298325
ref: refs/heads/main
299326
sha: ${{ steps.range.outputs.candidate_sha }}
300327
category: ${{ steps.range.outputs.category }}
301328

302-
- name: Enforce HIGH/CRITICAL threshold
303-
if: ${{ !cancelled() && steps.findings.outcome == 'success' }}
304-
env:
305-
HIGH_COUNT: ${{ steps.findings.outputs.high_count }}
306-
FAIL_ON_FINDINGS: ${{ inputs.fail-on-findings || false }}
307-
run: |
308-
if [ "$HIGH_COUNT" -gt 0 ]; then
309-
if [ "$FAIL_ON_FINDINGS" = "true" ]; then
310-
echo "::error::Codex reported $HIGH_COUNT HIGH/CRITICAL findings."
311-
exit 1
312-
fi
313-
echo "::warning::Codex reported $HIGH_COUNT HIGH/CRITICAL findings; enforcement is disabled."
314-
fi
315-
316-
result:
317-
name: ${{ inputs.fail-on-findings && 'OpenShell / Codex Security' || 'OpenShell / Codex Security (informational)' }}
318-
if: ${{ always() }}
319-
needs: analyze
320-
runs-on: ubuntu-latest
321-
permissions: {}
322-
steps:
323-
- name: Evaluate scanner execution
324-
env:
325-
ANALYZE_RESULT: ${{ needs.analyze.result }}
329+
- name: Report incomplete advisory review
330+
if: ${{ failure() }}
326331
run: |
327-
set -euo pipefail
328-
if [ "$ANALYZE_RESULT" != "success" ]; then
329-
echo "::error::Codex Security release qualification did not complete successfully."
330-
exit 1
331-
fi
332-
echo "Codex Security completed and the configured finding threshold passed."
332+
echo '::warning::Codex Security review failed; no successful assessment is available. Prerelease qualification is unchanged.'
333+
echo '### Codex Security review unavailable (advisory)' >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/release-qualification.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ jobs:
5454
secrets:
5555
CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }}
5656

57+
codex-security:
58+
name: Codex Security (advisory)
59+
if: inputs.is-prerelease
60+
permissions:
61+
actions: read
62+
contents: read
63+
security-events: write
64+
uses: ./.github/workflows/codex-security.yml
65+
with:
66+
candidate_ref: ${{ inputs.release-tag }}
67+
diagnostics_public_key: ${{ vars.CODEX_SECURITY_DIAGNOSTICS_PUBLIC_KEY }}
68+
secrets:
69+
CODEX_SECURITY_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
70+
5771
prepare-integration:
5872
permissions:
5973
actions: read

0 commit comments

Comments
 (0)