OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
ci: audit bundled MCP and triage eval dependencies (#2328)
Michael D'Angelob63d38afc743
diff --git a/.github/actions/audit-pnpm-lockfiles/action.yml b/.github/actions/audit-pnpm-lockfiles/action.ymlnew file mode 100644index 000000000..c68a2cc33--- /dev/null+++ b/.github/actions/audit-pnpm-lockfiles/action.yml@@ -0,0 +1,31 @@+name: Audit pnpm lockfiles+description: Check selected dependency trees locally against the vulnerability database.+inputs:+ targets:+ description: Space-separated workspaces to audit (mcp and/or evals).+ required: true+runs:+ using: composite+ steps:+ - name: Install Trivy+ uses: taiki-e/install-action@86f7a0ffb25f40114606501a311ebcfaf882ea32 # v2.88.0+ with:+ tool: [email protected]+ - name: Check for high and critical vulnerabilities+ shell: bash+ env:+ TARGETS: ${{ inputs.targets }}+ run: |+ read -ra targets <<< "$TARGETS"+ for target in "${targets[@]}"; do+ case "$target" in+ mcp) scope=(--dir plugins/codex-security/mcp-app sbom --prod) ;;+ evals) scope=(--dir evals/triage-finding sbom) ;;+ *) echo "Unknown audit target: $target" >&2; exit 1 ;;+ esac+ echo "Auditing $target lockfile"+ sbom="$RUNNER_TEMP/$target.cdx.json"+ pnpm "${scope[@]}" --lockfile-only --sbom-format cyclonedx > "$sbom"+ trivy sbom --offline-scan --disable-telemetry --skip-version-check \+ --exit-code 1 --severity HIGH,CRITICAL "$sbom"+ donediff --git a/.github/scripts/select-ci-checks.mjs b/.github/scripts/select-ci-checks.mjsindex 776486494..71af63192 100644--- a/.github/scripts/select-ci-checks.mjs+++ b/.github/scripts/select-ci-checks.mjs@@ -44,6 +44,23 @@ function scopeFor(paths, { event, baseChanged, modifiedOnly }) {return "full";}+export function selectLockfileAudits(paths, { event, baseChanged }) {+ // Full runs have no reliable pull-request diff. Exercise changes to the audit itself, too.+ if (+ event !== "pull_request" ||+ baseChanged ||+ paths.includes(".github/actions/audit-pnpm-lockfiles/action.yml")+ )+ return "mcp evals";+ return [+ ["mcp", "plugins/codex-security/mcp-app/pnpm-lock.yaml"],+ ["evals", "evals/triage-finding/pnpm-lock.yaml"],+ ]+ .filter(([, lockfile]) => paths.includes(lockfile))+ .map(([target]) => target)+ .join(" ");+}+export function selectChecks(paths, options) {const scope = scopeFor(paths, options);const full = scope === "full" || scope === "python-tests";@@ -144,7 +161,10 @@ if (: [];const paths = changes.filter((_, i) => i % 2);const modifiedOnly = changes.every((field, i) => i % 2 || field === "M");- const selected = selectChecks(paths, { event, baseChanged, modifiedOnly });+ const selected = {+ ...selectChecks(paths, { event, baseChanged, modifiedOnly }),+ "audit-lockfiles": selectLockfileAudits(paths, { event, baseChanged }),+ };appendFileSync(process.env.GITHUB_OUTPUT,Object.entries(selected)diff --git a/.github/scripts/test-ci-selection.mjs b/.github/scripts/test-ci-selection.mjsindex b8b91219a..9a3cf4e2e 100644--- a/.github/scripts/test-ci-selection.mjs+++ b/.github/scripts/test-ci-selection.mjs@@ -4,7 +4,7 @@ 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 { selectChecks, selectLockfileAudits } from "./select-ci-checks.mjs";import { failedChecks } from "./check-ci-results.mjs";const select = (paths, options = {}) =>@@ -153,10 +153,10 @@ test("only edits to existing direct pytest modules skip independent jobs", (t) =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,- );+ assert.deepEqual(Object.fromEntries(lines.map((line) => line.split("="))), {+ ...expected,+ "audit-lockfiles": "",+ });}});@@ -557,3 +557,26 @@ test("only an authenticated, successful classifier can propagate a source result);}});++test("audits the changed lockfiles and checks both trees on full event runs", () => {+ const pr = { event: "pull_request" };+ const mcp = "plugins/codex-security/mcp-app/pnpm-lock.yaml";+ const evals = "evals/triage-finding/pnpm-lock.yaml";+ assert.equal(selectLockfileAudits([mcp], pr), "mcp");+ assert.equal(selectLockfileAudits([evals], pr), "evals");+ assert.equal(selectLockfileAudits([mcp, evals], pr), "mcp evals");+ assert.equal(selectLockfileAudits(["sdk/typescript/pnpm-lock.yaml"], pr), "");+ for (const event of ["schedule", "workflow_dispatch", "push"])+ assert.equal(selectLockfileAudits([], { event }), "mcp evals");+ assert.equal(+ selectLockfileAudits([], { ...pr, baseChanged: true }),+ "mcp evals",+ );+ assert.equal(+ selectLockfileAudits(+ [".github/actions/audit-pnpm-lockfiles/action.yml"],+ pr,+ ),+ "mcp evals",+ );+});diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.ymlindex d243328f1..7d418d2cb 100644--- a/.github/workflows/node-ci.yml+++ b/.github/workflows/node-ci.yml@@ -37,6 +37,7 @@ jobs:container-required: ${{ steps.scope.outputs.container-required }}plugin-tests-required: ${{ steps.scope.outputs.plugin-tests-required }}package-required: ${{ steps.scope.outputs.package-required }}+ audit-lockfiles: ${{ steps.scope.outputs.audit-lockfiles }}action-ci: ${{ steps.scope.outputs.action-ci }}eval-contracts: ${{ steps.scope.outputs.eval-contracts }}workflow-quality: ${{ steps.scope.outputs.workflow-quality }}@@ -122,6 +123,11 @@ jobs:run: pnpm --dir sdk/typescript run format- name: Check MCP formattingrun: pnpm --dir plugins/codex-security/mcp-app exec prettier --check "**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}"+ - name: Audit changed MCP and eval lockfiles+ if: needs.classify-changes.outputs.audit-lockfiles != ''+ uses: ./.github/actions/audit-pnpm-lockfiles+ with:+ targets: ${{ needs.classify-changes.outputs.audit-lockfiles }}- name: Audit production dependenciesrun: pnpm --dir sdk/typescript run audit:proddiff --git a/.github/workflows/node-release.yml b/.github/workflows/node-release.ymlindex 3331e6aeb..c0db6d361 100644--- a/.github/workflows/node-release.yml+++ b/.github/workflows/node-release.yml@@ -159,6 +159,11 @@ jobs:name: Install ripgreprun: .github/scripts/install-ripgrep.sh+ - name: Audit bundled MCP production dependencies+ uses: ./.github/actions/audit-pnpm-lockfiles+ with:+ targets: mcp+- name: Audit production dependenciesrun: sfw pnpm --dir sdk/typescript run audit:prod