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(cli): explain the cost limit in scan dry runs (#2295)
Michael D'Angelo4abc9a83ac66
diff --git a/sdk/typescript/docs/cli.md b/sdk/typescript/docs/cli.mdindex d191056fe..b2d253b30 100644--- a/sdk/typescript/docs/cli.md+++ b/sdk/typescript/docs/cli.md@@ -438,6 +438,10 @@ show requested paths and exclusions. `coverage.deferred` records unfinishedrequested work separately from optional `coverage.openQuestions` follow-up.Human-readable output quotes ambiguous paths, while JSON retains their original strings.+When a cost limit is configured, `scan --dry-run` shows the resolved+`maxCostUsd` and a `costLimitNote` explaining how the scan measures usage+against the limit and why in-flight requests can exceed it.+Whole-codebase and path scans also accept ordinary directories, including SVNworking copies. Their source inventories exclude `.git` and `.svn` metadata.diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.tsindex 6519295a8..ea35b594c 100644--- a/sdk/typescript/src/cli.ts+++ b/sdk/typescript/src/cli.ts@@ -10815,6 +10815,12 @@ async function executeScan(data: {dryRun: true,...effectivePreflight,+ ...(effectivePreflight.maxCostUsd === undefined+ ? {}+ : {+ costLimitNote:+ "The limit uses reported token usage at short-context API prices. In-flight requests can push the estimate above the limit. Actual charges and ChatGPT allowance depend on your account.",+ }),...(arguments_.projectConfig === undefined? {}: {diff --git a/sdk/typescript/tests-ts/cli-fixtures.ts b/sdk/typescript/tests-ts/cli-fixtures.tsindex 3829351a6..c0a6771cf 100644--- a/sdk/typescript/tests-ts/cli-fixtures.ts+++ b/sdk/typescript/tests-ts/cli-fixtures.ts@@ -267,8 +267,11 @@ export function dependencies(}return result;},- preflight: async (repository: string) =>- options.preflight ?? fakePreflight(repository),+ preflight: async (repository: string, { maxCostUsd }: ScanOptions = {}) =>+ options.preflight ?? {+ ...fakePreflight(repository),+ ...(maxCostUsd === undefined ? {} : { maxCostUsd }),+ },validate: async (validationOptions: ValidationOptions) =>options.onValidate?.(validationOptions) ?? {disposition: "deferred",diff --git a/sdk/typescript/tests-ts/cli.test.ts b/sdk/typescript/tests-ts/cli.test.tsindex 1e4050ae6..3e0c59df1 100644--- a/sdk/typescript/tests-ts/cli.test.ts+++ b/sdk/typescript/tests-ts/cli.test.ts@@ -5730,6 +5730,22 @@ describe("CLI", () => {expect(stderr.text()).not.toContain("Running scan");});+ test("explains the resolved cost limit in a dry-run plan", async () => {+ const { stdout, runCli } = createCliTest(main);++ expect(+ await runCli(+ ["scan", "repo", "--max-cost", "5", "--dry-run", "--json"],+ dependencies(),+ ),+ ).toBe(0);+ const plan = JSON.parse(stdout.text());+ expect(plan.maxCostUsd).toBe(5);+ expect(plan.costLimitNote).toContain("short-context API prices");+ expect(plan.costLimitNote).toContain("In-flight requests");+ expect(plan.costLimitNote).toContain("ChatGPT allowance");+ });+test("renders dry-run output with Incur structured formats", async () => {for (const [format, marker] of [["toon", "dryRun: true"],