Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(ci): restore formatting and concurrent plugin repairs (#1328)

mldangelo-oaid7cbcb678a7e
diff --git a/github-action/README.md b/github-action/README.md
index cbf788edd..20a377a0c 100644
--- a/github-action/README.md
+++ b/github-action/README.md
@@ -20,7 +20,7 @@ name: Codex Security repository
on:
workflow_dispatch:
schedule:
- - cron: '23 7 * * 1' # Mondays at 07:23 UTC
+ - cron: "23 7 * * 1" # Mondays at 07:23 UTC
permissions:
contents: read
@@ -123,7 +123,7 @@ For a Deep scan of a repository or selected paths, add these inputs to the scan
```yaml
with:
mode: deep
- max-time-hours: '2'
+ max-time-hours: "2"
```
Deep mode does not support diff scans. `max-time-hours` limits Deep discovery;
@@ -255,49 +255,49 @@ validation. Verify report compatibility when adopting a new release.
Inputs are strings. Quote booleans and use newline-separated literal paths for lists.
-| Input | Default | Meaning |
-| --- | --- | --- |
-| `repository` | `${{ github.workspace }}` | Checkout root. Use paths to select folders within the checkout. |
-| `scope` | `repository` | repository or diff. Select diff for PR changes only; repository scans the full checkout. |
-| `paths` | Unset | Newline-delimited literal repository-relative files or folders. Only for repository scope; no glob expansion. |
-| `diff-base` | Unset | Diff base revision. Defaults to the PR merge base; required outside PRs when scope is diff. |
-| `mode` | `standard` | standard or deep. Deep supports repository scans, including selected paths; not diff scans. |
-| `model` | `gpt-5.6-sol` | Model with access through your API key. Cost limits require CLI pricing support for the model. |
-| `effort` | `xhigh` | Reasoning effort: minimal, low, medium, high, xhigh, or max (subject to model support). |
-| `max-cost` | Unset | Positive estimated USD stop threshold per invocation. In-flight requests can exceed it; unset means no cost limit. |
-| `max-time-hours` | Unset | Positive Deep discovery duration in hours, up to 96. Unset uses the CLI default. Finalization and job timeout are separate. |
-| `fail-on-severity` | `none` | none, low, medium, high, or critical. Applies to complete scans. Valid partial results warn; scanner and required reporting errors fail. |
-| `verbose` | `true` | Stream CLI diagnostics to the job log. Set false for lifecycle and elapsed-time messages only. |
-| `dry-run` | `false` | Validate local configuration without a scan or API key. Does not verify authentication or model access. Use a separate non-required job. |
-| `summary` | `true` | Write a human-readable job summary. |
-| `annotations` | `true` | Emit up to 50 source finding annotations; complete findings remain in reports. |
-| `upload-artifacts` | `false` | Upload an allowlist of validated reports. Reports may contain source and vulnerability details. |
-| `artifact-name` | `codex-security` | Report artifact name; choose distinct names for matrix jobs and multiple invocations. |
-| `retention-days` | `7` | Artifact retention, 1–90 days (subject to repository limits). |
+| Input | Default | Meaning |
+| ------------------ | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
+| `repository` | `${{ github.workspace }}` | Checkout root. Use paths to select folders within the checkout. |
+| `scope` | `repository` | repository or diff. Select diff for PR changes only; repository scans the full checkout. |
+| `paths` | Unset | Newline-delimited literal repository-relative files or folders. Only for repository scope; no glob expansion. |
+| `diff-base` | Unset | Diff base revision. Defaults to the PR merge base; required outside PRs when scope is diff. |
+| `mode` | `standard` | standard or deep. Deep supports repository scans, including selected paths; not diff scans. |
+| `model` | `gpt-5.6-sol` | Model with access through your API key. Cost limits require CLI pricing support for the model. |
+| `effort` | `xhigh` | Reasoning effort: minimal, low, medium, high, xhigh, or max (subject to model support). |
+| `max-cost` | Unset | Positive estimated USD stop threshold per invocation. In-flight requests can exceed it; unset means no cost limit. |
+| `max-time-hours` | Unset | Positive Deep discovery duration in hours, up to 96. Unset uses the CLI default. Finalization and job timeout are separate. |
+| `fail-on-severity` | `none` | none, low, medium, high, or critical. Applies to complete scans. Valid partial results warn; scanner and required reporting errors fail. |
+| `verbose` | `true` | Stream CLI diagnostics to the job log. Set false for lifecycle and elapsed-time messages only. |
+| `dry-run` | `false` | Validate local configuration without a scan or API key. Does not verify authentication or model access. Use a separate non-required job. |
+| `summary` | `true` | Write a human-readable job summary. |
+| `annotations` | `true` | Emit up to 50 source finding annotations; complete findings remain in reports. |
+| `upload-artifacts` | `false` | Upload an allowlist of validated reports. Reports may contain source and vulnerability details. |
+| `artifact-name` | `codex-security` | Report artifact name; choose distinct names for matrix jobs and multiple invocations. |
+| `retention-days` | `7` | Artifact retention, 1–90 days (subject to repository limits). |
## Outputs
All outputs are strings. An empty cost or count means unavailable, not zero.
-| Output | Meaning |
-| --- | --- |
-| `sarif-path` | Absolute validated SARIF file path, or empty when unavailable or withheld. |
-| `json-path` | Absolute canonical findings JSON path, or empty when unavailable or withheld. |
-| `coverage-path` | Absolute coverage JSON path, or empty when unavailable or withheld. |
-| `results-directory` | Runner-local reports directory; do not upload it recursively. |
-| `scan-status` | completed, incomplete, failed, or skipped. Valid partial results are incomplete and warn without failing the step. Skipped is reserved for empty diffs or dry-run. |
-| `skip-reason` | empty-diff or dry-run when no scan ran; otherwise empty. |
-| `policy-status` | passed, failed, or not-evaluated. Incomplete scans are not-evaluated, even when a severity threshold is configured. |
-| `report-status` | ready, partial, or failed. Missing optional SARIF yields partial without failing the scan; required reporting failures yield failed. |
-| `exit-code` | CLI exit code, or empty if the CLI was not started. Valid partial results may return 2 without failing the Action step. |
-| `scanned-sha` | Verified checkout commit SHA. |
-| `analysis-ref` | GitHub ref matching the scanned revision. |
-| `sarif-upload-ready` | true only for complete, validated reports with a publishable immutable revision. Remains true after severity-policy failure. |
-| `critical-count` | Available critical findings, or empty before results are available. |
-| `high-count` | Available high findings, or empty before results are available. |
-| `medium-count` | Available medium findings, or empty before results are available. |
-| `low-count` | Available low findings, or empty before results are available. |
-| `informational-count` | Available informational findings, or empty before results are available. |
-| `estimated-cost` | Estimated USD cost reported by the CLI. Empty means unavailable, not zero. |
+| Output | Meaning |
+| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `sarif-path` | Absolute validated SARIF file path, or empty when unavailable or withheld. |
+| `json-path` | Absolute canonical findings JSON path, or empty when unavailable or withheld. |
+| `coverage-path` | Absolute coverage JSON path, or empty when unavailable or withheld. |
+| `results-directory` | Runner-local reports directory; do not upload it recursively. |
+| `scan-status` | completed, incomplete, failed, or skipped. Valid partial results are incomplete and warn without failing the step. Skipped is reserved for empty diffs or dry-run. |
+| `skip-reason` | empty-diff or dry-run when no scan ran; otherwise empty. |
+| `policy-status` | passed, failed, or not-evaluated. Incomplete scans are not-evaluated, even when a severity threshold is configured. |
+| `report-status` | ready, partial, or failed. Missing optional SARIF yields partial without failing the scan; required reporting failures yield failed. |
+| `exit-code` | CLI exit code, or empty if the CLI was not started. Valid partial results may return 2 without failing the Action step. |
+| `scanned-sha` | Verified checkout commit SHA. |
+| `analysis-ref` | GitHub ref matching the scanned revision. |
+| `sarif-upload-ready` | true only for complete, validated reports with a publishable immutable revision. Remains true after severity-policy failure. |
+| `critical-count` | Available critical findings, or empty before results are available. |
+| `high-count` | Available high findings, or empty before results are available. |
+| `medium-count` | Available medium findings, or empty before results are available. |
+| `low-count` | Available low findings, or empty before results are available. |
+| `informational-count` | Available informational findings, or empty before results are available. |
+| `estimated-cost` | Estimated USD cost reported by the CLI. Empty means unavailable, not zero. |
<!-- action-reference:end -->
diff --git a/github-action/package-lock.json b/github-action/package-lock.json
index 57cb45b69..3f9465b85 100644
--- a/github-action/package-lock.json
+++ b/github-action/package-lock.json
@@ -15,6 +15,7 @@
"devDependencies": {
"@types/node": "24.13.4",
"esbuild": "0.28.2",
+ "prettier": "3.9.9",
"tsx": "4.23.13",
"typescript": "5.9.3",
"yaml": "2.8.3"
@@ -1997,6 +1998,22 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/prettier": {
+ "version": "3.9.9",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.9.tgz",
+ "integrity": "sha512-Z/CJHIkdujO/OtN7nXUii0Rf3VT5SRuhjBA82Xvu2XhBUgX3nhP67T0LHceBdQLex7OOFGTox+Q5Yg8Jk2Qivg==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "prettier": "bin/prettier.cjs"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
+ },
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
diff --git a/github-action/package.json b/github-action/package.json
index c63ffc3d2..dd458cb46 100644
--- a/github-action/package.json
+++ b/github-action/package.json
@@ -26,6 +26,7 @@
"devDependencies": {
"@types/node": "24.13.4",
"esbuild": "0.28.2",
+ "prettier": "3.9.9",
"tsx": "4.23.13",
"typescript": "5.9.3",
"yaml": "2.8.3"
diff --git a/github-action/scripts/generate-input-docs.mjs b/github-action/scripts/generate-input-docs.mjs
index b022aecb6..fe01e00a1 100644
--- a/github-action/scripts/generate-input-docs.mjs
+++ b/github-action/scripts/generate-input-docs.mjs
@@ -1,5 +1,6 @@
import { readFile, writeFile } from 'node:fs/promises';
import assert from 'node:assert/strict';
+import { format } from 'prettier';
import { parse } from 'yaml';
const data = parse(await readFile(new URL('../../action.yml', import.meta.url), 'utf8'));
@@ -10,6 +11,7 @@ for (const [name, value] of Object.entries(data.inputs)) {
}
reference += '\n## Outputs\n\nAll outputs are strings. An empty cost or count means unavailable, not zero.\n\n| Output | Meaning |\n| --- | --- |\n';
for (const [name, value] of Object.entries(data.outputs)) reference += `| \`${name}\` | ${escape(value.description)} |\n`;
+reference = await format(reference, { parser: 'markdown' });
const path = new URL('../README.md', import.meta.url);
const current = await readFile(path, 'utf8');
diff --git a/sdk/typescript/src/runtime.ts b/sdk/typescript/src/runtime.ts
index f13cd593d..873cc8837 100644
--- a/sdk/typescript/src/runtime.ts
+++ b/sdk/typescript/src/runtime.ts
@@ -2394,7 +2394,13 @@ async function writeMarketplaceManifest(
signal,
});
throwIfSignalAborted(signal);
- await rename(temporary, manifestPath);
+ try {
+ await rename(temporary, manifestPath);
+ } catch (error) {
+ // Concurrent replacement can fail on Windows after another repair wins.
+ const published = await readFile(manifestPath, "utf8").catch(() => null);
+ if (published !== MARKETPLACE_MANIFEST) throw error;
+ }
throwIfSignalAborted(signal);
} finally {
await rm(temporary, { force: true });
diff --git a/sdk/typescript/tests-ts/runtime-plugin-reuse.test.ts b/sdk/typescript/tests-ts/runtime-plugin-reuse.test.ts
index 2ff3ae2de..f8ac7eaed 100644
--- a/sdk/typescript/tests-ts/runtime-plugin-reuse.test.ts
+++ b/sdk/typescript/tests-ts/runtime-plugin-reuse.test.ts
@@ -17,7 +17,21 @@ test.each(["missing", "truncated"] as const)(
(metadata) => checkWorkerReuse(metadata, true),
);
-async function checkWorkerReuse(metadata: string, concurrent = false) {
+test.each(["missing", "truncated"] as const)(
+ "accepts a concurrent %s manifest repair when replacement fails",
+ (metadata) => checkWorkerReuse(metadata, true, true),
+);
+
+test.each(["missing", "truncated"] as const)(
+ "preserves the replacement error when the %s manifest remains unrepaired",
+ (metadata) => checkWorkerReuse(metadata, false, true),
+);
+
+async function checkWorkerReuse(
+ metadata: string,
+ concurrent = false,
+ failReplacement = false,
+) {
const root = await temporaryDirectory("codex-security-plugin-worker-", true);
try {
const selected = join(root, "plugin");
@@ -101,6 +115,26 @@ async function checkWorkerReuse(metadata: string, concurrent = false) {
return originalWrite(...args);
})
: undefined;
+ const originalRename = fsPromises.rename;
+ const replacementError = Object.assign(
+ new Error("synthetic manifest replacement failure"),
+ { code: "EPERM" },
+ );
+ let published: Promise<void> | undefined;
+ const rename = failReplacement
+ ? spyOn(fsPromises, "rename").mockImplementation(async (...args) => {
+ if (String(args[1]) !== manifest) return originalRename(...args);
+ if (concurrent) {
+ if (published === undefined) {
+ published = originalRename(...args);
+ return published;
+ }
+ // Windows can reject replacement after the other repair wins.
+ await published;
+ }
+ throw replacementError;
+ })
+ : undefined;
try {
const results = await Promise.allSettled(
Array.from({ length: concurrent ? 2 : 1 }, () =>
@@ -108,19 +142,39 @@ async function checkWorkerReuse(metadata: string, concurrent = false) {
),
);
for (const result of results) {
- expect(result.status).toBe("fulfilled");
- if (result.status === "fulfilled") {
+ if (failReplacement && !concurrent) {
+ expect(result.status).toBe("rejected");
+ if (result.status === "rejected") {
+ expect(result.reason).toBe(replacementError);
+ }
+ } else {
+ if (result.status === "rejected") throw result.reason;
expect(result.value.installedRoot).toBe(first.installedRoot);
}
}
} finally {
write?.mockRestore();
+ rename?.mockRestore();
}
const response = once(worker, "message");
worker.send("read");
const [content] = await Promise.race([response, exited]);
expect(content).toBe(helper);
expect(installs).toBe(1);
+ if (failReplacement && !concurrent) {
+ if (metadata === "missing") {
+ await expect(readFile(manifest, "utf8")).rejects.toHaveProperty(
+ "code",
+ "ENOENT",
+ );
+ } else {
+ expect(await readFile(manifest, "utf8")).toBe("{");
+ }
+ expect(await fsPromises.readdir(dirname(manifest))).toEqual(
+ metadata === "missing" ? [] : ["marketplace.json"],
+ );
+ await bootstrapPlugin(home, selected, options);
+ }
expect(await readFile(manifest, "utf8")).toBe(expectedManifest);
expect(await fsPromises.readdir(dirname(manifest))).toEqual([
"marketplace.json",