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
fix(pricing): remove Daybreak latest alias pricing (#2165)
Michael D'Angelo25b98eed85df
diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.tsindex b81bf6351..35022da9d 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts@@ -1227,7 +1227,7 @@ env_key = "CODEX_API_KEY"`CAPTURE_SYNTHETIC_OPENAI_AUTH\n${virtualenv === undefined ? "" : "CAPTURE_SYNTHETIC_PYTHON\n"}`,);const executor = new CodexSdkWorkerExecutor({- model: "gpt-daybreak-blue-latest",+ model: "gpt-6.1-sol",parentSandbox: trustedParentSandbox,});for (const kind of ["discovery", "dedup"] as const) {@@ -1250,11 +1250,7 @@ env_key = "CODEX_API_KEY"runtimeEnvironment.LD_LIBRARY_PATH,);assert.equal(invocation.codexHome, fixture.root);- assertFlagPair(- invocation.argv,- "--model",- "gpt-daybreak-blue-latest",- );+ assertFlagPair(invocation.argv, "--model", "gpt-6.1-sol");assert.deepEqual(invocation.runtimeEnvironment, runtimeEnvironment);if (virtualenv !== undefined) {assert.equal(invocation.pythonPrefix, virtualenv);diff --git a/plugins/codex-security/scripts/workbench_finding_workflows.py b/plugins/codex-security/scripts/workbench_finding_workflows.pyindex 010b87d71..28ca98751 100644--- a/plugins/codex-security/scripts/workbench_finding_workflows.py+++ b/plugins/codex-security/scripts/workbench_finding_workflows.py@@ -12,6 +12,7 @@ from pathlib import Pathfrom typing import Anysys.path.insert(0, str(Path(__file__).resolve().parent))+from workbench_scan_usage import stored_scan_cost_fieldsfrom workbench_target import (UnreadableLocalFile,UnsupportedLocalFileType,@@ -19,6 +20,7 @@ from workbench_target import (git_bytes,git_revision,)+from workbench_validation import _valid_legacy_scan_costWORKFLOW_BINDINGS = {"repositoryPath": "repository_path",@@ -31,13 +33,80 @@ WORKFLOW_BINDINGS = {WORKFLOW_STAGES = ("scan", "publish", "dedupe")+def _usable_cost_range(value: Any) -> bool:+ if not isinstance(value, dict) or value.get("context") != "unknown" or "max" not in value:+ return False+ minimum, maximum = value.get("min"), value["max"]+ return (+ type(minimum) in (int, float)+ and 0 <= minimum <= sys.float_info.max+ and (+ maximum is None+ or type(maximum) in (int, float)+ and minimum <= maximum <= sys.float_info.max+ )+ )+++def _recorded_cost(value: str | None) -> dict[str, Any] | None:+ """Recover the SDK cost fields that are usable from this historical receipt."""+ try:+ cost = stored_scan_cost_fields(value).get("cost")+ except (TypeError, ValueError, RecursionError):+ return None+ if not _valid_legacy_scan_cost(cost):+ return None++ fields = (+ "model",+ "inputTokens",+ "cachedInputTokens",+ "cacheWriteInputTokens",+ "outputTokens",+ "estimatedUsd",+ )+ result = {field: cost[field] for field in fields}+ if isinstance(cost.get("cacheWriteInputTokensReported"), bool):+ result["cacheWriteInputTokensReported"] = cost["cacheWriteInputTokensReported"]+ bounds = cost.get("estimatedUsdRange")+ if _usable_cost_range(bounds):+ result["estimatedUsdRange"] = {field: bounds[field] for field in ("min", "max", "context")}++ pricing = cost.get("pricing")+ if (+ isinstance(pricing, dict)+ and pricing.get("serviceTier") == "standard"+ and pricing.get("context") == "short"+ and isinstance(pricing.get("source"), str)+ and isinstance(pricing.get("asOf"), str)+ ):+ details = {field: pricing[field] for field in ("source", "asOf", "serviceTier", "context")}+ rate_keys = ("input", "cacheRead", "cacheWrite", "output")+ for field in ("usdPerMillionTokens", "longContextUsdPerMillionTokens"):+ rates = pricing.get(field)+ if isinstance(rates, dict) and all(+ type(rates.get(key)) in (int, float) and 0 <= rates[key] <= sys.float_info.max+ for key in rate_keys+ ):+ details[field] = {key: rates[key] for key in rate_keys}+ if "usdPerMillionTokens" in details:+ result["pricing"] = details+ return result++def read_workflow(connection: sqlite3.Connection, workflow_id: str) -> dict[str, Any] | None:row = connection.execute(- "SELECT * FROM finding_workflows WHERE id = ?", (workflow_id,)+ """SELECT w.*, s.cost_json FROM finding_workflows AS w+ LEFT JOIN scans AS s ON s.id = w.scan_id AND s.scan_dir = w.scan_dir+ AND s.status = 'complete'+ WHERE w.id = ?""",+ (workflow_id,),).fetchone()if row is None:return Nonestate = {"id": row["id"], "stages": {}}+ if (cost := _recorded_cost(row["cost_json"])) is not None:+ state["recordedCost"] = costfor field, column in WORKFLOW_BINDINGS.items():if row[column] is not None:state[field] = row[column]diff --git a/sdk/typescript/docs/cli.md b/sdk/typescript/docs/cli.mdindex 002dec82e..8227cf17c 100644--- a/sdk/typescript/docs/cli.md+++ b/sdk/typescript/docs/cli.md@@ -170,7 +170,8 @@ and project have access. An omitted `access_programs.cyber` field does not byitself mean that Daybreak treatment is disabled.Choose a compatible model available to your project and select Daybreak Blue-explicitly:+explicitly. If you use `--max-cost` or the SDK's `maxCostUsd`, choose a model+with built-in pricing so the scan can enforce the limit.```bashcodex-security scan /path/to/repository \@@ -183,11 +184,8 @@ Use `--mode deep` in the CLI or `mode: "deep"` in SDK scan options for Deep ScanThe selection reaches discovery and reducer workers, including resumed workers. See [Select a Cyber access program](#select-a-cyber-access-program)for configuration precedence and the API-key feature setting.-The previously documented `gpt-daybreak-blue-latest` alias is-[deprecated](https://developers.openai.com/api/docs/models/gpt-daybreak-blue-latest).-Use a current model available to your project. `access_programs.cyber` is a-Responses API field; use the supported selector instead of passing it as a-`--codex` configuration key.+`access_programs.cyber` is a Responses API field. Use `--cyber-access-program`+instead of passing it as a `--codex` configuration key.### Select a Cyber access programdiff --git a/sdk/typescript/src/api.ts b/sdk/typescript/src/api.tsindex c4015be5a..077c268db 100644--- a/sdk/typescript/src/api.ts+++ b/sdk/typescript/src/api.ts@@ -823,13 +823,16 @@ export class CodexSecurity {expectedScanId: state.scanId,signal,});- await workflow.bind({ artifactDigest: scanArtifactDigest(contract) });+ const verified = await workflow.bind({+ artifactDigest: scanArtifactDigest(contract),+ });metadata ??= { threadId: "", turnResult: { status: "completed" } };await workflow.complete("scan", metadata);return new ScanResult({...contract,scanDir: state.scanDir,...metadata,+ recordedCost: verified.recordedCost,threatModelPath: await readThreatModelPath(state.scanDir, {pythonPath: this.config.pythonPath,protectedRoot: local.protectedRoot,diff --git a/sdk/typescript/src/cost-model.ts b/sdk/typescript/src/cost-model.tsindex fa2fa63ea..34853147e 100644--- a/sdk/typescript/src/cost-model.ts+++ b/sdk/typescript/src/cost-model.ts@@ -93,15 +93,13 @@ const MODEL_PRICING_NANODOLLARS: Readonly<Record<string, ModelPricing>> = {"gpt-5.6-luna": [200, 20, 250, 1_200],// https://developers.openai.com/api/docs/pricing#cyber-models"gpt-5.6-cyber": [12_500, 1_250, 15_625, 75_000],- "gpt-daybreak-blue-latest": [4_000, 400, 5_000, 20_000],- "gpt-daybreak-red-latest": [12_500, 1_250, 15_625, 75_000],};// Verified Standard rates: https://developers.openai.com/api/docs/pricing// GPT-5.5: https://developers.openai.com/api/docs/models/gpt-5.5// GPT-6 Sol: https://developers.openai.com/api/docs/models/gpt-6-sol// Do not infer tiers from aggregate scan tokens: the runtime does not report-// which usage received long-context pricing. Cyber/Daybreak Red has no verified+// which usage received long-context pricing. GPT-5.6-Cyber has no verified// long-context rate in the pricing table, so its upper estimate stays unavailable.const LONG_CONTEXT_PRICING_NANODOLLARS: Readonly<Record<string, ModelPricing>> ={@@ -115,7 +113,6 @@ const LONG_CONTEXT_PRICING_NANODOLLARS: Readonly<Record<string, ModelPricing>> ="gpt-5.6-sol": [8_000, 800, 10_000, 30_000],"gpt-5.6-terra": [4_000, 400, 5_000, 18_000],"gpt-5.6-luna": [400, 40, 500, 1_800],- "gpt-daybreak-blue-latest": [8_000, 800, 10_000, 30_000],};function usdPerMillionTokens(pricing: ModelPricing, unitsPerUsd: number) {diff --git a/sdk/typescript/src/finding-workflow.ts b/sdk/typescript/src/finding-workflow.tsindex 1efeaba35..06d0d19a5 100644--- a/sdk/typescript/src/finding-workflow.ts+++ b/sdk/typescript/src/finding-workflow.ts@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";import { isAbsolute, relative, sep } from "node:path";import type { JsonObject } from "./config.js";import type { LoadedContract } from "./contract.js";+import type { ScanCost } from "./cost-model.js";import { CodexSecurityError, errorMessage } from "./errors.js";import { findingsBaseUrl } from "./findings-client.js";import type { FindingSearchScope } from "./finding-retrieval.js";@@ -27,6 +28,7 @@ export interface WorkflowBinding {}export interface WorkflowState extends WorkflowBinding {id: string;+ recordedCost?: ScanCost;stages: Record<WorkflowStage,{diff --git a/sdk/typescript/src/result.ts b/sdk/typescript/src/result.tsindex e2738328f..d413ea336 100644--- a/sdk/typescript/src/result.ts+++ b/sdk/typescript/src/result.ts@@ -44,6 +44,8 @@ export interface ScanResultOptions {scanDir: string;threadId: string;turnResult: TurnResultMetadata;+ /** Cost saved when this scan completed. */+ recordedCost?: Readonly<ScanCost>;sarifPath?: string | null;threatModelPath?: string | null;repositoryFindings?: readonly RepositoryFinding[];@@ -84,10 +86,9 @@ export class ScanResult {this.ownerSuggestionsPath = options.ownerSuggestionsPath;this.ownerSuggestionsError = options.ownerSuggestionsError;this.threatModelPath = options.threatModelPath ?? null;- this.cost = estimateScanCost(- options.turnResult.model,- options.turnResult.usage,- );+ this.cost =+ options.recordedCost ??+ estimateScanCost(options.turnResult.model, options.turnResult.usage);if (options.sarifPath !== undefined) {this.sarifPath = options.sarifPath;} else {diff --git a/sdk/typescript/tests-ts/api-attribution-concurrency.test.ts b/sdk/typescript/tests-ts/api-attribution-concurrency.test.tsindex d32313749..d530487e2 100644--- a/sdk/typescript/tests-ts/api-attribution-concurrency.test.ts+++ b/sdk/typescript/tests-ts/api-attribution-concurrency.test.ts@@ -51,7 +51,7 @@ describe("delegated scan attribution", () => {(["cli", "sdk"] as const).map(async (surface) => {const model = selectModel? surface === "cli"- ? "gpt-daybreak-blue-latest"+ ? "gpt-6.1-sol": "gpt-5.6-sol": undefined;const program = surface === "cli" ? programs[0] : programs[1];@@ -371,7 +371,7 @@ describe("delegated scan attribution", () => {expect(await client.preflight(repository, { mode }),).toMatchObject({- model: index === 0 ? "gpt-daybreak-blue-latest" : "gpt-5.6-sol",+ model: index === 0 ? "gpt-6.1-sol" : "gpt-5.6-sol",authentication: { method: "api_key", verified: false },});}),diff --git a/sdk/typescript/tests-ts/api-workflow.test.ts b/sdk/typescript/tests-ts/api-workflow.test.tsindex 2ea1a50ff..8ebffedf2 100644--- a/sdk/typescript/tests-ts/api-workflow.test.ts+++ b/sdk/typescript/tests-ts/api-workflow.test.ts@@ -1,5 +1,6 @@import { mkdir, readFile, rm, writeFile } from "node:fs/promises";import { dirname, join } from "node:path";+import { Database } from "bun:sqlite";import { afterEach, expect, spyOn, test } from "bun:test";import { runWorkbench } from "../src/runtime.js";import * as runtime from "../src/runtime.js";@@ -16,9 +17,15 @@ import {scanRuntimeDependencies,} from "./support/api-events.js";import { createApiTestFixtures } from "./support/temporary-directories.js";+import { writePublicationFindings } from "./support/sealed-scan.js";+import {+ scanRegistrationArguments,+ workbenchCommand,+} from "./support/workbench-command.js";import { FindingWorkflow } from "../src/finding-workflow.js";import { readKnowledgeBaseSnapshot } from "../src/knowledge-base.js";import { DEFAULT_DEEP_SCAN_SETTINGS } from "../src/deep-scan-defaults.js";+import { estimateScanCost } from "../src/cost-model.js";const { cleanup, temporaryDirectory } = createApiTestFixtures();afterEach(cleanup);@@ -106,13 +113,16 @@ test.each([await rm(promptFile);return state;}- if (args[0] === "get-scan")+ if (args[0] === "get-scan") {+ if (scenario === "completed" && attempt === 2)+ throw new Error("Synthetic unavailable scan history");return {scan: {progress: { status: completed ? "complete" : "failed" },continuationThreadId: "thread-1",},};+ }if (args[0] === "register-cli-scan") {expect(JSON.parse(input!).workflowId).toBe(workflowId);expect(JSON.parse(input!).recipe.ownerSuggestions).toBe(@@ -221,6 +231,150 @@ test.each([},);+const historicalRange = { min: 0.001, max: 0.002, context: "unknown" } as const;+const historicalCost = {+ model: "retired-test-model",+ inputTokens: 10,+ cachedInputTokens: 2,+ cacheWriteInputTokens: 0,+ outputTokens: 3,+ estimatedUsd: 0.001,+};+const historicalPricing = {+ source: "https://example.test/pricing",+ asOf: "2026-01-01",+ serviceTier: "standard",+ context: "short",+ usdPerMillionTokens: { input: 4, cacheRead: 0.4, cacheWrite: 5, output: 20 },+} as const;+const fullCost = {+ ...historicalCost,+ cacheWriteInputTokensReported: false,+ estimatedUsdRange: historicalRange,+ pricing: {+ ...historicalPricing,+ longContextUsdPerMillionTokens: {+ input: 8,+ cacheRead: 0.8,+ cacheWrite: 10,+ output: 30,+ },+ },+};+const openRangeCost = {+ ...historicalCost,+ estimatedUsdRange: { ...historicalRange, max: null },+ pricing: historicalPricing,+};+const fallbackModel = "gpt-5.6-sol";+const turnUsage = {+ input_tokens: 10,+ cached_input_tokens: 2,+ output_tokens: 3,+};+test.each([+ ["completed receipt", fullCost, fullCost],+ [+ "unknown upper bound",+ {+ ...openRangeCost,+ pricing: { ...historicalPricing, longContextUsdPerMillionTokens: {} },+ },+ openRangeCost,+ ],+ [+ "lost receipt",+ { ...historicalCost, estimatedUsdRange: null },+ historicalCost,+ ],+ [+ "malformed optional fields",+ {+ ...historicalCost,+ estimatedUsdRange: { min: 0.001, context: "unknown" },+ pricing: {},+ cacheWriteInputTokensReported: "false",+ },+ historicalCost,+ ],+ ["different scan directory", fullCost, null],+ ["unreadable cost", "{", estimateScanCost(fallbackModel, turnUsage)],+] as const)(+ "replays historical cost only for the bound scan: %s",+ async (scenario, saved, expected) => {+ const root = await temporaryDirectory();+ const repository = join(root, "repository");+ await mkdir(repository);+ const scanDir = join(root, "scan");+ const localDir =+ scenario === "different scan directory" ? join(root, "local") : scanDir;+ await mkdir(localDir, { mode: 0o700 });+ const environment = {+ PATH: process.env["PATH"],+ SystemRoot: process.env["SystemRoot"],+ CODEX_SECURITY_STATE_DIR: join(root, "state"),+ };+ const workbench = workbenchCommand(+ await runtime.resolvePluginPython({ environment }),+ () => environment,+ );+ const registration = await workbench(+ scanRegistrationArguments(repository, localDir),+ );+ const scanId = registration["scanId"] as string;+ await copyCompletedScan(root);+ await writePublicationFindings(scanDir, scanId, 1);+ const storedCost =+ scenario === "lost receipt"+ ? {+ usage: {+ coverage: "unavailable",+ source: "codex_rollout",+ threadCount: 0,+ },+ cost: saved,+ }+ : saved;+ using database = new Database(+ join(environment.CODEX_SECURITY_STATE_DIR, "workbench.sqlite3"),+ );+ database.run("UPDATE scans SET status='complete', cost_json=? WHERE id=?", [+ typeof storedCost === "string" ? storedCost : JSON.stringify(storedCost),+ scanId,+ ]);+ const workflow = new FindingWorkflow("historical-cost", environment);+ await workflow.bind({ repositoryPath: repository, scanId, scanDir });+ await workflow.begin("scan");+ if (scenario !== "lost receipt") {+ await workflow.complete("scan", {+ threadId: "thread-1",+ turnResult: {+ status: "completed",+ model:+ scenario === "unreadable cost"+ ? fallbackModel+ : historicalCost.model,+ usage: turnUsage,+ },+ });+ }+ const client = TestClient.withDependencies({+ environment,+ runWorkbench: async (options, args, input) => {+ if (args[0] === "get-scan") expect(scenario).toBe("lost receipt");+ return runWorkbench(options, args, input);+ },+ });+ try {+ const result = await client.run(repository, { workflowId: workflow.id });+ expect(result.cost).toEqual(expected);+ expect(result.toJSON()["cost"]).toEqual(expected);+ } finally {+ await client.close();+ }+ },+);+test.each(["ambient settings", "shipped defaults"])("a deep workflow can resume after changing %s but rejects a different request",async (change) => {diff --git a/sdk/typescript/tests-ts/cost-context.test.ts b/sdk/typescript/tests-ts/cost-context.test.tsindex 6d0346367..f859c8479 100644--- a/sdk/typescript/tests-ts/cost-context.test.ts+++ b/sdk/typescript/tests-ts/cost-context.test.ts@@ -16,7 +16,6 @@ test.each([["gpt-5.6-sol", [4, 0.4, 5, 20], [8, 0.8, 10, 30]],["gpt-5.6-terra", [2, 0.2, 2.5, 12], [4, 0.4, 5, 18]],["gpt-5.6-luna", [0.2, 0.02, 0.25, 1.2], [0.4, 0.04, 0.5, 1.8]],- ["gpt-daybreak-blue-latest", [4, 0.4, 5, 20], [8, 0.8, 10, 30]],] as const)("%s bounds each token category with verified rates",(model, short, long) => {@@ -39,6 +38,16 @@ test.each([},);+test.each(["blue", "red"])(+ "leaves the Daybreak %s latest alias unpriced",+ (program) => {+ const alias = `gpt-daybreak-${program}-latest`;+ const usage = { input_tokens: 1_000_000, output_tokens: 0 };+ expect(estimateScanCost(alias, usage)).toBeNull();+ expect(estimateScanCost(`openai.${alias}`, usage)).toBeNull();+ },+);+test("prices the exact Bedrock Daybreak Blue ID with AWS short and long context rates", () => {const usage = {input_tokens: 1_000_000,@@ -185,7 +194,7 @@ test("widens the maximum for unreported cache writes without changing token coun});test("keeps unverified long-context prices unavailable", () => {- const cost = estimateScanCost("gpt-daybreak-red-latest", {+ const cost = estimateScanCost("gpt-5.6-cyber", {input_tokens: 1_000_000,cache_write_input_tokens: 0,output_tokens: 0,diff --git a/sdk/typescript/tests-ts/cost-model.property.test.ts b/sdk/typescript/tests-ts/cost-model.property.test.tsindex 2067dc039..aa9297265 100644--- a/sdk/typescript/tests-ts/cost-model.property.test.ts+++ b/sdk/typescript/tests-ts/cost-model.property.test.ts@@ -13,8 +13,6 @@ const rates = [["gpt-5.6-sol", 4000n, 400n, 5000n, 20000n],["gpt-5.6-terra", 2000n, 200n, 2500n, 12000n],["gpt-5.6-luna", 200n, 20n, 250n, 1200n],- ["gpt-daybreak-blue-latest", 4000n, 400n, 5000n, 20000n],- ["gpt-daybreak-red-latest", 12500n, 1250n, 15625n, 75000n],["openai.gpt-daybreak-blue-5.6-sol", 4400n, 440n, 5500n, 22000n],] as const;const count = fc.integer({ min: 0, max: 1_000_000_000 });