mirror of
https://github.com/openai/codex-security.git
synced 2026-11-23 19:40:55 +08:00
fix(deep-scan): reconcile durable selection and worker recovery
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
.git
|
||||
.github
|
||||
plugins/codex-security/tests
|
||||
sdk/typescript/tests-ts/*.test.ts
|
||||
**/.DS_Store
|
||||
**/.env
|
||||
**/.env.*
|
||||
@@ -13,3 +15,4 @@
|
||||
**/security-scans
|
||||
**/state
|
||||
**/*.log
|
||||
docker/wolfi/build
|
||||
|
||||
@@ -13,3 +13,6 @@
|
||||
|
||||
# Bundled dependencies contain intentional whitespace in strings and comments.
|
||||
github-action/dist/*.cjs linguist-generated=true -whitespace
|
||||
|
||||
# This checksum-pinned upstream license contains its original whitespace.
|
||||
docker/wolfi/payload/notices/BUBBLEWRAP-COPYING -text -whitespace
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
## Changes
|
||||
|
||||
<!-- Summarize the specific changes that reviewers should understand. -->
|
||||
<!-- Summarize the changes reviewers should understand. If maintainers need to update
|
||||
https://learn.chatgpt.com/docs/security, you can name the affected page or workflow and suggest an edit. -->
|
||||
|
||||
## Testing
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
paths:
|
||||
.github/workflows/{container-release,node-github-release,node-release-cut,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 release queuing.
|
||||
# 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
|
||||
- '^unexpected key "queue" for "concurrency" section\.'
|
||||
.github/workflows/native-artifacts.yml:
|
||||
ignore:
|
||||
# actionlint 1.7.12 predates GitHub’s reference to the defining workflow's commit.
|
||||
# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsuses
|
||||
- '^specifying action "\$/\.github/actions/native-cache-key" in invalid format because ref is missing\.'
|
||||
.github/workflows/invoice-desk-scan.yml:
|
||||
ignore:
|
||||
# actionlint 1.7.12 predates GitHub's job-level cache permissions.
|
||||
|
||||
@@ -4,7 +4,7 @@ runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Set up Action Node.js runtime
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "24"
|
||||
package-manager-cache: false
|
||||
|
||||
@@ -3,7 +3,7 @@ description: Prepare the verified universal native payload for package builds.
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
name: native-universal-${{ github.sha }}
|
||||
path: plugins/codex-security/native/prebuilt
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
name: Native cache key
|
||||
description: Fingerprint the checked-out native build and proof inputs.
|
||||
outputs:
|
||||
key:
|
||||
description: Exact key for this source and UTC week.
|
||||
value: ${{ steps.key.outputs.key }}
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: key
|
||||
shell: bash
|
||||
run: bash "$GITHUB_ACTION_PATH/key.sh" >> "$GITHUB_OUTPUT"
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Include filenames and modes, not only file contents. Windows proofs
|
||||
# bundle MCP helpers, including their schema and workbench dependencies.
|
||||
empty_tree="$(git hash-object -t tree --stdin </dev/null)"
|
||||
# These existing CI entrypoints run outside the native jobs.
|
||||
ci_only=':(exclude).github/scripts/'
|
||||
source_hash="$(git diff-tree -r -z --no-abbrev "$empty_tree" HEAD -- \
|
||||
.gitattributes .cargo .npmrc .pnpmfile.cjs package.json pnpm-workspace.yaml \
|
||||
.github/actions/{native-cache-key,setup-tools} .github/scripts \
|
||||
"${ci_only}"invoice-desk-{source,target}{,.test}.mjs \
|
||||
"${ci_only}"{check-ci-results,select-ci-checks,test-ci-selection,test-release-guide}.mjs \
|
||||
"${ci_only}"{verify-pr-source,test-verify-pr-source,release-progress,test_release_progress}.mjs \
|
||||
"${ci_only}"test_check_plugin_source_compatibility.mts \
|
||||
"${ci_only}"{install-ripgrep.sh,require_native_python_report.py,test_require_native_python_report.py} \
|
||||
.github/workflows/native-artifacts.yml \
|
||||
.github/workflows/native-unix.yml \
|
||||
.github/workflows/native-windows.yml \
|
||||
.github/workflows/native-musl.yml \
|
||||
sdk/typescript/.npmrc sdk/typescript/.pnpmfile.cjs \
|
||||
sdk/typescript/package.json sdk/typescript/pnpm-lock.yaml \
|
||||
sdk/typescript/pnpm-workspace.yaml \
|
||||
sdk/typescript/tsconfig.json sdk/typescript/tsconfig.ci.json \
|
||||
plugins/codex-security/native plugins/codex-security/mcp-app \
|
||||
':(exclude)plugins/codex-security/mcp-app/tests' \
|
||||
plugins/codex-security/schemas plugins/codex-security/scripts \
|
||||
plugins/codex-security/shared | git hash-object --stdin)"
|
||||
# Hosted runner images can change without a source change.
|
||||
# Keep a protected push in the week it was classified, including at UTC rollover.
|
||||
week=${NATIVE_CACHE_WEEK:-0}
|
||||
if [[ $week == 0 ]]; then week="$(date -u +%G%V)"; fi
|
||||
key="native-universal-v1-${week:0:4}-${week:4}-$source_hash"
|
||||
if [[ ${1-} == cold-group ]]; then
|
||||
printf 'week=%s\n' "$week"
|
||||
# The listing is only a scheduling hint. prepare always restores or builds.
|
||||
hit="$(timeout 5s gh cache list --ref refs/heads/main --key "$key" --limit 1 --json key --jq '.[0].key // empty')"
|
||||
# Keep adjacent misses together, with at most 15 other runs in the group.
|
||||
if [[ "$hit" != "$key" ]]; then
|
||||
printf 'cold-group=%s-%s\n' "$key" "$(((GITHUB_RUN_NUMBER - 1) / 16))"
|
||||
fi
|
||||
else
|
||||
printf 'key=%s\n' "$key"
|
||||
fi
|
||||
@@ -1,9 +1,9 @@
|
||||
name: Set up TypeScript tools
|
||||
description: Install the pinned package manager and Node.js runtime for repository tools.
|
||||
inputs:
|
||||
setup-node:
|
||||
description: Install the pinned Node.js runtime; false keeps an earlier setup step.
|
||||
default: "true"
|
||||
node-version:
|
||||
description: Node.js version for repository tools.
|
||||
default: "22.13.0"
|
||||
cache-dependency-path:
|
||||
description: Lockfiles used for the pnpm store cache.
|
||||
default: "sdk/typescript/pnpm-lock.yaml"
|
||||
@@ -20,9 +20,9 @@ runs:
|
||||
package_json_file: package.json
|
||||
# setup-node saves its cache only after a successful job.
|
||||
- name: Set up Node.js and pnpm cache
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: ${{ inputs.setup-node == 'true' && '22.13.0' || '' }}
|
||||
node-version: ${{ inputs.node-version }}
|
||||
architecture: ${{ inputs.architecture }}
|
||||
cache: pnpm
|
||||
cache-dependency-path: ${{ inputs.cache-dependency-path }}
|
||||
|
||||
@@ -55,7 +55,9 @@ updates:
|
||||
|
||||
- package-ecosystem: github-actions
|
||||
labels: [dependencies]
|
||||
directory: /
|
||||
directories:
|
||||
- /
|
||||
- "/.github/actions/*"
|
||||
schedule:
|
||||
interval: cron
|
||||
cronjob: "0 9 * * *"
|
||||
|
||||
+10
-30
@@ -1,25 +1,17 @@
|
||||
<!-- release-version: 0.6.0 -->
|
||||
<!-- release-version: 0.8.2 -->
|
||||
|
||||
<!-- release-section: highlights:start -->
|
||||
|
||||
## Highlights
|
||||
|
||||
Codex Security 0.6.0 adds vendor report imports, optional owner suggestions, and hosted remediation commands. Severity classification now uses a built-in rubric and three independent reviews by default; review the model-access and cost changes below before upgrading.
|
||||
Codex Security 0.8.2 adds threat-model explorers and Amazon Inspector imports, and improves scan progress and finding review.
|
||||
|
||||
- **Import vendor findings.** Import supported Wiz, Snyk Open Source, Semgrep Code, and Endor Labs reports with `publish findings --to local`, or publish them with `--to cloud`. Read local evidence with `findings imported`. Local imports require no Cloud login or model call and remain separate from assessed scan findings. See the [Wiz](https://github.com/openai/codex-security/blob/npm-v0.6.0/sdk/typescript/docs/cli.md#import-wiz-findings), [Snyk](https://github.com/openai/codex-security/blob/npm-v0.6.0/docs/scanner-imports/snyk.md), [Semgrep](https://github.com/openai/codex-security/blob/npm-v0.6.0/docs/scanner-imports/semgrep.md), and [Endor](https://github.com/openai/codex-security/blob/npm-v0.6.0/docs/scanner-imports/endor.md) format guides.
|
||||
- **Configurable severity reviews.** `classify-severity` uses a bundled rubric when no custom rubric is supplied. `--runs N` selects 1–10 independent reviews, with three by default. The most common severity wins, with the highest severity breaking ties. ([#1765](https://github.com/openai/codex-security/pull/1765))
|
||||
- **Optional owner suggestions.** `scan --owner-suggestions` writes a separate owner-suggestion report after supported committed Git scans. Suggestions preserve the completed scan and do not assign users. Owner enrichment is skipped when a scan cost limit is set. ([#1760](https://github.com/openai/codex-security/pull/1760))
|
||||
- **Hosted patching and source-only verification.** `patch --host` and `verify-fix --host` expose the hosted remediation protocol through the CLI. Ordinary patch and verification commands accept `--verification-mode static` to assess source evidence; omitting it preserves standard verification. Static mode sets the assessment scope and does not enforce a command-execution boundary. See the [hosted remediation guide](https://github.com/openai/codex-security/blob/npm-v0.6.0/sdk/typescript/docs/hosted-remediation.md). ([#1854](https://github.com/openai/codex-security/pull/1854))
|
||||
- **Policy previews without Python.** Policy diffs now run in Node while preserving diff formatting, cancellation, and source freshness checks. ([#1837](https://github.com/openai/codex-security/pull/1837))
|
||||
|
||||
<details>
|
||||
<summary>Other improvements</summary>
|
||||
|
||||
- Patch project-trust overrides are serialized correctly for Codex. ([#1861](https://github.com/openai/codex-security/pull/1861))
|
||||
- Update Hono and the Linear SDK dependencies. ([#1831](https://github.com/openai/codex-security/pull/1831), [#1852](https://github.com/openai/codex-security/pull/1852))
|
||||
- Release verification runs test shards in parallel and reports publication progress on the release PR. ([#1798](https://github.com/openai/codex-security/pull/1798))
|
||||
|
||||
</details>
|
||||
- **Threat-model explorers.** Turn an existing threat model into a shareable HTML explorer with interactive architecture, scenarios, controls, and source evidence. Export HTML or SVG from the bundled skill.
|
||||
- **Amazon Inspector imports.** With external imports enabled, import a complete Inspector Code Security repository findings export while retaining each finding's identity across imports. See the [Inspector import guide](https://github.com/openai/codex-security/blob/npm-v0.8.2/docs/scanner-imports/inspector.md).
|
||||
- **Dedupe corrections.** Hosted reviewers can correct rejected decisions in the original open review when the host supports pending-call validation.
|
||||
- **Interactive scans.** Finding review shows critical findings first, followed by high, medium, and low severity. Component tables show saved review progress, and scan titles resolve relative directory names.
|
||||
- **Output directories.** Existing scan output directories keep their permissions across scans, saved-result reads, and resume. Newly created directories remain private by default.
|
||||
- **Container releases.** The release workflow builds Debian and Wolfi images from the same verified scanner package and frozen runtime dependency lock. See the [container guide](https://github.com/openai/codex-security/blob/npm-v0.8.2/docker/README.md).
|
||||
|
||||
<!-- release-section: highlights:end -->
|
||||
|
||||
@@ -27,20 +19,8 @@ Codex Security 0.6.0 adds vendor report imports, optional owner suggestions, and
|
||||
|
||||
## Upgrade notes
|
||||
|
||||
### Severity classification requires model access
|
||||
No migration is required for existing CLI workflows. Hosted integrations that opt into pending-call validation must keep the original review session open until they handle the CLI's feedback; existing hosts can continue returning final results.
|
||||
|
||||
Classification without `--rubric` previously inherited the scanner's severity without model work. It now requires Codex authentication and model access, using three model calls per uncached finding by default. Set `--runs 1` (SDK: `classificationRuns: 1`) for a single review. All requested reviews must succeed; failures do not fall back to the scanner's severity or save a partial vote.
|
||||
|
||||
Older classification checkpoints without a recorded review count, and former inherited assessments without a rubric hash, are reclassified on the next classification request. Changing the review count or rubric also invalidates matching checkpoints. Existing results remain readable, and publication does not silently classify findings. Use `--reprocess` when changing only the model or reasoning effort. See the [classification guide](https://github.com/openai/codex-security/blob/npm-v0.6.0/sdk/typescript/docs/cli.md#classify-finding-severity).
|
||||
|
||||
### Policy preview interpreter selection is deprecated
|
||||
|
||||
`securityPolicyDiff(draft, python, signal)` retains its call shape, but interpreter strings and paths returned by resolver callbacks no longer select or validate an executable. `previewPolicy()` no longer resolves Python, and `pythonPath` and `PYTHON` do not affect previews. Update integrations that relied on an invalid interpreter failing or a custom executable producing the diff. Explicit resolver callbacks still run for changed drafts and propagate their errors. Omit the second argument in new code, or pass `undefined` when supplying a cancellation signal. Python-dependent generation and other operations are unchanged.
|
||||
|
||||
### Import identity and earlier upgrades
|
||||
|
||||
Keep a stable source key and acquisition format across vendor imports. Switching formats can create separate records or replace richer evidence with less detail; omitted findings remain stored. Review each provider's format guide before changing inputs.
|
||||
|
||||
If upgrading from before 0.5.1, also review the [0.5.1 upgrade notes](https://github.com/openai/codex-security/releases/tag/npm-v0.5.1) and their guidance for earlier versions. Use `openai/codex-security@action-v0.6.0` for the matching GitHub Action, or pin the distribution commit in its companion release after publication.
|
||||
Inspector imports remain opt-in. Cloud publication requires a connected GitHub repository and a deployment that accepts the Inspector provider. The import guide describes repository matching and complete-export requirements.
|
||||
|
||||
<!-- release-section: upgrades:end -->
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"baseVersion": "0.5.1",
|
||||
"baseCommit": "b2fa51576d81cda5e311e7eb89131ffb13daad8b",
|
||||
"baseVersion": "0.8.1",
|
||||
"baseCommit": "1f2f96d562b98216257e7f7cdacd40c446b97f70",
|
||||
"sections": {
|
||||
"highlights": {
|
||||
"generatedHash": "9c17957f706150b5ebfb2effc42159606c808ed05bc44f80320bd0fb1518c5fc",
|
||||
"humanOwned": true
|
||||
"generatedHash": "7ace34ae350194f8b915aace54b89c6630f1f841af0e8de751eb1364457c78da",
|
||||
"humanOwned": false
|
||||
},
|
||||
"upgrades": {
|
||||
"generatedHash": "cdbfb62364372edf0e5202f7db41239aa0301d69187e022b9e9a9c9b0fcab298",
|
||||
"humanOwned": true
|
||||
"generatedHash": "f0e089f37da057fc30882ef40dfe50f6b52abdc17018bf2d70c34afb22c66fe2",
|
||||
"humanOwned": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,10 @@ export function failedChecks(needs) {
|
||||
const required = ["static-checks"];
|
||||
const groups = {
|
||||
"package-required": ["native", "package", "compatibility"],
|
||||
"source-required": [
|
||||
"test",
|
||||
"mcp",
|
||||
"plugin-host",
|
||||
"plugin-source",
|
||||
"windows-test",
|
||||
"windows-verify",
|
||||
],
|
||||
"source-required": ["test", "windows-test"],
|
||||
"container-required": ["container-validate"],
|
||||
"plugin-tests-required": ["mcp", "plugin-host", "plugin-source"],
|
||||
"workflow-quality": ["workflow-quality"],
|
||||
"container-validate": ["container-validate"],
|
||||
"action-ci": ["action-ci"],
|
||||
"eval-contracts": ["eval-contracts"],
|
||||
};
|
||||
@@ -36,9 +30,18 @@ if (
|
||||
process.argv[1] &&
|
||||
import.meta.url === pathToFileURL(process.argv[1]).href
|
||||
) {
|
||||
const failures = failedChecks(JSON.parse(process.env.CI_RESULTS));
|
||||
const needs = JSON.parse(process.env.CI_RESULTS);
|
||||
const failures = failedChecks(needs);
|
||||
if (failures.length) {
|
||||
console.error(`Required CI checks did not pass: ${failures.join(", ")}`);
|
||||
const details = failures.map((name) => {
|
||||
if (name.endsWith(" classification"))
|
||||
return `${name} (missing or invalid)`;
|
||||
const result = needs[name]?.result;
|
||||
if (name === "action-ci" && result === "success")
|
||||
return `${name} (passed output was not "true")`;
|
||||
return `${name} (${result || "missing result"})`;
|
||||
});
|
||||
console.error(`Required CI checks did not pass: ${details.join(", ")}`);
|
||||
process.exitCode = 1;
|
||||
} else console.log("All selected required CI checks passed.");
|
||||
}
|
||||
|
||||
@@ -27,53 +27,59 @@ function pullRequest(overrides = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
test("selects the requested PR head rather than the trusted workflow commit", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(context, async (number) => {
|
||||
assert.equal(number, "7");
|
||||
return pullRequest();
|
||||
}),
|
||||
[{ pr: 7, sha: sourceSha }],
|
||||
);
|
||||
});
|
||||
|
||||
test("includes fork and draft PRs without depending on a PR workflow run", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(context, async () =>
|
||||
pullRequest({
|
||||
draft: true,
|
||||
head: { sha: sourceSha, repo: { full_name: "contributor/invoices" } },
|
||||
}),
|
||||
),
|
||||
[{ pr: 7, sha: sourceSha }],
|
||||
);
|
||||
});
|
||||
|
||||
test("rechecking after approval excludes closed, retargeted, and superseded PRs", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(context, async () => pullRequest()),
|
||||
[{ pr: 7, sha: sourceSha }],
|
||||
);
|
||||
for (const changed of [
|
||||
{ state: "closed" },
|
||||
{ base: { ref: "release", repo: { full_name: repository } } },
|
||||
{ base: { ref: "main", repo: { full_name: "other/invoices" } } },
|
||||
{ head: { sha: "3".repeat(40) } },
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(context, async () => pullRequest(changed)),
|
||||
[],
|
||||
);
|
||||
test("initial selection and approval recheck require the selected PR and revision to remain eligible", async () => {
|
||||
const target = { pr: 7, sha: sourceSha };
|
||||
// The approval step must use its matrix target even if dispatch inputs differ.
|
||||
const recheck = {
|
||||
...context,
|
||||
target: { ...target },
|
||||
event: { inputs: { pr_number: "9", source_sha: mainSha } },
|
||||
};
|
||||
for (const request of [context, recheck]) {
|
||||
for (const [overrides, expected] of [
|
||||
[{}, [target]],
|
||||
[
|
||||
{
|
||||
draft: true,
|
||||
head: { sha: sourceSha, repo: { full_name: "contributor/invoices" } },
|
||||
},
|
||||
[target],
|
||||
],
|
||||
[{ state: "closed" }, []],
|
||||
[{ base: { ref: "release", repo: { full_name: repository } } }, []],
|
||||
[{ base: { ref: "main", repo: { full_name: "other/invoices" } } }, []],
|
||||
[{ head: { sha: mainSha } }, []],
|
||||
[{ head: { sha: "3".repeat(40) } }, []],
|
||||
]) {
|
||||
const actual = await resolveScanTargets(request, async (number) => {
|
||||
assert.equal(number, "7");
|
||||
return pullRequest(overrides);
|
||||
});
|
||||
assert.deepEqual(actual, expected);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("manual baseline scans use the trusted workflow commit", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets({ ...context, event: { inputs: {} } }, () =>
|
||||
assert.fail("unexpected API call"),
|
||||
),
|
||||
[{ pr: 0, sha: mainSha }],
|
||||
);
|
||||
test("manual and scheduled baselines use the trusted workflow commit before and after approval", async () => {
|
||||
const target = { pr: 0, sha: mainSha };
|
||||
const scheduled = {
|
||||
...context,
|
||||
eventName: "schedule",
|
||||
event: { schedule: "17 3 * * 1" },
|
||||
};
|
||||
for (const request of [
|
||||
{ ...context, event: { inputs: {} } },
|
||||
scheduled,
|
||||
{ ...context, target: { ...target } },
|
||||
{ ...scheduled, target: { ...target } },
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(request, () =>
|
||||
assert.fail("unexpected API call"),
|
||||
),
|
||||
[target],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("incomplete or invalid PR inputs fail instead of falling back to a baseline", async () => {
|
||||
@@ -92,74 +98,27 @@ test("incomplete or invalid PR inputs fail instead of falling back to a baseline
|
||||
}
|
||||
});
|
||||
|
||||
test("ignores unexpected events without querying GitHub", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets({ ...context, eventName: "pull_request" }, () =>
|
||||
assert.fail("unexpected API call"),
|
||||
),
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
test("scheduled baseline scans use the trusted workflow commit", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(
|
||||
{ ...context, eventName: "schedule", event: { schedule: "17 3 * * 1" } },
|
||||
() => assert.fail("unexpected API call"),
|
||||
),
|
||||
[{ pr: 0, sha: mainSha }],
|
||||
);
|
||||
});
|
||||
|
||||
test("completed behavior workflows no longer queue inference", async () => {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(
|
||||
{
|
||||
...context,
|
||||
eventName: "workflow_run",
|
||||
event: {
|
||||
workflow_run: {
|
||||
event: "pull_request",
|
||||
conclusion: "success",
|
||||
head_sha: sourceSha,
|
||||
pull_requests: [{ number: 7 }],
|
||||
},
|
||||
test("PR events and completed PR workflows do not queue inference or query GitHub", async () => {
|
||||
for (const trigger of [
|
||||
{ eventName: "pull_request", event: { pull_request: pullRequest() } },
|
||||
{
|
||||
eventName: "workflow_run",
|
||||
event: {
|
||||
workflow_run: {
|
||||
event: "pull_request",
|
||||
conclusion: "success",
|
||||
head_sha: sourceSha,
|
||||
pull_requests: [{ number: 7 }],
|
||||
},
|
||||
},
|
||||
() => assert.fail("unexpected API call"),
|
||||
),
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
test("approval recheck stays bound to its matrix PR and source revision", async () => {
|
||||
const run = { ...context, target: { pr: 7, sha: sourceSha } };
|
||||
for (const changed of [
|
||||
{ state: "closed" },
|
||||
{ base: { ref: "release", repo: { full_name: repository } } },
|
||||
{ head: { sha: mainSha } },
|
||||
},
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(run, async (number) => {
|
||||
assert.equal(number, "7");
|
||||
return pullRequest(changed);
|
||||
}),
|
||||
[],
|
||||
);
|
||||
}
|
||||
assert.deepEqual(await resolveScanTargets(run, async () => pullRequest()), [
|
||||
{ pr: 7, sha: sourceSha },
|
||||
]);
|
||||
});
|
||||
|
||||
test("baseline approval recheck retains the original trusted workflow commit", async () => {
|
||||
for (const eventName of ["workflow_dispatch", "schedule"]) {
|
||||
assert.deepEqual(
|
||||
await resolveScanTargets(
|
||||
{ ...context, eventName, target: { pr: 0, sha: mainSha } },
|
||||
() => assert.fail("unexpected API call"),
|
||||
await resolveScanTargets({ ...context, ...trigger }, () =>
|
||||
assert.fail("unexpected API call"),
|
||||
),
|
||||
[{ pr: 0, sha: mainSha }],
|
||||
[],
|
||||
trigger.eventName,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
release_npm_version=11.12.1
|
||||
release_npm_prefix="$RUNNER_TEMP/codex-security-provenance-npm"
|
||||
release_npm_bin="$release_npm_prefix/node_modules/.bin"
|
||||
|
||||
verify_release_npm() {
|
||||
if [[ "$1" != "$release_npm_bin/npm" || "$("$1" --version)" != "$release_npm_version" ]]; then
|
||||
echo "Expected npm $release_npm_version at $release_npm_bin/npm for provenance verification." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_release_npm() {
|
||||
npm install --prefix "$release_npm_prefix" --ignore-scripts --no-audit --no-fund \
|
||||
--registry=https://openai.firewall.socket.dev/npm/ "npm@$release_npm_version"
|
||||
verify_release_npm "$release_npm_bin/npm"
|
||||
}
|
||||
@@ -9,6 +9,23 @@ import { isMain } from "../../sdk/typescript/scripts/is-main.mjs";
|
||||
|
||||
const marker = "<!-- codex-security-release-progress -->";
|
||||
const workflows = ["node-ci", "node-release", "node-github-release"];
|
||||
const npmDeploymentJobs = {
|
||||
"Publish npm and container images": {
|
||||
stage: "Release approval and npm publication",
|
||||
prompt:
|
||||
"Approve the **npm** deployment to publish the npm package and its matching container images.",
|
||||
},
|
||||
"Verify existing npm release": {
|
||||
stage: "Existing npm release verification",
|
||||
prompt:
|
||||
"Approve the **npm** deployment to verify the existing npm package and its signed provenance.",
|
||||
},
|
||||
publish: {
|
||||
stage: "Protected npm publication",
|
||||
prompt:
|
||||
"Approve the protected **npm** deployment in the linked release run.",
|
||||
},
|
||||
};
|
||||
|
||||
function status(value) {
|
||||
if (!value) return "Not started";
|
||||
@@ -66,7 +83,14 @@ export function renderProgress(
|
||||
job.name.startsWith("native /") ||
|
||||
job.name.startsWith("release tests /"),
|
||||
);
|
||||
const publisher = npmJobs.find((job) => job.name === "publish");
|
||||
const npmDeploymentJob = npmJobs.find((job) =>
|
||||
Object.hasOwn(npmDeploymentJobs, job.name),
|
||||
);
|
||||
const npmDeployment = npmDeploymentJobs[npmDeploymentJob?.name] ?? {
|
||||
stage: "npm deployment",
|
||||
prompt:
|
||||
"Open the linked release run to see what the waiting job will do before approving the **npm** deployment.",
|
||||
};
|
||||
const verified = jobStatus(verification, npm);
|
||||
const actionPublisher = githubJobs.find(
|
||||
(job) => job.name === "publish matching Action",
|
||||
@@ -80,14 +104,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,
|
||||
@@ -104,15 +136,15 @@ export function renderProgress(
|
||||
row("npm release status", status(npm), npm, !npm && Boolean(github)),
|
||||
row(
|
||||
"Release verification",
|
||||
verified === "Passed" && !publisher && !awaitingApproval
|
||||
verified === "Passed" && !npmDeploymentJob && !awaitingApproval
|
||||
? status(npm)
|
||||
: verified,
|
||||
npm,
|
||||
!npm && Boolean(github),
|
||||
),
|
||||
row(
|
||||
"Protected npm publication",
|
||||
awaitingApproval ? "Waiting for npm approval" : status(publisher),
|
||||
npmDeployment.stage,
|
||||
awaitingApproval ? "Waiting for npm approval" : status(npmDeploymentJob),
|
||||
npm,
|
||||
!npm && Boolean(github),
|
||||
),
|
||||
@@ -178,7 +210,7 @@ export function renderProgress(
|
||||
),
|
||||
"",
|
||||
awaitingApproval
|
||||
? "Approve the protected **npm** deployment in the linked release run."
|
||||
? npmDeployment.prompt
|
||||
: awaitingContainerApproval
|
||||
? "Approve the protected **container** deployment in the linked release run."
|
||||
: "Progress updates do not change publication approvals or verification requirements.",
|
||||
|
||||
@@ -1,44 +1,70 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { appendFileSync, readFileSync } from "node:fs";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { checkoutBase } from "./verify-pr-source.mjs";
|
||||
|
||||
const documentation =
|
||||
/^(?:README\.md|CONTRIBUTING\.md|CODE_OF_CONDUCT\.md|docs\/.*\.md|github-action\/README\.md|docker\/README\.md)$/;
|
||||
const ordinarySource =
|
||||
/^(?:sdk\/typescript\/(?:src|tests-ts)|plugins\/codex-security\/mcp-app\/(?:src|tests))\/.*\.ts$/;
|
||||
const pythonTest = /^plugins\/codex-security\/tests\/test_[^/]*\.py$/;
|
||||
const sdkTest = /^sdk\/typescript\/tests-ts\/[^/]+\.test\.ts$/;
|
||||
const actionFiles =
|
||||
/^(?:action\.yml|github-action\/(?:README\.md|(?:runtime\/)?package(?:-lock)?\.json|dist\/(?:index|post)\.cjs|(?:src|scripts|tests)\/[^/]+\.(?:mjs|ts)))$/;
|
||||
const evalFiles =
|
||||
/^evals\/(?:standard-time-budget\/(?:[^/]+\.mts|experiment\.json|README\.md)|triage-finding\/(?:package\.json|pnpm-lock\.yaml|README\.md|(?:assertions|scripts)\/[^/]+\.mts))$/;
|
||||
|
||||
function scopeFor(paths, event, baseChanged) {
|
||||
const packageManifest = JSON.parse(
|
||||
readFileSync(
|
||||
new URL("../../sdk/typescript/package.json", import.meta.url),
|
||||
"utf8",
|
||||
),
|
||||
);
|
||||
const packagedDocs = new Set(
|
||||
packageManifest.files
|
||||
.filter((file) => file.endsWith(".md"))
|
||||
.map((file) => `sdk/typescript/${file}`),
|
||||
);
|
||||
const isDocumentation = (path) =>
|
||||
documentation.test(path) || packagedDocs.has(path);
|
||||
|
||||
function scopeFor(paths, { event, baseChanged, modifiedOnly }) {
|
||||
if (event !== "pull_request" || baseChanged || !paths.length) return "full";
|
||||
if (paths.every((path) => documentation.test(path))) return "docs";
|
||||
if (modifiedOnly && paths.every((path) => pythonTest.test(path)))
|
||||
return "python-tests";
|
||||
if (paths.every((path) => isDocumentation(path) || path === "RELEASING.md")) {
|
||||
// The Action profile already builds the package and installs it on Node 24.
|
||||
// Select the separate Action job from its own inputs below.
|
||||
return paths.some((path) => packagedDocs.has(path)) ? "action" : "docs";
|
||||
}
|
||||
if (paths.every((path) => actionFiles.test(path))) return "action";
|
||||
if (paths.every((path) => evalFiles.test(path))) return "evals";
|
||||
if (
|
||||
paths.every((path) => ordinarySource.test(path) || documentation.test(path))
|
||||
)
|
||||
if (paths.every((path) => ordinarySource.test(path) || isDocumentation(path)))
|
||||
return "source";
|
||||
return "full";
|
||||
}
|
||||
|
||||
export function selectChecks(paths, { event, baseChanged = false }) {
|
||||
const scope = scopeFor(paths, event, baseChanged);
|
||||
const full = scope === "full";
|
||||
export function selectChecks(paths, options) {
|
||||
const scope = scopeFor(paths, options);
|
||||
const full = scope === "full" || scope === "python-tests";
|
||||
const source = full || scope === "source";
|
||||
const sdkTestsOnly =
|
||||
scope === "source" && paths.every((path) => sdkTest.test(path));
|
||||
const sourceBeyondSdkTests = source && !sdkTestsOnly;
|
||||
const action =
|
||||
full ||
|
||||
scope === "action" ||
|
||||
paths.some(
|
||||
(path) =>
|
||||
path === "github-action/README.md" ||
|
||||
path === "sdk/typescript/src/git-remote.ts",
|
||||
actionFiles.test(path) || path === "sdk/typescript/src/git-remote.ts",
|
||||
);
|
||||
const compatibility = ["22.13.0", "24.0.0", "24", "26.0.0", "26"]
|
||||
.filter((version) => full || version !== "26")
|
||||
.map((version) => ({ os: "ubuntu-latest", node: version }));
|
||||
compatibility.push({ os: "macos-latest", node: "22.13.0" });
|
||||
if (scope !== "python-tests") {
|
||||
compatibility.push({ os: "windows-latest", node: "22.13.0" });
|
||||
if (full) compatibility.push({ os: "windows-latest", node: "24" });
|
||||
}
|
||||
const pythonMatrix = [
|
||||
...["3.10", "3.12", "3.14"]
|
||||
.filter((version) => full || version === "3.12")
|
||||
@@ -58,24 +84,33 @@ export function selectChecks(paths, { event, baseChanged = false }) {
|
||||
markers: "cross_platform or native_windows",
|
||||
},
|
||||
];
|
||||
return {
|
||||
const selected = {
|
||||
"source-required": String(source),
|
||||
"container-required": String(
|
||||
sourceBeyondSdkTests && scope !== "python-tests",
|
||||
),
|
||||
"plugin-tests-required": String(sourceBeyondSdkTests),
|
||||
"package-required": String(source || scope === "action"),
|
||||
"action-ci": String(action),
|
||||
"eval-contracts": String(source || scope === "evals"),
|
||||
"eval-contracts": String(
|
||||
sourceBeyondSdkTests ||
|
||||
scope === "evals" ||
|
||||
paths.includes("sdk/typescript/tests-ts/codex-dependency-pins.test.ts"),
|
||||
),
|
||||
"workflow-quality": String(full),
|
||||
"container-validate": String(source),
|
||||
"compatibility-matrix": JSON.stringify({
|
||||
include:
|
||||
scope === "action"
|
||||
scope === "action" || sdkTestsOnly
|
||||
? [{ os: "ubuntu-latest", node: "24" }]
|
||||
: compatibility,
|
||||
}),
|
||||
"python-matrix": JSON.stringify({ include: pythonMatrix }),
|
||||
"windows-node-matrix": JSON.stringify({
|
||||
node: full ? ["22.13.0", "24"] : ["22.13.0"],
|
||||
}),
|
||||
};
|
||||
if (scope === "python-tests") {
|
||||
for (const name of ["source-required", "action-ci", "eval-contracts"])
|
||||
selected[name] = "false";
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -85,33 +120,31 @@ if (
|
||||
const event = process.env.EVENT_NAME;
|
||||
const baseChanged = process.env.BASE_CHANGED === "true";
|
||||
if (event === "pull_request" && baseChanged) {
|
||||
const { base, head } = JSON.parse(
|
||||
const { changes, pull_request: pr } = JSON.parse(
|
||||
readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"),
|
||||
).pull_request;
|
||||
const parents = execFileSync("git", ["show", "-s", "--format=%P", "HEAD"], {
|
||||
encoding: "utf8",
|
||||
}).trim();
|
||||
const expected = `${base.sha} ${head.sha}`;
|
||||
console.log(
|
||||
`Requested base ${base.ref}. Expected merge parents ${expected}. Checked out ${parents}.`,
|
||||
);
|
||||
if (parents !== expected) {
|
||||
throw new Error(
|
||||
"GitHub supplied a stale test merge. After the merge ref updates, reopen the pull request to start a fresh source run. Rerunning this attempt uses the same commit.",
|
||||
);
|
||||
// Ordinary edits already proved their live target before falling back to full checks.
|
||||
if (changes?.base) {
|
||||
const base = checkoutBase(pr, process.env.GITHUB_SHA);
|
||||
if (base !== pr.base.sha)
|
||||
throw new Error(
|
||||
`Stale test merge. Requested ${pr.base.ref} at ${pr.base.sha}, checked out base ${base} with head ${pr.head.sha}. Start a fresh pull request event after the merge ref updates.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const paths =
|
||||
const changes =
|
||||
event === "pull_request" && !baseChanged
|
||||
? execFileSync(
|
||||
"git",
|
||||
["diff", "--no-renames", "--name-only", "-z", "HEAD^1", "HEAD"],
|
||||
["diff", "--no-renames", "--name-status", "-z", "HEAD^1", "HEAD"],
|
||||
{ encoding: "utf8" },
|
||||
)
|
||||
.split("\0")
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
const selected = selectChecks(paths, { event, baseChanged });
|
||||
const paths = changes.filter((_, i) => i % 2);
|
||||
const modifiedOnly = changes.every((field, i) => i % 2 || field === "M");
|
||||
const selected = selectChecks(paths, { event, baseChanged, modifiedOnly });
|
||||
appendFileSync(
|
||||
process.env.GITHUB_OUTPUT,
|
||||
Object.entries(selected)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { execFileSync, spawnSync } from "node:child_process";
|
||||
import * as fs from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join, resolve } from "node:path";
|
||||
import { test } from "node:test";
|
||||
import { selectChecks } from "./select-ci-checks.mjs";
|
||||
import { failedChecks } from "./check-ci-results.mjs";
|
||||
@@ -7,13 +10,18 @@ import { failedChecks } from "./check-ci-results.mjs";
|
||||
const select = (paths, options = {}) =>
|
||||
selectChecks(paths, { event: "pull_request", ...options });
|
||||
|
||||
const ubuntuNode24Install = JSON.stringify({
|
||||
include: [{ os: "ubuntu-latest", node: "24" }],
|
||||
});
|
||||
|
||||
const regularSource = {
|
||||
"source-required": "true",
|
||||
"container-required": "true",
|
||||
"plugin-tests-required": "true",
|
||||
"package-required": "true",
|
||||
"action-ci": "false",
|
||||
"eval-contracts": "true",
|
||||
"workflow-quality": "false",
|
||||
"container-validate": "true",
|
||||
"compatibility-matrix": JSON.stringify({
|
||||
include: [
|
||||
{ os: "ubuntu-latest", node: "22.13.0" },
|
||||
@@ -21,6 +29,7 @@ const regularSource = {
|
||||
{ os: "ubuntu-latest", node: "24" },
|
||||
{ os: "ubuntu-latest", node: "26.0.0" },
|
||||
{ os: "macos-latest", node: "22.13.0" },
|
||||
{ os: "windows-latest", node: "22.13.0" },
|
||||
],
|
||||
}),
|
||||
"python-matrix": JSON.stringify({
|
||||
@@ -38,13 +47,11 @@ const regularSource = {
|
||||
},
|
||||
],
|
||||
}),
|
||||
"windows-node-matrix": JSON.stringify({ node: ["22.13.0"] }),
|
||||
};
|
||||
const fullQualification = {
|
||||
...regularSource,
|
||||
"action-ci": "true",
|
||||
"workflow-quality": "true",
|
||||
"container-validate": "true",
|
||||
"compatibility-matrix": JSON.stringify({
|
||||
include: [
|
||||
{ os: "ubuntu-latest", node: "22.13.0" },
|
||||
@@ -53,6 +60,8 @@ const fullQualification = {
|
||||
{ os: "ubuntu-latest", node: "26.0.0" },
|
||||
{ os: "ubuntu-latest", node: "26" },
|
||||
{ os: "macos-latest", node: "22.13.0" },
|
||||
{ os: "windows-latest", node: "22.13.0" },
|
||||
{ os: "windows-latest", node: "24" },
|
||||
],
|
||||
}),
|
||||
"python-matrix": JSON.stringify({
|
||||
@@ -72,17 +81,85 @@ const fullQualification = {
|
||||
},
|
||||
],
|
||||
}),
|
||||
"windows-node-matrix": JSON.stringify({ node: ["22.13.0", "24"] }),
|
||||
};
|
||||
|
||||
const docs = {
|
||||
...regularSource,
|
||||
"source-required": "false",
|
||||
"container-required": "false",
|
||||
"plugin-tests-required": "false",
|
||||
"package-required": "false",
|
||||
"eval-contracts": "false",
|
||||
"container-validate": "false",
|
||||
};
|
||||
|
||||
test("the Docker context excludes the test modules skipped by container CI", () => {
|
||||
const ignore = ["Dockerfile.dockerignore", ".dockerignore"]
|
||||
.map((file) => new URL(`../../${file}`, import.meta.url))
|
||||
.find((file) => fs.existsSync(file));
|
||||
const rules = fs.readFileSync(ignore, "utf8");
|
||||
assert.match(rules, /^plugins\/codex-security\/tests\r?$/m);
|
||||
assert.match(rules, /^sdk\/typescript\/tests-ts\/\*\.test\.ts\r?$/m);
|
||||
assert.doesNotMatch(rules, /^\s*!/m);
|
||||
});
|
||||
|
||||
test("only edits to existing direct pytest modules skip independent jobs", (t) => {
|
||||
const cwd = fs.mkdtempSync(resolve(tmpdir(), "ci-pytest-"));
|
||||
t.after(() => fs.rmSync(cwd, { recursive: true, force: true }));
|
||||
const files = join(cwd, "plugins/codex-security/tests");
|
||||
const output = join(cwd, "output");
|
||||
const script = join(import.meta.dirname, "select-ci-checks.mjs");
|
||||
const env = {
|
||||
...process.env,
|
||||
EVENT_NAME: "pull_request",
|
||||
BASE_CHANGED: "false",
|
||||
GITHUB_OUTPUT: output,
|
||||
};
|
||||
// A Git hook may export its own repository and index into this process.
|
||||
for (const name of Object.keys(env))
|
||||
if (/^GIT_/iu.test(name)) delete env[name];
|
||||
env.GIT_CONFIG_GLOBAL = join(cwd, "empty.gitconfig");
|
||||
env.GIT_CONFIG_NOSYSTEM = "1";
|
||||
const git = (...args) => execFileSync("git", args, { cwd, env });
|
||||
git("init", "-q");
|
||||
git("config", "user.name", "CI Fixture");
|
||||
git("config", "user.email", "fixture@example.com");
|
||||
fs.mkdirSync(files, { recursive: true });
|
||||
let revision = 0;
|
||||
function commit(...names) {
|
||||
for (const name of names)
|
||||
fs.writeFileSync(join(files, name), String(revision++));
|
||||
git("add", "--force", "plugins");
|
||||
git("commit", "-qm", "fixture");
|
||||
}
|
||||
commit("test_2fa.py", "conftest.py");
|
||||
const reduced = {
|
||||
...fullQualification,
|
||||
"compatibility-matrix": JSON.stringify({
|
||||
include: JSON.parse(
|
||||
fullQualification["compatibility-matrix"],
|
||||
).include.filter(({ os }) => os !== "windows-latest"),
|
||||
}),
|
||||
"source-required": "false",
|
||||
"container-required": "false",
|
||||
"action-ci": "false",
|
||||
"eval-contracts": "false",
|
||||
};
|
||||
for (const [names, expected] of [
|
||||
[["test_2fa.py"], reduced],
|
||||
[["test_2fa.py", "test_added.py"], fullQualification],
|
||||
[["test_2fa.py", "conftest.py"], fullQualification],
|
||||
]) {
|
||||
commit(...names);
|
||||
fs.writeFileSync(output, "");
|
||||
execFileSync(process.execPath, [script], { cwd, env });
|
||||
const lines = fs.readFileSync(output, "utf8").trim().split("\n");
|
||||
assert.deepEqual(
|
||||
Object.fromEntries(lines.map((line) => line.split("="))),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("ordinary documentation selects static checks", () => {
|
||||
assert.deepEqual(select(["README.md", "docs/bedrock.md"]), docs);
|
||||
for (const path of [
|
||||
@@ -124,9 +201,7 @@ test("Action-only changes require Action CI and integration against the built pa
|
||||
...docs,
|
||||
"package-required": "true",
|
||||
"action-ci": "true",
|
||||
"compatibility-matrix": JSON.stringify({
|
||||
include: [{ os: "ubuntu-latest", node: "24" }],
|
||||
}),
|
||||
"compatibility-matrix": ubuntuNode24Install,
|
||||
};
|
||||
for (const paths of [
|
||||
["action.yml", "github-action/README.md"],
|
||||
@@ -202,41 +277,32 @@ test("Standard and triage eval changes require all deterministic eval contracts"
|
||||
);
|
||||
});
|
||||
|
||||
test("packaged SDK documentation keeps package validation selected", () => {
|
||||
const manifest = JSON.parse(
|
||||
readFileSync(
|
||||
new URL("../../sdk/typescript/package.json", import.meta.url),
|
||||
"utf8",
|
||||
),
|
||||
);
|
||||
for (const file of manifest.files.filter((file) => file.endsWith(".md"))) {
|
||||
const path = `sdk/typescript/${file}`;
|
||||
const selected = select([path]);
|
||||
assert.deepEqual(selected, fullQualification, path);
|
||||
test("packaged guides keep the archive and installed-package gates", () => {
|
||||
const expected = {
|
||||
...docs,
|
||||
"package-required": "true",
|
||||
"compatibility-matrix": ubuntuNode24Install,
|
||||
};
|
||||
for (const paths of [
|
||||
["sdk/typescript/README.md"],
|
||||
["RELEASING.md", "sdk/typescript/docs/cli.md"],
|
||||
// --no-renames includes the old required path even when the new path is ordinary docs.
|
||||
["sdk/typescript/docs/hosted-scans.md", "docs/hosted-scans.md"],
|
||||
]) {
|
||||
assert.deepEqual(select(paths), expected, paths.join(", "));
|
||||
}
|
||||
// The --no-renames diff reports the old path when a required doc is renamed.
|
||||
const renamed = select([
|
||||
"sdk/typescript/docs/hosted-scans.md",
|
||||
"docs/hosted-scans.md",
|
||||
]);
|
||||
assert.equal(renamed["source-required"], "true");
|
||||
assert.equal(
|
||||
select(["README.md", "sdk/typescript/README.md"])["source-required"],
|
||||
"true",
|
||||
assert.deepEqual(
|
||||
failedChecks({
|
||||
"classify-changes": { result: "success", outputs: expected },
|
||||
"static-checks": { result: "success" },
|
||||
}),
|
||||
["native", "package", "compatibility"],
|
||||
);
|
||||
});
|
||||
|
||||
test("release recovery documentation keeps its SDK contract selected", () => {
|
||||
for (const paths of [["RELEASING.md"], ["README.md", "RELEASING.md"]]) {
|
||||
const outputs = select(paths);
|
||||
assert.deepEqual(outputs, fullQualification);
|
||||
// release-automation.test.ts validates the documented recovery marker.
|
||||
const missing = failedChecks({
|
||||
"classify-changes": { result: "success", outputs },
|
||||
"static-checks": { result: "success" },
|
||||
});
|
||||
assert.ok(missing.includes("test"));
|
||||
}
|
||||
test("release guide changes select the static route", () => {
|
||||
assert.deepEqual(select(["RELEASING.md"]), docs);
|
||||
assert.deepEqual(select(["README.md", "RELEASING.md"]), docs);
|
||||
});
|
||||
|
||||
test("release helper changes select their release-progress regression checks", () => {
|
||||
@@ -249,14 +315,49 @@ test("release helper changes select their release-progress regression checks", (
|
||||
test("ordinary TypeScript source and tests retain the reduced version matrices", () => {
|
||||
for (const path of [
|
||||
"sdk/typescript/src/cost.ts",
|
||||
"sdk/typescript/tests-ts/skeleton.test.ts",
|
||||
"sdk/typescript/src/index.ts",
|
||||
"sdk/typescript/tests-ts/support/test-subprocess.ts",
|
||||
"plugins/codex-security/mcp-app/src/stdio-transport.ts",
|
||||
"plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts",
|
||||
"plugins/codex-security/mcp-app/tests/support/fixture.ts",
|
||||
]) {
|
||||
assert.deepEqual(select([path]), regularSource, path);
|
||||
assert.deepEqual(select(["README.md", path]), regularSource, path);
|
||||
for (const guide of ["README.md", "sdk/typescript/docs/cli.md"]) {
|
||||
assert.deepEqual(select([guide, path]), regularSource, path);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("SDK test-only PRs skip independent suites and retain any changed eval input", () => {
|
||||
const paths = [
|
||||
"sdk/typescript/tests-ts/skeleton.test.ts",
|
||||
"sdk/typescript/tests-ts/windows-machine-policy.test.ts",
|
||||
];
|
||||
const sdk = {
|
||||
...regularSource,
|
||||
"container-required": "false",
|
||||
"plugin-tests-required": "false",
|
||||
"compatibility-matrix": ubuntuNode24Install,
|
||||
};
|
||||
assert.deepEqual(select(paths), { ...sdk, "eval-contracts": "false" });
|
||||
assert.deepEqual(
|
||||
select([...paths, "sdk/typescript/tests-ts/codex-dependency-pins.test.ts"]),
|
||||
sdk,
|
||||
);
|
||||
for (const other of [
|
||||
"README.md",
|
||||
"sdk/typescript/tests-ts/support/test-subprocess.ts",
|
||||
"sdk/typescript/src/api.ts",
|
||||
]) {
|
||||
assert.deepEqual(select([...paths, other]), regularSource, other);
|
||||
}
|
||||
for (const options of [
|
||||
{ event: "push" },
|
||||
{ event: "schedule" },
|
||||
{ event: "workflow_dispatch" },
|
||||
{ baseChanged: true },
|
||||
]) {
|
||||
assert.deepEqual(select(paths, options), fullQualification);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -272,6 +373,9 @@ test("unknown paths and dependency configuration receive full qualification", ()
|
||||
["other/sdk/typescript/src/runtime.ts"],
|
||||
[".npmrc"],
|
||||
["sdk/typescript/.npmrc"],
|
||||
["sdk/typescript/docs/unlisted.md"],
|
||||
["RELEASING.md", "sdk/typescript/src/api.ts"],
|
||||
["sdk/typescript/docs/cli.md", "sdk/typescript/docs/unlisted.md"],
|
||||
["plugins/codex-security/mcp-app/src/.npmrc"],
|
||||
["pnpm-workspace.yaml"],
|
||||
["sdk/typescript/pnpm-workspace.yaml"],
|
||||
@@ -300,6 +404,13 @@ test("unknown paths and dependency configuration receive full qualification", ()
|
||||
|
||||
test("tooling and non-TypeScript product inputs receive full qualification", () => {
|
||||
for (const path of [
|
||||
"Dockerfile",
|
||||
".github/workflows/container-ci.yml",
|
||||
".github/workflows/container-validate.yml",
|
||||
".github/workflows/container-release.yml",
|
||||
".github/workflows/native-windows.yml",
|
||||
"sdk/typescript/scripts/run-ci-tests.mts",
|
||||
"plugins/codex-security/skills/example/SKILL.md",
|
||||
"package.json",
|
||||
"sdk/typescript/pnpm-lock.yaml",
|
||||
"sdk/typescript/bunfig.toml",
|
||||
@@ -332,7 +443,7 @@ test("main, scheduled, manual, empty and retargeted changes receive full qualifi
|
||||
assert.deepEqual(select([]), fullQualification);
|
||||
});
|
||||
|
||||
test("the final gate rejects every missing or unsuccessful selected check", () => {
|
||||
function successfulFullRun() {
|
||||
const outputs = select([".github/workflows/node-ci.yml"]);
|
||||
const needs = Object.fromEntries(
|
||||
[
|
||||
@@ -347,13 +458,17 @@ test("the final gate rejects every missing or unsuccessful selected check", () =
|
||||
"plugin-host",
|
||||
"plugin-source",
|
||||
"windows-test",
|
||||
"windows-verify",
|
||||
"workflow-quality",
|
||||
"container-validate",
|
||||
].map((name) => [name, { result: "success" }]),
|
||||
);
|
||||
needs["action-ci"].outputs = { passed: "true" };
|
||||
needs["classify-changes"] = { result: "success", outputs };
|
||||
return needs;
|
||||
}
|
||||
|
||||
test("the final gate rejects every missing or unsuccessful selected check", () => {
|
||||
const needs = successfulFullRun();
|
||||
assert.deepEqual(failedChecks(needs), []);
|
||||
for (const name of Object.keys(needs)) {
|
||||
for (const result of ["failure", "cancelled", "skipped", undefined]) {
|
||||
@@ -365,6 +480,37 @@ test("the final gate rejects every missing or unsuccessful selected check", () =
|
||||
}
|
||||
});
|
||||
|
||||
test("the final gate distinguishes a failed check from a skipped dependent job", () => {
|
||||
const run = (needs) =>
|
||||
spawnSync(process.execPath, ["check-ci-results.mjs"], {
|
||||
cwd: new URL(".", import.meta.url),
|
||||
env: { ...process.env, CI_RESULTS: JSON.stringify(needs) },
|
||||
encoding: "utf8",
|
||||
});
|
||||
const needs = successfulFullRun();
|
||||
const pythonTests = select(["plugins/codex-security/tests/test_workbench.py"], {
|
||||
modifiedOnly: true,
|
||||
});
|
||||
const passed = run({
|
||||
...needs,
|
||||
"classify-changes": { result: "success", outputs: pythonTests },
|
||||
test: { result: "failure" },
|
||||
"windows-test": { result: "cancelled" },
|
||||
"container-validate": { result: "skipped" },
|
||||
});
|
||||
assert.equal(passed.status, 0, passed.stderr);
|
||||
assert.equal(passed.stdout.trim(), "All selected required CI checks passed.");
|
||||
|
||||
needs["static-checks"].result = "failure";
|
||||
needs["container-validate"].result = "skipped";
|
||||
const failed = run(needs);
|
||||
assert.equal(failed.status, 1, failed.stderr);
|
||||
assert.match(
|
||||
failed.stderr,
|
||||
/^Required CI checks did not pass: static-checks \(failure\), container-validate \(skipped\)$/m,
|
||||
);
|
||||
});
|
||||
|
||||
test("documentation requires static checks and explicit selection, without skipped source failures", () => {
|
||||
const outputs = select(["README.md"]);
|
||||
const needs = {
|
||||
@@ -378,11 +524,12 @@ test("documentation requires static checks and explicit selection, without skipp
|
||||
);
|
||||
for (const key of [
|
||||
"source-required",
|
||||
"container-required",
|
||||
"plugin-tests-required",
|
||||
"package-required",
|
||||
"action-ci",
|
||||
"eval-contracts",
|
||||
"workflow-quality",
|
||||
"container-validate",
|
||||
]) {
|
||||
assert.deepEqual(
|
||||
failedChecks({
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { test } from "node:test";
|
||||
import { extractHistoricalReleaseSummary } from "../../sdk/typescript/scripts/release-automation.mjs";
|
||||
|
||||
test("the release recovery guide documents a canonical historical-summary block", () => {
|
||||
const guide = readFileSync(
|
||||
new URL("../../RELEASING.md", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
const recovery = guide.split("## Recover or repair a release")[1] ?? "";
|
||||
const start = "<!-- codex-security-release-summary:start -->";
|
||||
const end = "<!-- codex-security-release-summary:end -->";
|
||||
const block = [...recovery.matchAll(/^```text\r?\n([\s\S]*?)^```[ \t]*$/gmu)]
|
||||
.map((match) => match[1].replaceAll("\r\n", "\n"))
|
||||
.find((example) => example.includes(start) && example.includes(end));
|
||||
|
||||
assert.ok(block?.startsWith(`${start}\n`));
|
||||
assert.ok(block.includes(`${end}\n\n`));
|
||||
assert.equal(extractHistoricalReleaseSummary(block), "Reviewed summary");
|
||||
});
|
||||
@@ -6,7 +6,7 @@ import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import {
|
||||
checkCheckout,
|
||||
checkoutBase,
|
||||
confirmEdit,
|
||||
realSource,
|
||||
verifyEdit,
|
||||
@@ -23,6 +23,7 @@ const passed = { status: "completed", conclusion: "success" };
|
||||
function run(id, changes = {}) {
|
||||
return {
|
||||
id,
|
||||
html_url: `https://github.com/example/repo/actions/runs/${id}`,
|
||||
run_number: id,
|
||||
run_attempt: 1,
|
||||
run_started_at: id,
|
||||
@@ -39,11 +40,7 @@ function run(id, changes = {}) {
|
||||
const edit = (id, changes) =>
|
||||
run(id, { display_title: "PR edit CI · PR #42 → main", ...changes });
|
||||
function evidence(id, selected = "success") {
|
||||
const names = [
|
||||
"ci",
|
||||
"classify changes",
|
||||
...["ubuntu", "macos", "windows"].map((os) => os + "-latest / node-22"),
|
||||
];
|
||||
const names = ["ci", "classify changes"];
|
||||
const selection = {
|
||||
name: "Select required checks",
|
||||
status: "completed",
|
||||
@@ -60,7 +57,14 @@ function evidence(id, selected = "success") {
|
||||
}
|
||||
function fixture(
|
||||
history,
|
||||
{ jobs = evidence, targets = [target], wait = false, runAttempt = 1 } = {},
|
||||
{
|
||||
jobs = evidence,
|
||||
targets = [target],
|
||||
wait = false,
|
||||
runAttempt = 1,
|
||||
base = pr.base.sha,
|
||||
comparisons = [],
|
||||
} = {},
|
||||
) {
|
||||
let current = [],
|
||||
live = target;
|
||||
@@ -70,6 +74,12 @@ function fixture(
|
||||
if (live instanceof Error) throw live;
|
||||
return live;
|
||||
}
|
||||
if (path.startsWith("compare/")) {
|
||||
assert.equal(path, "compare/refs%2Fheads%2Fmain...base?per_page=1");
|
||||
const result = comparisons.shift();
|
||||
if (result instanceof Error) throw result;
|
||||
return result;
|
||||
}
|
||||
const runId = path.match(/runs\/(\d+)\/jobs/);
|
||||
if (runId) return jobs(Number(runId[1]));
|
||||
current = history.shift() ?? current;
|
||||
@@ -78,7 +88,7 @@ function fixture(
|
||||
const runs = [edit(99, { run_attempt: runAttempt }), ...current];
|
||||
return { total_count: runs.length, workflow_runs: runs };
|
||||
};
|
||||
const input = { pr, sha, runId: 99, runAttempt, api };
|
||||
const input = { pr, sha, base, runId: 99, runAttempt, api };
|
||||
return {
|
||||
check: () => verifyEdit(input, () => wait),
|
||||
finish: (id, classifierAttempt = runAttempt) =>
|
||||
@@ -134,8 +144,9 @@ test("only fresh canonical source jobs and genuine selection can qualify a sourc
|
||||
assert.ok(realSource(page, source));
|
||||
for (const change of [
|
||||
{ total_count: 99 },
|
||||
{ jobs: page.jobs.slice(1) },
|
||||
{ total_count: 6, jobs: [...page.jobs, page.jobs[0]] },
|
||||
{ total_count: 1, jobs: page.jobs.slice(1) },
|
||||
{ total_count: 1, jobs: page.jobs.slice(0, 1) },
|
||||
{ total_count: 3, jobs: [...page.jobs, page.jobs[0]] },
|
||||
{ jobs: page.jobs.map((j) => ({ ...j, run_id: 1 })) },
|
||||
{ jobs: page.jobs.map((j) => ({ ...j, run_attempt: 2 })) },
|
||||
{
|
||||
@@ -148,7 +159,7 @@ test("only fresh canonical source jobs and genuine selection can qualify a sourc
|
||||
assert.ok(!realSource({ ...page, ...change }, source));
|
||||
});
|
||||
|
||||
test("pending sources settle, genuine red remains red, and newer attempts cannot be masked", async () => {
|
||||
test("pending sources settle, genuine red remains red, and newer attempts cannot be masked", async (t) => {
|
||||
const green = run(3),
|
||||
red = run(3, { conclusion: "failure" }),
|
||||
pending = run(3, { status: "in_progress" });
|
||||
@@ -163,10 +174,14 @@ test("pending sources settle, genuine red remains red, and newer attempts cannot
|
||||
await fixture([[green, run(1, { run_attempt: 2 })]]).check(),
|
||||
"full",
|
||||
);
|
||||
const log = t.mock.method(console, "log", () => {});
|
||||
assert.equal(
|
||||
await fixture([[edit(8, { conclusion: "failure" }), red]]).check(),
|
||||
"failed",
|
||||
);
|
||||
assert.deepEqual(log.mock.calls[0]?.arguments, [
|
||||
`Failed source CI: ${red.html_url}/attempts/1`,
|
||||
]);
|
||||
for (const changed of [
|
||||
[run(3, { run_attempt: 2 })],
|
||||
[run(5, { conclusion: "failure" }), green],
|
||||
@@ -187,7 +202,7 @@ test("retrying a failed edit cannot replace its full checks with older green res
|
||||
await retry.finish();
|
||||
});
|
||||
|
||||
test("even full fallback needs a current target; repeat this check just before the aliases", async () => {
|
||||
test("even full fallback needs a current target when the CI gate finishes", async () => {
|
||||
const stale = { ...target, base: { ...pr.base, ref: "other" } },
|
||||
unavailable = new Error("target unavailable");
|
||||
for (const history of [
|
||||
@@ -218,6 +233,45 @@ test("even full fallback needs a current target; repeat this check just before t
|
||||
);
|
||||
});
|
||||
|
||||
test("an edit can use a newer test-merge base only while its named branch still proves that advance", async () => {
|
||||
const base = "new-base";
|
||||
const current = { base_commit: { sha: base }, status: "behind" };
|
||||
const changed = { base_commit: { sha: "moved" }, status: "behind" };
|
||||
const check = (comparisons, history = [[run(2)]]) =>
|
||||
fixture(history, { base, comparisons });
|
||||
const updated = { ...target, base: { ...pr.base, sha: base } };
|
||||
const source = run(2, { pull_requests: [updated] });
|
||||
const caughtUp = fixture([[run(2)], [source]], {
|
||||
base,
|
||||
comparisons: [current, current, current],
|
||||
targets: [target, updated],
|
||||
});
|
||||
assert.equal(await caughtUp.check(), 2);
|
||||
await caughtUp.finish(2);
|
||||
await assert.rejects(
|
||||
fixture([[source]], {
|
||||
base,
|
||||
targets: [{ ...updated, base: { ...pr.base, sha: "unrelated" } }],
|
||||
}).finish(2),
|
||||
/target changed/,
|
||||
);
|
||||
assert.equal(await check([current, current], [[]]).check(), "full");
|
||||
for (const invalid of [
|
||||
changed,
|
||||
{ ...current, status: "ahead" },
|
||||
{ ...current, status: "diverged" },
|
||||
{ ...current, status: "identical" },
|
||||
new Error("comparison unavailable"),
|
||||
]) {
|
||||
const error =
|
||||
invalid instanceof Error ? /comparison unavailable/ : /Stale test merge/;
|
||||
await assert.rejects(check([invalid]).check(), error);
|
||||
await assert.rejects(check([current, invalid]).check(), error);
|
||||
await assert.rejects(check([invalid]).finish(2), error);
|
||||
await assert.rejects(check([invalid]).finish(), error);
|
||||
}
|
||||
});
|
||||
|
||||
test("the final gate reads both actual merge parents from a depth-one checkout", (t) => {
|
||||
const root = mkdtempSync(join(tmpdir(), "ci-source-parents-"));
|
||||
t.after(() => rmSync(root, { recursive: true, force: true }));
|
||||
@@ -262,14 +316,10 @@ test("the final gate reads both actual merge parents from a depth-one checkout",
|
||||
);
|
||||
assert.equal(git(checkout, "rev-parse", "--is-shallow-repository"), "true");
|
||||
const pull = { base: { sha: base }, head: { sha: head } };
|
||||
checkCheckout(pull, merge, checkout);
|
||||
assert.equal(checkoutBase(pull, merge, checkout), base);
|
||||
assert.throws(
|
||||
() => checkCheckout({ ...pull, base: { sha: head } }, merge, checkout),
|
||||
/checked-out merge/,
|
||||
() => checkoutBase({ ...pull, head: { sha: base } }, merge, checkout),
|
||||
/Stale test merge/,
|
||||
);
|
||||
assert.throws(
|
||||
() => checkCheckout({ ...pull, head: { sha: base } }, merge, checkout),
|
||||
/checked-out merge/,
|
||||
);
|
||||
assert.throws(() => checkCheckout(pull, base, checkout), /checked-out merge/);
|
||||
assert.throws(() => checkoutBase(pull, base, checkout), /Stale test merge/);
|
||||
});
|
||||
|
||||
@@ -92,10 +92,10 @@ test("checkout preserves source size with autocrlf", () => {
|
||||
git(root, "add", "--", ".gitattributes", name);
|
||||
unlinkSync(source);
|
||||
git(root, "checkout-index", "--", name);
|
||||
const result = runChecker("--plugin-root", root);
|
||||
assert.equal(result.status, 0, result.stderr);
|
||||
assert.deepEqual(readFileSync(source), content);
|
||||
}
|
||||
const result = runChecker("--plugin-root", root);
|
||||
assert.equal(result.status, 0, result.stderr);
|
||||
});
|
||||
|
||||
test("accepts Markdown structures, natural line endings, and inline markup", () => {
|
||||
|
||||
@@ -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"));
|
||||
@@ -385,6 +413,7 @@ test("tracks protected container approval and failed reusable workflow jobs", as
|
||||
f.deployments.set(3, [{ environment: { name: "container" } }]);
|
||||
await f.update(3);
|
||||
assert.match(f.body(), /Container image \| Waiting for container approval/u);
|
||||
assert.match(f.body(), /Approve the protected \*\*container\*\* deployment/u);
|
||||
await f.watch(3, async () => {
|
||||
f.deployments.set(3, []);
|
||||
Object.assign(f.runs.get(3), {
|
||||
@@ -420,17 +449,46 @@ test("keeps one comment across CI, verification, and protected approval", async
|
||||
assert.equal(f.comments.length, 1);
|
||||
assert.match(f.body(), /Post-merge CI \| Passed/u);
|
||||
assert.match(f.body(), /Release verification \| Passed/u);
|
||||
assert.match(f.body(), /npm deployment \| Waiting for npm approval/u);
|
||||
assert.match(f.body(), /see what the waiting job will do/u);
|
||||
f.jobs.get(2).push(job("Publish npm and container images", null));
|
||||
assert.equal((await f.update(2)).action, "updated");
|
||||
assert.match(
|
||||
f.body(),
|
||||
/Protected npm publication \| Waiting for npm approval/u,
|
||||
/Release approval and npm publication \| Waiting for npm approval/u,
|
||||
);
|
||||
assert.match(
|
||||
f.body(),
|
||||
/publish the npm package and its matching container images/u,
|
||||
);
|
||||
assert.match(f.body(), /runs\/2/u);
|
||||
assert.deepEqual(
|
||||
f.writes().map((request) => request.method),
|
||||
["POST", "PATCH"],
|
||||
["POST", "PATCH", "PATCH"],
|
||||
);
|
||||
assert.equal((await f.update(2)).action, "unchanged");
|
||||
assert.equal(f.writes().length, 2);
|
||||
assert.equal(f.writes().length, 3);
|
||||
});
|
||||
|
||||
test("tracks approval and completion of existing npm release verification", async () => {
|
||||
const f = fixture();
|
||||
f.runs.set(2, run(2, "node-release", { status: "waiting" }));
|
||||
f.jobs.set(2, [job("verify"), job("Verify existing npm release", null)]);
|
||||
f.deployments.set(2, [{ environment: { name: "npm" } }]);
|
||||
await f.update(2);
|
||||
assert.match(
|
||||
f.body(),
|
||||
/Existing npm release verification \| Waiting for npm approval/u,
|
||||
);
|
||||
assert.match(
|
||||
f.body(),
|
||||
/verify the existing npm package and its signed provenance/u,
|
||||
);
|
||||
f.deployments.set(2, []);
|
||||
f.jobs.set(2, [job("verify"), job("Verify existing npm release")]);
|
||||
await f.update(2);
|
||||
assert.match(f.body(), /Existing npm release verification \| Passed/u);
|
||||
assert.match(f.body(), /Container image \| Not started/u);
|
||||
});
|
||||
|
||||
test("follows a release tagged on a successful fix back to its version-bump PR", async (t) => {
|
||||
@@ -471,7 +529,7 @@ test("follows a release tagged on a successful fix back to its version-bump PR",
|
||||
await f.update(1);
|
||||
assert.match(f.body(), /Post-merge CI \| Failed/u);
|
||||
f.runs.set(2, run(2, "node-release", { head_sha: fix, status: "waiting" }));
|
||||
f.jobs.set(2, [job("verify")]);
|
||||
f.jobs.set(2, [job("verify"), job("publish", null)]);
|
||||
f.deployments.set(2, [{ environment: { name: "npm" } }]);
|
||||
assert.equal((await f.update(2)).action, "updated");
|
||||
assert.equal(f.comments.length, 1);
|
||||
@@ -480,6 +538,7 @@ test("follows a release tagged on a successful fix back to its version-bump PR",
|
||||
f.body(),
|
||||
/Protected npm publication \| Waiting for npm approval/u,
|
||||
);
|
||||
assert.match(f.body(), /Approve the protected \*\*npm\*\* deployment/u);
|
||||
Object.assign(f.runs.get(2), { status: "completed", conclusion: "success" });
|
||||
f.runs.set(
|
||||
3,
|
||||
@@ -536,7 +595,7 @@ test("continues a release backfill when saved workflow runs were deleted", async
|
||||
assert.match(f.body(), /Post-merge CI \| Not recorded/u);
|
||||
if (deleted.includes(2)) {
|
||||
assert.match(f.body(), /npm release status \| Not recorded/u);
|
||||
assert.match(f.body(), /Protected npm publication \| Not recorded/u);
|
||||
assert.match(f.body(), /npm deployment \| Not recorded/u);
|
||||
}
|
||||
f.requests.length = 0;
|
||||
assert.equal((await f.update(4)).action, "unchanged");
|
||||
@@ -701,7 +760,7 @@ test("resolves GitHub publication to the release tag, including annotated tags",
|
||||
assert.match(f.body(), /## Automated release complete/u);
|
||||
assert.match(f.body(), /Post-merge CI \| Not recorded/u);
|
||||
assert.match(f.body(), /Release verification \| Not recorded/u);
|
||||
assert.match(f.body(), /Protected npm publication \| Not recorded/u);
|
||||
assert.match(f.body(), /npm deployment \| Not recorded/u);
|
||||
assert.match(f.body(), /GitHub Action \| Passed/u);
|
||||
assert.ok(
|
||||
f.requests.some(
|
||||
|
||||
@@ -7,51 +7,61 @@ const utf8 = { encoding: "utf8" };
|
||||
const successful = (job) =>
|
||||
job.status === "completed" && job.conclusion === "success";
|
||||
|
||||
function samePull(candidate, pr) {
|
||||
function samePull(candidate, pr, base) {
|
||||
return (
|
||||
candidate?.number === pr.number &&
|
||||
candidate.head?.sha === pr.head.sha &&
|
||||
[pr.base.sha, base].includes(candidate.base?.sha) &&
|
||||
["head", "base"].every(
|
||||
(side) =>
|
||||
candidate[side]?.ref === pr[side].ref &&
|
||||
candidate[side]?.sha === pr[side].sha &&
|
||||
candidate[side].repo?.id === pr[side].repo.id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function checkCheckout(pr, sha, cwd) {
|
||||
const git = (args) =>
|
||||
execFileSync("git", args, { encoding: "utf8", cwd }).trim();
|
||||
// The CI gate uses a depth-one checkout. Read its parent IDs from the raw object.
|
||||
const headers = git(["cat-file", "-p", "HEAD"])
|
||||
export function checkoutBase(pr, sha, cwd) {
|
||||
// A depth-one checkout still contains the raw commit and its parent IDs.
|
||||
const [object, ...headers] = execFileSync("git", ["cat-file", "--batch"], {
|
||||
cwd,
|
||||
input: "HEAD\n",
|
||||
encoding: "utf8",
|
||||
})
|
||||
.split("\n\n", 1)[0]
|
||||
.split("\n");
|
||||
const parents = headers
|
||||
.filter((h) => h.startsWith("parent "))
|
||||
.map((h) => h.slice(7));
|
||||
.filter((line) => line.startsWith("parent "))
|
||||
.map((line) => line.slice(7));
|
||||
if (
|
||||
git(["rev-parse", "HEAD"]) !== sha ||
|
||||
parents.join(" ") !== `${pr.base.sha} ${pr.head.sha}`
|
||||
!object.startsWith(`${sha} commit `) ||
|
||||
parents.length !== 2 ||
|
||||
parents[1] !== pr.head.sha
|
||||
)
|
||||
throw new Error(
|
||||
"The checked-out merge does not match the pull request base and head. Reopen the pull request or push a commit to qualify its current target.",
|
||||
`Stale test merge. Expected ${sha} with head ${pr.head.sha}, checked out ${object} with parents ${parents.join(" ")}. Start a fresh pull request event.`,
|
||||
);
|
||||
return parents[0];
|
||||
}
|
||||
|
||||
export async function confirmTarget(pr, sha, api) {
|
||||
async function confirmTarget({ pr, sha, base, api }) {
|
||||
const live = await api(`pulls/${pr.number}`);
|
||||
if (!samePull(live, pr) || live.merge_commit_sha !== sha)
|
||||
if (!samePull(live, pr, base) || live.merge_commit_sha !== sha)
|
||||
throw new Error(
|
||||
"The pull request target changed while its checks were running.",
|
||||
);
|
||||
if (base !== pr.base.sha) {
|
||||
// PR metadata can lag its test merge. Compare the named branch itself, including its ancestry.
|
||||
const ref = encodeURIComponent(`refs/heads/${pr.base.ref}`);
|
||||
const comparison = await api(`compare/${ref}...${pr.base.sha}?per_page=1`);
|
||||
if (comparison.base_commit.sha !== base || comparison.status !== "behind")
|
||||
throw new Error(
|
||||
`Stale test merge. Checked out base ${base}, but ${pr.base.ref} is at ${comparison.base_commit.sha} and event base ${pr.base.sha} is ${comparison.status}. Reopen the pull request or push a commit after its merge ref updates.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function realSource(page, run) {
|
||||
const required = [
|
||||
"ci",
|
||||
"classify changes",
|
||||
...["ubuntu", "macos", "windows"].map((os) => `${os}-latest / node-22`),
|
||||
];
|
||||
const required = ["ci", "classify changes"];
|
||||
const jobs = page.jobs.filter((job) => required.includes(job.name));
|
||||
if (
|
||||
page.total_count !== page.jobs.length ||
|
||||
@@ -70,7 +80,7 @@ export function realSource(page, run) {
|
||||
);
|
||||
}
|
||||
|
||||
function sourceCandidate(runs, { pr, sha }) {
|
||||
function sourceCandidate(runs, { pr, sha, base }) {
|
||||
const target = `PR #${pr.number} → ${pr.base.ref}`;
|
||||
const source = `Source CI · ${target}`;
|
||||
const edit = `PR edit CI · ${target}`;
|
||||
@@ -80,7 +90,7 @@ function sourceCandidate(runs, { pr, sha }) {
|
||||
run.event === "pull_request" &&
|
||||
run.head_sha === pr.head.sha &&
|
||||
run.run_attempt === 1 &&
|
||||
run.pull_requests.some((p) => samePull(p, pr)) &&
|
||||
run.pull_requests.some((p) => samePull(p, pr, base)) &&
|
||||
refs?.length &&
|
||||
refs.every(
|
||||
(ref) => ref.sha === sha && ref.ref === `refs/pull/${pr.number}/merge`,
|
||||
@@ -97,7 +107,10 @@ function sourceCandidate(runs, { pr, sha }) {
|
||||
return "full";
|
||||
if (runs.some((r) => r.status !== "completed")) return "pending";
|
||||
if (runs.every(successful)) return first;
|
||||
if (runs.every((r) => r.conclusion === "failure")) return "failed";
|
||||
if (runs.every((r) => r.conclusion === "failure")) {
|
||||
console.log(`Failed source CI: ${first.html_url}/attempts/1`);
|
||||
return "failed";
|
||||
}
|
||||
return "full";
|
||||
}
|
||||
|
||||
@@ -142,8 +155,7 @@ async function verifyHistory(input, wait) {
|
||||
}
|
||||
|
||||
export async function verifyEdit(input, wait) {
|
||||
const { pr, sha, api } = input;
|
||||
await confirmTarget(pr, sha, api);
|
||||
await confirmTarget(input);
|
||||
let result;
|
||||
try {
|
||||
result = await verifyHistory(input, wait);
|
||||
@@ -154,7 +166,7 @@ export async function verifyEdit(input, wait) {
|
||||
result = "full";
|
||||
}
|
||||
// A history failure can select full CI only while the originating PR target is still current.
|
||||
await confirmTarget(pr, sha, api);
|
||||
await confirmTarget(input);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -165,7 +177,7 @@ export async function confirmEdit(input, expectedId, classifierAttempt) {
|
||||
throw new Error(
|
||||
"The selected source qualification changed before the CI gate finished.",
|
||||
);
|
||||
await confirmTarget(input.pr, input.sha, input.api);
|
||||
await confirmTarget(input);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -177,7 +189,6 @@ if (
|
||||
readFileSync(env.GITHUB_EVENT_PATH, "utf8"),
|
||||
);
|
||||
const sha = env.GITHUB_SHA;
|
||||
checkCheckout(pr, sha);
|
||||
function api(path) {
|
||||
const endpoint = `repos/${env.GITHUB_REPOSITORY}/${path}`;
|
||||
return JSON.parse(execFileSync("gh", ["api", endpoint], utf8));
|
||||
@@ -185,6 +196,7 @@ if (
|
||||
const input = {
|
||||
pr,
|
||||
sha,
|
||||
base: checkoutBase(pr, sha),
|
||||
runId: Number(env.GITHUB_RUN_ID),
|
||||
runAttempt: Number(env.GITHUB_RUN_ATTEMPT),
|
||||
api,
|
||||
|
||||
@@ -59,9 +59,6 @@ jobs:
|
||||
with:
|
||||
node-version: "24"
|
||||
package-manager-cache: false
|
||||
- &set-up-the-ubuntu-sandbox
|
||||
name: Set up the Ubuntu sandbox
|
||||
run: bash scripts/setup-ubuntu-sandbox.sh
|
||||
- run: npm ci --ignore-scripts --no-audit --no-fund
|
||||
- run: npm run validate
|
||||
- name: Set up Bun for Action release contracts
|
||||
@@ -73,13 +70,13 @@ 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: Packaged Linux sandbox and configuration smoke test (no model calls)
|
||||
run: node scripts/linux-smoke.mjs
|
||||
- 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)
|
||||
run: npm run test:cli
|
||||
- name: Packaged Linux configuration smoke test (no model calls)
|
||||
run: node scripts/linux-smoke.mjs
|
||||
- name: Save generated release metadata
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
@@ -102,11 +99,10 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
# Run setup from the merge commit, then test the Action at its PR head.
|
||||
# Test the Action at its PR head.
|
||||
fetch-depth: 2
|
||||
persist-credentials: false
|
||||
- *actions-setup-node
|
||||
- *set-up-the-ubuntu-sandbox
|
||||
- name: Check out the PR head for the Action smoke tests
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
name: Clean merged PR caches
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches: [main]
|
||||
types: [closed]
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
clean:
|
||||
if: github.event.pull_request.merged
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: write
|
||||
steps:
|
||||
- name: Delete caches for this PR's merge ref
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: gh cache delete --all --ref "refs/pull/$PR_NUMBER/merge" --succeed-on-no-caches --repo "$GITHUB_REPOSITORY"
|
||||
@@ -0,0 +1,480 @@
|
||||
name: container-publish
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release-sha:
|
||||
required: true
|
||||
type: string
|
||||
release-version:
|
||||
required: true
|
||||
type: string
|
||||
combined-approval:
|
||||
required: true
|
||||
type: boolean
|
||||
refresh-wolfi-recipe:
|
||||
type: boolean
|
||||
default: false
|
||||
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 }}
|
||||
recipe-sha: ${{ inputs.refresh-wolfi-recipe && github.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:
|
||||
recipe-sha: ${{ needs.source.outputs.recipe-sha }}
|
||||
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 }}
|
||||
|
||||
preflight:
|
||||
name: Verify container publication prerequisites
|
||||
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
|
||||
outputs:
|
||||
npm-approved: ${{ steps.preflight.outputs.npm-approved }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
steps:
|
||||
- &require-public-registry
|
||||
name: Require a public registry before uploading either image
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: gh api "orgs/${GITHUB_REPOSITORY_OWNER,,}/packages/container/codex-security" | jq -e '.visibility == "public"'
|
||||
- name: Check whether npm approval covers the image inputs
|
||||
id: preflight
|
||||
shell: bash
|
||||
env:
|
||||
COMBINED_APPROVAL: ${{ inputs.combined-approval }}
|
||||
PUBLISH_WOLFI: ${{ needs.source.outputs.wolfi == 'true' && needs.wolfi.outputs.existing != 'true' }}
|
||||
RECIPE_SHA: ${{ needs.source.outputs.recipe-sha }}
|
||||
RELEASE_SHA: ${{ needs.source.outputs.sha }}
|
||||
run: |
|
||||
if [[ $COMBINED_APPROVAL == true && ( $PUBLISH_WOLFI == false || $RECIPE_SHA == "$RELEASE_SHA" ) ]]; then
|
||||
echo 'npm-approved=true' >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
authorize:
|
||||
name: authorize-container-publication
|
||||
needs: preflight
|
||||
if: >-
|
||||
!cancelled() && needs.preflight.result == 'success' &&
|
||||
needs.preflight.outputs.npm-approved != 'true'
|
||||
runs-on: ubuntu-24.04
|
||||
environment: container
|
||||
permissions:
|
||||
packages: read
|
||||
steps:
|
||||
# A backfill can wait for review after the initial registry check.
|
||||
- *require-public-registry
|
||||
|
||||
manifest:
|
||||
name: publish-and-verify-multiarchitecture-candidate
|
||||
needs: [source, debian, preflight, authorize]
|
||||
if: >-
|
||||
!cancelled() && needs.preflight.result == 'success' &&
|
||||
(needs.preflight.outputs.npm-approved == 'true' || 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@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.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, preflight, authorize, attest, wolfi]
|
||||
if: >-
|
||||
!cancelled() && needs.preflight.result == 'success' &&
|
||||
(needs.preflight.outputs.npm-approved == 'true' || 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, preflight, authorize, debian, attest, wolfi, publish-wolfi]
|
||||
if: >-
|
||||
!cancelled() && needs.preflight.result == 'success' &&
|
||||
(needs.preflight.outputs.npm-approved == 'true' || 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"
|
||||
@@ -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
|
||||
test "$GITHUB_REF" = "refs/tags/container-v$version"
|
||||
fi
|
||||
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"
|
||||
|
||||
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
|
||||
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:
|
||||
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"
|
||||
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
|
||||
|
||||
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
|
||||
- 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
|
||||
|
||||
@@ -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: |
|
||||
@@ -73,23 +107,60 @@ jobs:
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||
with:
|
||||
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
|
||||
@@ -98,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 ]]
|
||||
@@ -209,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
|
||||
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
- *set-up-node-js
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Restore CLI package download cache
|
||||
|
||||
@@ -11,6 +11,10 @@ on:
|
||||
description: Reuse this week's verified payload when all native build and proof inputs match.
|
||||
type: boolean
|
||||
default: false
|
||||
cache-week:
|
||||
description: UTC ISO year and week selected by the source CI classifier; zero uses the current week.
|
||||
type: number
|
||||
default: 0
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -30,29 +34,10 @@ jobs:
|
||||
persist-credentials: false
|
||||
- name: Identify native build and proof inputs
|
||||
id: key
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Include filenames and modes, not only file contents. Windows proofs
|
||||
# bundle MCP helpers, including their schema and workbench dependencies.
|
||||
empty_tree="$(git hash-object -t tree --stdin </dev/null)"
|
||||
source_hash="$(git diff-tree -r -z --no-abbrev "$empty_tree" HEAD -- \
|
||||
.gitattributes .cargo .npmrc .pnpmfile.cjs package.json pnpm-workspace.yaml \
|
||||
.github/actions/setup-tools .github/scripts ':(exclude).github/scripts/invoice-desk-*.mjs' \
|
||||
.github/workflows/native-artifacts.yml \
|
||||
.github/workflows/native-unix.yml \
|
||||
.github/workflows/native-windows.yml \
|
||||
.github/workflows/native-musl.yml \
|
||||
sdk/typescript/.npmrc sdk/typescript/.pnpmfile.cjs \
|
||||
sdk/typescript/package.json sdk/typescript/pnpm-lock.yaml \
|
||||
sdk/typescript/pnpm-workspace.yaml \
|
||||
sdk/typescript/tsconfig.json sdk/typescript/tsconfig.ci.json \
|
||||
plugins/codex-security/native plugins/codex-security/mcp-app \
|
||||
':(exclude)plugins/codex-security/mcp-app/tests' \
|
||||
plugins/codex-security/schemas plugins/codex-security/scripts \
|
||||
plugins/codex-security/shared | git hash-object --stdin)"
|
||||
# Hosted runner images can change without a source change.
|
||||
printf 'key=native-universal-v1-%s-%s\n' "$(date -u +%G-%V)" "$source_hash" >> "$GITHUB_OUTPUT"
|
||||
# Resolve the helper from this workflow even when the caller selects an older checkout.
|
||||
uses: $/.github/actions/native-cache-key
|
||||
env:
|
||||
NATIVE_CACHE_WEEK: ${{ inputs.cache-week }}
|
||||
- name: Restore verified native payload
|
||||
if: inputs.reuse-verified
|
||||
id: restore
|
||||
@@ -64,7 +49,7 @@ jobs:
|
||||
- name: Upload reused native payload for this commit
|
||||
if: steps.restore.outputs.cache-hit == 'true'
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
with: &upload-universal-native
|
||||
name: native-universal-${{ inputs.ref || github.sha }}
|
||||
path: native/
|
||||
if-no-files-found: error
|
||||
@@ -90,42 +75,30 @@ jobs:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
bundle:
|
||||
needs: [prepare, unix, windows, musl]
|
||||
if: ${{ !cancelled() }}
|
||||
if: ${{ !cancelled() && (needs.prepare.result != 'success' || needs.prepare.outputs.cache-hit != 'true') }}
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Require a verified native payload
|
||||
- name: Require every native build to pass
|
||||
shell: bash
|
||||
env:
|
||||
PREPARE_RESULT: ${{ needs.prepare.result }}
|
||||
CACHE_HIT: ${{ needs.prepare.outputs.cache-hit }}
|
||||
UNIX_RESULT: ${{ needs.unix.result }}
|
||||
WINDOWS_RESULT: ${{ needs.windows.result }}
|
||||
MUSL_RESULT: ${{ needs.musl.result }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
[[ "$PREPARE_RESULT" == success ]] || exit 1
|
||||
if [[ "$CACHE_HIT" != true ]]; then
|
||||
[[ "$UNIX_RESULT" == success && "$WINDOWS_RESULT" == success && "$MUSL_RESULT" == success ]] || exit 1
|
||||
fi
|
||||
[[ "$PREPARE_RESULT" == success && "$UNIX_RESULT" == success &&
|
||||
"$WINDOWS_RESULT" == success && "$MUSL_RESULT" == success ]]
|
||||
- name: Download verified platform payloads
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: native-platform-*-${{ inputs.ref || github.sha }}
|
||||
merge-multiple: true
|
||||
path: native
|
||||
- name: Upload universal native payload
|
||||
if: needs.prepare.outputs.cache-hit != 'true'
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: native-universal-${{ inputs.ref || github.sha }}
|
||||
path: native/
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
retention-days: 7
|
||||
with: *upload-universal-native
|
||||
- name: Save verified native payload from main
|
||||
if: >-
|
||||
needs.prepare.outputs.cache-hit != 'true' &&
|
||||
github.ref == 'refs/heads/main' &&
|
||||
(github.event_name == 'push' || github.event_name == 'schedule') &&
|
||||
(inputs.ref == '' || inputs.ref == github.sha)
|
||||
|
||||
@@ -69,6 +69,7 @@ jobs:
|
||||
- name: Check Rust source and fetch locked dependencies
|
||||
run: |
|
||||
cargo fmt --check
|
||||
cargo test --locked --lib
|
||||
cargo clippy --locked -- -D warnings
|
||||
cargo fetch --locked
|
||||
- name: Prepare shared native notices
|
||||
|
||||
@@ -29,17 +29,19 @@ jobs:
|
||||
actions: read
|
||||
pull-requests: read
|
||||
outputs:
|
||||
native-cache-group: ${{ steps.native-cache.outputs.cold-group }}
|
||||
native-cache-week: ${{ steps.native-cache.outputs.week }}
|
||||
source-run: ${{ steps.proof.outputs.source-run }}
|
||||
edit-attempt: ${{ steps.proof.outputs.edit-attempt }}
|
||||
source-required: ${{ steps.scope.outputs.source-required }}
|
||||
container-required: ${{ steps.scope.outputs.container-required }}
|
||||
plugin-tests-required: ${{ steps.scope.outputs.plugin-tests-required }}
|
||||
package-required: ${{ steps.scope.outputs.package-required }}
|
||||
action-ci: ${{ steps.scope.outputs.action-ci }}
|
||||
eval-contracts: ${{ steps.scope.outputs.eval-contracts }}
|
||||
container-validate: ${{ steps.scope.outputs.container-validate }}
|
||||
workflow-quality: ${{ steps.scope.outputs.workflow-quality }}
|
||||
compatibility-matrix: ${{ steps.scope.outputs.compatibility-matrix }}
|
||||
python-matrix: ${{ steps.scope.outputs.python-matrix }}
|
||||
windows-node-matrix: ${{ steps.scope.outputs.windows-node-matrix }}
|
||||
steps:
|
||||
- name: Checkout repository for change classification
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
@@ -60,6 +62,14 @@ jobs:
|
||||
BASE_CHANGED: ${{ github.event.action == 'edited' }}
|
||||
run: node .github/scripts/select-ci-checks.mjs
|
||||
|
||||
- name: Group protected pushes waiting for the same native cache
|
||||
id: native-cache
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.ref_protected && github.run_attempt == 1
|
||||
continue-on-error: true
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: bash .github/actions/native-cache-key/key.sh cold-group >> "$GITHUB_OUTPUT"
|
||||
|
||||
workflow-quality:
|
||||
needs: classify-changes
|
||||
if: needs.classify-changes.outputs.workflow-quality == 'true'
|
||||
@@ -104,8 +114,8 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: node --experimental-strip-types sdk/typescript/scripts/check-devcontainer-cooldown.mts
|
||||
- name: Test CI selection and result gating
|
||||
run: node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs
|
||||
- name: Test CI selection, result gating and the release guide
|
||||
run: node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs .github/scripts/test-release-guide.mjs
|
||||
- name: Typecheck
|
||||
run: pnpm --dir sdk/typescript run types
|
||||
- name: Check formatting
|
||||
@@ -118,13 +128,18 @@ jobs:
|
||||
native:
|
||||
if: needs.classify-changes.outputs.package-required == 'true'
|
||||
needs: classify-changes
|
||||
# Hits and PRs keep a unique group. Every entrant restores or rebuilds on its own commit.
|
||||
concurrency:
|
||||
group: native-producer-${{ github.run_attempt == 1 && needs.classify-changes.outputs.native-cache-group || github.run_id }}
|
||||
queue: max
|
||||
uses: ./.github/workflows/native-artifacts.yml
|
||||
with:
|
||||
reuse-verified: true
|
||||
cache-week: ${{ fromJSON(github.run_attempt == 1 && needs.classify-changes.outputs.native-cache-week || '0') }}
|
||||
|
||||
container-validate:
|
||||
needs: [classify-changes, native, static-checks]
|
||||
if: needs.classify-changes.outputs.container-validate == 'true'
|
||||
if: needs.classify-changes.outputs.container-required == 'true'
|
||||
uses: ./.github/workflows/container-validate.yml
|
||||
|
||||
package:
|
||||
@@ -161,9 +176,13 @@ jobs:
|
||||
retention-days: 7
|
||||
|
||||
test:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
if: &run-sdk-shards >-
|
||||
${{ !cancelled() && needs.package.result == 'success' &&
|
||||
needs['classify-changes'].outputs['source-required'] == 'true' &&
|
||||
(github.event_name != 'pull_request' || github.event.action == 'edited' ||
|
||||
needs['static-checks'].result == 'success') }}
|
||||
name: tests / ${{ matrix.os }} / shard-${{ matrix.shard }}
|
||||
needs: [classify-changes, package]
|
||||
needs: &sdk-shard-needs [classify-changes, package, static-checks]
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
@@ -192,6 +211,7 @@ jobs:
|
||||
run: |
|
||||
tar -xzf dist/*.tgz --strip-components=1 -C sdk/typescript package/_bundled_plugin
|
||||
cp -R sdk/typescript/_bundled_plugin/mcp/native/. plugins/codex-security/native/prebuilt
|
||||
python3 -I -m compileall -q --invalidation-mode checked-hash sdk/typescript/_bundled_plugin/scripts
|
||||
- name: Install ripgrep
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: .github/scripts/install-ripgrep.sh
|
||||
@@ -202,6 +222,7 @@ jobs:
|
||||
TMP: ${{ runner.temp }}
|
||||
TMPDIR: ${{ runner.temp }}
|
||||
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false"
|
||||
CODEX_SECURITY_TEST_MCP_WORKERS_SEPARATE: ${{ needs.classify-changes.outputs.plugin-tests-required }}
|
||||
run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ matrix.shard }}/6 --seed=${{ github.run_number }} ${{ matrix.os == 'ubuntu-latest' && '--coverage --coverage-reporter=text --coverage-reporter=lcov' || '' }}
|
||||
- name: Upload test reports
|
||||
if: always()
|
||||
@@ -228,16 +249,19 @@ jobs:
|
||||
matrix: ${{ fromJSON(needs.classify-changes.outputs.compatibility-matrix) }}
|
||||
steps:
|
||||
- *checkout-repository
|
||||
- &set-up-node-js
|
||||
name: Set up Node.js
|
||||
- name: Set up Python on Windows
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Set up Node.js
|
||||
id: node
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
cache: npm
|
||||
cache-dependency-path: sdk/typescript/pnpm-lock.yaml
|
||||
- &resolve-npm-cache
|
||||
name: Resolve npm download cache
|
||||
- name: Resolve npm download cache
|
||||
id: npm-cache
|
||||
if: steps.node.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
@@ -246,8 +270,7 @@ jobs:
|
||||
run: |
|
||||
echo "path=$(npm config get cache)" >> "$GITHUB_OUTPUT"
|
||||
echo "restore-prefix=${PRIMARY_CACHE_KEY%-*}-" >> "$GITHUB_OUTPUT"
|
||||
- &restore-npm-cache
|
||||
name: Restore previous npm downloads
|
||||
- name: Restore previous npm downloads
|
||||
if: steps.node.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
|
||||
with:
|
||||
@@ -257,8 +280,9 @@ jobs:
|
||||
- *download-package-for-this-commit
|
||||
- name: Inspect installed package
|
||||
working-directory: sdk/typescript
|
||||
env: &package-deep-retry
|
||||
# On PRs, exercise the real retry delay on each OS's floor or only runtime.
|
||||
shell: bash
|
||||
env:
|
||||
# A successful main push can be tagged for release. Only PRs sample retries by runtime.
|
||||
PACKAGE_DEEP_RETRY: ${{ github.event_name != 'pull_request' || matrix.node == '22.13.0' || strategy.job-total == 1 }}
|
||||
run: node scripts/check-package.mjs ../../dist/*.tgz
|
||||
|
||||
@@ -267,7 +291,7 @@ jobs:
|
||||
uses: ./.github/actions/check-action-candidate
|
||||
|
||||
mcp:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
if: needs.classify-changes.outputs.plugin-tests-required == 'true'
|
||||
name: MCP app tests (${{ matrix.shard }}/${{ strategy.job-total }})
|
||||
needs: [classify-changes, package]
|
||||
runs-on: ubuntu-latest
|
||||
@@ -292,11 +316,9 @@ jobs:
|
||||
run: tar -xzf dist/*.tgz --strip-components=1 -C sdk/typescript package/_bundled_plugin
|
||||
- name: Test MCP app
|
||||
working-directory: plugins/codex-security/mcp-app
|
||||
# Keep Node options before the glob; trailing shard flags run every file.
|
||||
run: >-
|
||||
node --experimental-strip-types --test --test-concurrency=2
|
||||
--test-shard=${{ matrix.shard }}/${{ strategy.job-total }}
|
||||
--test-reporter=./scripts/test_reporter.mts "tests/test_*.ts" "tests/test_*.mjs"
|
||||
node --experimental-strip-types ../../../sdk/typescript/scripts/run-mcp-test-shard.mts
|
||||
${{ matrix.shard }} ${{ strategy.job-total }}
|
||||
- name: Upload MCP test reports
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
@@ -309,7 +331,7 @@ jobs:
|
||||
retention-days: 14
|
||||
|
||||
plugin-host:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
if: needs.classify-changes.outputs.plugin-tests-required == 'true'
|
||||
name: standalone plugin / ${{ matrix.os }}
|
||||
needs: classify-changes
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -334,7 +356,7 @@ jobs:
|
||||
run: node --experimental-strip-types --test plugins/codex-security/mcp-app/scripts/test_host_build.mts
|
||||
|
||||
plugin-source:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
if: needs.classify-changes.outputs.plugin-tests-required == 'true'
|
||||
name: plugin source contracts / ${{ matrix.os }} / python-${{ matrix.python }}
|
||||
needs: classify-changes
|
||||
runs-on: ${{ matrix.os }}
|
||||
@@ -344,16 +366,10 @@ jobs:
|
||||
matrix: ${{ fromJSON(needs.classify-changes.outputs.python-matrix) }}
|
||||
steps:
|
||||
- *checkout-repository
|
||||
- name: Set up Node.js
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "22.13.0"
|
||||
- name: Set up pnpm
|
||||
- name: Set up TypeScript tools
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
|
||||
uses: ./.github/actions/setup-tools
|
||||
with:
|
||||
setup-node: false
|
||||
compile: true
|
||||
cache-dependency-path: |
|
||||
sdk/typescript/pnpm-lock.yaml
|
||||
@@ -362,7 +378,7 @@ jobs:
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
|
||||
run: pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
cache: pip
|
||||
@@ -424,25 +440,19 @@ jobs:
|
||||
- *set-up-bun
|
||||
- name: Check the Codex version across the SDK, MCP app and evals
|
||||
run: bun test sdk/typescript/tests-ts/codex-dependency-pins.test.ts
|
||||
- uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
with:
|
||||
package_json_file: package.json
|
||||
- name: Set up eval Node.js and pnpm cache
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
- name: Set up eval tools
|
||||
uses: ./.github/actions/setup-tools
|
||||
with:
|
||||
node-version: "24.15.0"
|
||||
cache: pnpm
|
||||
cache-dependency-path: |
|
||||
sdk/typescript/pnpm-lock.yaml
|
||||
plugins/codex-security/mcp-app/pnpm-lock.yaml
|
||||
evals/triage-finding/pnpm-lock.yaml
|
||||
- &set-up-python
|
||||
name: Set up Python
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Install ripgrep
|
||||
run: .github/scripts/install-ripgrep.sh
|
||||
- name: Set up eval dependencies and host runtime
|
||||
run: |
|
||||
pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
@@ -479,9 +489,8 @@ jobs:
|
||||
container-validate,
|
||||
workflow-quality,
|
||||
windows-test,
|
||||
windows-verify,
|
||||
]
|
||||
if: &source-aggregate always()
|
||||
if: always()
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -501,33 +510,10 @@ jobs:
|
||||
CLASSIFIER_ATTEMPT: ${{ needs.classify-changes.outputs.edit-attempt }}
|
||||
run: node .github/scripts/verify-pr-source.mjs confirm-target
|
||||
|
||||
# Retain required names until the repository ruleset has migrated to `ci`.
|
||||
required-test:
|
||||
name: ${{ matrix.os }} / node-22
|
||||
needs: [classify-changes, ci]
|
||||
if: *source-aggregate
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
steps:
|
||||
- name: Require CI gate
|
||||
if: needs.ci.result != 'success'
|
||||
run: exit 1
|
||||
- name: Require the edit classifier from this attempt
|
||||
if: >-
|
||||
github.event_name == 'pull_request' && github.event.action == 'edited' &&
|
||||
github.event.changes.base == null &&
|
||||
needs['classify-changes'].outputs['edit-attempt'] != github.run_attempt
|
||||
run: |
|
||||
echo 'Re-run all jobs to qualify this pull request edit.'
|
||||
exit 1
|
||||
|
||||
windows-test:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
if: *run-sdk-shards
|
||||
name: windows-latest / node-22 / tests-${{ matrix.shard }}
|
||||
needs: [classify-changes, package]
|
||||
needs: *sdk-shard-needs
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 40
|
||||
strategy:
|
||||
@@ -578,25 +564,3 @@ jobs:
|
||||
TMPDIR: ${{ steps.windows-temp.outputs.path }}
|
||||
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "true"
|
||||
run: bun test --timeout 360000 ./tests-ts/windows-machine-policy.test.ts
|
||||
|
||||
windows-verify:
|
||||
if: needs.classify-changes.outputs.source-required == 'true'
|
||||
name: windows-latest / node-${{ matrix.node == '22.13.0' && '22' || matrix.node }} / verify
|
||||
needs: [classify-changes, package]
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJSON(needs.classify-changes.outputs.windows-node-matrix) }}
|
||||
steps:
|
||||
- *checkout-repository
|
||||
- *set-up-python
|
||||
- *set-up-node-js
|
||||
- *resolve-npm-cache
|
||||
- *restore-npm-cache
|
||||
- *download-package-for-this-commit
|
||||
- name: Inspect installed package
|
||||
working-directory: sdk/typescript
|
||||
shell: bash
|
||||
env: *package-deep-retry
|
||||
run: node scripts/check-package.mjs ../../dist/*.tgz
|
||||
|
||||
@@ -12,6 +12,10 @@ on:
|
||||
description: Successful node-release run to use for backfill
|
||||
required: false
|
||||
type: string
|
||||
refresh-wolfi-recipe:
|
||||
description: Use the current main Wolfi recipe when building a missing image.
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -34,8 +38,11 @@ jobs:
|
||||
version: ${{ steps.release.outputs.version }}
|
||||
sha: ${{ steps.release.outputs.sha }}
|
||||
integrity: ${{ steps.artifact.outputs.integrity }}
|
||||
combined-approval: ${{ steps.artifact.outputs.combined-approval }}
|
||||
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
|
||||
@@ -56,29 +63,16 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
npm_tools="$RUNNER_TEMP/codex-security-provenance-npm"
|
||||
npm install \
|
||||
--prefix "$npm_tools" \
|
||||
--ignore-scripts \
|
||||
--no-audit \
|
||||
--no-fund \
|
||||
--registry=https://openai.firewall.socket.dev/npm/ \
|
||||
npm@11.12.1
|
||||
source .github/scripts/release-npm.sh
|
||||
install_release_npm
|
||||
printf '%s\n' "$release_npm_bin" >> "$GITHUB_PATH"
|
||||
|
||||
if [[ "$("$npm_tools/node_modules/.bin/npm" --version)" != "11.12.1" ]]; then
|
||||
echo "npm 11.12.1 is required to verify Sigstore attestations." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$npm_tools/node_modules/.bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Verify bundled provenance-capable npm
|
||||
- name: Verify npm on PATH
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [[ "$(npm --version)" != "11.12.1" ]]; then
|
||||
echo "npm 11.12.1 is required to verify Sigstore attestations." >&2
|
||||
exit 1
|
||||
fi
|
||||
source .github/scripts/release-npm.sh
|
||||
verify_release_npm "$(command -v npm)"
|
||||
|
||||
- name: Resolve the successful protected release
|
||||
id: release
|
||||
@@ -158,11 +152,12 @@ jobs:
|
||||
for ((attempt = 1; attempt <= 30; attempt++)); do
|
||||
run_fields="$(
|
||||
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$release_run" \
|
||||
--jq '[.name, .status, (.conclusion // "pending"), .head_sha, .head_branch] | @tsv'
|
||||
--jq '[.path, .event, .status, (.conclusion // "pending"), .head_sha, .head_branch] | @tsv'
|
||||
)"
|
||||
IFS=$'\t' read -r run_name run_status run_conclusion run_sha run_tag <<< "$run_fields"
|
||||
IFS=$'\t' read -r run_path run_event run_status run_conclusion run_sha run_tag <<< "$run_fields"
|
||||
|
||||
if [[ "$run_name" != "node-release" ||
|
||||
if [[ "${run_path%%@*}" != ".github/workflows/node-release.yml" ||
|
||||
( "$run_event" != push && "$run_event" != workflow_dispatch ) ||
|
||||
"$run_sha" != "$release_sha" ||
|
||||
"$run_tag" != "$release_tag" ]]; then
|
||||
echo "The release run must successfully publish the exact tagged commit." >&2
|
||||
@@ -303,12 +298,11 @@ jobs:
|
||||
echo "Verified npm provenance for the resolved release run."
|
||||
else
|
||||
recovery_conclusion="$(
|
||||
gh api \
|
||||
"repos/$GITHUB_REPOSITORY/actions/runs/$RELEASE_RUN_ID/jobs?per_page=100" \
|
||||
--paginate \
|
||||
--jq '.jobs[] | select(.name == "publish") | .steps[] | select(.name == "Verify recovered npm release provenance") | .conclusion'
|
||||
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RELEASE_RUN_ID/jobs?per_page=100" --paginate \
|
||||
--jq '.jobs[] | select(.conclusion == "success" and (.name == "publish" or .name == "Verify existing npm release"))
|
||||
| .steps[] | select(.name == "Verify recovered npm release provenance") | .conclusion'
|
||||
)"
|
||||
if [[ "$recovery_conclusion" != "success" ]]; then
|
||||
if [[ "$recovery_conclusion" != success ]]; then
|
||||
echo "Signed npm provenance must identify the resolved successful release run." >&2
|
||||
exit 1
|
||||
fi
|
||||
@@ -336,10 +330,10 @@ jobs:
|
||||
original_run_fields="$(
|
||||
gh api \
|
||||
"repos/$GITHUB_REPOSITORY/actions/runs/$original_run_id" \
|
||||
--jq '[.name, .status, .head_sha, .head_branch] | @tsv'
|
||||
--jq '[.path, .status, .head_sha, .head_branch] | @tsv'
|
||||
)"
|
||||
IFS=$'\t' read -r original_name original_status original_sha original_tag <<< "$original_run_fields"
|
||||
if [[ "$original_name" != "node-release" ||
|
||||
IFS=$'\t' read -r original_path original_status original_sha original_tag <<< "$original_run_fields"
|
||||
if [[ "${original_path%%@*}" != ".github/workflows/node-release.yml" ||
|
||||
"$original_status" != "completed" ||
|
||||
"$original_sha" != "$RELEASE_SHA" ||
|
||||
"$original_tag" != "$RELEASE_TAG" ]]; then
|
||||
@@ -364,6 +358,15 @@ jobs:
|
||||
|
||||
printf 'archive=%s\n' "$archive" >> "$GITHUB_OUTPUT"
|
||||
printf 'integrity=%s\n' "$(jq -r '."dist.integrity" // .dist.integrity' <<< "$metadata")" >> "$GITHUB_OUTPUT"
|
||||
# Only the attempt identified by signed npm provenance can authorize
|
||||
# images. If its job record is unavailable, request container review.
|
||||
signing_attempt=$(jq -er '.runAttempt' <<< "$verified_provenance")
|
||||
if combined_publisher="$(
|
||||
gh api "repos/$GITHUB_REPOSITORY/actions/runs/$verified_run_id/attempts/$signing_attempt/jobs?per_page=100" --paginate \
|
||||
--jq '.jobs[] | select(.name == "Publish npm and container images") | .conclusion'
|
||||
)" && [[ "$combined_publisher" == success ]]; then
|
||||
echo 'combined-approval=true' >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Detect Action release source
|
||||
id: action
|
||||
@@ -385,10 +388,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
|
||||
@@ -728,18 +744,26 @@ 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:
|
||||
combined-approval: ${{ needs.release.outputs.combined-approval == 'true' }}
|
||||
refresh-wolfi-recipe: ${{ inputs.refresh-wolfi-recipe }}
|
||||
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
|
||||
@@ -753,11 +777,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'
|
||||
@@ -766,7 +794,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"
|
||||
@@ -785,3 +834,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
|
||||
|
||||
@@ -10,12 +10,22 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: node-release-cut
|
||||
queue: max
|
||||
|
||||
jobs:
|
||||
progress:
|
||||
if: >-
|
||||
github.repository == 'openai/codex-security' &&
|
||||
github.event_name == 'workflow_run' &&
|
||||
github.event.workflow_run.event == 'push'
|
||||
uses: ./.github/workflows/release-progress.yml
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
cut:
|
||||
concurrency:
|
||||
group: node-release-cut
|
||||
queue: max
|
||||
if: >-
|
||||
github.repository == 'openai/codex-security' &&
|
||||
(github.event_name == 'workflow_dispatch' ||
|
||||
@@ -35,6 +45,9 @@ jobs:
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
.github
|
||||
sdk/typescript/scripts
|
||||
persist-credentials: false
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
@@ -89,47 +102,45 @@ jobs:
|
||||
fi
|
||||
|
||||
if [[ "$GITHUB_EVENT_NAME" == "workflow_run" ]] &&
|
||||
previous_sha="$(git rev-parse "$RELEASE_SHA^" 2>/dev/null)"; then
|
||||
if previous_manifest="$(git show "$previous_sha:sdk/typescript/package.json" 2>/dev/null)"; then
|
||||
previous_version="$(
|
||||
printf '%s\n' "$previous_manifest" |
|
||||
node --input-type=module --eval '
|
||||
import { readFileSync } from "node:fs";
|
||||
const manifest = JSON.parse(readFileSync(0, "utf8"));
|
||||
if (typeof manifest.version !== "string") {
|
||||
throw new Error("The previous package version is missing.");
|
||||
}
|
||||
process.stdout.write(manifest.version);
|
||||
'
|
||||
previous_manifest_oid="$(git rev-parse --verify "$RELEASE_SHA^:sdk/typescript/package.json" 2>/dev/null)"; then
|
||||
previous_version="$(
|
||||
git cat-file blob "$previous_manifest_oid" |
|
||||
node --input-type=module --eval '
|
||||
import { readFileSync } from "node:fs";
|
||||
const manifest = JSON.parse(readFileSync(0, "utf8"));
|
||||
if (typeof manifest.version !== "string") {
|
||||
throw new Error("The previous package version is missing.");
|
||||
}
|
||||
process.stdout.write(manifest.version);
|
||||
'
|
||||
)"
|
||||
if [[ "$version" == "$previous_version" ]]; then
|
||||
release_mode="$(
|
||||
printf '%s\n' "$published_versions" |
|
||||
node sdk/typescript/scripts/release-automation.mjs \
|
||||
release-mode "$version"
|
||||
)"
|
||||
if [[ "$version" == "$previous_version" ]]; then
|
||||
release_mode="$(
|
||||
printf '%s\n' "$published_versions" |
|
||||
node sdk/typescript/scripts/release-automation.mjs \
|
||||
release-mode "$version"
|
||||
if [[ "$release_mode" == "recover" ]]; then
|
||||
echo "Package version is unchanged and already published."
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
if tagged_sha="$(git rev-parse --verify "refs/tags/npm-v$version^{commit}" 2>/dev/null)" &&
|
||||
[[ "$tagged_sha" != "$RELEASE_SHA" ]] &&
|
||||
git merge-base --is-ancestor "$tagged_sha" "$RELEASE_SHA"; then
|
||||
tagged_version="$(
|
||||
git show "$tagged_sha:sdk/typescript/package.json" |
|
||||
node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version'
|
||||
)"
|
||||
if [[ "$release_mode" == "recover" ]]; then
|
||||
echo "Package version is unchanged and already published."
|
||||
if [[ "$tagged_version" == "$version" ]]; then
|
||||
echo "Package version is unchanged and already tagged at $tagged_sha."
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
if tagged_sha="$(git rev-parse --verify "refs/tags/npm-v$version^{commit}" 2>/dev/null)" &&
|
||||
[[ "$tagged_sha" != "$RELEASE_SHA" ]] &&
|
||||
git merge-base --is-ancestor "$tagged_sha" "$RELEASE_SHA"; then
|
||||
tagged_version="$(
|
||||
git show "$tagged_sha:sdk/typescript/package.json" |
|
||||
node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version'
|
||||
)"
|
||||
if [[ "$tagged_version" == "$version" ]]; then
|
||||
echo "Package version is unchanged and already tagged at $tagged_sha."
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
else
|
||||
node sdk/typescript/scripts/release-automation.mjs \
|
||||
require-increase "$version" "$previous_version" >/dev/null
|
||||
fi
|
||||
else
|
||||
node sdk/typescript/scripts/release-automation.mjs \
|
||||
require-increase "$version" "$previous_version" >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ permissions:
|
||||
pull-requests: read
|
||||
|
||||
concurrency:
|
||||
group: node-release-pr
|
||||
# A newer push can replace a pending push without displacing a manual run.
|
||||
group: node-release-pr-${{ github.event_name == 'push' && 'push' || github.run_id }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
@@ -26,6 +27,10 @@ jobs:
|
||||
(github.event_name != 'workflow_dispatch' && vars.RELEASE_PR_ENABLED != 'true'))
|
||||
name: preview release PR
|
||||
runs-on: ubuntu-latest
|
||||
# Keep the writer from changing the release branch while a preview reads it.
|
||||
concurrency: &release-pr-queue
|
||||
group: node-release-pr
|
||||
queue: max
|
||||
env:
|
||||
RELEASE_PR_DRY_RUN: "true"
|
||||
|
||||
@@ -56,6 +61,7 @@ jobs:
|
||||
(github.event_name != 'workflow_dispatch' && vars.RELEASE_PR_ENABLED == 'true'))
|
||||
name: maintain release PR
|
||||
runs-on: ubuntu-latest
|
||||
concurrency: *release-pr-queue
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
@@ -303,7 +303,7 @@ jobs:
|
||||
|
||||
publish:
|
||||
if: github.repository == 'openai/codex-security'
|
||||
name: publish
|
||||
name: ${{ needs.verify.outputs.mode == 'recover' && 'Verify existing npm release' || 'Publish npm and container images' }}
|
||||
needs: [verify, test]
|
||||
runs-on: ubuntu-latest
|
||||
environment: npm
|
||||
@@ -329,42 +329,16 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
npm_tools="$RUNNER_TEMP/codex-security-provenance-npm"
|
||||
npm install \
|
||||
--prefix "$npm_tools" \
|
||||
--ignore-scripts \
|
||||
--no-audit \
|
||||
--no-fund \
|
||||
--registry=https://openai.firewall.socket.dev/npm/ \
|
||||
npm@11.12.1
|
||||
source .github/scripts/release-npm.sh
|
||||
install_release_npm
|
||||
printf '%s\n' "$release_npm_bin" >> "$GITHUB_PATH"
|
||||
|
||||
if [[ "$("$npm_tools/node_modules/.bin/npm" --version)" != "11.12.1" ]]; then
|
||||
echo "npm 11.12.1 is required to verify Sigstore attestations." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$npm_tools/node_modules/.bin" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Verify bundled trusted-publishing npm
|
||||
- name: Verify npm on PATH
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
node --eval '
|
||||
const version = process.argv[1];
|
||||
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
|
||||
const [major, minor, patch] = match?.slice(1).map(Number) ?? [];
|
||||
if (
|
||||
!match ||
|
||||
major < 11 ||
|
||||
(major === 11 && (minor < 5 || (minor === 5 && patch < 1)))
|
||||
) {
|
||||
console.error(
|
||||
"npm 11.5.1 or newer is required for trusted publishing; found " +
|
||||
version +
|
||||
".",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
' "$(npm --version)"
|
||||
source .github/scripts/release-npm.sh
|
||||
verify_release_npm "$(command -v npm)"
|
||||
|
||||
- name: Download verified package
|
||||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
name: Publish Wolfi scanner
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
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: {}
|
||||
|
||||
env:
|
||||
IMAGE: ghcr.io/openai/codex-security
|
||||
|
||||
jobs:
|
||||
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
|
||||
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:
|
||||
- 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: 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
|
||||
concurrency:
|
||||
group: publish-wolfi-amd64
|
||||
queue: max
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
attestations: write
|
||||
id-token: write
|
||||
artifact-metadata: write
|
||||
env:
|
||||
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: ${{ inputs.artifact || needs.os-update.outputs.artifact }}
|
||||
merge-multiple: true
|
||||
path: ${{ runner.temp }}/candidate
|
||||
- name: Check the public package, immutable tag and local artifacts
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
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 -
|
||||
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" |
|
||||
jq -r --arg tag "$TAG" '.[][] | select(any(.metadata.container.tags[]?; . == $tag)) | .name')
|
||||
if [[ -n $existing && $existing != "$DIGEST" ]]; then
|
||||
echo "::error::Refusing to replace $TAG ($existing) with $DIGEST"
|
||||
exit 1
|
||||
fi
|
||||
- uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ github.token }}
|
||||
- name: Upload by digest and verify an anonymous pull
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
skopeo copy --preserve-digests "oci:$RUNNER_TEMP/candidate/layout:wolfi" "docker://$IMAGE@$DIGEST"
|
||||
skopeo copy --src-no-creds --preserve-digests --digestfile "$RUNNER_TEMP/pulled.digest" \
|
||||
"docker://$IMAGE@$DIGEST" "oci:$RUNNER_TEMP/pulled:wolfi"
|
||||
[[ $(cat "$RUNNER_TEMP/pulled.digest") == "$DIGEST" ]]
|
||||
- name: Attest build provenance
|
||||
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
||||
with:
|
||||
subject-name: ${{ env.IMAGE }}
|
||||
subject-digest: ${{ env.DIGEST }}
|
||||
push-to-registry: true
|
||||
- name: Attest the SPDX inventory
|
||||
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
||||
with:
|
||||
subject-name: ${{ env.IMAGE }}
|
||||
subject-digest: ${{ env.DIGEST }}
|
||||
sbom-path: ${{ runner.temp }}/candidate/sbom.spdx.json
|
||||
push-to-registry: true
|
||||
- name: Promote only the verified Wolfi tag
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
for predicate in https://slsa.dev/provenance/v1 https://spdx.dev/Document/v2.3; do
|
||||
gh attestation verify "oci://$IMAGE@$DIGEST" --repo "$GITHUB_REPOSITORY" --predicate-type "$predicate" \
|
||||
--signer-workflow "$GITHUB_REPOSITORY/.github/workflows/publish-wolfi.yml" \
|
||||
--source-ref refs/heads/main --source-digest "$GITHUB_SHA"
|
||||
done
|
||||
skopeo list-tags --no-creds "docker://$IMAGE" > "$RUNNER_TEMP/tags.json"
|
||||
count=$(jq -er --arg tag "$TAG" '[.Tags[] | select(. == $tag)] | length' "$RUNNER_TEMP/tags.json")
|
||||
if [[ $count == 0 ]]; then
|
||||
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" || true
|
||||
@@ -11,7 +11,7 @@ on:
|
||||
schedule:
|
||||
- cron: "43 9 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
inputs: &smoke-inputs
|
||||
version:
|
||||
description: Published npm version to verify, or latest
|
||||
type: string
|
||||
@@ -21,15 +21,7 @@ on:
|
||||
type: string
|
||||
required: false
|
||||
workflow_call:
|
||||
inputs:
|
||||
version:
|
||||
description: Published npm version to verify, or latest
|
||||
type: string
|
||||
default: latest
|
||||
ref:
|
||||
description: Source commit or tag containing the smoke checks
|
||||
type: string
|
||||
required: false
|
||||
inputs: *smoke-inputs
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
name: release-progress
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_run:
|
||||
workflows: ["node-ci", "node-release", "node-github-release"]
|
||||
workflows: ["node-release", "node-github-release"]
|
||||
types: [in_progress, completed]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -20,19 +21,14 @@ permissions: {}
|
||||
concurrency:
|
||||
# Refreshes read the latest upstream state, so only one pending refresh is needed.
|
||||
# Observers must not hold that slot while their upstream run awaits approval.
|
||||
group: release-progress-${{ inputs.run-id || github.event.workflow_run.id }}-${{ (inputs.watch || (github.event.action == 'in_progress' && github.event.workflow_run.name != 'node-ci')) && github.run_id || 'refresh' }}
|
||||
group: release-progress-${{ inputs.run-id || github.event.workflow_run.id }}-${{ (inputs.watch || github.event.action == 'in_progress') && github.run_id || 'refresh' }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
identify:
|
||||
if: >-
|
||||
github.repository == 'openai/codex-security' &&
|
||||
(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main') &&
|
||||
(github.event_name != 'workflow_run' ||
|
||||
github.event.workflow_run.name != 'node-ci' ||
|
||||
(github.event.action == 'completed' &&
|
||||
github.event.workflow_run.event == 'push' &&
|
||||
github.event.workflow_run.head_branch == 'main'))
|
||||
(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main')
|
||||
name: identify release
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
@@ -116,9 +112,7 @@ jobs:
|
||||
if: >-
|
||||
needs.report.outputs.pull != '' &&
|
||||
((github.event_name == 'workflow_dispatch' && inputs.watch) ||
|
||||
(github.event_name == 'workflow_run' &&
|
||||
github.event.action == 'in_progress' &&
|
||||
github.event.workflow_run.name != 'node-ci'))
|
||||
(github.event_name == 'workflow_run' && github.event.action == 'in_progress'))
|
||||
name: observe release milestones
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
|
||||
@@ -30,10 +30,8 @@ env:
|
||||
|
||||
jobs:
|
||||
native:
|
||||
if: ${{ !inputs.native-artifacts-ready }}
|
||||
if: inputs.compare-layouts && !inputs.native-artifacts-ready
|
||||
uses: ./.github/workflows/native-artifacts.yml
|
||||
with:
|
||||
reuse-verified: ${{ !inputs.compare-layouts }}
|
||||
|
||||
runner:
|
||||
needs: native
|
||||
@@ -89,26 +87,21 @@ jobs:
|
||||
- { os: windows-latest, shard: 12, count: 14, mode: expanded }
|
||||
- { os: windows-latest, shard: 13, count: 14, mode: expanded }
|
||||
- { os: windows-latest, shard: 14, count: 14, mode: expanded }
|
||||
steps: &sdk-test-steps
|
||||
steps:
|
||||
- &actions-checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Python
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: "3.12"
|
||||
- name: Prepare native runtime
|
||||
uses: ./.github/actions/download-native
|
||||
- &actions-setup-node
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "22.13.0"
|
||||
- name: Set up pnpm
|
||||
- name: Set up TypeScript tools
|
||||
uses: ./.github/actions/setup-tools
|
||||
with:
|
||||
setup-node: false
|
||||
cache-dependency-path: |
|
||||
sdk/typescript/pnpm-lock.yaml
|
||||
plugins/codex-security/mcp-app/pnpm-lock.yaml
|
||||
@@ -121,7 +114,8 @@ jobs:
|
||||
run: |
|
||||
pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
|
||||
- name: Prepare private Windows test root
|
||||
- &prepare-windows-test-root
|
||||
name: Prepare private Windows test root
|
||||
if: runner.os == 'Windows'
|
||||
id: windows-temp
|
||||
shell: pwsh
|
||||
@@ -132,23 +126,14 @@ jobs:
|
||||
if: runner.os == 'Linux'
|
||||
run: .github/scripts/install-ripgrep.sh
|
||||
- name: Test shard layout
|
||||
if: inputs.compare-layouts
|
||||
working-directory: sdk/typescript
|
||||
env: &test-temp
|
||||
TEMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
TMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
TMPDIR: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
run: node --experimental-strip-types scripts/run-ci-tests.mts ${{ env.SHARD }} ${{ runner.os == 'Linux' && '--coverage --coverage-reporter=lcov' || '' }} --coverage-dir=reports/coverage-${{ env.REPORT_ID }} --seed=${{ env.CODEX_SECURITY_PROPERTY_SEED }} --reporter-outfile=reports/runner-${{ env.REPORT_ID }}.xml
|
||||
- name: Test rotating properties
|
||||
if: ${{ !inputs.compare-layouts }}
|
||||
working-directory: sdk/typescript
|
||||
shell: bash
|
||||
env: *test-temp
|
||||
run: |
|
||||
git grep -lzF 'support/property' -- 'tests-ts/*.test.ts' > "$RUNNER_TEMP/property-tests"
|
||||
mkdir -p reports
|
||||
xargs -0 bun test --timeout="$CODEX_SECURITY_TEST_TIMEOUT_MS" --seed="$CODEX_SECURITY_PROPERTY_SEED" --reporter=junit --reporter-outfile=reports/properties.xml < "$RUNNER_TEMP/property-tests"
|
||||
- name: Upload runner report
|
||||
- &upload-runner-report
|
||||
name: Upload runner report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
@@ -160,8 +145,7 @@ jobs:
|
||||
|
||||
properties:
|
||||
name: ${{ matrix.os }} / rotating properties
|
||||
needs: native
|
||||
if: ${{ !cancelled() && !inputs.compare-layouts && (inputs.native-artifacts-ready || needs.native.result == 'success') }}
|
||||
if: ${{ !inputs.compare-layouts }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
@@ -172,7 +156,27 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
steps: *sdk-test-steps
|
||||
steps:
|
||||
- *actions-checkout
|
||||
- &set-up-sdk-tools
|
||||
name: Set up TypeScript tools
|
||||
uses: ./.github/actions/setup-tools
|
||||
- *set-up-bun
|
||||
- &install-sdk-dependencies
|
||||
name: Install dependencies
|
||||
run: pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
- *prepare-windows-test-root
|
||||
- name: Test rotating properties
|
||||
working-directory: sdk/typescript
|
||||
shell: bash
|
||||
env: *test-temp
|
||||
run: |
|
||||
git grep -lzF 'support/property' -- 'tests-ts/*.test.ts' > "$RUNNER_TEMP/property-tests"
|
||||
mkdir -p reports _bundled_plugin/examples
|
||||
cp -R ../../plugins/codex-security/examples/completed-scan _bundled_plugin/examples/
|
||||
cp -R ../../plugins/codex-security/schemas _bundled_plugin/
|
||||
xargs -0 bun test --timeout="$CODEX_SECURITY_TEST_TIMEOUT_MS" --seed="$CODEX_SECURITY_PROPERTY_SEED" --reporter=junit --reporter-outfile=reports/properties.xml < "$RUNNER_TEMP/property-tests"
|
||||
- *upload-runner-report
|
||||
|
||||
compare:
|
||||
name: Runner inventory and timing
|
||||
@@ -181,13 +185,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- *actions-checkout
|
||||
- *actions-setup-node
|
||||
- &github-actions-setup-tools
|
||||
uses: ./.github/actions/setup-tools
|
||||
with:
|
||||
setup-node: false
|
||||
- name: Install dependencies
|
||||
run: pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
- *set-up-sdk-tools
|
||||
- *install-sdk-dependencies
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: runner-*
|
||||
@@ -202,8 +201,13 @@ jobs:
|
||||
for mode in baseline expanded; do
|
||||
shards=3
|
||||
if [[ "$os" == windows-latest ]]; then shards=7; fi
|
||||
if [[ "$mode" == expanded ]]; then shards=$((shards * 2)); fi
|
||||
reports=(reports/runner-"$os"-"$mode"-*.xml)
|
||||
if [[ "$mode" == expanded ]]; then
|
||||
shards=$((shards * 2))
|
||||
expanded_reports=("${reports[@]}")
|
||||
else
|
||||
baseline_reports=("${reports[@]}")
|
||||
fi
|
||||
if (( ${#reports[@]} != shards )); then
|
||||
echo "Expected $shards reports for $os/$mode, found ${#reports[@]}" >&2
|
||||
comparison_status=1
|
||||
@@ -216,7 +220,7 @@ jobs:
|
||||
fi
|
||||
done
|
||||
done
|
||||
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts "reports/runner-$os-baseline-*.xml" "reports/runner-$os-expanded-*.xml" >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
|
||||
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts "${baseline_reports[@]}" -- "${expanded_reports[@]}" >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
|
||||
done
|
||||
exit "$comparison_status"
|
||||
|
||||
@@ -226,14 +230,12 @@ jobs:
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- *actions-checkout
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
- uses: ./.github/actions/setup-tools
|
||||
with:
|
||||
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
|
||||
node-version: "24.15.0"
|
||||
- *github-actions-setup-tools
|
||||
- *set-up-bun
|
||||
- name: Install dependencies
|
||||
run: pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
- *install-sdk-dependencies
|
||||
- name: Run mutation trial
|
||||
run: pnpm --dir sdk/typescript run test:mutation
|
||||
- name: Upload mutation report
|
||||
|
||||
@@ -0,0 +1,205 @@
|
||||
name: Build Wolfi scanner
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release-version: {type: string, required: true}
|
||||
release-sha: {type: string}
|
||||
recipe-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:
|
||||
ref: ${{ inputs.recipe-sha || github.sha }}
|
||||
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 }}
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Install ShellCheck and zizmor
|
||||
uses: taiki-e/install-action@8cca0918f8471c33515202b73f56ab27f2bed283 # v2.87.29
|
||||
uses: taiki-e/install-action@5488ac5a951645ce95062214902ac4b6bc1a1037 # v2.87.32
|
||||
with:
|
||||
tool: shellcheck@0.11.0,zizmor@1.30.1
|
||||
- name: Install actionlint
|
||||
@@ -38,7 +38,8 @@ jobs:
|
||||
SHELLCHECK_OPTS: --severity=warning
|
||||
run: |
|
||||
actionlint -color
|
||||
shellcheck .github/scripts/install-ripgrep.sh docker/verify-container-compose.sh github-action/scripts/setup-ubuntu-sandbox.sh
|
||||
actionlint -color github-action/examples/*.yml
|
||||
shellcheck .github/scripts/*.sh docker/verify-container-compose.sh github-action/scripts/setup-ubuntu-sandbox.sh
|
||||
- name: Test release progress reporting
|
||||
run: node --test .github/scripts/test_release_progress.mjs
|
||||
- name: Check workflow security
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
rules:
|
||||
dangerous-triggers:
|
||||
ignore:
|
||||
# Deletes only the merged PR's cache ref without checking out any code.
|
||||
- clean-merged-pr-caches.yml:3
|
||||
# Labels only: no checkout or execution of pull request code.
|
||||
- node-release-labels.yml:3
|
||||
# Reads run metadata and comments using helpers checked out from protected main.
|
||||
|
||||
@@ -87,6 +87,12 @@ variables, and defaults as public API.
|
||||
- Update relevant help, schemas, documentation, and tests in the same change.
|
||||
Describe the public CLI change in the pull request.
|
||||
|
||||
## Published documentation
|
||||
|
||||
For changes to how developers use the CLI, SDK, or plugin, update the affected
|
||||
docs and examples in this repository. Maintainers update the [published docs](https://learn.chatgpt.com/docs/security).
|
||||
To suggest a website edit, name the page or workflow and describe the change in your PR.
|
||||
|
||||
## Pull request labels
|
||||
|
||||
- Use existing labels only when they convey release behavior, dependency updates,
|
||||
|
||||
+35
-20
@@ -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,6 +39,39 @@ RUN apt-get update \
|
||||
python3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
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
|
||||
|
||||
RUN groupadd --gid 10001 codex-security \
|
||||
&& useradd --uid 10001 --gid 10001 --no-create-home codex-security \
|
||||
&& mkdir -p /input /output /state \
|
||||
&& chown 10001:10001 /output /state
|
||||
|
||||
ENV CODEX_SECURITY_STATE_DIR=/output/.codex-security-state \
|
||||
GIT_TERMINAL_PROMPT=0 \
|
||||
PYTHON=/usr/bin/python3
|
||||
|
||||
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 \
|
||||
@@ -48,23 +81,5 @@ RUN npm install --global --include=optional --no-audit --no-fund \
|
||||
&& 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
|
||||
|
||||
RUN groupadd --gid 10001 codex-security \
|
||||
&& useradd --uid 10001 --gid 10001 --no-create-home codex-security \
|
||||
&& mkdir -p /input /output /state \
|
||||
&& chown 10001:10001 /output /state
|
||||
|
||||
ENV CODEX_HOME=/state \
|
||||
CODEX_SECURITY_STATE_DIR=/output/.codex-security-state \
|
||||
GIT_TERMINAL_PROMPT=0 \
|
||||
HOME=/state \
|
||||
PYTHON=/usr/bin/python3
|
||||
|
||||
ENV HOME=/state CODEX_HOME=/state
|
||||
USER 10001:10001
|
||||
WORKDIR /state
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/codex-security-entrypoint"]
|
||||
CMD ["--help"]
|
||||
|
||||
@@ -17,8 +17,8 @@ Use its security workflows in Codex, or automate them with the
|
||||
- Draft `SECURITY.md` policies and save threat models for later review.
|
||||
- Browse saved scans and findings, identify duplicates, assess severity against
|
||||
your own rubric, and suggest owners from source and Git history.
|
||||
- Import GitHub code scanning alerts, export SARIF, JSON, or CSV, and publish
|
||||
findings to Linear or a findings service.
|
||||
- Import Semgrep, Snyk, and Wiz findings locally or publish them to Codex Security Cloud. [All scanner import guides](docs/scanner-imports/README.md).
|
||||
- Export SARIF, JSON, or CSV, and publish findings to Linear or a findings service.
|
||||
- Automate scans across repositories or project components, including in CI and
|
||||
containers.
|
||||
|
||||
@@ -188,7 +188,8 @@ cs export --scan SCAN_ID --artifact threat-model --output threatmodel.md
|
||||
|
||||
Omit `--scan` to use the current repository's latest completed scan. The
|
||||
[export guide](sdk/typescript/docs/cli.md#exports-and-ci) also covers findings,
|
||||
SARIF output for CI, and the offline TypeScript API.
|
||||
SARIF output for CI, and the offline TypeScript API. For ServiceNow Application
|
||||
Vulnerability Response, see [Export findings for ServiceNow](sdk/typescript/docs/cli.md#export-findings-for-servicenow).
|
||||
|
||||
## GitHub Actions
|
||||
|
||||
@@ -196,7 +197,8 @@ Run scheduled, manual, or pull request scans with the GitHub Action. For a weekl
|
||||
repository scan, add an OpenAI API key as the repository secret
|
||||
`CODEX_SECURITY_API_KEY`, then save this workflow in
|
||||
`.github/workflows/codex-security.yml`. Replace `REPLACE_WITH_REVIEWED_COMMIT`
|
||||
with the full SHA of an Action commit.
|
||||
with the full SHA of an Action release that includes automatic Ubuntu sandbox setup.
|
||||
For older pins, including `action-v0.6.0`, keep the [manual sandbox setup](https://github.com/openai/codex-security/blob/action-v0.6.0/github-action/README.md#ubuntu-sandbox-setup).
|
||||
|
||||
This workflow requests Daybreak Blue. Use an API key from a project with Blue
|
||||
enabled; without Daybreak access, omit `cyber-access-program` or set it to
|
||||
@@ -216,12 +218,6 @@ jobs:
|
||||
security:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
# Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.
|
||||
- name: Set up the Ubuntu sandbox
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install --yes bubblewrap apparmor-profiles
|
||||
sudo apparmor_parser -r /usr/share/apparmor/extra-profiles/bwrap-userns-restrict
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
@@ -234,6 +230,9 @@ jobs:
|
||||
OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}
|
||||
```
|
||||
|
||||
The Action sets up and verifies the sandbox on GitHub-hosted Ubuntu 24.04 VMs.
|
||||
Self-hosted runners and job containers must provide a working Codex sandbox.
|
||||
|
||||
Findings are report-only by default. Set a severity threshold to fail on reported
|
||||
findings at or above it. Scanner and required reporting errors fail the job;
|
||||
intentional file exclusions and investigation notes do not.
|
||||
@@ -271,6 +270,7 @@ for examples.
|
||||
- [Online documentation](https://learn.chatgpt.com/docs/security/cli)
|
||||
- [Agent workflows and recovery](docs/agent-workflows.md)
|
||||
- [CLI reference](sdk/typescript/docs/cli.md)
|
||||
- [Imported finding identity and evidence](docs/scanner-imports/schema-guide.md)
|
||||
- [Project configuration](docs/project-configuration.md)
|
||||
- [Examples](examples/README.md)
|
||||
|
||||
|
||||
+68
-44
@@ -92,6 +92,8 @@ Review this policy before enabling automation for `1.x`.
|
||||
## Rolling release PRs
|
||||
|
||||
`node-release-pr` runs after pushes to `main` and can be dispatched manually.
|
||||
Newer pushes can replace pending pushes. Manual runs keep their own place.
|
||||
Previews and writes share one queue so a preview sees a consistent proposal.
|
||||
It defaults to a read-only preview. It does not merge, tag, publish, or change
|
||||
the existing publication gates.
|
||||
|
||||
@@ -108,7 +110,8 @@ the latest `main` and appends a commit; the updater never force-pushes.
|
||||
A concurrent commit causes it to reread and
|
||||
retry. It requests Codex review when the proposal files change. Updates that
|
||||
only incorporate `main` keep CI current without repeating the same proposal
|
||||
review. New suggestions for human-owned notes still appear in a comment.
|
||||
review, even when the earlier request names an older commit. New suggestions
|
||||
for human-owned notes still appear in a comment.
|
||||
Before merging the proposal, check CI and request a final Codex review
|
||||
if the last review targets an older head.
|
||||
|
||||
@@ -127,7 +130,10 @@ changes; other workflow content comes from the latest `main`. After the release
|
||||
PR merges, this example can reference the new version before npm publication
|
||||
finishes. Wait for publication before using that pin.
|
||||
|
||||
If a run reports that GitHub has not exposed the updated PR head, manually
|
||||
After updating an existing release branch and its title, the updater waits briefly
|
||||
if GitHub still shows the exact commit it just replaced. A different head or a
|
||||
newer `main` stops that review handoff; the next updater can use the current branches.
|
||||
If GitHub still has not exposed the updated PR head, manually
|
||||
rerun the updater with **dry_run** disabled after the PR catches up. This
|
||||
allows any deferred review request or note suggestions to be posted. Verify
|
||||
review on the current head before merging the proposal.
|
||||
@@ -225,8 +231,11 @@ job with read-only permissions for both scopes.
|
||||
|
||||
Review the resulting PR and select **Approve workflows to run** in its merge
|
||||
box to start hosted CI. GitHub requires this approval for PRs created or updated
|
||||
with `GITHUB_TOKEN`. Check the Codex review on the current head as well, and
|
||||
request it manually if the automated request has not started a review.
|
||||
with `GITHUB_TOKEN`. Check that a Codex code review completed on the current
|
||||
commit; a passing security check alone does not confirm this. If the automated
|
||||
request does not start a review or the integration asks the automated account
|
||||
to connect, a maintainer with a connected account should request the code
|
||||
review manually and verify it completed on that commit.
|
||||
|
||||
For CI to start without this approval, optionally configure a GitHub App
|
||||
installed on this repository with **Contents: write** and **Pull requests: write**.
|
||||
@@ -254,11 +263,16 @@ Generated PRs leave the disclosure attestations unchecked for maintainer review.
|
||||
3. Summarize the changes a user will notice. Call out required migration or
|
||||
compatibility work, link relevant public documentation, and leave the
|
||||
pull-request inventory to the generated section.
|
||||
The release maintainer checks the [published guides and examples](https://learn.chatgpt.com/docs/security)
|
||||
against the highlights and upgrade notes and prepares a docs PR for any that need updating.
|
||||
4. Open a pull request with a strict Conventional Commit title such as
|
||||
`chore(release): 0.2.0`.
|
||||
5. Run the checks required by the changed files and record the results in the
|
||||
pull request. Do not merge until required CI, review, and public disclosure
|
||||
checks pass on the current commit.
|
||||
5. Run the checks required by the changed files and record the initial results
|
||||
in the PR description. Post later manual test results in a comment or review
|
||||
with the tested commit SHA. Editing the description to update status can
|
||||
trigger CI. Before merging, confirm that required CI passed in the **Checks**
|
||||
tab and that review and the PR's public disclosure checklist cover the current
|
||||
commit.
|
||||
|
||||
Review the summary with the same standard as product documentation. Keep it
|
||||
specific, describe behavior before implementation, and do not include private
|
||||
@@ -271,11 +285,13 @@ for that exact commit:
|
||||
|
||||
1. `node-release-cut` verifies that the version increased, checks the reviewed
|
||||
summary, and creates the exact `npm-vX.Y.Z` tag.
|
||||
2. `node-release` installs the committed dependency graph, tests and packs the
|
||||
package, publishes it to npm, and records npm provenance. Three TypeScript
|
||||
test shards and the MCP tests run in parallel with package verification.
|
||||
Every shard and package check must pass before the protected npm job can
|
||||
publish the verified archive.
|
||||
2. `node-release` installs the committed dependency graph and packs the
|
||||
package. Three TypeScript test shards and the MCP tests run in parallel
|
||||
with package verification.
|
||||
After every shard and package check passes, approve the **npm** deployment
|
||||
for **Publish npm and container images**. This authorizes the npm archive
|
||||
and the matching container images built from the tagged release. The job
|
||||
publishes the verified archive to npm with signed provenance.
|
||||
3. `node-github-release` verifies the public package, provenance, tag, and
|
||||
archive before publishing the GitHub release. It prepends the reviewed
|
||||
summary to GitHub's categorized notes.
|
||||
@@ -318,10 +334,11 @@ registry errors fail immediately.
|
||||
do not prepare a release by editing or committing files there.
|
||||
|
||||
The merged release PR receives one progress comment covering post-merge CI,
|
||||
release verification, protected npm approval, public-package provenance,
|
||||
installation checks, Action publication, and container approval and publication.
|
||||
It links to the relevant workflow
|
||||
runs and updates at workflow boundaries. Each automatic release dispatch starts
|
||||
release verification and approval, public-package provenance, installation
|
||||
checks, and Action and container publication. It links to any pending deployment.
|
||||
The main CI completion handler requests the first update for a merged release
|
||||
PR, including when CI fails. Subsequent updates link to the relevant workflows
|
||||
and track each publication stage. Each automatic release dispatch starts
|
||||
a separate observer using the returned run ID; this does not depend on chained
|
||||
`workflow_run` events from the built-in token. The observer checks release jobs
|
||||
every 30 seconds, including while protected approval is pending, and requests a refresh
|
||||
@@ -336,7 +353,7 @@ and `watch` enabled. GitHub publication starts its own observer after npm succee
|
||||
|
||||
The observer and comment writer execute only helpers from protected `main`.
|
||||
Only the comment writer can update PR comments, and only the observer can request
|
||||
a refresh. Both run outside the publication workflows. Verification and
|
||||
a refresh. Reporting runs independently of the tag-cut job. Verification and
|
||||
publication jobs retain their existing permissions. The dispatch jobs use their
|
||||
existing Actions permission for a best-effort notification bounded to 15 seconds,
|
||||
within the downstream resolver's 60-second completion wait. Progress-reporting
|
||||
@@ -347,43 +364,37 @@ The automated release is complete when npm and GitHub publication, exact-version
|
||||
install checks, and applicable Action and container publication have succeeded.
|
||||
The final job summarizes each result and identifies Marketplace publication as a
|
||||
separate step. A successful workflow does not confirm a Marketplace listing.
|
||||
The protected npm publication gates and immutable `npm-vX.Y.Z` tag remain in place.
|
||||
|
||||
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.
|
||||
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.
|
||||
Debian (amd64 and arm64) and Wolfi (amd64) use the tagged release recipes.
|
||||
After the native builds pass, the coordinator publishes the tested images
|
||||
under the release approval and verifies both public version tags.
|
||||
|
||||
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.
|
||||
To recover a missing image, dispatch `node-github-release` on `main` with the
|
||||
original `npm-vX.Y.Z` tag. The default backfill uses the release recipes.
|
||||
Publishing missing images for a historical npm-only approval, or using a
|
||||
different Wolfi recipe commit on request, requires a `container` approval.
|
||||
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
|
||||
|
||||
Publishing the companion `action-vX.Y.Z` GitHub Release does not publish its
|
||||
Marketplace listing. Complete this step separately for each Action version
|
||||
that should appear in Marketplace:
|
||||
Before announcing a new release that includes the GitHub Action, a maintainer
|
||||
must publish the companion `action-vX.Y.Z` release to GitHub Marketplace.
|
||||
|
||||
1. Wait for `node-github-release` to succeed for the version.
|
||||
2. Open the existing `action-vX.Y.Z` release and choose **Edit**. Select
|
||||
**Publish this Action to the GitHub Marketplace**. Use the Action release,
|
||||
whose tag contains the tested distribution, rather than the `npm-vX.Y.Z`
|
||||
source release or a new tag on `main`.
|
||||
1. After `node-github-release` succeeds, follow **edit the Action release** in
|
||||
the **release status** job summary, or open `action-vX.Y.Z` and choose **Edit**.
|
||||
That tag contains the tested Action distribution. `npm-vX.Y.Z` points to the
|
||||
CLI source.
|
||||
2. Under **Release Action**, select **Publish this Action to the GitHub Marketplace**.
|
||||
3. Confirm the metadata checks pass. The Marketplace display name comes from
|
||||
`name` in the tagged `action.yml`, currently **OpenAI Codex Security**.
|
||||
GitHub requires a globally unique Action name. If a released version's name
|
||||
@@ -412,11 +423,15 @@ 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
|
||||
npm changelog, and lists that full distribution commit SHA. The manifest and
|
||||
runtime lock identify the same CLI version and npm integrity.
|
||||
- For new releases with the Action, the public Marketplace listing offers the
|
||||
matching `action-vX.Y.Z` version.
|
||||
- The newest npm release is marked Latest. Action releases and historical
|
||||
backfills are not.
|
||||
- For releases created under this process, the reviewed highlights, category
|
||||
@@ -424,6 +439,8 @@ Check the published state before announcing the release:
|
||||
Historical releases may have generated notes only.
|
||||
- Every merged pull request is included or has an intentional
|
||||
`skip-release-notes` label.
|
||||
- Once the documented version ships, publish any prepared docs updates and
|
||||
verify the changed instructions on the live site.
|
||||
|
||||
The `published-install-smoke` workflow checks each exact version during release
|
||||
publication. It also checks npm's current `latest` daily and on pull requests
|
||||
@@ -448,6 +465,13 @@ Do not retarget a release tag or publish a second package under the same
|
||||
version. The workflows are designed to recover from partial publication while
|
||||
keeping the original tag and package identity.
|
||||
|
||||
When the package is already published, `node-release` requests **npm** approval
|
||||
for **Verify existing npm release**. This job verifies the original archive
|
||||
and its signed provenance. Container publication uses the approval from the
|
||||
run attempt that signed the package. If that attempt has no record of a
|
||||
combined approval, the coordinator requests **container** approval before
|
||||
publishing missing images.
|
||||
|
||||
To retry GitHub publication, run `node-github-release` from `main` with the
|
||||
existing `npm-vX.Y.Z` tag. Supply the successful `node-release` run ID when
|
||||
automatic lookup is not enough. The workflow verifies the npm artifact and
|
||||
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
name: OpenAI Codex Security
|
||||
description: Scan code with Codex Security, enforce findings policy, and produce JSON, coverage, and SARIF reports.
|
||||
description: Scan code with Codex Security, enforce findings policy, and produce JSON and SARIF reports.
|
||||
branding:
|
||||
icon: shield
|
||||
color: black
|
||||
@@ -38,7 +38,7 @@ inputs:
|
||||
description: Stream CLI diagnostics to the job log. Set false for lifecycle and elapsed-time messages only.
|
||||
default: 'true'
|
||||
dry-run:
|
||||
description: Validate local configuration without a scan or API key. Does not verify authentication or model access. Use a separate non-required job.
|
||||
description: 'Validate local configuration without a scan or API key. Does not verify authentication or model access. Requires fail-on-severity: none; use a separate non-required job.'
|
||||
default: 'false'
|
||||
summary:
|
||||
description: Write a human-readable job summary.
|
||||
@@ -47,7 +47,7 @@ inputs:
|
||||
description: Emit up to 50 source finding annotations; complete findings remain in reports.
|
||||
default: 'true'
|
||||
upload-artifacts:
|
||||
description: Upload an allowlist of validated reports. Reports may contain source and vulnerability details.
|
||||
description: Upload an allowlist of validated reports and link the artifact in the job summary. Reports may contain source and vulnerability details.
|
||||
default: 'false'
|
||||
artifact-name:
|
||||
description: Report artifact name; choose distinct names for matrix jobs and multiple invocations.
|
||||
@@ -60,8 +60,10 @@ outputs:
|
||||
description: Absolute validated SARIF file path, or empty when unavailable or withheld.
|
||||
json-path:
|
||||
description: Absolute canonical findings JSON path, or empty when unavailable or withheld.
|
||||
manifest-path:
|
||||
description: Absolute scan manifest path, including scan status and scope, or empty when unavailable or withheld.
|
||||
coverage-path:
|
||||
description: Absolute coverage JSON path, or empty when unavailable or withheld.
|
||||
description: Legacy coverage JSON path. Empty for current CLI results.
|
||||
results-directory:
|
||||
description: Runner-local reports directory; do not upload it recursively.
|
||||
scan-status:
|
||||
|
||||
@@ -11,6 +11,7 @@ services:
|
||||
environment:
|
||||
CODEX_API_KEY:
|
||||
CODEX_SECURITY_EMBEDDINGS_URL:
|
||||
CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS:
|
||||
CODEX_SECURITY_GIT_HOST:
|
||||
GH_TOKEN:
|
||||
GITHUB_TOKEN:
|
||||
|
||||
@@ -13,6 +13,7 @@ services:
|
||||
environment:
|
||||
CODEX_API_KEY:
|
||||
CODEX_SECURITY_EMBEDDINGS_URL:
|
||||
CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS:
|
||||
CODEX_SECURITY_GIT_HOST:
|
||||
GH_TOKEN:
|
||||
GITHUB_TOKEN:
|
||||
|
||||
+62
-43
@@ -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
|
||||
@@ -72,8 +80,10 @@ Prepare the [universal native payload](../plugins/codex-security/native/README.m
|
||||
**Public**, and grant the repository **Write** under **Manage Actions access**.
|
||||
The workflow uses `GITHUB_TOKEN` and refuses missing, private, or unreadable
|
||||
packages. Verify `docker pull` works after logging out of GHCR.
|
||||
3. Protect the repository's `container` environment with required reviewers and
|
||||
deployment rules for protected `main` and approved `container-v*` tags.
|
||||
3. Configure the protected `npm` environment with release reviewers authorized
|
||||
for both npm and GHCR and limit it to `npm-v*` tags. For image backfills
|
||||
and standalone Wolfi OS updates, protect the `container` environment with
|
||||
required reviewers and deployment rules for `main` and approved `container-v*` tags.
|
||||
Allow the workflow's pinned actions, package writes, and OIDC attestations.
|
||||
Update branch-protection check names if they reference the old release jobs.
|
||||
|
||||
@@ -82,35 +92,40 @@ 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.
|
||||
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 and Wolfi builds
|
||||
on amd64, both using recipes from the scanner release commit. Approving
|
||||
**Publish npm and container images** in the `npm` environment authorizes both
|
||||
images for that release. 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 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.
|
||||
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. A default backfill uses the scanner release commit's recipes.
|
||||
If the Wolfi build needs updated OS pins, dispatch `node-github-release` with
|
||||
`refresh-wolfi-recipe=true` to use the recipe from protected `main` with the
|
||||
original scanner tarball and runtime lock. Review and approve the `container`
|
||||
deployment when publishing with a different recipe commit or recovering
|
||||
images for a release whose approval covered only npm. A backfill that
|
||||
verifies all existing tags finishes without a deployment approval.
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
@@ -120,12 +135,13 @@ commands, output, and exit codes through the existing scanner entrypoint.
|
||||
|
||||
Run these commands from the repository root after
|
||||
[verifying an image](#image-metadata-and-verification). Keep the verified
|
||||
`reference` in the same shell. Prepare private directories and choose the host
|
||||
user's UID/GID so the runner can write its bind mounts:
|
||||
`reference` in the same shell. Prepare the output and state directories, keep
|
||||
state private, and choose the host user's UID/GID so the runner can write its
|
||||
bind mounts:
|
||||
|
||||
```bash
|
||||
mkdir -p results state
|
||||
chmod 700 results state
|
||||
chmod 700 state
|
||||
export CODEX_SECURITY_USER="$(id -u):$(id -g)"
|
||||
export CODEX_SECURITY_IMAGE="$reference"
|
||||
docker compose -f compose.runner.yaml pull
|
||||
@@ -149,6 +165,9 @@ docker build --target scanner -t codex-security:local .
|
||||
export CODEX_SECURITY_IMAGE=codex-security:local
|
||||
```
|
||||
|
||||
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
|
||||
the host directories (default `./results` and `./state`):
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -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));
|
||||
@@ -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/codex-security@1.2.3?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
|
||||
@@ -5,20 +5,20 @@ set -euo pipefail
|
||||
# Resolve the environment on the host; these checks need no running container.
|
||||
for compose_file in compose.yaml compose.runner.yaml; do
|
||||
endpoint="https://embeddings.example.com/custom/v1/embeddings?api-version=synthetic"
|
||||
CODEX_SECURITY_EMBEDDINGS_URL="$endpoint" \
|
||||
CODEX_SECURITY_EMBEDDINGS_URL="$endpoint" CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 \
|
||||
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
||||
jq --exit-status --arg endpoint "$endpoint" \
|
||||
'.services["codex-security"].environment.CODEX_SECURITY_EMBEDDINGS_URL == $endpoint' > /dev/null
|
||||
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == $endpoint and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == "1"' > /dev/null
|
||||
|
||||
env -u CODEX_SECURITY_EMBEDDINGS_URL \
|
||||
env -u CODEX_SECURITY_EMBEDDINGS_URL -u CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS \
|
||||
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
||||
jq --exit-status \
|
||||
'.services["codex-security"].environment.CODEX_SECURITY_EMBEDDINGS_URL == null' > /dev/null
|
||||
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == null and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == null' > /dev/null
|
||||
|
||||
CODEX_SECURITY_EMBEDDINGS_URL="" \
|
||||
CODEX_SECURITY_EMBEDDINGS_URL="" CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS="" \
|
||||
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
||||
jq --exit-status \
|
||||
'.services["codex-security"].environment.CODEX_SECURITY_EMBEDDINGS_URL == ""' > /dev/null
|
||||
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == "" and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == ""' > /dev/null
|
||||
done
|
||||
|
||||
mkdir -p results state
|
||||
|
||||
@@ -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
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -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
|
||||
'
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/.build/
|
||||
/build/
|
||||
*.rsa
|
||||
__pycache__/
|
||||
@@ -0,0 +1,124 @@
|
||||
# Wolfi scanner image
|
||||
|
||||
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 [Debian image](../README.md). The local build below
|
||||
uses the scanner version pinned in [payload/package.json](payload/package.json).
|
||||
|
||||
## Build and inspect
|
||||
|
||||
Use a Linux amd64 builder with user namespaces and Bubblewrap, apko 1.4.13,
|
||||
melange 0.61.1, Python 3.9 or later, Node.js with npm 11, OpenSSL,
|
||||
and Docker for runtime testing. From the repository root:
|
||||
|
||||
```sh
|
||||
docker/wolfi/build.sh /tmp/codex-security-wolfi
|
||||
docker load --input /tmp/codex-security-wolfi/image.tar
|
||||
docker run --rm --pull=never --network=none codex-security:wolfi-amd64 --version
|
||||
```
|
||||
|
||||
Use a new output directory for each build. Alongside the Docker archive,
|
||||
the builder writes the signed scanner APK and index, apko locks, SPDX SBOMs,
|
||||
a [component inventory](verify-public.py), and a signed `SHA256SUMS`. To verify
|
||||
the saved files later, use the public key retained from that build:
|
||||
|
||||
```sh
|
||||
cd /tmp/codex-security-wolfi
|
||||
openssl dgst -sha256 -verify melange.rsa.pub -signature SHA256SUMS.sig SHA256SUMS
|
||||
sha256sum --check SHA256SUMS
|
||||
```
|
||||
|
||||
Each run generates a local signing key, adds its public half to the APK keyring,
|
||||
and removes the private key at exit. The key identifies that build; it is not
|
||||
an upstream release signature. A new key changes the APK and image digests.
|
||||
|
||||
To test that the melange guest can be built without access to Wolfi, run a
|
||||
build with the [offline melange wrapper](tests/offline-melange.sh) on a Linux
|
||||
builder that permits `unshare --net`:
|
||||
|
||||
```sh
|
||||
MELANGE="$PWD/docker/wolfi/tests/offline-melange.sh" docker/wolfi/build.sh /tmp/codex-security-offline-guest
|
||||
```
|
||||
|
||||
The wrapper disconnects melange before it installs the guest packages. Staging
|
||||
the inputs and resolving the runtime lock still need the network.
|
||||
|
||||
## Run the offline smoke test
|
||||
|
||||
On a native Linux amd64 Docker host with AppArmor and user namespaces, load
|
||||
the built image and run the following from the repository root. If the
|
||||
`codex-security-container` AppArmor profile is already loaded, omit the setup
|
||||
and cleanup commands. Otherwise use a disposable test host:
|
||||
|
||||
```sh
|
||||
sudo apparmor_parser --skip-cache --add docker/codex-security.apparmor
|
||||
docker/wolfi/tests/smoke.sh codex-security:wolfi-amd64
|
||||
sudo apparmor_parser --skip-cache --remove docker/codex-security.apparmor
|
||||
```
|
||||
|
||||
The test uses the repository's seccomp profile with a read-only root filesystem,
|
||||
no capabilities, and no external network. It exercises the CLI, the native plugin,
|
||||
artifact and SARIF output, saved history, and a model turn against a loopback
|
||||
fixture. It also checks that a sandboxed child can read the test repository but
|
||||
cannot modify it. A real scan needs a compatible model endpoint; the image
|
||||
does not include a model.
|
||||
|
||||
## Publish the amd64 variant
|
||||
|
||||
For a scanner release, `container-publish` supplies the same verified npm tarball
|
||||
and runtime lock used for Debian. The scanner and Wolfi recipe both come from
|
||||
`npm-vX.Y.Z`. One `npm` deployment approval authorizes the package and both
|
||||
container images. 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`. To recover a missing image
|
||||
using refreshed OS pins, follow the [container backfill instructions](../README.md#publishing).
|
||||
|
||||
### 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 -f release-version=X.Y.Z
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
[builder.yaml](builder.yaml) and [apko.yaml](apko.yaml) list the exact builder
|
||||
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. 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
|
||||
voice runtime and plugin binaries for other platforms; it keeps the matching
|
||||
Linux addon, Codex, code-mode host, Bubblewrap, ripgrep, and license notices.
|
||||
In the image, `/usr/share/licenses/codex-security/SOURCES.json` records the
|
||||
sources and hashes of the native files along with the npm dependency inventory.
|
||||
The original npm lock is retained, including optional packages for other
|
||||
platforms; the inventory lists only packages installed in the image.
|
||||
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. 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.
|
||||
@@ -0,0 +1,100 @@
|
||||
# The image lock binds the public Wolfi packages and the locally signed scanner.
|
||||
contents:
|
||||
repositories:
|
||||
- https://packages.wolfi.dev/os
|
||||
build_repositories:
|
||||
- ./packages
|
||||
keyring:
|
||||
- ./wolfi-signing.rsa.pub
|
||||
- ./melange.rsa.pub
|
||||
packages:
|
||||
- busybox=1.38.0-r3
|
||||
- c-ares=1.34.9-r0
|
||||
- ca-certificates-bundle=20261020-r0
|
||||
- "@LOCAL_PACKAGE@"
|
||||
- cyrus-sasl-heimdal-libs=2.1.28-r58
|
||||
- gdbm=1.26-r8
|
||||
- git=2.56.0-r3
|
||||
- glibc-2.44-locale-posix=2.44-r9
|
||||
- glibc-2.44=2.44-r9
|
||||
- heimdal-libs=7.8.0-r54
|
||||
- icu78-data-full=78.3-r4
|
||||
- keyutils-libs=1.6.3-r41
|
||||
- krb5-conf=1.0-r10
|
||||
- krb5-libs=1.22.2-r5
|
||||
- ld-linux-2.44=2.44-r9
|
||||
- libbrotlicommon1=1.2.1-r1
|
||||
- libbrotlidec1=1.2.1-r1
|
||||
- libbrotlienc1=1.2.1-r1
|
||||
- libbz2-1=1.0.8-r27
|
||||
- libcom_err=1.47.4-r4
|
||||
- libcrypt1-2.44=2.44-r9
|
||||
- libcurl-openssl4=8.23.0-r2
|
||||
- libedit=3.1-r20
|
||||
- libexpat1=2.9.0-r0
|
||||
- libffi=3.8.0-r2
|
||||
- libgcc=16.2.0-r1
|
||||
- libicu78=78.3-r4
|
||||
- libidn2=2.3.8-r11
|
||||
- libldap-2.7=2.7.2-r0
|
||||
- libnghttp2-14=1.70.0-r6
|
||||
- libpcre2-8-0=10.49-r1
|
||||
- libpsl=0.23.3-r3
|
||||
- libselinux=3.11-r2
|
||||
- libsepol=3.11-r3
|
||||
- libstdc++=16.2.0-r1
|
||||
- libunistring=1.5-r0
|
||||
- libuuid=2.42.4-r1
|
||||
- libuv=1.53.0-r0
|
||||
- libverto=0.3.2-r10
|
||||
- libxcrypt=4.5.2-r6
|
||||
- mpdecimal=4.0.1-r5
|
||||
- ncurses-terminfo-base=6.6.20261024-r0
|
||||
- ncurses=6.6.20261024-r0
|
||||
- nghttp3=1.18.0-r2
|
||||
- ngtcp2=1.25.0-r6
|
||||
- nodejs-26=26.12.1-r2
|
||||
- openssh-client=10.6_p1-r0
|
||||
- openssl-4.0-libcrypto=4.0.3-r8
|
||||
- openssl-4.0-libssl=4.0.3-r8
|
||||
- openssl-provider-legacy-allowed=4.1.0-r0
|
||||
- py3-pip-wheel=26.2.2-r0
|
||||
- python-3.13-base=3.13.17_git20261023-r0
|
||||
- python-3.13=3.13.17_git20261023-r0
|
||||
- readline=8.3-r3
|
||||
- sqlite-libs=3.54.1-r0
|
||||
- wolfi-baselayout=20230201-r30
|
||||
- xz=5.8.4-r0
|
||||
- zlib=1.3.2.1_rc20260921-r0
|
||||
archs:
|
||||
- x86_64
|
||||
accounts:
|
||||
groups:
|
||||
- groupname: codex-security
|
||||
gid: 10001
|
||||
users:
|
||||
- username: codex-security
|
||||
uid: 10001
|
||||
gid: 10001
|
||||
homedir: /state
|
||||
shell: /bin/sh
|
||||
run-as: '10001:10001'
|
||||
paths:
|
||||
- {path: /input, type: directory, uid: 0, gid: 0, permissions: 0o755}
|
||||
- {path: /output, type: directory, uid: 10001, gid: 10001, permissions: 0o755}
|
||||
- {path: /state, type: directory, uid: 10001, gid: 10001, permissions: 0o755}
|
||||
environment:
|
||||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOME: /state
|
||||
CODEX_HOME: /state
|
||||
CODEX_SECURITY_STATE_DIR: /output/.codex-security-state
|
||||
GIT_TERMINAL_PROMPT: '0'
|
||||
PYTHON: /usr/bin/python3
|
||||
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt
|
||||
work-dir: /state
|
||||
entrypoint:
|
||||
command: /usr/local/bin/codex-security-entrypoint
|
||||
cmd: --help
|
||||
annotations:
|
||||
# @RECIPE_REVISION@
|
||||
io.openai.codex-security.payload-sha256: "@PAYLOAD_SHA256@"
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"wolfi_key_source": "https://packages.wolfi.dev/os/wolfi-signing.rsa.pub",
|
||||
"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": {
|
||||
"lock_identity_sha256": "77cd79a5f9b66efc5d0f03dee78f2e24b66dc1a5acfc2454ba33e124aeb758a0"
|
||||
},
|
||||
"runtime": {
|
||||
"lock_identity_sha256": "6ed7b6d59587eb43f7e831ca4faca86310d6c2a6438288e2ef5a98b870d5517a"
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and verify a local linux/amd64 image from the public Wolfi repository.
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: ./build.sh [NEW_OUTPUT_DIR] (default: ./build next to this script)
|
||||
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 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
|
||||
}
|
||||
die() { printf '%s\n' "$*" >&2; exit 1; }
|
||||
[[ ${1:-} != -h && ${1:-} != --help ]] || { usage; exit 0; }
|
||||
[[ $# -le 1 && ${1:-} != -* ]] || { usage >&2; exit 2; }
|
||||
root=$(cd "$(dirname "$0")" && pwd -P)
|
||||
out=${1:-"$root/build"}
|
||||
apko=${APKO:-apko}; melange=${MELANGE:-melange}
|
||||
"$apko" version | grep -Eq '^GitVersion:[[:space:]]+v1\.4\.13$' || die 'Expected apko 1.4.13'
|
||||
"$melange" version | grep -Eq '^GitVersion:[[:space:]]+v0\.61\.1$' || die 'Expected melange 0.61.1'
|
||||
python3 -c 'import sys; sys.exit(0 if sys.version_info >= (3,9) else "Python 3.9+ required")'
|
||||
if [[ -n ${STAGED_PAYLOAD:-} ]]; then
|
||||
[[ $STAGED_PAYLOAD == /* && -f $STAGED_PAYLOAD ]] || die 'STAGED_PAYLOAD must be an existing absolute file path'
|
||||
else
|
||||
[[ $(npm --version) == 11.* ]] || die 'Expected npm 11'
|
||||
fi
|
||||
mkdir -p "$(dirname "$out")"
|
||||
(umask go-w; mkdir "$out") || die 'Use a new output directory for each build'
|
||||
cd "$out"; out=$(pwd -P)
|
||||
scratch=$(mktemp -d /tmp/codex-security-build.XXXXXXXX)
|
||||
trap 'rm -rf -- "$scratch"' EXIT
|
||||
trap 'exit 130' INT; trap 'exit 143' TERM
|
||||
unset HTTP_AUTH SOURCE_DATE_EPOCH
|
||||
mkdir -p src packages sbom
|
||||
cp "$root"/{wolfi-signing.rsa.pub,builder.yaml,apko.yaml,melange.yaml,build-inputs.json} .
|
||||
(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()
|
||||
if actual != json.load(open("build-inputs.json"))["wolfi_key_sha256"]: sys.exit("Unexpected Wolfi signing key")'
|
||||
|
||||
# Verify the lock's origin, architecture, control/data checksums and exact keyring.
|
||||
check_lock() {
|
||||
python3 - "$1" "$2" <<'PY'
|
||||
import hashlib, json, sys
|
||||
from pathlib import Path
|
||||
m=json.loads(Path("build-inputs.json").read_text()); which=sys.argv[1]; snap=m["snapshots"][which]
|
||||
c=json.loads(Path(sys.argv[2]).read_text())["contents"]; local_spec=m["local_package"]
|
||||
rows=[]; local=[]
|
||||
for p in c["packages"]:
|
||||
n=p["name"]; v=p["version"]; filename=f"{n}-{v}.apk"
|
||||
if p["architecture"]!="x86_64": raise ValueError(f"Unexpected architecture: {n}")
|
||||
if p["url"]=="./packages/x86_64/"+filename: local.append(n+"="+v)
|
||||
else:
|
||||
if p["url"]!=m["repository"]+"/x86_64/"+filename: raise ValueError(f"Unexpected package URL: {n}")
|
||||
rows.append({k:v for k,v in p.items() if k!="url"})
|
||||
rows.sort(key=lambda r:r["name"])
|
||||
digest=hashlib.sha256(json.dumps(rows,sort_keys=True,separators=(",",":")).encode()).hexdigest()
|
||||
if digest!=snap["lock_identity_sha256"] or local!=([] if which=="builder" else [local_spec]):
|
||||
raise ValueError(f"{which}: package identities differ from the public snapshot")
|
||||
keys={(Path(k["name"]).name,k["content"]) for k in c["keyring"]}
|
||||
expected={"wolfi-signing.rsa.pub":Path("wolfi-signing.rsa.pub").read_text()}
|
||||
if which=="runtime": expected["melange.rsa.pub"]=Path("melange.rsa.pub").read_text()
|
||||
if keys!=set(expected.items()): raise ValueError(f"{which}: unrecognized or missing APK signing keys")
|
||||
PY
|
||||
}
|
||||
"$apko" lock builder.yaml --arch x86_64 --output builder.lock.json --cache-dir "$scratch/cache"
|
||||
check_lock builder builder.lock.json
|
||||
# Sign an index over exactly the APK bytes authenticated by the builder lock.
|
||||
snapshot=$scratch/builder-repo
|
||||
python3 "$root/snapshot-builder.py" builder.lock.json "$snapshot"
|
||||
"$melange" index --arch x86_64 --signing-key "$scratch/melange.rsa" \
|
||||
--output "$snapshot/x86_64/APKINDEX.tar.gz" "$snapshot"/x86_64/*.apk
|
||||
if [[ -n ${STAGED_PAYLOAD:-} ]]; then
|
||||
cp "$STAGED_PAYLOAD" src/payload.tar.gz
|
||||
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" \
|
||||
--repository-append "$snapshot" --keyring-append "$out/melange.rsa.pub" --package-append "$pins" \
|
||||
--build-date "$stamp" --apk-cache-dir "$scratch/guest-apk-cache" --cache-dir "$scratch/melange-cache"
|
||||
"$apko" lock apko.yaml --arch x86_64 --output image.lock.json --cache-dir "$scratch/cache"
|
||||
check_lock runtime image.lock.json
|
||||
tag=codex-security:wolfi
|
||||
"$apko" build apko.yaml "$tag" .image.unverified.tar --arch x86_64 --lockfile image.lock.json \
|
||||
--cache-dir "$scratch/cache" --vcs=false --sbom-path ./sbom --build-date "$stamp"
|
||||
|
||||
python3 "$root/verify-public.py" .image.unverified.tar image.lock.json
|
||||
mv .image.unverified.tar image.tar
|
||||
# This single detached signature covers the image, locks, SBOMs and signed local APK evidence.
|
||||
sha256sum build-inputs.json builder.yaml builder.lock.json apko.yaml image.lock.json melange.yaml \
|
||||
melange.rsa.pub wolfi-signing.rsa.pub verification.json public-components.json image.tar sbom/*.spdx.json \
|
||||
packages/x86_64/APKINDEX.tar.gz packages/x86_64/*.apk > SHA256SUMS
|
||||
openssl dgst -sha256 -sign "$scratch/melange.rsa" -out SHA256SUMS.sig SHA256SUMS
|
||||
openssl dgst -sha256 -verify melange.rsa.pub -signature SHA256SUMS.sig SHA256SUMS
|
||||
sha256sum -c SHA256SUMS
|
||||
loaded_tag=$(python3 -c 'import json; print(json.load(open("verification.json"))["tag"])')
|
||||
printf 'Built %s: %s/image.tar\n' "$loaded_tag" "$out"
|
||||
@@ -0,0 +1,18 @@
|
||||
# Public packages used to populate the local melange repository.
|
||||
contents:
|
||||
repositories:
|
||||
- https://packages.wolfi.dev/os
|
||||
keyring:
|
||||
- ./wolfi-signing.rsa.pub
|
||||
packages:
|
||||
- busybox=1.38.0-r3
|
||||
- ca-certificates-bundle=20261020-r0
|
||||
- glibc-2.44=2.44-r9
|
||||
- glibc-2.44-locale-posix=2.44-r9
|
||||
- ld-linux-2.44=2.44-r9
|
||||
- libcrypt1-2.44=2.44-r9
|
||||
- libgcc=16.2.0-r1
|
||||
- libxcrypt=4.5.2-r6
|
||||
- wolfi-baselayout=20230201-r30
|
||||
archs:
|
||||
- x86_64
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and smoke-test one archive on a fresh GitHub-hosted ubuntu-24.04 VM.
|
||||
# The workflow supplies Node 24.15.0 (npm 11) and an absolute, new output directory.
|
||||
set -euo pipefail
|
||||
die() { echo "$*" >&2; exit 1; }
|
||||
[[ $# == 1 && $1 == /* && ! -e $1 ]] || die 'Usage: ci-build.sh NEW_ABSOLUTE_OUTPUT_DIRECTORY'
|
||||
[[ ${RUNNER_ENVIRONMENT:-} == github-hosted && $(uname -s -m) == 'Linux x86_64' ]] ||
|
||||
die 'Use a disposable GitHub-hosted Ubuntu 24.04 amd64 VM'
|
||||
[[ $(id -u) != 0 && $(npm --version) == 11.* ]] || die 'Run as the runner user with npm 11 on PATH'
|
||||
|
||||
recipe=$(cd "$(dirname "$0")" && pwd -P)
|
||||
out=$1
|
||||
tools=$(mktemp -d "${RUNNER_TEMP:?}/wolfi-tools.XXXXXXXX")
|
||||
profile=$recipe/../codex-security.apparmor
|
||||
added_profile=false
|
||||
cleanup() {
|
||||
if "$added_profile"; then sudo -n apparmor_parser --skip-cache --remove "$profile"; fi
|
||||
rm -rf -- "$tools"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Reuse the repository's Ubuntu Bubblewrap setup. Its packaged AppArmor profile
|
||||
# grants user namespaces to bwrap without changing any host security sysctl.
|
||||
bash "$recipe/../../github-action/scripts/setup-ubuntu-sandbox.sh"
|
||||
bwrap --unshare-user --unshare-net --uid 1000 --gid 1000 --ro-bind / / --dev /dev --proc /proc -- /usr/bin/true
|
||||
|
||||
# SHA-256 pins from each tagged upstream release's checksums.txt. Extract only
|
||||
# the binary after verification; no installer or downloaded source is executed.
|
||||
install_tool() {
|
||||
local name=$1 version=$2 sha=$3 base
|
||||
base="${name}_${version}_linux_amd64"
|
||||
curl --proto '=https' --proto-redir '=https' --fail --location --silent --show-error --retry 3 \
|
||||
"https://github.com/chainguard-dev/$name/releases/download/v$version/$base.tar.gz" \
|
||||
--output "$tools/$base.tar.gz"
|
||||
printf '%s %s\n' "$sha" "$tools/$base.tar.gz" | sha256sum --check --strict
|
||||
tar -xOzf "$tools/$base.tar.gz" "$base/$name" > "$tools/$name"
|
||||
chmod 0755 "$tools/$name"
|
||||
}
|
||||
install_tool apko 1.4.13 2377cd4a2efed58905da580f835fbdf2a6ed4ad0f10ff541827153a42d491cee
|
||||
install_tool melange 0.61.1 4f2d104f1149e4bcf63c7f7a71deeae385d453c3bdf0f987c9c2d16a2efdd7da
|
||||
|
||||
# Stage and resolve the public inputs normally. For the guest build alone,
|
||||
# unshare needs CAP_SYS_ADMIN: create its network namespace, then drop back
|
||||
# to the runner UID before starting melange. The APK snapshot is its only source.
|
||||
export REAL_MELANGE="$tools/melange"
|
||||
cat > "$tools/offline-melange" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [[ $1 == build ]]; then
|
||||
exec sudo -n /usr/bin/unshare --net -- /usr/bin/setpriv \
|
||||
--reuid "$(id -u)" --regid "$(id -g)" --clear-groups --reset-env -- "$REAL_MELANGE" "$@"
|
||||
fi
|
||||
exec "$REAL_MELANGE" "$@"
|
||||
EOF
|
||||
chmod 0755 "$tools/offline-melange"
|
||||
APKO="$tools/apko" MELANGE="$tools/offline-melange" "$recipe/build.sh" "$out"
|
||||
|
||||
# build.sh has verified the package locks, original archive and signed checksums.
|
||||
# Bind the smoke test to the verified config, including its rootfs diff IDs.
|
||||
tag=$(jq -er .tag "$out/verification.json")
|
||||
config_digest=$(jq -er .config_digest "$out/verification.json")
|
||||
if docker image inspect "$tag" >/dev/null 2>&1; then die "Test image tag already exists: $tag"; fi
|
||||
docker load --input "$out/image.tar"
|
||||
image_id=$(docker image inspect --format '{{.Id}}' "$tag")
|
||||
if [[ $image_id != "$config_digest" ]]; then
|
||||
# The containerd image store returns a manifest digest as the ID; the
|
||||
# classic store returns the config digest itself. Inspect the same local ID.
|
||||
loaded_config=$(skopeo inspect --raw "docker-daemon:$image_id" | jq -er .config.digest)
|
||||
[[ $loaded_config == "$config_digest" ]] || die "Docker's loaded config differs from the verified archive"
|
||||
fi
|
||||
|
||||
# Fail if AppArmor cannot enforce the repository's profile. The smoke script
|
||||
# also applies the committed seccomp policy and disables container networking.
|
||||
sudo -n apparmor_parser --skip-cache --add "$profile"
|
||||
added_profile=true
|
||||
sudo -n grep -Fxq 'codex-security-container (enforce)' /sys/kernel/security/apparmor/profiles
|
||||
"$recipe/tests/smoke.sh" "$image_id"
|
||||
@@ -0,0 +1,43 @@
|
||||
# Stage once using payload/stage.py; pass that directory as melange --source-dir.
|
||||
# build.sh supplies the signed local repository prepared from builder.lock.json.
|
||||
package:
|
||||
name: codex-security
|
||||
version: "@SCANNER_VERSION@"
|
||||
epoch: 1
|
||||
description: Codex Security repository scanner and bundled Linux amd64 Codex runtime
|
||||
target-architecture: [x86_64]
|
||||
copyright:
|
||||
- license: Apache-2.0
|
||||
# The npm native add-ons are loaded by Node, not system SONAME providers.
|
||||
# Their shared runtime requirements are declared explicitly below.
|
||||
options:
|
||||
no-provides: true
|
||||
no-depends: true
|
||||
dependencies:
|
||||
runtime:
|
||||
- busybox
|
||||
- ca-certificates-bundle
|
||||
- cmd:node
|
||||
- git
|
||||
- glibc
|
||||
- libgcc
|
||||
- openssh-client
|
||||
- python3
|
||||
|
||||
environment:
|
||||
contents:
|
||||
packages:
|
||||
- busybox
|
||||
|
||||
pipeline:
|
||||
- name: Verify and install the locked Linux scanner payload
|
||||
runs: |
|
||||
set -eu
|
||||
expected=@PAYLOAD_SHA256@
|
||||
actual=$(gzip -dc payload.tar.gz | sha256sum)
|
||||
test "${actual%% *}" = "$expected"
|
||||
mkdir -p "${{targets.destdir}}"
|
||||
tar -xzf payload.tar.gz -C "${{targets.destdir}}"
|
||||
test -x "${{targets.destdir}}/usr/bin/codex-security"
|
||||
test -x "${{targets.destdir}}/usr/local/bin/codex-security-entrypoint"
|
||||
test -s "${{targets.destdir}}/usr/share/licenses/codex-security/SOURCES.json"
|
||||
@@ -0,0 +1,6 @@
|
||||
OpenAI Codex
|
||||
Copyright 2025 OpenAI
|
||||
|
||||
This project includes code derived from [Ratatui](https://github.com/ratatui/ratatui), licensed under the MIT license.
|
||||
Copyright (c) 2016-2022 Florian Dehau
|
||||
Copyright (c) 2023-2025 The Ratatui Developers
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"@openai/codex@0.164.0-linux-x64": "https://github.com/openai/codex/tree/6aaac694803004a63c6f393d153c96d22521a6b9",
|
||||
"@openai/codex@0.165.0-linux-x64": "https://github.com/openai/codex/tree/360319d8dee62d87e2d59fc0c21805d79519cfed",
|
||||
"@napi-rs/canvas-linux-x64-gnu@1.0.10": "https://github.com/Brooooooklyn/canvas/tree/7d19abed029287e7c26b14eaa6e67d560a37d853",
|
||||
"@napi-rs/canvas-linux-x64-gnu@1.0.13": "https://github.com/Brooooooklyn/canvas/tree/00a115d9903647f116daf86eccd2c6ba36128371",
|
||||
"@openai/codex@0.166.0-linux-x64": "https://github.com/openai/codex/tree/6ff1e1ca3b30fc8b914720681fcf5fe62e95f856"
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Jeremy Danyow
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 OpenAI, Shantanu Jain
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Andrew Gallant
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,64 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
The following license is the one that governed sax, from which saxes
|
||||
was forked. Isaac Schlueter is not *directly* involved with saxes so
|
||||
don't go bugging him for saxes issues.
|
||||
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
====
|
||||
|
||||
`String.fromCodePoint` by Mathias Bynens is no longer used, but it can
|
||||
still be found in old commits. It was once used according to terms of
|
||||
MIT License, as follows:
|
||||
|
||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023-present Scalar
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"BUBBLEWRAP-COPYING": {
|
||||
"source": "https://raw.githubusercontent.com/openai/codex/6aaac694803004a63c6f393d153c96d22521a6b9/codex-rs/vendor/bubblewrap/COPYING",
|
||||
"sha256": "b7993225104d90ddd8024fd838faf300bea5e83d91203eab98e29512acebd69c"
|
||||
},
|
||||
"CFWORKER-LICENSE": {
|
||||
"source": "https://raw.githubusercontent.com/cfworker/cfworker/5409fdc2bd144f68e8b28c61c71fcb16600000a6/LICENSE.md",
|
||||
"sha256": "376944252ab78ca6b41aee44ddea8894927ee67891e77e61eb9d59af63e35094"
|
||||
},
|
||||
"JS-TIKTOKEN-LICENSE": {
|
||||
"source": "https://raw.githubusercontent.com/dqbd/tiktoken/4c8b748e07992c00386f3180af5c574b27b65139/LICENSE",
|
||||
"sha256": "418cb499b436128d653d79941333a5437b7be2ea9213dcc2f04d15d5d2c51d86"
|
||||
},
|
||||
"RIPGREP-LICENSE-MIT": {
|
||||
"source": "https://raw.githubusercontent.com/BurntSushi/ripgrep/e89fff89ac9af12e8d4ce9d5fd07beb408ca730f/LICENSE-MIT",
|
||||
"sha256": "0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f"
|
||||
},
|
||||
"SAXES-LICENSE": {
|
||||
"source": "https://raw.githubusercontent.com/lddubeau/saxes/211fa0ebec9b628affc09219199639887174bfc3/LICENSE",
|
||||
"sha256": "0fac2374380621b22e6b50451057721a9c52935b02d16d106a9f04897f061d0e"
|
||||
},
|
||||
"SCALAR-LICENSE": {
|
||||
"source": "https://raw.githubusercontent.com/scalar/scalar/71c72fbc1c3860ac741812617057141db2033fcd/LICENSE",
|
||||
"sha256": "380cd0a6ad700e1f821f2a509f0dd9ff835041cee2d43daf5dedc1adb2bcc620"
|
||||
},
|
||||
"YOGA-LICENSE": {
|
||||
"source": "https://raw.githubusercontent.com/react/yoga/042f5013152eb81c1552dec945b88f7b95ca350f/LICENSE",
|
||||
"sha256": "52412d7bc7ce4157ea628bbaacb8829e0a9cb3c58f57f99176126bc8cf2bfc85"
|
||||
}
|
||||
}
|
||||
Generated
+1819
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "codex-security-image-payload",
|
||||
"version": "0.7.0",
|
||||
"private": true,
|
||||
"dependencies": { "@openai/codex-security": "0.7.0" }
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage the open-source scanner payload for offline Linux/amd64 melange builds.
|
||||
|
||||
Usage: python3 payload/stage.py PATH_TO_MELANGE_SOURCE_DIR
|
||||
Requires Python 3.9+, Node and npm 11 on a POSIX host. No target code is run.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
DOCKER = HERE.parent.parent
|
||||
REPO = DOCKER.parent
|
||||
INSTALL = Path("usr/lib/codex-security")
|
||||
SDK = "node_modules/@openai/codex-security"
|
||||
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)"}
|
||||
OFF_TARGET_PLUGIN_TARGETS = {
|
||||
"darwin-arm64", "darwin-x64", "linux-arm64-gnu", "linux-arm64-musl",
|
||||
"linux-x64-musl", "win32-arm64", "win32-x64",
|
||||
}
|
||||
|
||||
# Reuse this repository's Docker scripts at their released hashes. The root
|
||||
# LICENSE is byte-identical to the LICENSE in the pinned native Codex release.
|
||||
EXTRAS = {
|
||||
DOCKER / "entrypoint.sh": ("usr/local/bin/codex-security-entrypoint", "5bcce4a6b0f6a57d938f3e9def0aea93660d41356fdf0ddad1d343a067fc6610"),
|
||||
DOCKER / "git-credential.sh": ("usr/local/bin/codex-security-git-credential", "0b792c2304abcd60366aed3040287ecee4d8e336c121516d8112f577fc2af360"),
|
||||
REPO / "LICENSE": ("usr/share/licenses/codex-security/CODEX-LICENSE", "d17f227e4df5da1600391338865ce0f3055211760a36688f816941d58232d8dc"),
|
||||
HERE / "CODEX-NOTICE": ("usr/share/licenses/codex-security/CODEX-NOTICE", "9d71575ecfd9a843fc1677b0efb08053c6ba9fd686a0de1a6f5382fd3c220915"),
|
||||
}
|
||||
|
||||
|
||||
def read_json(path):
|
||||
return json.loads(path.read_text())
|
||||
|
||||
|
||||
def matches_target(package):
|
||||
for key, target in TARGET.items():
|
||||
values = package.get(key, [])
|
||||
allowed = [v for v in values if not v.startswith("!")]
|
||||
if "!" + target in values or (allowed and target not in allowed):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def source_url(pkg):
|
||||
repo = pkg.get("repository")
|
||||
raw = repo.get("url") if isinstance(repo, dict) else repo
|
||||
# npm accepts both GitHub shorthand and conventional git URLs. Do not
|
||||
# silently accept missing metadata, new repository hosts or unknown terms.
|
||||
match = re.fullmatch(r"(?:(?:git\+https://|https://|git://|git@)github\.com[:/]|github:)?([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)", raw or "")
|
||||
if not match:
|
||||
raise ValueError(f"Review repository for {pkg['name']}: {raw}")
|
||||
return "https://github.com/" + match[1].removesuffix(".git")
|
||||
|
||||
|
||||
def select_scanner_payload(app):
|
||||
# Voice belongs to the interactive client, not repository scanning. The
|
||||
# MCP server uses Node's target (Linux x64 glibc), while the Codex executable
|
||||
# itself is the upstream static musl build.
|
||||
shutil.rmtree(app / VENDOR / "codex-resources/voice")
|
||||
native = app / SDK / "_bundled_plugin/mcp/native"
|
||||
if {p.name for p in native.iterdir() if p.is_dir()} != OFF_TARGET_PLUGIN_TARGETS | {"licenses", "linux-x64-gnu"}:
|
||||
raise ValueError("Review changed native MCP targets")
|
||||
for target in OFF_TARGET_PLUGIN_TARGETS:
|
||||
shutil.rmtree(native / target)
|
||||
known = {
|
||||
"bin/codex", "bin/codex-code-mode-host", "codex-resources/bwrap",
|
||||
"codex-path/rg", "codex-package.json",
|
||||
}
|
||||
vendor = app / VENDOR
|
||||
if {p.relative_to(vendor).as_posix() for p in vendor.rglob("*") if p.is_file()} != known:
|
||||
raise ValueError("Review changed Codex release files")
|
||||
|
||||
|
||||
def write_attributions(root, app, wanted):
|
||||
license_dir = root / LICENSE_DIR
|
||||
notices = read_json(HERE / "notices/sources.json")
|
||||
for name, item in notices.items():
|
||||
source = HERE / "notices" / name
|
||||
if hashlib.sha256(source.read_bytes()).hexdigest() != item["sha256"]:
|
||||
raise ValueError(f"Changed upstream notice: {name}")
|
||||
shutil.copyfile(source, license_dir / name)
|
||||
shutil.copyfile(HERE / "notices/sources.json", license_dir / "NOTICE-SOURCES.json")
|
||||
npm = []
|
||||
for key, lock_record in sorted(wanted.items()):
|
||||
pkg = read_json(app / key / "package.json")
|
||||
if pkg.get("license") != lock_record.get("license") or pkg.get("license") not in REVIEWED_NPM_LICENSES:
|
||||
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 + "/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": native_source("@napi-rs/canvas-linux-x64-gnu"),
|
||||
}
|
||||
native_records = []
|
||||
for file, source in codex_native.items():
|
||||
hasher = hashlib.sha256()
|
||||
with (app / file).open("rb") as f:
|
||||
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,
|
||||
"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)]}
|
||||
(license_dir / "SOURCES.json").write_text(json.dumps(manifest, indent=2) + "\n")
|
||||
|
||||
|
||||
def stage_root(root):
|
||||
app = root / INSTALL
|
||||
app.mkdir(parents=True)
|
||||
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():
|
||||
if (not pkg["resolved"].startswith("https://registry.npmjs.org/")
|
||||
or not pkg["integrity"].startswith("sha512-") or pkg.get("hasInstallScript")):
|
||||
raise ValueError(f"Unexpected source, integrity, or lifecycle script: {name}")
|
||||
global_config = root.parent / "empty-npmrc"
|
||||
global_config.touch()
|
||||
subprocess.run([
|
||||
"npm", "ci", "--os=linux", "--cpu=x64", "--libc=glibc", "--omit=dev",
|
||||
"--include=optional", "--ignore-scripts", "--no-audit", "--no-fund",
|
||||
"--userconfig=/dev/null", f"--globalconfig={global_config}", "--registry=https://registry.npmjs.org",
|
||||
], cwd=app, check=True)
|
||||
# npm treats failed optional installs as success. Check the full target graph,
|
||||
# including platform packages, before accepting the install.
|
||||
installed = read_json(app / "node_modules/.package-lock.json")["packages"]
|
||||
wanted = {k: v for k, v in packages.items() if matches_target(v)}
|
||||
if installed.keys() != wanted.keys():
|
||||
raise ValueError(f"Installed graph differs from lock: {sorted(installed.keys() ^ wanted.keys())}")
|
||||
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}")
|
||||
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"):
|
||||
binary = app / VENDOR / name
|
||||
with binary.open("rb") as f:
|
||||
header = f.read(20)
|
||||
if header[:6] != b"\x7fELF\x02\x01" or header[18:20] != b"\x3e\x00" or not os.access(binary, os.X_OK):
|
||||
raise ValueError(f"Missing executable ELF64 x86-64 {name}")
|
||||
for name in (".codex-plugin/plugin.json", "scripts/launch_codex_security_mcp", "mcp/native/linux-x64-gnu/unix.node", "mcp/server.mjs", "mcp/native/THIRD_PARTY_NOTICES.txt"):
|
||||
if not (app / SDK / "_bundled_plugin" / name).is_file():
|
||||
raise ValueError(f"Incomplete bundled plugin: {name}")
|
||||
bindir = root / "usr/bin"
|
||||
bindir.mkdir()
|
||||
for name in ("cs", "codex-security"):
|
||||
(bindir / name).symlink_to("../lib/codex-security/" + SDK + "/bin/codex-security.mjs")
|
||||
for source, (dest, sha) in EXTRAS.items():
|
||||
data = source.read_bytes()
|
||||
if hashlib.sha256(data).hexdigest() != sha:
|
||||
raise ValueError(f"Release file differs from pin: {source.name}")
|
||||
path = root / dest
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_bytes(data)
|
||||
path.chmod(0o755 if source.suffix == ".sh" else 0o644)
|
||||
write_attributions(root, app, wanted)
|
||||
return len(wanted)
|
||||
|
||||
|
||||
def normalize(entry):
|
||||
if not (entry.isdir() or entry.isreg() or entry.issym()):
|
||||
raise ValueError(f"Unexpected file type: {entry.name}")
|
||||
entry.uid = entry.gid = entry.mtime = 0
|
||||
entry.uname = entry.gname = "root"
|
||||
entry.mode = (0o777 if entry.issym() else 0o755 if entry.isdir() or entry.mode & 0o111 else 0o644)
|
||||
return entry
|
||||
|
||||
|
||||
def main():
|
||||
args = argparse.ArgumentParser(description=__doc__)
|
||||
args.add_argument("stage", type=Path, help="melange --source-dir (only payload.tar.gz will be written)")
|
||||
output = args.parse_args().stage.resolve()
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
with tempfile.TemporaryDirectory(prefix="codex-security-payload-") as work:
|
||||
root = Path(work) / "root"
|
||||
count = stage_root(root)
|
||||
# The recipe pins the uncompressed tar hash, independent of gzip/zlib.
|
||||
# Normalize sort order, mtime, owners and permissions across build hosts.
|
||||
with tempfile.NamedTemporaryFile(dir=output, prefix="payload-", delete=False) as temp:
|
||||
temporary = Path(temp.name)
|
||||
try:
|
||||
with temporary.open("wb") as raw, gzip.GzipFile(filename="", mode="wb", fileobj=raw, compresslevel=3, mtime=0) as gz:
|
||||
with tarfile.open(fileobj=gz, mode="w|", format=tarfile.GNU_FORMAT) as archive:
|
||||
archive.add(root / "usr", arcname="usr", filter=normalize)
|
||||
digest = hashlib.sha256()
|
||||
with gzip.open(temporary, "rb") as gz:
|
||||
while chunk := gz.read(1024 * 1024):
|
||||
digest.update(chunk)
|
||||
temporary.chmod(0o644)
|
||||
temporary.replace(output / "payload.tar.gz")
|
||||
print(f"{count} locked production packages; uncompressed tar SHA-256: {digest.hexdigest()}")
|
||||
finally:
|
||||
temporary.unlink(missing_ok=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Add the verified scanner payload to apko's single-platform SPDX document."""
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path, PurePosixPath
|
||||
from urllib.parse import quote
|
||||
|
||||
|
||||
def enrich(sbom, components):
|
||||
packages = sbom["packages"]
|
||||
image, = (p for p in packages if p["SPDXID"] in sbom["documentDescribes"])
|
||||
if image["name"] != components["image_manifest"]:
|
||||
raise ValueError("apko SBOM and payload inventory describe different images")
|
||||
apk, = (p for p in packages if p["name"] == "codex-security")
|
||||
install = PurePosixPath("/usr/lib/codex-security")
|
||||
|
||||
def add(parent_id, package):
|
||||
packages.append(package)
|
||||
sbom["relationships"].append({"spdxElementId": parent_id, "relationshipType": "CONTAINS",
|
||||
"relatedSpdxElement": package["SPDXID"]})
|
||||
|
||||
# Use the manifest name for npm aliases, but keep each installed path distinct.
|
||||
npm_ids = {}
|
||||
for i, item in enumerate(components["installed_npm"]):
|
||||
path = PurePosixPath(item["path"])
|
||||
npm_ids[path] = f"SPDXRef-npm-{i}"
|
||||
name, version = item["name"], item["version"]
|
||||
purl = f"pkg:npm/{quote(name)}@{quote(version, safe='')}"
|
||||
checksum = base64.b64decode(item["integrity"].removeprefix("sha512-"), validate=True).hex()
|
||||
add(apk["SPDXID"], {
|
||||
"SPDXID": npm_ids[path], "name": name, "versionInfo": version,
|
||||
"downloadLocation": item["source"], "licenseDeclared": item["license"],
|
||||
"filesAnalyzed": False, "sourceInfo": f"Installed at {install / path}; SHA512 identifies the source archive.",
|
||||
"checksums": [{"algorithm": "SHA512", "checksumValue": checksum}],
|
||||
"externalRefs": [{"referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl",
|
||||
"referenceLocator": purl}],
|
||||
})
|
||||
|
||||
for i, item in enumerate(components["bundled_native"]):
|
||||
path = PurePosixPath(item["path"])
|
||||
owner = next(npm_ids[p] for p in path.parents if p in npm_ids)
|
||||
add(owner, {
|
||||
"SPDXID": f"SPDXRef-native-{i}", "name": path.name, "primaryPackagePurpose": "FILE",
|
||||
"packageFileName": str(install / path), "downloadLocation": "NOASSERTION",
|
||||
"filesAnalyzed": False, "sourceInfo": item["source"],
|
||||
"checksums": [{"algorithm": "SHA256", "checksumValue": item["sha256"]}],
|
||||
})
|
||||
|
||||
# A changed SPDX document needs its own namespace, distinct from apko's original.
|
||||
sbom["creationInfo"]["creators"].append("Tool: codex-security/release-sbom.py")
|
||||
digest = hashlib.sha256(json.dumps(sbom, sort_keys=True).encode()).hexdigest()
|
||||
sbom["documentNamespace"] = f"https://github.com/openai/codex-security/spdx/wolfi-{digest}"
|
||||
return sbom
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("sbom", type=Path)
|
||||
parser.add_argument("components", type=Path)
|
||||
parser.add_argument("destination", type=Path)
|
||||
args = parser.parse_args()
|
||||
result = enrich(json.loads(args.sbom.read_bytes()), json.loads(args.components.read_bytes()))
|
||||
args.destination.write_text(json.dumps(result, indent=2) + "\n")
|
||||
@@ -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"
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage the APKs from a verified apko builder lock for an offline Melange build."""
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from urllib.request import HTTPRedirectHandler, build_opener
|
||||
|
||||
ARCH = "x86_64"
|
||||
REPO = "https://packages.wolfi.dev/os/" + ARCH
|
||||
|
||||
|
||||
class NoRedirect(HTTPRedirectHandler):
|
||||
def redirect_request(self, *args):
|
||||
return None # Only fetch the exact URLs in the lock.
|
||||
|
||||
|
||||
def stage_package(pkg, directory, fetch):
|
||||
name, version = pkg["name"], pkg["version"]
|
||||
filename = f"{name}-{version}.apk"
|
||||
if not all(re.fullmatch(r"[a-zA-Z0-9][a-zA-Z0-9.+_~-]*", s) for s in (name, version)):
|
||||
raise ValueError(f"Invalid package name or version: {filename}")
|
||||
if pkg["architecture"] != ARCH or pkg["url"] != f"{REPO}/{filename}":
|
||||
raise ValueError(f"Unexpected package source or architecture: {filename}")
|
||||
|
||||
with (directory / filename).open("xb") as dest, fetch(pkg["url"], timeout=60) as source:
|
||||
offset = 0
|
||||
for part, algorithm in (("signature", "sha1"), ("control", "sha1"), ("data", "sha256")):
|
||||
record = pkg[part]
|
||||
if part == "signature" and record == {"range": "", "checksum": ""}:
|
||||
continue
|
||||
match = re.fullmatch(r"bytes=([0-9]+)-([0-9]+)", record["range"])
|
||||
if not match or int(match[1]) != offset or int(match[2]) < offset:
|
||||
raise ValueError(f"{filename}: invalid {part} range {record['range']!r}")
|
||||
length = int(match[2]) + 1 - offset
|
||||
block = source.read(length)
|
||||
digest = base64.b64encode(hashlib.new(algorithm, block).digest()).decode("ascii")
|
||||
if len(block) != length or f"{algorithm}-{digest}" != record["checksum"]:
|
||||
raise ValueError(f"{filename}: {part} differs from builder lock")
|
||||
dest.write(block)
|
||||
offset += length
|
||||
if source.read(1):
|
||||
raise ValueError(f"{filename}: bytes beyond locked ranges")
|
||||
|
||||
|
||||
def snapshot(lock, output, fetch):
|
||||
if lock["version"] != "v1" or not lock["contents"]["packages"]:
|
||||
raise ValueError("Expected a nonempty apko v1 builder lock")
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
if output.is_symlink() or any(output.iterdir()):
|
||||
raise ValueError("Builder repository must be a new or empty directory")
|
||||
with tempfile.TemporaryDirectory(dir=output) as staging:
|
||||
packages = Path(staging) / ARCH
|
||||
packages.mkdir()
|
||||
for pkg in lock["contents"]["packages"]:
|
||||
stage_package(pkg, packages, fetch)
|
||||
packages.rename(output / ARCH) # Publish only after the entire lock verifies.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("lock", type=Path)
|
||||
parser.add_argument("repository", type=Path)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
snapshot(json.loads(args.lock.read_bytes()), args.repository, build_opener(NoRedirect()).open)
|
||||
except (KeyError, ValueError, OSError) as exc:
|
||||
parser.exit(1, f"Could not stage builder repository: {exc}\n")
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Use as MELANGE for a build: the guest must install from the local snapshot
|
||||
# even when melange itself has no route to the upstream repository.
|
||||
set -euo pipefail
|
||||
if [[ $1 == build ]]; then
|
||||
exec unshare --net -- "${REAL_MELANGE:-melange}" "$@"
|
||||
fi
|
||||
exec "${REAL_MELANGE:-melange}" "$@"
|
||||
@@ -0,0 +1,167 @@
|
||||
// Read from stdin in a fresh isolated container by smoke.sh.
|
||||
import assert from "node:assert/strict";
|
||||
import { execFile, execFileSync, spawnSync } from "node:child_process";
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import { accessSync, constants, mkdtempSync, readFileSync,
|
||||
realpathSync, statSync, writeFileSync } from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
import { createServer } from "node:http";
|
||||
import { once } from "node:events";
|
||||
import { dirname, join } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const run = (cmd, args, opts = {}) => execFileSync(cmd, args, {
|
||||
encoding: "utf8", stdio: ["pipe", "pipe", "pipe"], timeout: 180_000,
|
||||
maxBuffer: 16 * 1024 * 1024, ...opts
|
||||
}).trim();
|
||||
const read = (file) => JSON.parse(readFileSync(file, "utf8"));
|
||||
const cli = (...args) => JSON.parse(run("/usr/local/bin/codex-security-entrypoint", [...args, "--json"]));
|
||||
|
||||
assert.equal(process.getuid(), 10001);
|
||||
assert.equal(process.getgid(), 10001);
|
||||
assert.equal(process.cwd(), "/state");
|
||||
assert.equal(process.env.HOME, "/state");
|
||||
assert.equal(process.env.CODEX_HOME, "/state");
|
||||
assert.equal(process.env.CODEX_SECURITY_STATE_DIR, "/output/.codex-security-state");
|
||||
assert.equal(process.env.GIT_TERMINAL_PROMPT, "0");
|
||||
assert.equal(process.env.PYTHON, "/usr/bin/python3");
|
||||
accessSync("/input", constants.R_OK | constants.X_OK);
|
||||
for (const p of ["/state", "/output"]) accessSync(p, constants.W_OK | constants.X_OK);
|
||||
run(process.env.PYTHON, ["-c",
|
||||
"import ssl, sqlite3; assert ssl.create_default_context().get_ca_certs(); assert sqlite3.connect(':memory:').execute('select 1').fetchone() == (1,)"]);
|
||||
console.log("PASS non-root account, state directories, Python SQLite and CA trust");
|
||||
|
||||
const info = cli("info");
|
||||
const launcher = realpathSync(run("/bin/sh", ["-c", "command -v codex-security"]));
|
||||
const pkg = dirname(dirname(launcher));
|
||||
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}`);
|
||||
const plugin = join(pkg, "_bundled_plugin");
|
||||
const libc = process.report.getReport().header.glibcVersionRuntime ? "gnu" : "musl";
|
||||
const addon = join(plugin, "mcp/native", `linux-${process.arch}-${libc}`, "unix.node");
|
||||
assert.equal(createRequire(import.meta.url)(addon).unixEnvironment(Buffer.from("HOME")).toString(), "/state");
|
||||
const mcp = read(join(plugin, ".mcp.json")).mcpServers["codex-security"];
|
||||
const initialized = JSON.parse(run(join(plugin, mcp.command), mcp.args, { cwd: plugin,
|
||||
input: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "initialize", params: {
|
||||
protocolVersion: "2025-11-25", capabilities: {}, clientInfo: { name: "offline-image-test", version: "1" }
|
||||
} }) + "\n" }));
|
||||
assert.equal(initialized.result.serverInfo.name, "codex-security");
|
||||
console.log(`PASS native Codex ${info.codexVersion}, plugin addon and MCP startup on linux/${process.arch}; Node ${process.version}`);
|
||||
|
||||
const helper = "/usr/local/bin/codex-security-git-credential";
|
||||
const helperResult = (host) => run(helper, ["get"], { env: { ...process.env, GH_TOKEN: "fixture-only" },
|
||||
input: `protocol=https\nhost=${host}\n\n` });
|
||||
assert.equal(helperResult("github.com"), "username=x-access-token\npassword=fixture-only");
|
||||
assert.equal(helperResult("not-github.example"), "");
|
||||
console.log("PASS Git credential helper is limited to its configured host");
|
||||
|
||||
process.umask(0o077);
|
||||
const repo = mkdtempSync("/input/codex-smoke-");
|
||||
const scanDir = join(mkdtempSync("/output/codex-smoke-"), "scan");
|
||||
const source = join(repo, "hello.py");
|
||||
const original = 'print("offline fixture")\n';
|
||||
writeFileSync(source, original);
|
||||
const git = (...args) => run("git", ["-C", repo, ...args]);
|
||||
git("init", "-q"); git("add", "hello.py");
|
||||
git("-c", "user.name=Fixture", "-c", "user.email=fixture@example.invalid", "commit", "-qm", "fixture");
|
||||
// /input is a writable, disposable tmpfs in this test. Use the exact same
|
||||
// child in both cases to distinguish Codex confinement from a Docker mount.
|
||||
const probe = [process.env.PYTHON, "-c", `from pathlib import Path
|
||||
import errno,sys
|
||||
p=Path(sys.argv[1])
|
||||
if p.read_text() != sys.argv[2]: sys.exit(41)
|
||||
try: p.write_text("changed")
|
||||
except OSError as e: sys.exit({errno.EROFS:45, errno.EACCES:46, errno.EPERM:47}.get(e.errno, 48))
|
||||
sys.exit(42)`, source, original];
|
||||
const launch = (args) => spawnSync(args[0], args.slice(1), {cwd: repo, encoding: "utf8", timeout: 30_000});
|
||||
const control = launch(probe);
|
||||
assert.equal(control.status, 42, control.error?.message || control.stderr);
|
||||
assert.equal(readFileSync(source, "utf8"), "changed");
|
||||
writeFileSync(source, original);
|
||||
const sandbox = launch([codex, "sandbox", "--permission-profile", ":read-only", "--", ...probe]);
|
||||
const why = {45: "EROFS", 46: "EACCES", 47: "EPERM"}[sandbox.status];
|
||||
assert(why, `sandbox code=${sandbox.status} signal=${sandbox.signal}; ${sandbox.error?.message || sandbox.stderr}`);
|
||||
assert.equal(readFileSync(source, "utf8"), original);
|
||||
assert.equal(git("status", "--porcelain"), "");
|
||||
console.log(`PASS read-only sandbox: the child read hello.py and its write failed with ${why}; the same child wrote it outside, and the checkout is clean`);
|
||||
|
||||
// This turn goes through the installed native model client and its shell tool.
|
||||
// The only server is this loopback Responses fixture.
|
||||
const nonce = randomUUID();
|
||||
const draft = `python3 - <<'PY'
|
||||
import json,os
|
||||
from pathlib import Path
|
||||
assert (Path(os.environ["CODEX_SECURITY_REPOSITORY"])/"hello.py").read_text() == ${JSON.stringify(original)}
|
||||
out = Path(os.environ["CODEX_SECURITY_SCAN_DIR"])
|
||||
docs = {"scan-manifest.json":{"scan":{"target":{"kind":os.environ["CODEX_SECURITY_TARGET_KIND"]},
|
||||
"scope":{"summary":"Synthetic offline smoke test: ${nonce}"}}}, "findings.json":{"findings":[]},
|
||||
"coverage.json":{"inventoryStrategy":"repository","surfaces":[],"explicitExclusions":[],"deferred":[]}}
|
||||
for name,data in docs.items():
|
||||
with (out/name).open("x") as f: json.dump(data,f)
|
||||
print("fixture-draft-written")
|
||||
PY`;
|
||||
let requests = 0;
|
||||
let fixtureError;
|
||||
const server = createServer(async (req, res) => {
|
||||
try {
|
||||
assert.equal(req.method, "POST");
|
||||
assert.equal(req.url, "/openai/v1/responses");
|
||||
const chunks = [];
|
||||
for await (const chunk of req) chunks.push(chunk);
|
||||
const request = JSON.parse(Buffer.concat(chunks));
|
||||
requests++;
|
||||
let item;
|
||||
if (requests === 1) {
|
||||
assert(request.tools.some(t => t.name === "exec_command"));
|
||||
item = {type: "function_call", call_id: "draft", name: "exec_command",
|
||||
arguments: JSON.stringify({cmd: draft})};
|
||||
} else {
|
||||
assert.equal(requests, 2);
|
||||
assert(request.input.some(i => i.type === "function_call_output" && i.call_id === "draft" &&
|
||||
JSON.stringify(i.output).includes("fixture-draft-written")));
|
||||
item = {type: "message", role: "assistant", id: "reply", content: [{type: "output_text", text: nonce}]};
|
||||
}
|
||||
const response = {id: `r${requests}`, usage: {input_tokens: 1, output_tokens: 1, total_tokens: 2}};
|
||||
const events = [{type:"response.created",response}, {type:"response.output_item.done",item},
|
||||
{type:"response.completed",response}];
|
||||
res.writeHead(200, {"Content-Type": "text/event-stream"});
|
||||
res.end(events.map(e => `data: ${JSON.stringify(e)}\n\n`).join(""));
|
||||
} catch (error) {
|
||||
fixtureError = error;
|
||||
res.writeHead(400).end("invalid fixture request");
|
||||
}
|
||||
});
|
||||
server.listen(0, "127.0.0.1");
|
||||
await once(server, "listening");
|
||||
try {
|
||||
const base = `http://127.0.0.1:${server.address().port}/openai/v1`;
|
||||
await promisify(execFile)("/usr/local/bin/codex-security-entrypoint",
|
||||
["scan", repo, "--mode", "standard", "--headless", "--output-dir", scanDir, "--provider", "amazon-bedrock", "--model", "openai.gpt-5.6-luna",
|
||||
"--codex", `model_providers.amazon-bedrock.base_url="${base}"`, "--codex", 'model_providers.amazon-bedrock.aws.region="us-west-2"'],
|
||||
{env:{...process.env, AWS_ACCESS_KEY_ID:"offline-test", AWS_SECRET_ACCESS_KEY:"offline-test-only",
|
||||
AWS_REGION:"us-west-2", AWS_EC2_METADATA_DISABLED:"true", NO_PROXY:"127.0.0.1,localhost"},timeout:75_000});
|
||||
assert.ifError(fixtureError);
|
||||
assert.equal(requests, 2);
|
||||
const scan = read(join(scanDir, "scan-manifest.json")).scan;
|
||||
assert(scan.status === "completed" && scan.sealedAt && scan.scope.summary.includes(nonce));
|
||||
assert(scan.artifacts.length > 0);
|
||||
for (const artifact of scan.artifacts) {
|
||||
const sha256 = createHash("sha256").update(readFileSync(join(scanDir, artifact.path))).digest("hex");
|
||||
assert.equal(sha256, artifact.sha256, artifact.path);
|
||||
}
|
||||
assert.deepEqual(read(join(scanDir, "findings.json")).findings, []);
|
||||
assert.equal(read(join(scanDir, "exports/results.sarif")).version, "2.1.0");
|
||||
assert(statSync(join(process.env.CODEX_SECURITY_STATE_DIR, "workbench.sqlite3")).size > 0);
|
||||
assert(cli("scans", "list", repo).scans.some(s => s.scanId === scan.id));
|
||||
assert.equal(git("status", "--porcelain"), "");
|
||||
console.log("PASS loopback scan: native shell tool, sealed marker and artifact hashes, SARIF, SQLite history, unchanged source");
|
||||
} finally {
|
||||
server.closeAllConnections();
|
||||
server.close();
|
||||
}
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# Native Linux/amd64. Load the repository's Docker AppArmor profile first.
|
||||
# The offline fixture creates its own repository and output in disposable tmpfs.
|
||||
set -euo pipefail
|
||||
if (( $# != 1 )); then
|
||||
echo 'usage: tests/smoke.sh LOCAL_IMAGE' >&2
|
||||
exit 2
|
||||
fi
|
||||
test_dir=$(cd -- "$(dirname -- "$0")" && pwd)
|
||||
docker_dir=$(cd -- "$test_dir/../.." && pwd)
|
||||
case "$(docker info --format '{{.OSType}}/{{.Architecture}}')" in
|
||||
linux/x86_64|linux/amd64) ;;
|
||||
*) echo 'Run on native Linux/amd64 so the nested sandbox can be tested.' >&2; exit 2 ;;
|
||||
esac
|
||||
image=$(docker image inspect "$1" --format '{{.Id}}')
|
||||
[[ $(docker image inspect "$image" --format '{{.Os}}/{{.Architecture}} {{join .Config.Entrypoint " "}}') == 'linux/amd64 /usr/local/bin/codex-security-entrypoint' ]]
|
||||
echo "Image: $image"
|
||||
flags=(--rm --pull=never --network=none --read-only --cap-drop=ALL
|
||||
--security-opt=no-new-privileges --security-opt=apparmor=codex-security-container
|
||||
--security-opt="seccomp=$docker_dir/codex-security-seccomp.json"
|
||||
--tmpfs /tmp:rw,nodev,nosuid,mode=1777
|
||||
--tmpfs /input:rw,nodev,nosuid,uid=10001,gid=10001,mode=0755
|
||||
--tmpfs /output:rw,nodev,nosuid,uid=10001,gid=10001
|
||||
--tmpfs /state:rw,nodev,nosuid,uid=10001,gid=10001)
|
||||
|
||||
# Exercise the image's configured entrypoint & CMD before using Node as a harness.
|
||||
help=$(docker run "${flags[@]}" "$image")
|
||||
[[ $help == *'Usage: codex-security'* ]]
|
||||
version=$(docker run "${flags[@]}" "$image" --version)
|
||||
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'* ]]
|
||||
echo "PASS default help, version $version, and noninteractive bulk-scan guard"
|
||||
docker run "${flags[@]}" -i --entrypoint /usr/bin/node "$image" --input-type=module - < "$test_dir/runtime.mjs"
|
||||
@@ -0,0 +1,70 @@
|
||||
import base64
|
||||
import gzip
|
||||
import hashlib
|
||||
import io
|
||||
import runpy
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
snapshot = runpy.run_path(str(Path(__file__).resolve().parents[1] / "snapshot-builder.py"))["snapshot"]
|
||||
|
||||
|
||||
def fixture(name, signed):
|
||||
# APK v2 stores consecutive, independently compressed gzip members.
|
||||
url = f"https://packages.wolfi.dev/os/x86_64/{name}-1-r0.apk"
|
||||
pkg = {"name": name, "version": "1-r0", "url": url, "architecture": "x86_64"}
|
||||
data = b""
|
||||
for part, algorithm in (("signature", "sha1"), ("control", "sha1"), ("data", "sha256")):
|
||||
if part == "signature" and not signed:
|
||||
pkg[part] = {"range": "", "checksum": ""}
|
||||
continue
|
||||
block = gzip.compress(f"{name} {part}".encode(), mtime=0)
|
||||
digest = base64.b64encode(hashlib.new(algorithm, block).digest()).decode()
|
||||
pkg[part] = {"range": f"bytes={len(data)}-{len(data) + len(block) - 1}",
|
||||
"checksum": f"{algorithm}-{digest}"}
|
||||
data += block
|
||||
return pkg, data
|
||||
|
||||
|
||||
class SnapshotTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.first, self.a = fixture("first", signed=False)
|
||||
self.second, self.b = fixture("second", signed=True)
|
||||
self.lock = {"version": "v1", "contents": {"packages": [self.first, self.second]}}
|
||||
self.served = {self.first["url"]: self.a, self.second["url"]: self.b}
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.repo = Path(temp.name) / "repository"
|
||||
|
||||
def fetch(self, url, *, timeout):
|
||||
return io.BytesIO(self.served[url])
|
||||
|
||||
def test_stages_exact_bytes_for_signed_and_unsigned_packages(self):
|
||||
snapshot(self.lock, self.repo, self.fetch)
|
||||
apks = {f.name: f.read_bytes() for f in (self.repo / "x86_64").iterdir()}
|
||||
self.assertEqual(apks, {"first-1-r0.apk": self.a, "second-1-r0.apk": self.b})
|
||||
|
||||
def test_same_url_tampering_never_publishes_a_partial_repository(self):
|
||||
corrupt = {"truncated": self.b[:-1], "extra": self.b + b"x"}
|
||||
for part in ("signature", "control", "data"):
|
||||
offset = int(self.second[part]["range"].split("=")[1].split("-")[0])
|
||||
corrupt[part] = self.b[:offset] + bytes([self.b[offset] ^ 1]) + self.b[offset + 1:]
|
||||
for case, changed in corrupt.items():
|
||||
with self.subTest(case=case):
|
||||
self.served[self.second["url"]] = changed
|
||||
with self.assertRaises(ValueError):
|
||||
snapshot(self.lock, self.repo, self.fetch)
|
||||
self.assertEqual(list(self.repo.iterdir()), [])
|
||||
|
||||
def test_refuses_a_gap_before_control_and_an_unlocked_origin(self):
|
||||
self.first["control"]["range"] = self.first["control"]["range"].replace("bytes=0-", "bytes=1-")
|
||||
with self.assertRaisesRegex(ValueError, "invalid control range"):
|
||||
snapshot(self.lock, self.repo, self.fetch)
|
||||
self.first["url"] = "https://example.org/first-1-r0.apk"
|
||||
with self.assertRaisesRegex(ValueError, "Unexpected package source"):
|
||||
snapshot(self.lock, self.repo, self.fetch)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Copy a verified single-platform apko archive into a new OCI image layout.
|
||||
|
||||
Verify the build's signed SHA256SUMS before using its image.tar and verification.json.
|
||||
The layout names its single image 'wolfi'. The OCI manifest, config and compressed
|
||||
layer bytes remain identical. No registry access is needed.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import tarfile
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def convert(archive, verification, destination):
|
||||
if destination.exists() or destination.is_symlink():
|
||||
raise ValueError(f"Destination already exists: {destination}")
|
||||
expected = json.loads(verification.read_bytes())
|
||||
with tempfile.TemporaryDirectory(dir=destination.parent) as tmp, tarfile.open(archive, "r:") as tar:
|
||||
layout = Path(tmp) / "layout"
|
||||
blobs = layout / "blobs" / "sha256"
|
||||
blobs.mkdir(parents=True)
|
||||
members = tar.getmembers()
|
||||
entries = {m.name: m for m in members}
|
||||
if len(entries) != len(members):
|
||||
raise ValueError("Archive contains duplicate member names")
|
||||
|
||||
def member(name):
|
||||
m = entries[name]
|
||||
if not m.isfile():
|
||||
raise ValueError(f"Expected a regular archive member: {name}")
|
||||
return m
|
||||
|
||||
def copy_blob(name, desc):
|
||||
digest = desc["digest"]
|
||||
if not re.fullmatch(r"sha256:[0-9a-f]{64}", digest):
|
||||
raise ValueError(f"Invalid blob digest: {digest}")
|
||||
m = member(name)
|
||||
if type(desc["size"]) is not int or m.size != desc["size"]:
|
||||
raise ValueError(f"Size mismatch: {name}")
|
||||
path = blobs / digest.split(":")[1]
|
||||
h = hashlib.sha256()
|
||||
total = 0
|
||||
with tar.extractfile(m) as source, path.open("wb") as dest:
|
||||
for chunk in iter(lambda: source.read(1 << 20), b""):
|
||||
dest.write(chunk)
|
||||
total += len(chunk)
|
||||
h.update(chunk)
|
||||
if total != desc["size"] or "sha256:" + h.hexdigest() != digest:
|
||||
raise ValueError(f"Blob does not match its descriptor: {name}")
|
||||
return path
|
||||
|
||||
with tar.extractfile(member("index.json")) as f:
|
||||
index = json.load(f)
|
||||
descriptor, = index["manifests"]
|
||||
if (index["schemaVersion"] != 2 or index["mediaType"] != "application/vnd.oci.image.index.v1+json"
|
||||
or descriptor["mediaType"] != "application/vnd.oci.image.manifest.v1+json"
|
||||
or descriptor["digest"] != expected["oci_manifest"]):
|
||||
raise ValueError("OCI manifest does not match verification.json")
|
||||
platform = descriptor["platform"]
|
||||
if f"{platform['os']}/{platform['architecture']}" != expected["platform"]:
|
||||
raise ValueError("OCI platform does not match verification.json")
|
||||
manifest = json.loads(copy_blob(descriptor["digest"], descriptor).read_bytes())
|
||||
if (manifest["schemaVersion"] != 2 or manifest["mediaType"] != descriptor["mediaType"]
|
||||
or manifest["config"]["digest"] != expected["config_digest"]):
|
||||
raise ValueError("Unexpected OCI manifest or configuration digest")
|
||||
with tar.extractfile(member("manifest.json")) as f:
|
||||
docker, = json.load(f)
|
||||
config = json.loads(copy_blob(docker["Config"], manifest["config"]).read_bytes())
|
||||
if any(config[k] != platform[k] for k in ("os", "architecture")):
|
||||
raise ValueError("OCI config and platform descriptor disagree")
|
||||
if len(docker["Layers"]) != len(manifest["layers"]):
|
||||
raise ValueError("Docker and OCI layer counts disagree")
|
||||
for name, desc in zip(docker["Layers"], manifest["layers"]):
|
||||
copy_blob(name, desc)
|
||||
(layout / "oci-layout").write_bytes(b'{"imageLayoutVersion":"1.0.0"}\n')
|
||||
descriptor.setdefault("annotations", {})["org.opencontainers.image.ref.name"] = "wolfi"
|
||||
(layout / "index.json").write_text(json.dumps(index, separators=(",", ":")) + "\n")
|
||||
layout.rename(destination)
|
||||
return descriptor["digest"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("archive", type=Path, help="Verified apko image.tar")
|
||||
parser.add_argument("verification", type=Path, help="Build's verification.json")
|
||||
parser.add_argument("destination", type=Path, help="New layout directory (parent must exist)")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
print(convert(args.archive, args.verification, args.destination))
|
||||
except (KeyError, OSError, ValueError, tarfile.TarError) as exc:
|
||||
parser.exit(1, f"Failed to convert archive: {exc}\n")
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Verify the release lock's scanner archive against the signed npm provenance.
|
||||
set -euo pipefail
|
||||
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/
|
||||
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
|
||||
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
|
||||
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify the local apko image and write verification.json and public-components.json."""
|
||||
import argparse
|
||||
import gzip
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
|
||||
WOLFI = "https://packages.wolfi.dev/os"
|
||||
REGISTRY = "https://registry.npmjs.org/"
|
||||
APP = "usr/lib/codex-security/"
|
||||
ENTRYPOINT = "/usr/local/bin/codex-security-entrypoint"
|
||||
SOURCES = "usr/share/licenses/codex-security/SOURCES.json"
|
||||
APK_DATABASES = {"lib/apk/db/installed", "usr/lib/apk/db/installed"}
|
||||
# A package can contain other package.json files (for example, in examples/).
|
||||
NPM_MANIFEST = re.compile(r"(?:node_modules/(?:@[^/]+/)?[^/]+/)+package\.json")
|
||||
LICENSES = set("""MIT Apache-2.0 BSD-1-Clause BSD-2-Clause BSD-3-Clause BSD-4-Clause-UC
|
||||
ISC CC0-1.0 MPL-2.0 PSF-2.0 OLDAP-2.8 Artistic-1.0-Perl GPL-1.0-only GPL-1.0-or-later
|
||||
GPL-2.0-only GPL-2.0-or-later GPL-3.0-or-later LGPL-2.0-or-later LGPL-2.1 LGPL-2.1-only
|
||||
LGPL-2.1-or-later LGPL-3.0-or-later GCC-exception-3.1 libselinux-1.0 blessing CC-PDDC AND OR WITH""".split())
|
||||
|
||||
def check(ok, message):
|
||||
if not ok:
|
||||
raise SystemExit(message)
|
||||
|
||||
def check_license(name, expression):
|
||||
terms = set(re.findall(r"[\w.+-]+", expression or ""))
|
||||
check(terms and not (terms - LICENSES), f"Unreviewed license for {name}: {expression}")
|
||||
|
||||
class HashingReader:
|
||||
"""Hash what the gzip and tar readers consume, including trailing tar padding."""
|
||||
|
||||
def __init__(self, stream):
|
||||
self.stream = stream
|
||||
self.hash = hashlib.sha256()
|
||||
|
||||
def read(self, size):
|
||||
chunk = self.stream.read(size)
|
||||
self.hash.update(chunk)
|
||||
return chunk
|
||||
|
||||
@property
|
||||
def digest(self):
|
||||
return "sha256:" + self.hash.hexdigest()
|
||||
|
||||
|
||||
def read_blob(tar, descriptor):
|
||||
data = tar.extractfile(descriptor["digest"]).read()
|
||||
check(len(data) == descriptor["size"] and "sha256:" + hashlib.sha256(data).hexdigest() == descriptor["digest"],
|
||||
f"OCI blob does not match descriptor: {descriptor['digest']}")
|
||||
return json.loads(data)
|
||||
|
||||
|
||||
def inspect_layer(fs):
|
||||
raw, manifests, keys, native = {}, {}, {}, {}
|
||||
executable = False
|
||||
for ent in fs:
|
||||
path = ent.name.removeprefix("./")
|
||||
check(path.rsplit("/", 1)[-1] != "melange.rsa", f"Signing private key in the image: {path}")
|
||||
if path == ENTRYPOINT.lstrip("/"):
|
||||
bit = 0o100 if ent.uid == 10001 else 0o010 if ent.gid == 10001 else 0o001
|
||||
executable = ent.isfile() and bool(ent.mode & bit)
|
||||
elif path.startswith("etc/apk/keys/"):
|
||||
check(ent.isfile(), f"Unexpected public key format: {path}")
|
||||
keys[path.removeprefix("etc/apk/keys/")] = fs.extractfile(ent).read()
|
||||
elif ent.isfile():
|
||||
if path in APK_DATABASES or path in {"etc/apk/repositories", APP + "package-lock.json", SOURCES}:
|
||||
raw[path] = fs.extractfile(ent).read()
|
||||
elif path.startswith(APP) and NPM_MANIFEST.fullmatch(path[len(APP):]):
|
||||
manifests[path[len(APP):-len("/package.json")]] = json.load(fs.extractfile(ent))
|
||||
elif ("/@openai/codex-linux-x64/vendor/" in path and ent.mode & 0o111) or (path.startswith(APP) and path.endswith(".node")):
|
||||
h = hashlib.sha256()
|
||||
stream = fs.extractfile(ent)
|
||||
for chunk in iter(lambda: stream.read(1024 * 1024), b""):
|
||||
h.update(chunk)
|
||||
native[path] = h.hexdigest()
|
||||
check(executable, "Expected a regular entrypoint executable by UID/GID 10001")
|
||||
return raw, manifests, keys, native
|
||||
|
||||
|
||||
def inventory_apks(database, packages):
|
||||
apks = []
|
||||
lock = {p["name"]:p for p in packages}
|
||||
for record in database.decode().strip().split("\n\n"):
|
||||
fields = dict(line.split(":",1) for line in record.splitlines() if line[:2] in {"P:","V:","L:","o:"})
|
||||
name, version, license = fields["P"],fields["V"],fields["L"]
|
||||
check_license(name, license)
|
||||
item = lock.pop(name)
|
||||
check(item["version"] == version, "Lock version mismatch: "+name)
|
||||
url = f"{WOLFI}/x86_64/{name}-{version}.apk"
|
||||
if name == "codex-security":
|
||||
url = f"./packages/x86_64/{name}-{version}.apk"
|
||||
check(item["url"] == url, "Unexpected package source: "+item["url"])
|
||||
apks.append({"name":name, "version":version, "origin":fields["o"], "license":license, "source":url})
|
||||
check(not lock, "Missing locked APKs")
|
||||
return sorted(apks, key=lambda p: p["name"])
|
||||
|
||||
|
||||
def inventory_npm(manifests, packages, sources):
|
||||
paths = {p["path"] for p in sources}
|
||||
check(len(paths) == len(sources) and paths == manifests.keys(),
|
||||
"Installed npm package paths differ from SOURCES.json")
|
||||
npm = []
|
||||
for item in sources:
|
||||
path = item["path"]
|
||||
pkg = packages[path]
|
||||
meta = manifests[path]
|
||||
check(pkg["resolved"].startswith(REGISTRY) and pkg["integrity"].startswith("sha512-"), "Unexpected npm source: "+path)
|
||||
# npm aliases have a different package name from their installed path.
|
||||
identity = (pkg.get("name", path.rsplit("node_modules/", 1)[-1]), pkg["version"], pkg["license"])
|
||||
check(identity == (meta["name"], meta["version"], meta["license"]) == (item["name"], item["version"], item["license"]),
|
||||
"npm metadata mismatch: "+path)
|
||||
check((pkg["resolved"], pkg["integrity"]) == (item["input_archive"], item["integrity"]), "npm source mismatch: "+path)
|
||||
check_license(path, meta["license"])
|
||||
repository = meta.get("repository")
|
||||
npm.append({"path":path, "name":meta["name"], "version":meta["version"], "license":meta["license"],
|
||||
"source":pkg["resolved"], "integrity":pkg["integrity"],
|
||||
"source_repository":repository.get("url") if isinstance(repository,dict) else repository})
|
||||
return npm
|
||||
|
||||
|
||||
def verify(archive, lock):
|
||||
with tarfile.open(archive) as tar:
|
||||
manifest, = json.load(tar.extractfile("manifest.json"))
|
||||
index, = json.load(tar.extractfile("index.json"))["manifests"]
|
||||
platform = {"architecture": "amd64", "os": "linux"}
|
||||
check(index["platform"] == platform, "Expected Linux amd64")
|
||||
oci = read_blob(tar, index)
|
||||
check(manifest["Config"] == oci["config"]["digest"], "Docker and OCI configuration disagree")
|
||||
config = read_blob(tar, oci["config"])
|
||||
check(all(config[k] == v for k, v in platform.items()), "Unexpected image platform")
|
||||
c = config["config"]
|
||||
check((c["Entrypoint"], c["Cmd"], c["User"]) == ([ENTRYPOINT], ["--help"], "10001:10001"),
|
||||
"Unexpected entrypoint, default command or user")
|
||||
layer, = manifest["Layers"]
|
||||
descriptor, = oci["layers"]
|
||||
check(tar.getmember(layer).size == descriptor["size"], "OCI layer size mismatch")
|
||||
with tar.extractfile(layer) as stream:
|
||||
compressed = HashingReader(stream)
|
||||
with gzip.GzipFile(fileobj=compressed, mode="rb") as gz:
|
||||
uncompressed = HashingReader(gz)
|
||||
with tarfile.open(fileobj=uncompressed, mode="r|", bufsize=1024*1024) as fs:
|
||||
raw, manifests, keys, native = inspect_layer(fs)
|
||||
while uncompressed.read(1024*1024): # gzip trailer and any remaining tar padding
|
||||
pass
|
||||
check(compressed.digest == descriptor["digest"], "Compressed layer checksum mismatch")
|
||||
check(config["rootfs"]["diff_ids"] == [uncompressed.digest], "Uncompressed layer checksum mismatch")
|
||||
repos = raw["etc/apk/repositories"].decode().splitlines()
|
||||
check(repos == [WOLFI], "Unexpected runtime repository")
|
||||
expected = {Path(k["name"]).name: k["content"].encode() for k in lock["keyring"]}
|
||||
check(set(expected) == {"wolfi-signing.rsa.pub", "melange.rsa.pub"} and keys == expected, "Incorrect runtime APK trust keys")
|
||||
key_hashes = {name: hashlib.sha256(data).hexdigest() for name, data in sorted(keys.items())}
|
||||
databases = {raw[p] for p in APK_DATABASES if p in raw}
|
||||
check(len(databases) == 1, "Missing or conflicting installed APK database")
|
||||
apks = inventory_apks(databases.pop(), lock["packages"])
|
||||
local = sum(p["name"] == "codex-security" for p in apks)
|
||||
check(local == 1, "Expected one local scanner APK")
|
||||
src = json.loads(raw[SOURCES])
|
||||
npm = inventory_npm(manifests, json.loads(raw[APP+"package-lock.json"])["packages"], src["npm"])
|
||||
records = src["native_executables_and_addons"]
|
||||
check(len(records) == 6 and all(p["source"].startswith("https://github.com/") for p in records),
|
||||
"Unknown native runtime source")
|
||||
check({APP+p["path"]:p["sha256"] for p in records} == native, "Native files differ from source inventory")
|
||||
components = {"image_manifest":index["digest"], "platform":"linux/amd64", "apk_repository":WOLFI,
|
||||
"apk_trust_sha256":key_hashes, "apk_count":len(apks), "installed_apks":apks,
|
||||
"npm_package_count":len(npm), "installed_npm":npm, "bundled_native":records,
|
||||
"scope":"Installed package sources and declared licenses. The model service is external to the image."
|
||||
}
|
||||
verification = {"platform":"linux/amd64", "tag":manifest["RepoTags"][0], "config_digest":manifest["Config"],
|
||||
"oci_manifest":index["digest"], "runtime_repositories":repos, "entrypoint":ENTRYPOINT, "user":c["User"],
|
||||
"public_upstream_packages":len(apks)-local, "local_scanner_packages":local,
|
||||
"keyring_sha256":{k:"sha256:"+v for k,v in key_hashes.items()},
|
||||
"signed_build_manifest":"SHA256SUMS", "manifest_signature":"SHA256SUMS.sig"}
|
||||
return {"verification.json": verification, "public-components.json": components}
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("archive", type=Path)
|
||||
parser.add_argument("lock", type=Path)
|
||||
args = parser.parse_args()
|
||||
reports = verify(args.archive, json.loads(args.lock.read_bytes())["contents"])
|
||||
for name, report in reports.items():
|
||||
Path(name).write_text(json.dumps(report, indent=2) + "\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,14 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA5qQUHmzqX9oa/RS3OSgL
|
||||
YTYB1mzvVmnWC0JXsAafdgRkavJ9xRhsXMKXWPKMghZw6UnkxuxQCZlB9UhaFqed
|
||||
X7SWfQ8qRgECFmdGUjoeV7P3VUkg17RU0mUKsXZZF/2mU+jCGyk5eweKcLWrk6bn
|
||||
lNNF1vBJ9EXbHdfvbQsA5GfLku5tJhqRJ4FVQAGCw+1JoSKu+o3q+6xP7z6kMfR9
|
||||
cp54FSj48rTJUibbAv+cPtZ3AnbpjdyarV7SYMfxp14Q/KR0CJYDihG3CFoU+TaM
|
||||
dr7LUrgXaYw7m7g8hA2PY1jF8aqDqVFjVu/csPKnKVQSqNHfm4C4gljwT6TDVhPe
|
||||
6xKSGKfAUNvHx2RIqSsZJCh68Af+VnfuimbHMYzGhzV4/efihpJlYsDnOXJj/PeY
|
||||
SbEIYG2yoI3AYvDFyFX2OAOtQ9d4TPs4zS4aDg4R3UseXLib46FX3ZTfIi1/W0IO
|
||||
eC3AFU5mK+02jq+7swcGbgzem30dFA/B3n8NQExJjF2WlGNJxFw2WnJQqKIkIh0s
|
||||
km5jaxJ28xYgik+bEgxy1LsilKTowdkbEPRKv36JGdap4dOEGR+LwZsM+ontF1AO
|
||||
wY6tvwtZKJWhgj7ES3BdtiC1GA2htFnP90lA7KnKbSMOxwWtSCH8spitdPdzgI8G
|
||||
SxrOb0SZs6ZFAxYYe3GlvS0CAwEAAQ==
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -28,12 +28,30 @@ Codex plugin session.
|
||||
|
||||
## Choose a task
|
||||
|
||||
To review a skill before giving it to a coding agent, ask
|
||||
[`$check-skills`](../plugins/codex-security/skills/check-skills/SKILL.md) directly:
|
||||
|
||||
> Use $check-skills on ../downloaded-skills before I install them in Claude Code.
|
||||
|
||||
Start the chat in a trusted workspace with the Codex Security checker enabled.
|
||||
Keep the downloaded checkout outside the host's skill discovery paths and pass
|
||||
its path to the checker. If you already opened the checkout as your workspace
|
||||
or enabled its skills, start a clean chat with the target outside discovery.
|
||||
The previous chat may have loaded its `AGENTS.md` or a replacement checker.
|
||||
|
||||
Point it at a file, an extracted bundle, a checkout containing several skills,
|
||||
or paste the skill text. It returns a per-skill **PASS**, **REVIEW**, **BLOCK**,
|
||||
or **INCOMPLETE** with source evidence and coverage limits. A file review covers
|
||||
only that file. Supply the folder to include helpers and references. The review
|
||||
does not install the target or require the plugin MCP server.
|
||||
|
||||
| Task | In Codex | From the terminal |
|
||||
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Find vulnerabilities in a repository or selected paths | [`$security-scan`](../plugins/codex-security/skills/security-scan/SKILL.md): one Standard audit. | `cs scan .`, optionally `--path src`. |
|
||||
| Review a PR, commit, branch diff, or working-tree patch | [`$security-diff-scan`](../plugins/codex-security/skills/security-diff-scan/SKILL.md): review changes and trace their supporting code. | `cs scan . --diff origin/main` for committed changes, or `cs scan . --working-tree` for local changes. |
|
||||
| Investigate a repository or paths deeply | [`$deep-security-scan`](../plugins/codex-security/skills/deep-security-scan/SKILL.md): repeated independent audits; excludes diff reviews. | `cs scan . --mode deep`. |
|
||||
| Triage supplied reports or claims | [`$triage-finding`](../plugins/codex-security/skills/triage-finding/SKILL.md): one static-evidence verdict per finding, with proof gaps. | `cs validate findings.json` also assesses supplied claims using static evidence; its output contract differs from plugin triage. See [validation](../sdk/typescript/docs/cli.md#validate-and-patch-findings). |
|
||||
| Resolve a vulnerable dependency | [`$resolve-dependency-alert`](../plugins/codex-security/skills/resolve-dependency-alert/SKILL.md) traces affected versions and prepares an upgrade or dismissal proposal. | With external imports enabled, read saved alerts with `cs findings imported ./project --format json`. |
|
||||
| Fix a security finding | Explicitly request [`$fix-finding`](../plugins/codex-security/skills/fix-finding/SKILL.md) with the finding and affected repository. | `cs patch --scan SCAN_ID`; see [patching](../sdk/typescript/docs/cli.md#patch-existing-findings) for individual findings and options. |
|
||||
| Check an existing security fix | Explicitly request [`$verify-fix`](../plugins/codex-security/skills/verify-fix/SKILL.md) with the original finding and current checkout. Verification leaves repository files unchanged. | `cs verify-fix --scan SCAN_ID`; see [fix verification](../sdk/typescript/docs/cli.md#verify-fixes). |
|
||||
|
||||
@@ -69,6 +87,24 @@ scan. See [scan output](../sdk/typescript/docs/cli.md#scan-options-and-output)
|
||||
and [SDK results](../sdk/typescript/README.md#read-results) for the saved fields
|
||||
and failure output.
|
||||
|
||||
### Check a revision-range scan for missing files
|
||||
|
||||
If your scan retained `artifacts/02_discovery/in_scope_files.txt`, open it in
|
||||
the saved results directory. It lists the paths selected for discovery. For a
|
||||
scan between two commits, find `baseRevision` and `headRevision` under
|
||||
`scan.target` in the saved `scan-manifest.json`. In your Git client, compare
|
||||
the two commit trees directly (`base..head`). A three-dot PR comparison uses
|
||||
the merge base and can show different files when the commits have diverged.
|
||||
Current diff scans select regular text files regardless of extension. Git can
|
||||
also list changes to binary files, symlinks, and submodules.
|
||||
|
||||
Plugin 0.1.32 could omit changed Perl files (`.cgi`, `.pl`, `.pm`, and `.t`).
|
||||
CLI 0.3.0 was the first release to bundle the fix. To repeat the scan with
|
||||
that version or later, use a clean, full checkout at the original head.
|
||||
Select the same two commits from your repository,
|
||||
passing the base to `--diff` and the head to `--head`. See the
|
||||
[CLI quick start](../README.md#quick-start).
|
||||
|
||||
## Give an agent CLI guidance
|
||||
|
||||
The full plugin, generated CLI skills, and CLI MCP registration serve different
|
||||
|
||||
+62
-36
@@ -5,25 +5,46 @@ ordinary documentation-only change runs static checks and the final `ci` gate.
|
||||
Static checks format the tracked Markdown in this route. The Action README also
|
||||
runs Action CI to check generated input documentation and usage examples.
|
||||
Plugin skills, references, schemas, examples, and unrecognized paths receive
|
||||
full qualification because plugin Markdown is part of the product. SDK README and
|
||||
documentation changes also receive full qualification because those files are
|
||||
required package contents. Deleting or renaming them must pass archive checks.
|
||||
`RELEASING.md` also receives full qualification because SDK tests validate its
|
||||
canonical release recovery example.
|
||||
full qualification because plugin Markdown is part of the product.
|
||||
|
||||
Source changes run the complete SDK suite on Linux, macOS, and Windows, plus
|
||||
MCP, standalone-plugin, native-runtime, and installed-package checks. Tests
|
||||
PRs limited to the SDK package manifest's Markdown files, optionally mixed with
|
||||
ordinary docs or `RELEASING.md`, require the native payload, the real package
|
||||
build and archive inspection, and one Ubuntu Node 24 installation. Removing or
|
||||
renaming a required guide must still pass archive inspection. The static job
|
||||
validates the canonical recovery example in `RELEASING.md` on docs-only PRs too.
|
||||
Mixing the release guide with product source selects full qualification.
|
||||
|
||||
Product source changes run the complete SDK suite on Linux, macOS, and Windows,
|
||||
plus MCP, standalone-plugin, native-runtime, and installed-package checks. Tests
|
||||
are discovered from the source tree, including new files without timing data.
|
||||
Platform-specific filesystem, credential, process, cancellation, and resumed
|
||||
worker cases remain enabled.
|
||||
|
||||
SDK shards wait for static checks and a successful package build. A failing
|
||||
static check skips the shards when a PR opens, reopens, or receives new commits.
|
||||
Pushes to `main`, nightly and manual runs, and PR edits that need full
|
||||
qualification still run the shards.
|
||||
|
||||
The two Linux MCP jobs discover the same test files as local MCP testing. CI
|
||||
assigns files by observed runtimes and starts the longest files first on each
|
||||
job's two Node workers. Refresh the
|
||||
slow-file estimates in `run-mcp-test-shard.mts` when the jobs drift apart.
|
||||
|
||||
Pull requests limited to `.ts` files under `sdk/typescript/src/`,
|
||||
`sdk/typescript/tests-ts/`, `plugins/codex-security/mcp-app/src/`, and
|
||||
`plugins/codex-security/mcp-app/tests/`, optionally mixed with ordinary docs,
|
||||
`plugins/codex-security/mcp-app/tests/`, plus any ordinary docs or packaged SDK guides,
|
||||
use reduced version matrices. They test the minimum Node 22, 24, and 26 versions,
|
||||
current Node 24 for the Action adapter, macOS installation, and Windows Node 22
|
||||
installation. Python runs the full suite on 3.12 and the native subsets on macOS
|
||||
and Windows. All source changes still select container validation.
|
||||
installation. When selected, Python runs the full suite on 3.12 and the native
|
||||
subsets on macOS and Windows. Product source changes select container validation.
|
||||
|
||||
PRs limited to top-level `sdk/typescript/tests-ts/*.test.ts` keep all SDK shards,
|
||||
static checks, native builds, and packaging. Docker excludes these top-level
|
||||
test modules, so these PRs skip container validation. Test support files used by
|
||||
package inspection remain in the build context. The test modules are outside the
|
||||
npm package, so one Ubuntu Node 24 install checks it and the Action adapter.
|
||||
These PRs skip the plugin suites and run evals only for `codex-dependency-pins.test.ts`.
|
||||
Mixed changes follow the usual source or full route.
|
||||
|
||||
PRs limited to Action metadata, wrapper implementation, tests, npm manifests,
|
||||
locks, or checked-in bundles run Action CI. It verifies a clean rebuild, runs
|
||||
@@ -40,8 +61,13 @@ README, or to the triage eval's scripts, assertions, README, manifest or lock,
|
||||
run the deterministic eval job and static checks. The eval job builds the SDK
|
||||
and host plugin, checks the Codex version across the SDK, MCP and triage
|
||||
lockfiles, and runs the triage, secret-discovery, Standard time-budget and
|
||||
workflow-routing suites. This job also runs on source changes, independently
|
||||
of the Python matrix.
|
||||
workflow-routing suites.
|
||||
|
||||
Edits limited to existing top-level `plugins/codex-security/tests/test_*.py`
|
||||
modules keep all five Python jobs, static and workflow checks, MCP, plugin host,
|
||||
native builds, packaging, and Unix installs. Docker excludes these modules from
|
||||
the image. Adding, removing, or renaming modules, editing shared helpers, or
|
||||
including any other path selects full qualification.
|
||||
|
||||
Inputs outside these routes select full qualification, including workflow checks,
|
||||
containers, current Node 26, Windows Node 24 installation, and Python 3.10 and
|
||||
@@ -56,6 +82,10 @@ successful CI for the exact main commit before publication. Title and body edits
|
||||
leave source CI running. On an edit, CI checks the source result for the same
|
||||
pull request, base, head and test merge. It waits for a running source check and
|
||||
reports a verified result, including static checks, through the required checks.
|
||||
If the PR event reports an older base, CI can verify the edit on a newer test
|
||||
merge whose first parent is the current tip of that same branch. A stale merge
|
||||
or a retarget with different parents needs a fresh PR event after the merge ref
|
||||
updates. Reopening the PR or pushing a commit starts one.
|
||||
Only the original source run and an uninterrupted sequence of successful edits
|
||||
can carry a green result. A cancelled or retried run, a changed target, missing
|
||||
evidence or conflicting results require full qualification. Use **Re-run all
|
||||
@@ -70,26 +100,16 @@ job can be skipped. Static checks are always required. The separate `test-qualit
|
||||
workflow runs weekly property and mutation tests. Dispatch it to compare full SDK
|
||||
shard layouts.
|
||||
|
||||
One compatibility matrix forwards the `ci` result to the three OS-named Node 22
|
||||
checks required by the current `main` ruleset. Migrate the required checks in
|
||||
this order.
|
||||
|
||||
1. Merge the workflow change and verify that `ci` is reported for source and
|
||||
documentation pull requests, including a failing selected-check example.
|
||||
2. Change the repository's required status checks to `ci` and `Validate PR Title`,
|
||||
preserving their GitHub Actions integration and all unrelated protection rules.
|
||||
3. Remove the compatibility matrix `required-test` and its three OS check
|
||||
names from source verification in a follow-up.
|
||||
|
||||
Do not remove the old contexts before changing the rules. The workflow change
|
||||
itself does not change repository protection settings.
|
||||
The required GitHub Actions checks on `main` are `ci` and `Validate PR Title`.
|
||||
The title check runs on pull request edits. To diagnose a failed `ci`, open
|
||||
the selected job named in the gate output.
|
||||
|
||||
## Diagnostics and local checks
|
||||
|
||||
The workflow-selection and gate tests run without installing dependencies:
|
||||
|
||||
```bash
|
||||
node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs
|
||||
node --test .github/scripts/test-ci-selection.mjs .github/scripts/test-verify-pr-source.mjs .github/scripts/test-release-guide.mjs
|
||||
```
|
||||
|
||||
The [SDK testing guide](../sdk/typescript/TESTING.md) describes local behavioral
|
||||
@@ -102,19 +122,25 @@ Linux coverage artifacts are review evidence, not a percentage-based merge
|
||||
gate. Mutation diagnostics also measure results without enforcing a minimum
|
||||
score. Ordinary report upload failures do not replace the test result.
|
||||
|
||||
Only the same pull request can reuse caches saved on `refs/pull/<number>/merge`.
|
||||
After the PR merges into `main`, a maintenance job deletes those caches.
|
||||
|
||||
When measuring CI changes, separate time to required-green from summed job
|
||||
execution time, prerequisite waits, runner scheduling, approval waits, and
|
||||
manual retry delays. Compare matching revisions and test configurations, and
|
||||
record failures as well as successful runs.
|
||||
|
||||
When a batch of merges can wait, check **Restore verified native payload** in
|
||||
an active `node-ci` push or scheduled run on `main`. On a miss, another push
|
||||
with the same inputs can start all eight platform builds again. Before merging
|
||||
a PR that leaves those inputs unchanged, look for the exact key in
|
||||
`gh cache list --ref refs/heads/main --key KEY`. Once it is there, it does not
|
||||
matter which `main` run saved it. Different inputs can build in parallel.
|
||||
Protected `main` pushes that miss the same native cache share a queue per block
|
||||
of 16 consecutive workflow numbers. Each run waits behind at most 15 others,
|
||||
then restores the verified payload or builds and proves all eight platforms.
|
||||
Hits, unavailable listings, different inputs, and PR checks can start independently.
|
||||
|
||||
The key uses the UTC week and the paths listed in **Identify native build and
|
||||
proof inputs**. Compare the next change against current `main`: its PR run may
|
||||
have tested an older base or skipped native preparation entirely. PR runs
|
||||
cannot populate this cache for `main`.
|
||||
When a batch can wait, look for the first protected cache save before landing
|
||||
more changes with the same inputs: `gh cache list --ref refs/heads/main --key KEY`.
|
||||
The key uses the UTC week selected for the run and the paths in
|
||||
[the native key action](../.github/actions/native-cache-key/key.sh). Repository
|
||||
scripts are included by default: a native proof can load a helper at runtime.
|
||||
The workflow excludes known CI entrypoints that run elsewhere. Compare the
|
||||
next change against current `main`: its PR run may have tested an older base
|
||||
or skipped native preparation. PRs cannot populate this
|
||||
cache for `main`.
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
# Plugin connectors
|
||||
|
||||
Codex Security uses optional connected apps for ticket intake and finding tracking. Their identities are declared in `plugins/codex-security/.app.json`.
|
||||
Codex Security uses optional connected apps for Cloud reads, finding intake
|
||||
and tracking. The [app manifest](../plugins/codex-security/.app.json)
|
||||
declares their identities.
|
||||
|
||||
| App | Workflows |
|
||||
| --------- | ------------------------------------------------- |
|
||||
| Linear | Ticket intake and finding tracking |
|
||||
| GitHub | Finding intake, source lookup, and issue tracking |
|
||||
| Atlassian | Jira Cloud ticket intake and finding tracking |
|
||||
| App | Workflows |
|
||||
| -------------------- | --------------------------------------------------------- |
|
||||
| Codex Security Cloud | Read existing findings, evidence, reports and scan status |
|
||||
| Linear | Ticket intake and finding tracking |
|
||||
| GitHub | Finding intake, source lookup and issue tracking |
|
||||
| Atlassian | Jira Cloud ticket intake and finding tracking |
|
||||
|
||||
For scanner imports, use a connected tool or signed-in CLI to obtain the
|
||||
requested records. Follow the [scanner import guide](scanner-imports/README.md)
|
||||
to select and preview the evidence for your destination.
|
||||
|
||||
Finding tracking and CLI publication share issue associations when they use the same local state directory, including reuse across scan occurrences. The tracking skill reads them with `get_codex_security_finding_issues` and records accepted writes or verified reuse with `record_codex_security_finding_issues`. Provider reads still confirm saved candidates and search for unrecorded duplicates. Accepted writes remain recorded even when follow-up reads fail. The tools accept sealed scan bundles without requiring their original local scan history and keep receipts outside those bundles.
|
||||
|
||||
To replace `scripts/validate_tracking_source.py`, run the plugin launcher with `--helper validate-tracking-source <scan-directory> [--finding-id <id> | --fingerprint <fingerprint>]`. The Node helper validates the sealed scan before printing the selected finding IDs in scan order.
|
||||
|
||||
For GitHub triage, use a connected tool that can read the requested records and
|
||||
evidence. The [GitHub intake reference](../plugins/codex-security/skills/triage-finding/references/github-rest-intake.md)
|
||||
covers scoped reads using an existing GitHub CLI login and how to handle an
|
||||
explicit choice of account or transport.
|
||||
|
||||
## Jira setup
|
||||
|
||||
Connect the **Atlassian** app in the app directory. Existing Atlassian Rovo (Legacy) connections do not connect the new app; authorize it separately with the intended account and site.
|
||||
|
||||
Intake and duplicate checks need read and search access. Creating or updating issues also needs write access. Before creating an issue, the tracking skill resolves the project, issue type, and required fields.
|
||||
For user-selected Jira CLI or Linear MCP reads, see the [ticket intake guide](../plugins/codex-security/skills/triage-finding/references/ticket-intake.md#retrieval). Intake and duplicate checks need read and search access. Creating or updating issues also needs write access. Before creating an issue, the tracking skill resolves the project, issue type, and required fields.
|
||||
|
||||
Use the app's live schemas and discover deferred operations when needed. See Atlassian's [supported tools](https://developer.atlassian.com/cloud/rovo-mcp/guides/supported-tools/) and the skill's [Jira workflow](../plugins/codex-security/skills/track-findings/references/jira.md).
|
||||
|
||||
@@ -22,7 +36,7 @@ Use the app's live schemas and discover deferred operations when needed. See Atl
|
||||
|
||||
Test the plugin build with synthetic findings in a selected QA project:
|
||||
|
||||
- Verify that Jira calls use the new Atlassian app and the selected account and site.
|
||||
- Verify that Jira tracking uses the Atlassian app and that intake reads use the selected connection and account on the intended site or workspace.
|
||||
- Read a synthetic issue directly and through project-scoped JQL, including pagination.
|
||||
- Create one issue, reuse it without creating a duplicate, and update approved fields. Verify each write by reading the issue back.
|
||||
- Verify that missing connections and insufficient access produce recovery guidance without duplicate creates.
|
||||
|
||||
@@ -76,6 +76,57 @@ cd ../..
|
||||
node sdk/typescript/bin/codex-security.mjs scan . -c docs/examples/codex-security.yaml --dry-run --json
|
||||
```
|
||||
|
||||
## Desktop and conversational Deep Scans
|
||||
|
||||
When the Codex host supplies the launching turn’s speed, Deep Scan uses it for
|
||||
discovery and reducer workers, including resumed workers. Selecting Default
|
||||
overrides a faster tier in the worker’s Codex config. On hosts that omit the
|
||||
turn’s speed, each worker uses the Codex configuration it loads. To keep a scan
|
||||
at Default on those hosts, leave `service_tier = "default"` in the worker’s
|
||||
config for the duration of the scan, including any resumes. Other scans that
|
||||
load the same config also use that setting. The usual config file is
|
||||
`$CODEX_HOME/config.toml`, or `~/.codex/config.toml` when `$CODEX_HOME` is unset.
|
||||
|
||||
Deep Scan setup accepts an explicitly selected `.yaml`, `.yml`, or `.json` project
|
||||
file using the same format. For example:
|
||||
|
||||
```yaml
|
||||
scan:
|
||||
mode: deep
|
||||
max_time_minutes: 30
|
||||
deep:
|
||||
workers: 2
|
||||
subagents_per_worker: 1
|
||||
stop_after_no_new: 2
|
||||
max_discovery_runs: 4
|
||||
```
|
||||
|
||||
The plugin's `inspect_codex_security_setup` tool accepts `projectConfigPath` and
|
||||
returns `setup.deepScanConfig`: effective worker count, subagents per worker,
|
||||
novelty-stop threshold, consecutive-error threshold, review cap, and discovery
|
||||
time limit, with the source of each value. Desktop setup clients should display
|
||||
these values before starting a scan. Conversational scans inspect the same setup
|
||||
before passing `projectConfigPath` to `start_codex_security_deep_scan`.
|
||||
|
||||
Explicit project settings override per-user `[deep_scan]` settings, which override
|
||||
built-in defaults. The per-user file remains
|
||||
`$CODEX_HOME/codex-security/config.toml`, or the existing
|
||||
`CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH` selection. The project selection does not
|
||||
change that file or unrelated scans. No repository configuration is discovered or
|
||||
activated automatically.
|
||||
|
||||
This integration supports `scan.mode: deep`, `scan.max_time_minutes`, and all
|
||||
`scan.deep` fields listed below. Other configured fields, including `codex`,
|
||||
`auth`, scope, context files, cost limits, output, and exit policy, are rejected
|
||||
with their names before model work starts. Use CLI/SDK configuration for those
|
||||
settings. If both minute and hour limits are present, they must agree.
|
||||
|
||||
Saving native setup freezes the effective settings and their sources. Headless
|
||||
scans freeze them when first started. Reconnecting or resuming with the returned
|
||||
scan ID uses that snapshot even if the selected file or global defaults change.
|
||||
The time limit bounds discovery; scans may stop sooner after novelty or review
|
||||
limits, and aggregation and reporting can continue afterward.
|
||||
|
||||
## Settings
|
||||
|
||||
| Field | Meaning | Default |
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
# Import external scanner findings
|
||||
|
||||
Choose the guide for your report. Each guide shows how to preview the findings
|
||||
in a local checkout and which source key to reuse on later imports.
|
||||
|
||||
Use a supported report or retrieve the full records for the requested repository
|
||||
and ref with a connected tool or signed-in CLI. Fetch selected IDs directly when
|
||||
the provider supports it. If a saved report or collector covers more findings,
|
||||
use the provider's selection controls or retain only the selected native records
|
||||
where the report format permits. Check the accepted findings and their evidence
|
||||
in the JSON preview against the requested selection before saving or publishing.
|
||||
Use an API response only for an input and destination supported by the provider
|
||||
guide. Otherwise, ask for a supported report. A fresh scan produces new results.
|
||||
|
||||
| Guide | Supported input |
|
||||
| ----------------------------------------------------------- | ------------------------------------------------------------------------------- |
|
||||
| [Amazon Inspector](inspector.md) | Inspector2 `ListFindings` JSON for one Code Security repository |
|
||||
| [AWS Continuum](continuum.md) | Code finding summaries or a detailed finding verified for one repository |
|
||||
| [Black Duck SCA](blackduck.md) | BOM component vulnerabilities for one project version |
|
||||
| [Endor Labs](endor.md) | Finding JSON from `endorctl`, or SARIF with finding UUIDs |
|
||||
| [GitHub code scanning](github-code-scanning.md) | Alerts selected for one repository and Git ref |
|
||||
| [GitHub Dependabot](github-dependabot.md) | Dependency alerts exported from one repository |
|
||||
| [GitHub Security Advisories](github-security-advisories.md) | Selected repository or global advisories |
|
||||
| [OpenGrep](opengrep.md) | Native scan JSON, optionally gzip-compressed |
|
||||
| [Semgrep Code](semgrep.md) | CLI/CI JSON, self-contained SARIF, or selected Platform API pages (local SDK) |
|
||||
| [Snyk Open Source](snyk.md) | CLI JSON, a Codex plugin export, or SARIF |
|
||||
| [SonarQube Cloud](sonar.md) | Issues selected with the signed-in Sonar CLI, or saved issue-search pages |
|
||||
| [Veracode Static Analysis](veracode.md) | Findings API pages for one application's policy flaws |
|
||||
| [Wiz](wiz.md) | Native JSON, normalized JSONL, or detailed repository package vulnerability CSV |
|
||||
|
||||
## Preview a report
|
||||
|
||||
Enable external imports in the shell where you run the CLI.
|
||||
|
||||
```sh
|
||||
export CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1
|
||||
```
|
||||
|
||||
In PowerShell, use `$env:CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS = '1'`.
|
||||
Follow your guide's quick start to collect or select the report. Run examples
|
||||
that use `--repository .` from the checkout root, or pass the same checkout
|
||||
path you used previously. Use `--dry-run` to review the repository, source key,
|
||||
findings, and exclusions.
|
||||
Keep the export private. In automation, direct stdout and stderr for collection,
|
||||
preview, confirmation, and readback to private files outside the checkout.
|
||||
For examples that use `mktemp -d` without a path, set `TMPDIR` to a private
|
||||
directory outside the checkout if temporary files would otherwise land inside it.
|
||||
|
||||
## Save or publish and verify
|
||||
|
||||
The steps below apply to `publish findings FILE`. For `import sonar`,
|
||||
[confirm the capture returned by the Sonar preview](sonar.md#import-and-verify).
|
||||
|
||||
**Local workbench.** Run the same command with the same file, checkout, and
|
||||
source key. Remove `--dry-run` and confirm the prompt.
|
||||
For noninteractive use, add `--yes` after reviewing that preview. Read back
|
||||
the stored evidence using the checkout path from the preview:
|
||||
|
||||
```sh
|
||||
codex-security findings imported /path/to/project --format json
|
||||
```
|
||||
|
||||
**Codex Security Cloud.** Use a file-backed ChatGPT login for a deployment that
|
||||
accepts the provider and a repository environment you can publish to. See
|
||||
[Cloud setup](../../sdk/typescript/docs/cli.md#preview-and-publish). Keep the
|
||||
file, provider, source key, and scanner-specific options. Set `--to cloud` and
|
||||
replace the local checkout in `--repository` with the connected repository URL
|
||||
or Cloud repository ID. Use the ID if several connectors share the URL.
|
||||
Run with `--dry-run` first. Check that `cloudApiUrl`
|
||||
is the intended API endpoint, then review the account, repository, environments,
|
||||
and exclusions. Remove `--dry-run` and confirm, or use `--yes` after that
|
||||
review. Check `status`, the `verified` and
|
||||
`unacknowledged` counts, and the `failures` and `excluded` lists. For a `partial`
|
||||
result, correct exclusions or resolve version conflicts before starting a new
|
||||
submission. If an `interrupted` result includes `savedSubmission`,
|
||||
[resume from that checkpoint](schema-guide.md#retry-a-cloud-submission).
|
||||
|
||||
## Work with imported findings
|
||||
|
||||
Imported records start with assessment state `not_assessed`. Use the source
|
||||
evidence to check whether a finding affects your repository. For the identity
|
||||
of a record, the fields each reader retains, and how repeat imports update
|
||||
evidence, see [Imported finding identity and evidence](schema-guide.md).
|
||||
|
||||
For findings from a completed Codex scan, see
|
||||
[Track findings in Linear, Jira, or GitHub](../../plugins/codex-security/skills/track-findings/SKILL.md)
|
||||
or [Export findings for ServiceNow](../../sdk/typescript/docs/cli.md#export-findings-for-servicenow).
|
||||
@@ -0,0 +1,142 @@
|
||||
# Import Black Duck SCA findings
|
||||
|
||||
Import vulnerable BOM components from one Black Duck SCA project version.
|
||||
Verify in the scan configuration which Git repository that version represents.
|
||||
|
||||
## Quick start
|
||||
|
||||
[Enable external imports](README.md#preview-a-report) and use a read-only token to
|
||||
[export the BOM-6 collection](#export-the-bom-6-collection). From the matching
|
||||
checkout root, preview the saved file with the verified Git URL and a source key
|
||||
for this deployment, project, and version.
|
||||
|
||||
```sh
|
||||
codex-security publish findings /private/path/blackduck.json \
|
||||
--to local --repository . --provider blackduck \
|
||||
--source-repository-url https://github.com/example/project \
|
||||
--source-key blackduck/deployment-alias/project-id/version-id \
|
||||
--dry-run --format json
|
||||
```
|
||||
|
||||
## Import and verify
|
||||
|
||||
Check the source Git URL against the checkout’s configured remotes or the
|
||||
authorized GitHub repository in Cloud. A project name or component download
|
||||
URL alone cannot establish that link.
|
||||
[Save or publish and verify](README.md#save-or-publish-and-verify) using the same
|
||||
source key for subsequent exports of this project version.
|
||||
|
||||
## Reference
|
||||
|
||||
### Identity and evidence
|
||||
|
||||
Each occurrence is identified by its project version, component version,
|
||||
origin, advisory source, and advisory name. Package URLs and origin coordinates
|
||||
supply the package identity. The `advisory_ids` field preserves
|
||||
`vulnerabilityName` and any distinct `relatedVulnerability` verbatim, including
|
||||
Black Duck resource URLs. The original row retains its CWE, matched-files link,
|
||||
and remediation status. Imported records start unassessed. The importer does
|
||||
not infer a fix, Git revision, or source location. Aggregate product BOMs,
|
||||
image-only scans, license violations, and global advisory catalogs are outside
|
||||
this import.
|
||||
|
||||
For SDK imports, select the `blackduck` provider when replaying retained BOM
|
||||
records. Reader-supplied repository references must agree with the repository
|
||||
on local findings. Opaque IDs and caller-authored text alone cannot establish
|
||||
repository ownership.
|
||||
|
||||
### Export the BOM-6 collection
|
||||
|
||||
The [Black Duck SCA MCP](https://github.com/blackducksoftware/sca-mcp#capabilities)
|
||||
can locate the project version with `search_projects_versions`. Its
|
||||
`fetch_project_vulnerabilities` tool returns a summary and CSV. Use the REST
|
||||
export below for BOM rows. The MCP’s `scan` starts a new scan. Coverity and
|
||||
Polaris reports use different formats.
|
||||
|
||||
Request the project version’s `vulnerable-components` relation with media type
|
||||
`application/vnd.blackducksoftware.bill-of-materials-6+json`. The importer
|
||||
requires BOM-6. If the deployment only serves BOM-8 or another inventory format,
|
||||
it cannot supply this collection.
|
||||
|
||||
Install the vendor’s `blackduck` Python client in a trusted virtual environment
|
||||
outside the checkout. Set `BLACKDUCK_URL` to the deployment’s HTTPS URL,
|
||||
`BLACKDUCK_TOKEN` to the read-only token, and `BLACKDUCK_PROJECT_ID` and
|
||||
`BLACKDUCK_VERSION_ID` to their UUIDs. Keep redirects disabled for the client
|
||||
session, including the token exchange.
|
||||
|
||||
Save the script outside the checkout and run it with
|
||||
`/path/to/venv/bin/python -I /private/path/export.py` to keep checkout modules
|
||||
and `PYTHONPATH` off the import path. Redirect stdout to a private temporary file
|
||||
and rename it to `blackduck.json` after the script succeeds.
|
||||
|
||||
```python
|
||||
import json
|
||||
import os
|
||||
from hashlib import sha256
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
from uuid import UUID
|
||||
from blackduck import Client
|
||||
|
||||
base = os.environ["BLACKDUCK_URL"].rstrip("/")
|
||||
parts = urlsplit(base)
|
||||
if (parts.scheme != "https" or not parts.hostname or parts.username is not None
|
||||
or parts.password is not None or parts.query or parts.fragment):
|
||||
raise ValueError("Use your trusted HTTPS Black Duck URL")
|
||||
project = UUID(os.environ["BLACKDUCK_PROJECT_ID"])
|
||||
version = UUID(os.environ["BLACKDUCK_VERSION_ID"])
|
||||
collection = f"{project}/versions/{version}/vulnerable-bom-components"
|
||||
url = f"{base}/api/projects/{collection}"
|
||||
paths = {f"{parts.path}/api/{relation}/{collection}" for relation in ("projects", "project")}
|
||||
|
||||
def authority(url):
|
||||
return url.netloc.lower().removesuffix(":443")
|
||||
|
||||
client = Client(base_url=base + "/", token=os.environ["BLACKDUCK_TOKEN"])
|
||||
client.session.max_redirects = 0
|
||||
media_type = "application/vnd.blackducksoftware.bill-of-materials-6+json"
|
||||
items = []
|
||||
seen = set()
|
||||
total = None
|
||||
while True:
|
||||
offset = len(items)
|
||||
response = client.session.get(url, params={"offset": offset, "limit": 250},
|
||||
headers={"Accept": media_type}, allow_redirects=False)
|
||||
if response.status_code != 200:
|
||||
raise ValueError(f"Black Duck returned HTTP {response.status_code}; refusing partial export")
|
||||
received_type = response.headers.get("Content-Type", "").split(";", 1)[0].strip().lower()
|
||||
if received_type != media_type:
|
||||
raise ValueError("Expected a BOM-6 response")
|
||||
page = response.json()
|
||||
href = urlsplit(page["_meta"]["href"])
|
||||
if (href.scheme != "https" or authority(href) != authority(parts)
|
||||
or href.fragment or href.path not in paths):
|
||||
raise ValueError("Page identifies a different Black Duck collection")
|
||||
query = parse_qs(href.query, keep_blank_values=True)
|
||||
if "offset" in query and query["offset"] != [str(offset)]:
|
||||
raise ValueError("Page identifies a different or ambiguous offset")
|
||||
batch, declared = page["items"], page["totalCount"]
|
||||
if not isinstance(batch, list) or type(declared) is not int or declared < 0:
|
||||
raise ValueError("Invalid Black Duck collection")
|
||||
if total is not None and declared != total:
|
||||
raise ValueError("Collection changed; retry the export")
|
||||
total = declared
|
||||
for row in batch:
|
||||
digest = sha256(json.dumps(row, sort_keys=True).encode()).digest()
|
||||
if digest in seen:
|
||||
raise ValueError("Repeated row; retry the export")
|
||||
seen.add(digest)
|
||||
items.extend(batch)
|
||||
if len(items) == total:
|
||||
if any(link.get("rel") == "next" for link in page["_meta"].get("links", [])):
|
||||
raise ValueError("Final page has a next link; retry the export")
|
||||
break
|
||||
if not batch or len(items) > total:
|
||||
raise ValueError("Incomplete or inconsistent Black Duck collection")
|
||||
print(json.dumps({"_meta": {"href": url}, "totalCount": total, "items": items}))
|
||||
```
|
||||
|
||||
Keep the original rows and collection total. If the BOM changes during offset
|
||||
pagination, export it again after the scan finishes. For a selection, supply
|
||||
an array of native rows that each identify the same project version. See the
|
||||
[Black Duck Python client](https://github.com/blackducksoftware/hub-rest-api-python)
|
||||
and its [vulnerable BOM component example](https://github.com/blackducksoftware/hub-client-go/blob/5f78f7257c00fe9cebabf1bf89a6fc36a4d1f095/hubapi/testdata/vulnerableBomComponents.json).
|
||||
@@ -0,0 +1,70 @@
|
||||
# Import AWS Continuum code findings
|
||||
|
||||
Import a saved JSON response from AWS Continuum for Code Vulnerabilities.
|
||||
Use a detailed finding for investigation or a list of summaries for an
|
||||
overview of one repository.
|
||||
|
||||
## Export findings for one repository
|
||||
|
||||
Use an AWS CLI with the `continuum` commands, signed in to the account and
|
||||
Region where the environment lives. Set `ENVIRONMENT_ID` to that environment.
|
||||
Check its code sources against the repository you intend to import into. For
|
||||
an S3 source, verify which repository supplied the scanned archive.
|
||||
[AWS Continuum code sources](https://docs.aws.amazon.com/continuum/latest/userguide/cv-getting-started.html)
|
||||
|
||||
**One finding.** Check the finding against its scanned code source, then set
|
||||
`FINDING_ID` to its Continuum finding ID. For a finding from another scanner,
|
||||
you can also verify the repository in the originating scanner. The detail
|
||||
response can include code locations, descriptions, mitigation and AWS
|
||||
validation evidence.
|
||||
[AWS CLI get-code-finding](https://docs.aws.amazon.com/cli/latest/reference/continuum/get-code-finding.html)
|
||||
|
||||
```sh
|
||||
out=$(mktemp -d) &&
|
||||
aws continuum get-code-finding --environment-id "$ENVIRONMENT_ID" \
|
||||
--finding-id "$FINDING_ID" --output json > "$out/continuum.tmp" &&
|
||||
mv "$out/continuum.tmp" "$out/continuum.json"
|
||||
```
|
||||
|
||||
**All summaries.** For bulk import, use an environment dedicated to one
|
||||
repository and verify that the export belongs to that repository. Start on
|
||||
the first page with automatic pagination enabled. Keep the JSON object with
|
||||
its `items` array. In a mixed environment, export verified findings with
|
||||
`get-code-finding`.
|
||||
[AWS CLI list-code-findings](https://docs.aws.amazon.com/cli/latest/reference/continuum/list-code-findings.html)
|
||||
|
||||
```sh
|
||||
out=$(mktemp -d) &&
|
||||
aws continuum list-code-findings --environment-id "$ENVIRONMENT_ID" \
|
||||
--output json > "$out/continuum.tmp" &&
|
||||
mv "$out/continuum.tmp" "$out/continuum.json"
|
||||
```
|
||||
|
||||
## Preview and import
|
||||
|
||||
[Enable external imports](README.md#preview-a-report). From the matching
|
||||
checkout, preview the export with the verified Git URL and a stable source key
|
||||
for the environment and repository.
|
||||
|
||||
```sh
|
||||
codex-security publish findings "$out/continuum.json" \
|
||||
--to local --repository . --provider continuum \
|
||||
--source-repository-url https://github.com/example/project \
|
||||
--source-key "continuum/$ENVIRONMENT_ID/example/project" \
|
||||
--dry-run --format json
|
||||
```
|
||||
|
||||
Check the destination, finding ARNs, reported paths and exclusions. In
|
||||
multi-repository environments, customer-supplied paths can start with a
|
||||
repository name. The reader preserves that prefix. Follow
|
||||
the shared steps to save locally or publish to a Cloud deployment that
|
||||
accepts the `continuum` provider. [Save or publish and verify](README.md#save-or-publish-and-verify)
|
||||
|
||||
The finding ARN identifies the same occurrence in either export. With the
|
||||
same source key, importing a detail response after its summary updates the
|
||||
existing record. A subsequent summary replaces that richer evidence. Reuse
|
||||
`get-code-finding` for updates when you need the details.
|
||||
Both scanner-generated and customer-supplied code findings retain their AWS
|
||||
fields in `evidence.source_data.finding`. Continuum status and validation
|
||||
are vendor evidence. New findings start with a Codex assessment of
|
||||
`not_assessed`.
|
||||
@@ -1,81 +1,77 @@
|
||||
# Import Endor Labs findings
|
||||
|
||||
Use authenticated `endorctl` to export complete native Finding JSON through the
|
||||
[official CLI API](https://docs.endorlabs.com/developers-api/cli/commands/api).
|
||||
Scope the export to one project and context, omit `--field-mask`, and use
|
||||
`--list-all` to fetch every page. Replace the namespace and project UUID below
|
||||
to select the project's default-branch findings:
|
||||
Import findings from one Endor Labs project and scan context. Native Finding
|
||||
JSON preserves the scanned commit, severity, and dependency and location
|
||||
details reported by Endor.
|
||||
|
||||
## Quick start
|
||||
|
||||
[Enable external imports](README.md#preview-a-report) and
|
||||
[export the native findings](#native-finding-json) from the intended project
|
||||
and context. From the matching checkout root, preview the saved file. Replace
|
||||
the file path, namespace, and project UUID.
|
||||
|
||||
```sh
|
||||
endorctl api list --resource Finding --namespace "YOUR_NAMESPACE" \
|
||||
--filter 'context.type==CONTEXT_TYPE_MAIN and spec.project_uuid=="PROJECT_UUID"' \
|
||||
--list-all --output-type json > endor-findings.json
|
||||
|
||||
codex-security publish findings endor-findings.json --to local \
|
||||
--provider endor --repository ./project \
|
||||
--source-key "YOUR_NAMESPACE/PROJECT_UUID/main" --dry-run
|
||||
codex-security publish findings /private/path/endor-findings.json \
|
||||
--to local --repository . --provider endor \
|
||||
--source-key "YOUR_NAMESPACE/PROJECT_UUID/main" --dry-run --format json
|
||||
```
|
||||
|
||||
Use `--to local` with a local repository path to store unassessed source evidence
|
||||
without a Cloud login or model call. After reviewing the preview, remove
|
||||
`--dry-run` to confirm the import. Read the stored records with
|
||||
`codex-security findings imported ./project --format json`.
|
||||
## Import and verify
|
||||
|
||||
To publish the same export to Cloud, select its connected repository instead:
|
||||
Confirm the project and context belong to this repository. The importer retains
|
||||
the project UUID but does not look up its Git repository.
|
||||
[Save or publish and verify](README.md#save-or-publish-and-verify) using the same
|
||||
source key for later exports from this context.
|
||||
|
||||
## Reference
|
||||
|
||||
### Native Finding JSON
|
||||
|
||||
Authenticate `endorctl` for the namespace that owns the project. Replace
|
||||
`YOUR_NAMESPACE` and `PROJECT_UUID`, then export the findings.
|
||||
|
||||
```sh
|
||||
codex-security publish findings endor-findings.json --to cloud \
|
||||
--provider endor --repository "CLOUD_REPOSITORY_ID" \
|
||||
--source-key "YOUR_NAMESPACE/PROJECT_UUID/main" --dry-run
|
||||
out=$(mktemp -d) &&
|
||||
endorctl api list --resource Finding --namespace "YOUR_NAMESPACE" \
|
||||
--filter 'context.type==CONTEXT_TYPE_MAIN and spec.project_uuid=="PROJECT_UUID"' \
|
||||
--list-all --output-type json > "$out/endor-findings.tmp" &&
|
||||
mv "$out/endor-findings.tmp" "$out/endor-findings.json"
|
||||
```
|
||||
|
||||
Confirm that the selected Endor project and context correspond to the destination
|
||||
repository. Native JSON retains the project UUID, but the importer does not look
|
||||
it up to verify that association. For another branch or scan context, change the
|
||||
Endor filter and use a distinct, stable source key. An unfinished paginated
|
||||
response is rejected by the importer. Remove `--dry-run` to review and confirm
|
||||
the upload.
|
||||
The filter selects default-branch findings. For another context, change both
|
||||
the filter and source key. Keep `--list-all` and omit `--field-mask` to export
|
||||
complete Finding objects. The saved file is `$out/endor-findings.json`.
|
||||
|
||||
The official [Endor Labs Agent Kit for Codex](https://github.com/endorlabs/ai-plugins/tree/main/plugins/codex/endor-labs-agent-kit)
|
||||
can help with setup and interactive investigation. Its Findings Browser summaries,
|
||||
counts and field-masked results do not replace the complete Finding objects used
|
||||
here. `endorctl` reads the Endor API; the Codex Security importer reads the saved
|
||||
export. It does not establish a persistent API connection or write changes back
|
||||
to Endor.
|
||||
The importer accepts a single Finding, an array, or a `ListFindingsResponse`
|
||||
containing `list.objects`. An unfinished paginated response is rejected. Native
|
||||
JSON retains the complete Finding and maps severity, dependency and advisory
|
||||
details, scanned commit SHA, and primary SAST or AI SAST locations when
|
||||
available. See the [Endor CLI API](https://docs.endorlabs.com/developers-api/cli/commands/api)
|
||||
and [Finding model](https://github.com/endorlabs/endorlabs-sdk/blob/8a41756890c2dee3bb089fee881cae4f2adbde03/src/endorlabs/generated/models/finding_service.py).
|
||||
|
||||
Native JSON is the preferred import format: it preserves Endor severity,
|
||||
dependency and advisory details, the scanned commit SHA, primary SAST/AI SAST
|
||||
locations, and the complete original Finding. The importer accepts a single
|
||||
Finding, an array, or a `ListFindingsResponse` containing `list.objects`. Mapping
|
||||
follows Endor's public [Finding model](https://github.com/endorlabs/endorlabs-sdk/blob/8a41756890c2dee3bb089fee881cae4f2adbde03/src/endorlabs/generated/models/finding_service.py).
|
||||
The [Endor Labs Agent Kit for Codex](https://github.com/endorlabs/ai-plugins/tree/main/plugins/codex/endor-labs-agent-kit)
|
||||
can identify UUIDs. For a fresh export, append `and uuid in ["UUID_A","UUID_B"]`
|
||||
to the project and context filter above, using the requested UUIDs. For a saved
|
||||
export, select their complete objects from `list.objects`. Before import, verify
|
||||
the preview contains each requested UUID once, no other IDs, and no exclusions.
|
||||
[Endor filter syntax](https://docs.endorlabs.com/developers-api/rest-api/using-the-rest-api/filters#values)
|
||||
|
||||
Existing self-contained `endorctl` SARIF 2.1.0 reports are accepted as a lossy
|
||||
compatibility format. The importer retains finding UUIDs and links but does not
|
||||
infer native Endor severity or scanned revisions from SARIF. Diagnostic levels
|
||||
and CVSS stay in the original evidence;
|
||||
displayed severity remains unknown. Direct repository paths and reported SAST or
|
||||
Secrets lines are mapped. Indexed or base-relative artifact references remain in
|
||||
the original evidence. Run artifact inventories that are unrelated to the selected
|
||||
finding are omitted from its evidence. Declared SARIF repository URLs must
|
||||
match the selected Cloud repository for a new upload. For local imports, those
|
||||
URLs must match a configured Git remote when the checkout has remotes.
|
||||
### SARIF and repeat imports
|
||||
|
||||
Both formats use the native finding UUID as identity within the selected
|
||||
repository and source key. Keep the source key stable across repeated imports.
|
||||
Importing the same UUID from SARIF after native JSON updates the same source
|
||||
record: it replaces the evidence snapshot rather than merging it. Severity can
|
||||
become unknown, and commit, package, advisory and other native detail absent from
|
||||
SARIF is no longer present in that snapshot. Importing native JSON again replaces
|
||||
it with the richer native evidence. Use native JSON consistently for ongoing
|
||||
imports.
|
||||
Self-contained `endorctl` SARIF 2.1.0 reports preserve finding UUIDs, links,
|
||||
direct repository paths, and reported SAST or Secrets lines. Native severity
|
||||
and scanned revision are unavailable. Diagnostic levels, CVSS, and indexed or
|
||||
base-relative artifact references stay in the original evidence. Unrelated run
|
||||
artifact inventories are omitted. For a new Cloud submission, declared
|
||||
repository URLs must match the selected repository. For local imports, they
|
||||
must match a comparable configured Git remote when one is available.
|
||||
|
||||
Recommended upgrades, reachability, dismissals and other Endor assessments remain
|
||||
source claims. Local records remain unassessed and separate from completed scans;
|
||||
imports do not automatically investigate or patch them. Records omitted from a
|
||||
later local import remain stored. Saved Cloud requests retain their destination
|
||||
repository ID when resumed.
|
||||
Both formats identify a record by finding UUID within the repository and source
|
||||
key. Reimporting replaces its evidence snapshot. Importing SARIF after native
|
||||
JSON can clear commit, package, and advisory details and make severity unknown.
|
||||
For ongoing imports use native JSON and the same source key. Local records
|
||||
omitted from later imports remain stored.
|
||||
|
||||
The adapter can be tested with synthetic records and the public SARIF sample.
|
||||
Verifying acquisition requires an authenticated Endor namespace with findings.
|
||||
Verifying Cloud publication also requires a Cloud environment that supports
|
||||
finding imports.
|
||||
Upgrades, reachability, and dismissals remain Endor’s claims. Imported findings
|
||||
start unassessed and are separate from completed scans.
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Import GitHub code scanning findings
|
||||
|
||||
Import code scanning alerts from one repository and Git ref. The collector
|
||||
saves each alert with the instance that GitHub returned for the selected ref.
|
||||
|
||||
## Quick start
|
||||
|
||||
Sign in with `gh auth login`. A fine-grained token needs **Code scanning alerts: read**.
|
||||
A classic token needs `security_events`, or `public_repo` for a public repository.
|
||||
[GitHub API permissions](https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository)
|
||||
For GitHub Enterprise, set `GH_HOST` to the host you signed in to.
|
||||
If `gh` is unavailable, the SDK accepts `githubHost` and a `githubToken` for that host.
|
||||
|
||||
From the destination checkout root, set `repo` to its GitHub repository. Set
|
||||
`source_key` to your existing code scanning key exactly, including case. For a
|
||||
first import, choose a key for the host, repository and finding family. Replace
|
||||
`/path/to/private/reports` with an existing private directory outside the checkout,
|
||||
then preview the default branch’s open alerts.
|
||||
|
||||
```sh
|
||||
export CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1
|
||||
repo=OWNER/REPO
|
||||
source_key=github.com/example/project/code-scanning
|
||||
out=$(mktemp -d "/path/to/private/reports/github.XXXXXX") &&
|
||||
codex-security import github "$repo" --format json > "$out/alerts.json" &&
|
||||
codex-security publish findings "$out/alerts.json" \
|
||||
--to local --repository . --provider github \
|
||||
--source-key "$source_key" --dry-run --format json
|
||||
```
|
||||
|
||||
## Import and verify
|
||||
|
||||
Check the ref and alert numbers in the preview. The alert repository must match
|
||||
a comparable local Git remote when available or the selected Cloud repository.
|
||||
Reuse the source key when you [save or publish and verify](README.md#save-or-publish-and-verify).
|
||||
|
||||
## Reference
|
||||
|
||||
- To select another ref, add `--github-ref refs/heads/BRANCH` to the collector.
|
||||
Use `--github-state all` to include fixed and dismissed alerts, or repeat
|
||||
`--github-alert NUMBER` to select exact alerts regardless of state.
|
||||
- Save the collector’s complete JSON array. Omit field or token filters and
|
||||
`--full-output` when saving it for the reader.
|
||||
- The GitHub host, repository, alert number and ref identify a finding, so the
|
||||
same alert on two refs retains separate evidence. Missing security severity
|
||||
stays `unknown`.
|
||||
- See the [GitHub SDK examples](../../sdk/typescript/docs/cli.md#import-github-findings-locally-or-to-cloud)
|
||||
for programmatic collection and destination-specific normalization.
|
||||
@@ -0,0 +1,68 @@
|
||||
# Import GitHub Dependabot findings
|
||||
|
||||
Import Dependabot alerts from one GitHub repository. An alert identifies a
|
||||
dependency occurrence in a manifest. Its advisory describes the vulnerability.
|
||||
|
||||
## Quick start
|
||||
|
||||
[Enable external imports](README.md#preview-a-report) and
|
||||
[export the repository alerts](#export-repository-alerts). From the matching
|
||||
checkout root, replace the file path, hostname, and repository in this preview.
|
||||
|
||||
```sh
|
||||
codex-security publish findings /private/path/dependabot.jsonl \
|
||||
--to local --repository . --provider github \
|
||||
--source-key github.com/OWNER/REPO/dependabot --dry-run --format json
|
||||
```
|
||||
|
||||
## Import and verify
|
||||
|
||||
The alert repository must match a configured network remote when one is
|
||||
available. For a checkout with only filesystem remotes or no remote, verify
|
||||
the export belongs to it. [Save or publish and verify](README.md#save-or-publish-and-verify)
|
||||
using the same source key for later exports from this repository.
|
||||
|
||||
## Reference
|
||||
|
||||
### Identity and evidence
|
||||
|
||||
The host, repository, and alert number identify an occurrence, so two alerts
|
||||
for one GHSA keep separate histories. Reimport updates included alerts and
|
||||
leaves omitted alerts in place.
|
||||
|
||||
Each finding records the matched package, ecosystem, manifest path, vulnerable
|
||||
version range, first patched version when available, and advisory IDs. The
|
||||
native alert retains GitHub’s state and timestamps. An alert does not establish
|
||||
the installed version, an affected line, or a Codex assessment. The importer
|
||||
requires repository-relative manifest paths and rejects conflicts between
|
||||
alert identities, affected packages, or ranges.
|
||||
|
||||
To investigate a local alert, use the
|
||||
[`$resolve-dependency-alert` skill](../../plugins/codex-security/skills/resolve-dependency-alert/SKILL.md)
|
||||
with the saved alert and checkout. GitHub [code scanning](github-code-scanning.md)
|
||||
and [security advisories](github-security-advisories.md) have separate guides.
|
||||
|
||||
### Export repository alerts
|
||||
|
||||
In Codex, replace the host, repository and private output path in this request:
|
||||
|
||||
> Use the scoped GitHub read procedure in the Codex Security triage-finding skill.
|
||||
> Export the unmodified REST Dependabot alert objects for https://HOST/OWNER/REPO
|
||||
> across all states and classifications. Write each page as one compact JSON array
|
||||
> per line to a private temporary file beside /private/path/dependabot.jsonl.
|
||||
> Rename it to that destination only after verifying and saving every page.
|
||||
|
||||
Follow the [scoped GitHub read procedure](../../plugins/codex-security/skills/triage-finding/references/github-rest-intake.md#github-finding-retrieval)
|
||||
for the selected transport and identity. Ask before changing either. A connected
|
||||
app must return complete, unmodified REST alert objects, including `html_url`,
|
||||
`security_advisory` and `security_vulnerability`, and confirm it enumerated every
|
||||
matching page. For HTTPS, use a credential with Dependabot alerts read access to request
|
||||
`GET /repos/OWNER/REPO/dependabot/alerts?per_page=100` on the selected host's API. Omit `state` and `classification` to export every alert
|
||||
the deployment exposes. Note any unknown malware coverage. For HTTPS,
|
||||
reject redirects and rebuild each next page on the same API origin and repository
|
||||
endpoint with the requested filters. [Dependabot alerts endpoint](https://docs.github.com/en/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository)
|
||||
|
||||
Keep every field. Write each successful page as one compact JSON array per line,
|
||||
including `[]` for an empty page. Write to a private temporary file in the
|
||||
destination directory outside the checkout, then rename it to the requested
|
||||
output path only after all pages have been verified and saved.
|
||||
@@ -0,0 +1,60 @@
|
||||
# Import GitHub Security Advisories
|
||||
|
||||
Import repository disclosures or selected entries from GitHub's global advisory
|
||||
database. Use the affected packages and version ranges to investigate whether
|
||||
a dependency in your checkout is affected.
|
||||
|
||||
## Quick start
|
||||
|
||||
Sign in with `gh auth login`. For GitHub Enterprise, set `GH_HOST` to the host
|
||||
you signed in to. If `gh` is unavailable, the SDK accepts `githubHost` and a
|
||||
`githubToken` for that host.
|
||||
|
||||
From the destination checkout root, set `repo` to its GitHub
|
||||
repository and `source_key` to your existing advisories key exactly, including
|
||||
case. For a first import, choose a key for the host, repository and finding
|
||||
family. Replace `/path/to/private/reports` with an existing private directory
|
||||
outside the checkout. Collect published advisories as a complete JSON array
|
||||
without field or token filters or `--full-output`, then preview the saved file.
|
||||
|
||||
```sh
|
||||
export CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1
|
||||
repo=OWNER/REPO
|
||||
source_key=github.com/example/project/security-advisories
|
||||
out=$(mktemp -d "/path/to/private/reports/github.XXXXXX") &&
|
||||
codex-security import github-advisories "$repo" --format json > "$out/advisories.json" &&
|
||||
codex-security publish findings "$out/advisories.json" \
|
||||
--to local --repository . --provider github \
|
||||
--source-key "$source_key" --dry-run --format json
|
||||
```
|
||||
|
||||
## Import and verify
|
||||
|
||||
Check the advisory IDs and source in the preview. For repository advisories, the
|
||||
source must match a comparable local Git remote when available or the selected
|
||||
Cloud repository. Use a source key separate from code scanning and Dependabot
|
||||
when you [save or publish and verify](README.md#save-or-publish-and-verify).
|
||||
|
||||
## Reference
|
||||
|
||||
- **Repository advisories.** Repeat `--github-advisory GHSA-xxxx-xxxx-xxxx` to select exact
|
||||
IDs. To list an unpublished state instead, pass `--github-state draft`,
|
||||
`triage`, or `closed`. Private advisories require repository advisory read
|
||||
permission and access to the disclosures.
|
||||
- **Global advisories.** Add `--github-advisory-source global` and at least one
|
||||
`--github-advisory GHSA-xxxx-xxxx-xxxx` to the collector. The repository argument selects
|
||||
the context for investigation. A global record has no source repository.
|
||||
- An advisory retains the GHSA ID, reported packages and affected version
|
||||
ranges. Check the installed versions in your repository separately. For
|
||||
programmatic imports, see the [advisory SDK examples](../../sdk/typescript/docs/cli.md#import-ghsa-advisories-separately).
|
||||
|
||||
To collect a specific global advisory, use the same shell and replace the
|
||||
example ID. Preview `"$out/global-advisories.json"` with the same command and
|
||||
advisories source key. Each finding’s ID already distinguishes global and
|
||||
repository scope.
|
||||
|
||||
```sh
|
||||
codex-security import github-advisories "$repo" \
|
||||
--github-advisory-source global --github-advisory GHSA-2345-6789-cfgh \
|
||||
--format json > "$out/global-advisories.json"
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user