mirror of
https://github.com/openai/codex-security.git
synced 2026-12-03 02:41:33 +08:00
test(ci): diagnose Windows policy sandbox initialization
This commit is contained in:
@@ -1,216 +1,56 @@
|
||||
name: test-quality
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
native-artifacts-ready:
|
||||
description: Use the native artifacts already built by the caller in this run.
|
||||
type: boolean
|
||||
default: false
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "23 9 * * 1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: test-quality-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
CODEX_SECURITY_INTEGRATION: "0"
|
||||
CODEX_SECURITY_ALLOW_MACHINE_POLICY_TEST: "false"
|
||||
actions: read
|
||||
|
||||
jobs:
|
||||
native:
|
||||
if: ${{ !inputs.native-artifacts-ready }}
|
||||
uses: ./.github/workflows/native-artifacts.yml
|
||||
|
||||
runner:
|
||||
needs: native
|
||||
if: ${{ !cancelled() && (inputs.native-artifacts-ready || needs.native.result == 'success') }}
|
||||
name: ${{ matrix.os }} / ${{ matrix.mode }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: ${{ matrix.os == 'windows-latest' && (matrix.mode == 'baseline' && 90 || matrix.mode == 'parallel' && 60) || 30 }}
|
||||
env:
|
||||
CODEX_SECURITY_PROPERTY_SEED: ${{ github.event_name == 'pull_request' && 1 || github.run_number }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
mode: [baseline, isolated, parallel]
|
||||
exclude:
|
||||
- os: windows-latest
|
||||
mode: isolated
|
||||
include:
|
||||
- mode: baseline
|
||||
args: ""
|
||||
- mode: isolated
|
||||
args: --isolate
|
||||
- mode: parallel
|
||||
args: --parallel=2
|
||||
- os: windows-latest
|
||||
mode: isolated-1
|
||||
args: --isolate --shard=1/7
|
||||
- os: windows-latest
|
||||
mode: isolated-2
|
||||
args: --isolate --shard=2/7
|
||||
- os: windows-latest
|
||||
mode: isolated-3
|
||||
args: --isolate --shard=3/7
|
||||
- os: windows-latest
|
||||
mode: isolated-4
|
||||
args: --isolate --shard=4/7
|
||||
- os: windows-latest
|
||||
mode: isolated-5
|
||||
args: --isolate --shard=5/7
|
||||
- os: windows-latest
|
||||
mode: isolated-6
|
||||
args: --isolate --shard=6/7
|
||||
- os: windows-latest
|
||||
mode: isolated-7
|
||||
args: --isolate --shard=7/7
|
||||
- os: windows-latest
|
||||
mode: shard-1
|
||||
args: --shard=1/7
|
||||
- os: windows-latest
|
||||
mode: shard-2
|
||||
args: --shard=2/7
|
||||
- os: windows-latest
|
||||
mode: shard-3
|
||||
args: --shard=3/7
|
||||
- os: windows-latest
|
||||
mode: shard-4
|
||||
args: --shard=4/7
|
||||
- os: windows-latest
|
||||
mode: shard-5
|
||||
args: --shard=5/7
|
||||
- os: windows-latest
|
||||
mode: shard-6
|
||||
args: --shard=6/7
|
||||
- os: windows-latest
|
||||
mode: shard-7
|
||||
args: --shard=7/7
|
||||
policy-sandbox-diagnostic:
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- &actions-checkout
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- 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@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
node-version: "22.13.0"
|
||||
- name: Set up pnpm
|
||||
uses: ./.github/actions/setup-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
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
if: runner.os == 'Windows'
|
||||
with:
|
||||
bun-version: "1.4.2"
|
||||
- name: Set up Bun on Linux
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
# Includes the subprocess fix from https://github.com/oven-sh/bun/pull/44581
|
||||
# for the isolated-runner hang tracked in https://github.com/oven-sh/bun/issues/34069.
|
||||
npm install --prefix "$RUNNER_TEMP/bun" --ignore-scripts --no-audit --no-fund @oven/bun-linux-x64@1.4.2-canary.20261008.1
|
||||
echo "$RUNNER_TEMP/bun/node_modules/@oven/bun-linux-x64/bin" >> "$GITHUB_PATH"
|
||||
- name: Install dependencies
|
||||
- name: Download native payload from the unchanged main implementation
|
||||
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: native-universal-50e6de4555afe4a665a7a29419ce9bda335a13c3
|
||||
path: plugins/codex-security/native/prebuilt
|
||||
github-token: ${{ github.token }}
|
||||
run-id: 39369177286
|
||||
- name: Install and build
|
||||
run: |
|
||||
pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
pnpm --dir plugins/codex-security/mcp-app install --frozen-lockfile
|
||||
pnpm --dir sdk/typescript run build:plugin
|
||||
- name: Prepare private Windows test root
|
||||
if: runner.os == 'Windows'
|
||||
id: windows-temp
|
||||
shell: pwsh
|
||||
run: ./sdk/typescript/scripts/prepare-windows-test-root.ps1
|
||||
- name: Test runner mode
|
||||
- name: Reproduce scan then policy
|
||||
working-directory: sdk/typescript
|
||||
env:
|
||||
CODEX_SECURITY_TEST_TIMEOUT_MS: ${{ runner.os == 'Windows' && '120000' || '30000' }}
|
||||
TEMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
TMP: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
TMPDIR: ${{ steps.windows-temp.outputs.path || runner.temp }}
|
||||
TEMP: ${{ steps.windows-temp.outputs.path }}
|
||||
TMP: ${{ steps.windows-temp.outputs.path }}
|
||||
TMPDIR: ${{ steps.windows-temp.outputs.path }}
|
||||
run: |
|
||||
node -e "require('node:fs').mkdirSync('sdk/typescript/reports',{recursive:true})"
|
||||
pnpm --dir sdk/typescript run test ${{ runner.os == 'Windows' && '--timeout=120000' || '' }} ${{ matrix.args }} --seed=${{ env.CODEX_SECURITY_PROPERTY_SEED }} --reporter=junit --reporter-outfile=reports/runner-${{ matrix.os }}-${{ matrix.mode }}.xml
|
||||
- name: Upload runner report
|
||||
if: always()
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: runner-${{ matrix.os }}-${{ matrix.mode }}
|
||||
overwrite: true
|
||||
path: sdk/typescript/reports/runner-*.xml
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
compare:
|
||||
name: Runner inventory and timing
|
||||
if: always() && !cancelled()
|
||||
needs: [runner]
|
||||
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
|
||||
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||
with:
|
||||
pattern: runner-*
|
||||
merge-multiple: true
|
||||
path: reports
|
||||
- name: Compare inventories and outcomes
|
||||
shell: bash
|
||||
run: |
|
||||
comparison_status=0
|
||||
for os in ubuntu-latest windows-latest; do
|
||||
for mode in isolated parallel; do
|
||||
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts "reports/runner-$os-baseline.xml" "reports/runner-$os-$mode*.xml" >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
|
||||
done
|
||||
done
|
||||
node --experimental-strip-types sdk/typescript/scripts/compare-test-reports.mts reports/runner-windows-latest-baseline.xml 'reports/runner-windows-latest-shard-*.xml' >> "$GITHUB_STEP_SUMMARY" || comparison_status=1
|
||||
exit "$comparison_status"
|
||||
|
||||
mutation:
|
||||
name: Pure-module mutation trial
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- *actions-checkout
|
||||
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
|
||||
node-version: "24.15.0"
|
||||
- *github-actions-setup-tools
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
|
||||
with:
|
||||
bun-version: "1.3.14"
|
||||
- name: Install dependencies
|
||||
run: pnpm --dir sdk/typescript install --frozen-lockfile
|
||||
- name: Run mutation trial
|
||||
run: pnpm --dir sdk/typescript run test:mutation
|
||||
- name: Upload mutation report
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: mutation-report
|
||||
overwrite: true
|
||||
path: sdk/typescript/reports/mutation/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
bun test --timeout 120000 tests-ts/config.test.ts -t "allows scan helpers to write workspace files"
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
bun test --timeout 120000 tests-ts/config.test.ts -t "reads policy source without exposing credentials"
|
||||
exit $LASTEXITCODE
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
||||
import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
||||
import { join, resolve } from "node:path";
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { parse } from "smol-toml";
|
||||
@@ -146,6 +146,21 @@ function macOsSandboxUnavailable(): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
async function sandboxFailureDetails(codexHome: string, details: string) {
|
||||
if (process.platform !== "win32") return details;
|
||||
const directory = join(codexHome, ".sandbox");
|
||||
try {
|
||||
for (const name of (await readdir(directory)).sort()) {
|
||||
if (/^sandbox\.\d{4}-\d{2}-\d{2}\.log$/u.test(name)) {
|
||||
details += `\n${name}:\n${await readFile(join(directory, name), "utf8")}`;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
details += `\nCould not read native sandbox logs: ${String(error)}`;
|
||||
}
|
||||
return details;
|
||||
}
|
||||
|
||||
async function scanSandboxFixture() {
|
||||
const root = await temporaryDirectory();
|
||||
const stateDirectory = join(root, "state");
|
||||
@@ -583,7 +598,7 @@ describe("Codex configuration", () => {
|
||||
return;
|
||||
}
|
||||
throw new Error(
|
||||
`The pinned Codex CLI rejected an allowed scan write: ${details}`,
|
||||
`The pinned Codex CLI rejected an allowed scan write: ${await sandboxFailureDetails(codexHome, details)}`,
|
||||
);
|
||||
}
|
||||
expect(await readFile(allowed, "utf8")).toBe("probe");
|
||||
@@ -751,7 +766,7 @@ describe("Codex configuration", () => {
|
||||
return;
|
||||
}
|
||||
throw new Error(
|
||||
`The pinned Codex CLI rejected an allowed policy read: ${details}`,
|
||||
`The pinned Codex CLI rejected an allowed policy read: ${await sandboxFailureDetails(codexHome, details)}`,
|
||||
);
|
||||
}
|
||||
expect(new TextDecoder().decode(read.stdout)).toBe("original");
|
||||
|
||||
Reference in New Issue
Block a user