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
feat(action): support optional Cyber access program selection (#1516)
dans-oai8ff5b39e1ecd
diff --git a/README.md b/README.mdindex 1a1ea882f..441958068 100644--- a/README.md+++ b/README.md@@ -21,10 +21,15 @@ fixing security vulnerabilities in your code.Requires Node.js 22.13.0+ within 22.x, or Node.js 24.x or 26.x, and Python 3.10+.Python 3.10 also requires `tomli`.+This example explicitly requests Daybreak Blue and requires the corresponding+access. Without Daybreak access, omit `--cyber-access-program daybreak_blue`+or use `--cyber-access-program standard`.+```bashnpm install @openai/codex-securitynpx @openai/codex-security login-npx @openai/codex-security scan /path/to/repository+npx @openai/codex-security scan /path/to/repository \+ --cyber-access-program daybreak_blue```For CI, set `OPENAI_API_KEY` or `CODEX_API_KEY` in the scan process's environment.@@ -104,6 +109,10 @@ repository scan, add an OpenAI API key as the repository secret`.github/workflows/codex-security.yml`. Replace `REPLACE_WITH_REVIEWED_COMMIT`with the full SHA of an Action commit.+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+`standard`.+```yamlname: Codex Securityon:@@ -118,6 +127,7 @@ jobs:security:runs-on: ubuntu-24.04steps:+ # Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.- name: Set up the Ubuntu sandboxrun: |sudo apt-get update@@ -130,6 +140,7 @@ jobs:with:model: gpt-5.6-soleffort: high+ cyber-access-program: daybreak_blueenv:OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}```diff --git a/action.yml b/action.ymlindex 0ee14dcf0..bc42712e0 100644--- a/action.yml+++ b/action.yml@@ -20,6 +20,8 @@ inputs:model:description: Model with access through your API key. Cost limits require CLI pricing support for the model.default: gpt-5.6-sol+ cyber-access-program:+ description: 'Optional Cyber access program: standard, daybreak_blue, or daybreak_red. Unset preserves CLI defaults. Daybreak selections require approved organization and enabled API project access; model access is checked separately.'effort:description: 'Reasoning effort: minimal, low, medium, high, xhigh, or max (subject to model support).'default: xhighdiff --git a/github-action/README.md b/github-action/README.mdindex 0099f2886..93117d0e3 100644--- a/github-action/README.md+++ b/github-action/README.md@@ -15,6 +15,10 @@ save this workflow in `.github/workflows/codex-security.yml`.Replace `REPLACE_WITH_REVIEWED_COMMIT` with the full SHA of an Action commit.When using a fork, replace `openai` with the fork owner.+This example requests Daybreak Blue. Use an API key from a project with Blue+enabled; without Daybreak access, omit `cyber-access-program` or set it to+`standard`. See [Daybreak access and refusals](#daybreak-access-and-refusals).+```yamlname: Codex Security repositoryon:@@ -29,6 +33,7 @@ jobs:security:runs-on: ubuntu-24.04steps:+ # Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.- name: Set up the Ubuntu sandboxrun: |sudo apt-get update@@ -41,6 +46,7 @@ jobs:with:model: gpt-5.6-soleffort: high+ cyber-access-program: daybreak_blueenv:OPENAI_API_KEY: ${{ secrets.CODEX_SECURITY_API_KEY }}```@@ -51,6 +57,48 @@ Findings are report-only by default. Valid partial results produce a warning;scanner and required reporting errors fail the job. Set `fail-on-severity` tofail on findings at or above a selected severity when the scan is complete.+### Ubuntu sandbox setup++Codex Security runs commands inside a sandbox to limit their filesystem and+network access. On the Ubuntu 24.04 runner used above, that sandbox uses+Bubblewrap (`bwrap`), and Ubuntu's AppArmor policy must allow it to create the+required isolated environment.++The setup step installs `bubblewrap` and `apparmor-profiles`, then uses+`apparmor_parser -r` to load the supplied `bwrap-userns-restrict` profile. The+profile permits Bubblewrap's sandbox setup while retaining Ubuntu's broader+AppArmor restrictions. Keep this step before the Action: the CLI checks that+its sandbox works before scanning and fails if it cannot start, for example+with `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted`.++This setup is specific to the Linux runner. Local macOS scans use the built-in+Seatbelt sandbox and do not need Bubblewrap. See the+[sandbox documentation](https://learn.chatgpt.com/docs/sandboxing) for details.++## Daybreak access and refusals++Daybreak is optional. You can use the Action with a general-purpose model your+API key can access under standard safeguards. Some security tasks may trigger+model refusals or API cybersecurity safety blocks. **If a refusal or safety+block aborts the scan, the Action fails**, even with `fail-on-severity: none`.+That setting controls failures caused by findings; it does not suppress scanner+errors. Check the job summary and logs for the reason. A failed scan does not+mean the repository has no vulnerabilities.++For authorized security work that needs reduced refusals,+[request Daybreak access](https://openai.com/form/enterprise-trusted-access-for-cyber/).+After organization approval, enable the required program for the API project+and use a key from that project. Daybreak reduces some refusals but does not+remove every safeguard or guarantee that a scan will complete.++To explicitly select an approved Cyber access program, add+`cyber-access-program: daybreak_blue` to the scan step's `with` settings.+The input also accepts `standard` and `daybreak_red`; choose a program supported+by your model and API project. Leaving it unset preserves CLI defaults.+Selecting `standard` does not require Daybreak approval. Selecting a Daybreak+program does not grant access; an unavailable program or incompatible model+causes the scan to fail.+## Scan pull requestsUse the same API-key secret and Action commit as above. Check out the PR head@@ -76,6 +124,7 @@ jobs:runs-on: ubuntu-24.04timeout-minutes: 60steps:+ # Configure Bubblewrap and AppArmor so Codex Security can run safely in its sandbox.- name: Set up the Ubuntu sandboxrun: |sudo apt-get update@@ -277,25 +326,26 @@ 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. |+| `cyber-access-program` | Unset | Optional Cyber access program: standard, daybreak_blue, or daybreak_red. Unset preserves CLI defaults. Daybreak selections require approved organization and enabled API project access; model access is checked separately. |+| `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). |## Outputsdiff --git a/github-action/dist/index.cjs b/github-action/dist/index.cjsindex a5a8cbd97..be85b9b37 100644--- a/github-action/dist/index.cjs+++ b/github-action/dist/index.cjs@@ -55585,12 +55585,14 @@ function parseInputs(read, workspace) {const maxTimeHours = num("max-time-hours", false, Number.MIN_VALUE, 96);if (maxTimeHours !== void 0 && mode !== "deep") throw new Error("max-time-hours requires mode: deep.");const dryRun = bool("dry-run", false);+ const cyberAccessProgram = str("cyber-access-program") ? choice("cyber-access-program", ["standard", "daybreak_blue", "daybreak_red"], "standard") : void 0;return {repository: str("repository", workspace),scope,paths,diffBase,mode,+ cyberAccessProgram,model: str("model", "gpt-5.6-sol"),effort: choice("effort", ["minimal", "low", "medium", "high", "xhigh", "max"], "xhigh"),maxCost: num("max-cost", false, Number.MIN_VALUE),@@ -55627,6 +55629,7 @@ function scanArguments(inputs, target, resultsDirectory) {args.push("--codex", "analytics.enabled=false");for (const path6 of inputs.paths) args.push(`--path=./${path6}`);const options = [+ ["--cyber-access-program", inputs.cyberAccessProgram],["--diff", target.diffBase],["--head", target.diffHead],["--max-cost", inputs.maxCost],@@ -99279,6 +99282,7 @@ async function runAction(actionRoot, overrides = {}) {log2(`Target commit: ${target.scannedSha}.${target.diffBase ? ` Diff: ${target.diffBase}..${target.diffHead}.` : ""}`);if (inputs.paths.length) log2(`Paths: ${inputs.paths.join(", ")}.`);log2(`Model: ${inputs.model}; estimated cost stop threshold: ${inputs.maxCost === void 0 ? "unset" : `$${inputs.maxCost}`}; findings failure threshold: ${inputs.failOnSeverity}.`);+ if (inputs.cyberAccessProgram) log2(`Requested Cyber access program: ${inputs.cyberAccessProgram}.`);const scanLabel = inputs.dryRun ? "CLI configuration validation" : "Security scan";const scanStarted = performance.now();info(`Starting ${scanLabel.toLowerCase()}. CLI diagnostics: ${inputs.verbose ? "streaming" : "disabled (verbose: false)"}.`);diff --git a/github-action/scripts/cli-integration.ts b/github-action/scripts/cli-integration.tsindex 869760284..55f0b34c6 100644--- a/github-action/scripts/cli-integration.ts+++ b/github-action/scripts/cli-integration.ts@@ -81,6 +81,16 @@ try {assert.equal(deepPreflight.maxTimeHours, 0.25);assert.deepEqual(deepPreflight.target.paths, ['example.ts']);+ // Validate explicit program selection against the locked CLI, without model calls.+ for (const mode of ['standard', 'deep']) for (const program of ['standard', 'daybreak_blue', 'daybreak_red']) {+ const values: Record<string, string> = {mode, 'cyber-access-program':program, 'dry-run':'true'};+ const args = scanArguments(parseInputs(name => values[name] ?? '', repository),+ {repository}, join(root, `cyber-${mode}-${program}`));+ const preflight = JSON.parse(run(args, 0));+ assert.equal(preflight.dryRun, true);+ assert.equal(preflight.mode, mode);+ }+// Normalization must not let a literal repository path become a framework option.await mkdir(join(repository, '--help'));await writeFile(join(repository, '--help/example.ts'), 'export const example = 1;\n');diff --git a/github-action/src/inputs.ts b/github-action/src/inputs.tsindex 8c0dc6e48..97c3320c0 100644--- a/github-action/src/inputs.ts+++ b/github-action/src/inputs.ts@@ -1,6 +1,6 @@export const INPUT_NAMES = ['repository', 'scope', 'paths', 'diff-base', 'mode',- 'model', 'effort', 'max-cost', 'max-time-hours', 'fail-on-severity', 'verbose', 'dry-run',+ 'model', 'cyber-access-program', 'effort', 'max-cost', 'max-time-hours', 'fail-on-severity', 'verbose', 'dry-run','summary', 'annotations','upload-artifacts', 'artifact-name', 'retention-days',] as const;@@ -42,8 +42,11 @@ export function parseInputs(read: (name: string) => string, workspace: string) {const maxTimeHours = num('max-time-hours', false, Number.MIN_VALUE, 96);if (maxTimeHours !== undefined && mode !== 'deep') throw new Error('max-time-hours requires mode: deep.');const dryRun = bool('dry-run', false);+ const cyberAccessProgram = str('cyber-access-program')+ ? choice('cyber-access-program', ['standard', 'daybreak_blue', 'daybreak_red'], 'standard')+ : undefined;return {- repository: str('repository', workspace), scope, paths, diffBase, mode,+ repository: str('repository', workspace), scope, paths, diffBase, mode, cyberAccessProgram,model: str('model', 'gpt-5.6-sol'), effort: choice('effort', ['minimal','low','medium','high','xhigh','max'], 'xhigh'),maxCost: num('max-cost', false, Number.MIN_VALUE), maxTimeHours, failOnSeverity: choice('fail-on-severity', ['none','low','medium','high','critical'], 'none'),verbose: bool('verbose', true), dryRun,@@ -66,6 +69,7 @@ export function scanArguments(inputs: Inputs, target: {repository: string; diffB// leading '-' and '~' as literal repository filenames.for (const path of inputs.paths) args.push(`--path=./${path}`);const options: Array<[string, string | number | undefined]> = [+ ['--cyber-access-program', inputs.cyberAccessProgram],['--diff', target.diffBase], ['--head', target.diffHead], ['--max-cost', inputs.maxCost],['--max-time-hours', inputs.maxTimeHours],];diff --git a/github-action/src/main.ts b/github-action/src/main.tsindex 1020e7477..fe62d854e 100644--- a/github-action/src/main.ts+++ b/github-action/src/main.ts@@ -97,6 +97,7 @@ export async function runAction(actionRoot: string, overrides: Partial<Dependenclog(`Target commit: ${target.scannedSha}.${target.diffBase ? ` Diff: ${target.diffBase}..${target.diffHead}.` : ''}`);if (inputs.paths.length) log(`Paths: ${inputs.paths.join(', ')}.`);log(`Model: ${inputs.model}; estimated cost stop threshold: ${inputs.maxCost === undefined ? 'unset' : `$${inputs.maxCost}`}; findings failure threshold: ${inputs.failOnSeverity}.`);+ if (inputs.cyberAccessProgram) log(`Requested Cyber access program: ${inputs.cyberAccessProgram}.`);const scanLabel = inputs.dryRun ? 'CLI configuration validation' : 'Security scan';const scanStarted = performance.now();core.info(`Starting ${scanLabel.toLowerCase()}. CLI diagnostics: ${inputs.verbose ? 'streaming' : 'disabled (verbose: false)'}.`);diff --git a/github-action/tests/inputs.test.ts b/github-action/tests/inputs.test.tsindex 500a4bbcf..b862b7634 100644--- a/github-action/tests/inputs.test.ts+++ b/github-action/tests/inputs.test.ts@@ -6,7 +6,7 @@ const parse = (values: Record<string, string> = {}) => parseInputs(key => valuestest('defaults are stable across events', () => {const input = parse();assert.deepEqual(input, {- repository: '/checkout', scope: 'repository', paths: [], diffBase: undefined, mode: 'standard',+ repository: '/checkout', scope: 'repository', paths: [], diffBase: undefined, mode: 'standard', cyberAccessProgram: undefined,model: 'gpt-5.6-sol', effort: 'xhigh', maxCost: undefined, maxTimeHours: undefined, failOnSeverity: 'none',verbose: true, dryRun: false, summary: true, annotations: true,uploadArtifacts: false, artifactName: 'codex-security', retentionDays: 7,@@ -16,6 +16,16 @@ test('defaults are stable across events', () => {assert.ok(!args.includes('--max-time-hours'));assert.ok(!args.includes('--fail-on-severity'));assert.ok(!args.includes('--python'));+ assert.ok(!args.includes('--cyber-access-program'));+});+test('Cyber access selections reach both standard and Deep scan CLI invocations', () => {+ for (const mode of ['standard', 'deep']) for (const program of ['standard', 'daybreak_blue', 'daybreak_red']) {+ const args = scanArguments(parse({mode, 'cyber-access-program':program}), {repository:'/checkout'}, '/results');+ assert.equal(args[args.indexOf('--cyber-access-program') + 1], program);+ }+ const blank = scanArguments(parse({'cyber-access-program':' '}), {repository:'/checkout'}, '/results');+ assert.ok(!blank.includes('--cyber-access-program'));+ assert.throws(() => parse({'cyber-access-program':'unsupported'}), /cyber-access-program must be one of/);});test('Deep scans forward an explicit discovery budget and selected repository paths', () => {const input = parse({mode:'deep', paths:'./src/\nlib', 'max-time-hours':'1.5'});