@openai/codex-security 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +92 -51
  2. package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
  3. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  5. package/_bundled_plugin/scripts/config_preflight.py +1 -1
  6. package/_bundled_plugin/scripts/deep_scan_workbench.py +1 -1
  7. package/_bundled_plugin/scripts/finalize_scan_contract.py +289 -4
  8. package/_bundled_plugin/scripts/workbench_cli.py +5 -0
  9. package/_bundled_plugin/scripts/workbench_db.py +39 -100
  10. package/_bundled_plugin/scripts/workbench_feedback.py +96 -0
  11. package/_bundled_plugin/scripts/workbench_scan_history.py +11 -1
  12. package/_bundled_plugin/scripts/workbench_scan_start.py +76 -0
  13. package/_bundled_plugin/scripts/workbench_schema.py +8 -0
  14. package/_bundled_plugin/scripts/workbench_target.py +95 -0
  15. package/_bundled_plugin/scripts/workbench_validation.py +7 -0
  16. package/_bundled_plugin/skills/validation/SKILL.md +2 -0
  17. package/dist/api.d.ts +2 -1
  18. package/dist/api.d.ts.map +1 -1
  19. package/dist/api.js +49 -5
  20. package/dist/api.js.map +1 -1
  21. package/dist/bulk-scan-discovery.js +10 -11
  22. package/dist/bulk-scan-discovery.js.map +1 -1
  23. package/dist/cli.d.ts +4 -1
  24. package/dist/cli.d.ts.map +1 -1
  25. package/dist/cli.js +162 -45
  26. package/dist/cli.js.map +1 -1
  27. package/dist/config.d.ts.map +1 -1
  28. package/dist/config.js +4 -0
  29. package/dist/config.js.map +1 -1
  30. package/dist/multiscan.d.ts.map +1 -1
  31. package/dist/multiscan.js +3 -1
  32. package/dist/multiscan.js.map +1 -1
  33. package/dist/scan-history-renderer.d.ts.map +1 -1
  34. package/dist/scan-history-renderer.js +8 -0
  35. package/dist/scan-history-renderer.js.map +1 -1
  36. package/dist/version.d.ts +14 -0
  37. package/dist/version.d.ts.map +1 -1
  38. package/dist/version.js +102 -0
  39. package/dist/version.js.map +1 -1
  40. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"bulk-scan-discovery.js","sourceRoot":"","sources":["../src/bulk-scan-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,QAAQ,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC;AAC7C,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;CAmBjC,CAAC;AAmDF,MAAM,UAAU,mCAAmC,CAAC,OAInD;IACC,OAAO;QACL,MAAM,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC;QAC5C,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE;YAChC,CAAC,CAAC,EAAE,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AAE,CAAC,CACxD;iBACA,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACzD,EACD,OAAO,EAAE,CACV;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { lstat, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { stdin } from \"node:process\";\nimport { Writable } from \"node:stream\";\nimport { promisify } from \"node:util\";\nimport { confirm, input, search } from \"@inquirer/prompts\";\nimport { Octokit } from \"@octokit/core\";\nimport Papa from \"papaparse\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\n\nconst execFile = promisify(execFileCallback);\nconst GITHUB_REPOSITORIES_QUERY = `\n query($owner: String!, $cursor: String) {\n repositoryOwner(login: $owner) {\n repositories(\n first: 100\n after: $cursor\n isArchived: false\n isFork: false\n orderBy: { field: PUSHED_AT, direction: DESC }\n ) {\n nodes {\n nameWithOwner\n pushedAt\n defaultBranchRef { target { oid } }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n }\n`;\n\ninterface GitHubRepository {\n fullName: string;\n url: string;\n revision: string;\n}\n\ninterface GitHubRepositoriesResponse {\n repositoryOwner: {\n repositories: {\n nodes: Array<{\n nameWithOwner: string;\n pushedAt: string;\n defaultBranchRef: { target: { oid: string } } | null;\n }>;\n pageInfo: { hasNextPage: boolean; endCursor: string | null };\n };\n } | null;\n}\n\nexport interface BulkScanPrompt {\n isInteractive(): boolean;\n write(value: string): void;\n confirm(question: string, defaultValue?: boolean): Promise<boolean>;\n input(question: string, defaultValue?: string): Promise<string>;\n select<Value extends string>(\n question: string,\n options: readonly { label: string; value: Value }[],\n ): Promise<Value>;\n}\n\nexport interface BulkScanDiscoveryDependencies {\n prompt: BulkScanPrompt;\n now(): number;\n currentDirectory(): string;\n githubHost?: string;\n createGitHub(host: string, signal?: AbortSignal): Promise<Octokit>;\n}\n\nexport interface BulkScanWizardResult {\n inputPath: string;\n outputDir: string;\n githubHost: string;\n}\n\ninterface PromptOutput {\n write(value: string): unknown;\n readonly isTTY?: boolean;\n}\n\nexport function createBulkScanDiscoveryDependencies(options: {\n output: PromptOutput;\n now(): number;\n currentDirectory(): string;\n}): BulkScanDiscoveryDependencies {\n return {\n prompt: createTerminalPrompt(options.output),\n now: options.now,\n currentDirectory: options.currentDirectory,\n ...(process.env[\"GH_HOST\"]?.trim()\n ? { githubHost: process.env[\"GH_HOST\"].trim() }\n : {}),\n createGitHub: async (host, signal) => {\n const trusted = await resolveTrustedExecutable(\n \"gh\",\n process.env,\n options.currentDirectory(),\n );\n if (trusted === null) {\n throw new Error(\n \"GitHub CLI is required. Install gh and sign in first.\",\n );\n }\n\n let token: string;\n try {\n const { stdout } = await execFile(\n trusted.executable,\n [\"auth\", \"token\", \"--hostname\", host],\n { env: trusted.environment, signal },\n );\n token = stdout.trim();\n } catch {\n signal?.throwIfAborted();\n throw new Error(\n \"GitHub sign-in is required. Run 'gh auth login' first.\",\n );\n }\n return new Octokit({\n auth: token,\n ...(host === \"github.com\" ? {} : { baseUrl: `https://${host}/api/v3` }),\n });\n },\n };\n}\n\nexport async function runBulkScanWizard(\n dependencies: BulkScanDiscoveryDependencies,\n signal?: AbortSignal,\n): Promise<BulkScanWizardResult | null> {\n const { prompt } = dependencies;\n if (!prompt.isInteractive()) {\n throw new Error(\n \"Interactive repository selection requires a terminal. Provide a CSV with 'codex-security bulk-scan repositories.csv --output-dir ./security-scans'.\",\n );\n }\n signal?.throwIfAborted();\n\n const githubHost = dependencies.githubHost ?? \"github.com\";\n const github = await dependencies.createGitHub(githubHost, signal);\n const owner = await selectGitHubOwner(github, prompt, signal);\n prompt.write(\"\\nFinding active repositories...\\n\");\n const discovered = await discoverGitHubRepositories(\n github,\n githubHost,\n owner,\n dependencies.now() - 90 * 86_400_000,\n signal,\n );\n if (discovered.length === 0) {\n prompt.write(\"\\nNo repositories matched your selection.\\n\");\n return null;\n }\n\n prompt.write(`\\nFound ${discovered.length} repositories.\\n`);\n const repositories = await selectGitHubRepositories(discovered, prompt);\n\n const outputDir = resolve(\n dependencies.currentDirectory(),\n await prompt.input(\n \"Where should scan results be saved?\",\n \"./security-scans\",\n ),\n );\n const inputPath = join(outputDir, \"repositories.csv\");\n await validateWizardOutput(outputDir);\n prompt.write(\n `\\nReady to scan ${repositories.length} repositories?\\n` +\n `Results: ${outputDir}\\nRepository list: ${inputPath}\\n`,\n );\n if (!(await prompt.confirm(\"Start scanning?\"))) {\n prompt.write(\"\\nScan canceled.\\n\");\n return null;\n }\n signal?.throwIfAborted();\n\n await mkdir(outputDir, { recursive: true, mode: 0o700 });\n await writeFile(\n inputPath,\n `${Papa.unparse(\n repositories.map(({ fullName, url, revision }) => ({\n id: repositoryId(fullName),\n repository: url,\n revision,\n })),\n )}\\n`,\n { flag: \"wx\", mode: 0o600, ...(signal === undefined ? {} : { signal }) },\n );\n return { inputPath, outputDir, githubHost };\n}\n\nasync function selectGitHubOwner(\n github: Octokit,\n prompt: BulkScanPrompt,\n signal?: AbortSignal,\n): Promise<string> {\n const { data } = await github.request(\"GET /user/orgs\", {\n per_page: 100,\n request: { signal },\n });\n const organizations = data.map(({ login }) => login).sort();\n if (organizations.length > 1) {\n return await prompt.select(\n \"Which account or organization should we scan?\",\n organizations.map((owner) => ({ label: owner, value: owner })),\n );\n }\n const owner =\n organizations[0] ??\n (await github.request(\"GET /user\", { request: { signal } })).data.login;\n prompt.write(`\\nFinding repositories in ${owner}.\\n`);\n return owner;\n}\n\nasync function selectGitHubRepositories(\n repositories: GitHubRepository[],\n prompt: BulkScanPrompt,\n): Promise<GitHubRepository[]> {\n const selected = new Set<string>();\n while (selected.size < repositories.length) {\n const choice = await prompt.select(\n \"Select repositories to scan (type to filter)\",\n [\n {\n label: selected.size\n ? `Done (${selected.size} selected)`\n : `All ${repositories.length} repositories`,\n value: \"\",\n },\n ...repositories\n .filter(({ fullName }) => !selected.has(fullName))\n .map(({ fullName }) => ({ label: fullName, value: fullName })),\n ],\n );\n if (!choice) break;\n selected.add(choice);\n }\n return selected.size\n ? repositories.filter(({ fullName }) => selected.has(fullName))\n : repositories;\n}\n\nasync function discoverGitHubRepositories(\n github: Octokit,\n host: string,\n owner: string,\n cutoff: number,\n signal?: AbortSignal,\n): Promise<GitHubRepository[]> {\n const repositories: GitHubRepository[] = [];\n let cursor: string | null = null;\n\n do {\n signal?.throwIfAborted();\n const result: GitHubRepositoriesResponse = await github.graphql(\n GITHUB_REPOSITORIES_QUERY,\n { owner, cursor, request: { signal } },\n );\n const connection = result.repositoryOwner?.repositories;\n if (connection === undefined) {\n throw new Error(\"GitHub could not list repositories for this account.\");\n }\n\n for (const repository of connection.nodes) {\n if (Date.parse(repository.pushedAt) < cutoff) return repositories;\n if (repository.defaultBranchRef === null) continue;\n repositories.push({\n fullName: repository.nameWithOwner,\n url: `https://${host}/${repository.nameWithOwner}.git`,\n revision: repository.defaultBranchRef.target.oid.toLowerCase(),\n });\n }\n cursor = connection.pageInfo.hasNextPage\n ? connection.pageInfo.endCursor\n : null;\n } while (cursor !== null);\n\n return repositories;\n}\n\nfunction repositoryId(fullName: string): string {\n const id = fullName.replace(\"/\", \"--\");\n if (id.length <= 128) return id;\n const hash = createHash(\"sha256\").update(fullName).digest(\"hex\").slice(0, 16);\n return `${id.slice(0, 111)}-${hash}`;\n}\n\nasync function validateWizardOutput(outputDir: string): Promise<void> {\n let metadata;\n try {\n metadata = await lstat(outputDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n throw error;\n }\n if (!metadata.isDirectory()) {\n throw new Error(\"The scan output must be a real directory.\");\n }\n\n for (const name of [\"repositories.csv\", \"manifest.json\"]) {\n try {\n await lstat(join(outputDir, name));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n throw error;\n }\n throw new Error(\n \"The selected output directory already contains a repository list or scan. Choose a new directory or resume the existing scan.\",\n );\n }\n}\n\nfunction createTerminalPrompt(output: PromptOutput): BulkScanPrompt {\n const context = () => ({\n input: stdin,\n output: new Writable({\n write(chunk: Buffer, _encoding, callback) {\n output.write(chunk.toString(\"utf8\"));\n callback();\n },\n }),\n });\n\n return {\n isInteractive: () => stdin.isTTY === true && output.isTTY === true,\n write: (value) => {\n output.write(value);\n },\n confirm: (message, defaultValue = false) =>\n confirm({ message, default: defaultValue }, context()),\n input: (message, defaultValue) =>\n input({ message, default: defaultValue }, context()),\n select: (message, options) =>\n search(\n {\n message,\n source: (term) =>\n options\n .filter(({ label }) =>\n label.toLowerCase().includes(term?.toLowerCase() ?? \"\"),\n )\n .map(({ label, value }) => ({ name: label, value })),\n },\n context(),\n ),\n };\n}\n"]}
1
+ {"version":3,"file":"bulk-scan-discovery.js","sourceRoot":"","sources":["../src/bulk-scan-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAEnE,MAAM,QAAQ,GAAG,SA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AE,EAAE,OAAO,EAAE,CAAC;QACxD,KAAK,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,CAC/B,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC;QACtD,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAC3B,MAAM,CACJ;YACE,OAAO;YACP,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CACf,OAAO;iBACJ,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACpB,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CACxD;iBACA,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;SACzD,EACD,OAAO,EAAE,CACV;KACJ,CAAC;AACJ,CAAC","sourcesContent":["import { execFile as execFileCallback } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport { lstat, mkdir, writeFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport { stdin } from \"node:process\";\nimport { Writable } from \"node:stream\";\nimport { promisify } from \"node:util\";\nimport { confirm, input, search } from \"@inquirer/prompts\";\nimport { Octokit } from \"@octokit/core\";\nimport Papa from \"papaparse\";\nimport { resolveTrustedExecutable } from \"./trusted-executable.js\";\n\nconst execFile = promisify(execFileCallback);\nconst GITHUB_REPOSITORIES_QUERY = `\n query($owner: String!, $cursor: String) {\n repositoryOwner(login: $owner) {\n repositories(\n first: 100\n after: $cursor\n isArchived: false\n isFork: false\n orderBy: { field: PUSHED_AT, direction: DESC }\n ) {\n nodes {\n nameWithOwner\n pushedAt\n defaultBranchRef { target { oid } }\n }\n pageInfo { hasNextPage endCursor }\n }\n }\n }\n`;\n\ninterface GitHubRepository {\n fullName: string;\n url: string;\n revision: string;\n}\n\ninterface GitHubRepositoriesResponse {\n repositoryOwner: {\n repositories: {\n nodes: Array<{\n nameWithOwner: string;\n pushedAt: string;\n defaultBranchRef: { target: { oid: string } } | null;\n }>;\n pageInfo: { hasNextPage: boolean; endCursor: string | null };\n };\n } | null;\n}\n\nexport interface BulkScanPrompt {\n isInteractive(): boolean;\n write(value: string): void;\n confirm(question: string, defaultValue?: boolean): Promise<boolean>;\n input(question: string, defaultValue?: string): Promise<string>;\n select<Value extends string>(\n question: string,\n options: readonly { label: string; value: Value }[],\n ): Promise<Value>;\n}\n\nexport interface BulkScanDiscoveryDependencies {\n prompt: BulkScanPrompt;\n now(): number;\n currentDirectory(): string;\n githubHost?: string;\n createGitHub(host: string, signal?: AbortSignal): Promise<Octokit>;\n}\n\nexport interface BulkScanWizardResult {\n inputPath: string;\n outputDir: string;\n githubHost: string;\n}\n\ninterface PromptOutput {\n write(value: string): unknown;\n readonly isTTY?: boolean;\n}\n\nexport function createBulkScanDiscoveryDependencies(options: {\n output: PromptOutput;\n now(): number;\n currentDirectory(): string;\n}): BulkScanDiscoveryDependencies {\n return {\n prompt: createTerminalPrompt(options.output),\n now: options.now,\n currentDirectory: options.currentDirectory,\n ...(process.env[\"GH_HOST\"]?.trim()\n ? { githubHost: process.env[\"GH_HOST\"].trim() }\n : {}),\n createGitHub: async (host, signal) => {\n const trusted = await resolveTrustedExecutable(\n \"gh\",\n process.env,\n options.currentDirectory(),\n );\n if (trusted === null) {\n throw new Error(\n \"GitHub CLI is required. Install gh and sign in first.\",\n );\n }\n\n let token: string;\n try {\n const { stdout } = await execFile(\n trusted.executable,\n [\"auth\", \"token\", \"--hostname\", host],\n { env: trusted.environment, signal },\n );\n token = stdout.trim();\n } catch {\n signal?.throwIfAborted();\n throw new Error(\n \"GitHub sign-in is required. Run 'gh auth login' first.\",\n );\n }\n return new Octokit({\n auth: token,\n ...(host === \"github.com\" ? {} : { baseUrl: `https://${host}/api/v3` }),\n });\n },\n };\n}\n\nexport async function runBulkScanWizard(\n dependencies: BulkScanDiscoveryDependencies,\n signal?: AbortSignal,\n): Promise<BulkScanWizardResult | null> {\n const { prompt } = dependencies;\n if (!prompt.isInteractive()) {\n throw new Error(\n \"Interactive repository selection requires a terminal. Provide a CSV with 'codex-security bulk-scan repositories.csv --output-dir ./security-scans'.\",\n );\n }\n signal?.throwIfAborted();\n\n const githubHost = dependencies.githubHost ?? \"github.com\";\n const github = await dependencies.createGitHub(githubHost, signal);\n const owner = await selectGitHubOwner(github, prompt, signal);\n prompt.write(\"\\nFinding active repositories...\\n\");\n const discovered = await discoverGitHubRepositories(\n github,\n githubHost,\n owner,\n dependencies.now() - 90 * 86_400_000,\n signal,\n );\n if (discovered.length === 0) {\n prompt.write(\"\\nNo repositories matched your selection.\\n\");\n return null;\n }\n\n prompt.write(`\\nFound ${discovered.length} repositories.\\n`);\n const repositories = await selectGitHubRepositories(discovered, prompt);\n\n const outputDir = resolve(\n dependencies.currentDirectory(),\n await prompt.input(\n \"Where should scan results be saved?\",\n \"./security-scans\",\n ),\n );\n const inputPath = join(outputDir, \"repositories.csv\");\n await validateWizardOutput(outputDir);\n prompt.write(\n `\\nReady to scan ${repositories.length} repositories?\\n` +\n `Results: ${outputDir}\\nRepository list: ${inputPath}\\n`,\n );\n if (!(await prompt.confirm(\"Start scanning?\"))) {\n prompt.write(\"\\nScan canceled.\\n\");\n return null;\n }\n signal?.throwIfAborted();\n\n await mkdir(outputDir, { recursive: true, mode: 0o700 });\n await writeFile(\n inputPath,\n `${Papa.unparse(\n repositories.map(({ fullName, url, revision }) => ({\n id: repositoryId(fullName),\n repository: url,\n revision,\n })),\n )}\\n`,\n { flag: \"wx\", mode: 0o600, ...(signal === undefined ? {} : { signal }) },\n );\n return { inputPath, outputDir, githubHost };\n}\n\nasync function selectGitHubOwner(\n github: Octokit,\n prompt: BulkScanPrompt,\n signal?: AbortSignal,\n): Promise<string> {\n const [orgs, user] = await Promise.all([\n github.request(\"GET /user/orgs\", { per_page: 100, request: { signal } }),\n github.request(\"GET /user\", { request: { signal } }),\n ]);\n const personal = user.data.login;\n const owners = [personal, ...orgs.data.map(({ login }) => login)].sort();\n if (owners.length > 1) {\n return await prompt.select(\n \"Which account or organization should we scan?\",\n owners.map((owner) => ({ label: owner, value: owner })),\n );\n }\n prompt.write(`\\nFinding repositories in ${personal}.\\n`);\n return personal;\n}\n\nasync function selectGitHubRepositories(\n repositories: GitHubRepository[],\n prompt: BulkScanPrompt,\n): Promise<GitHubRepository[]> {\n const selected = new Set<string>();\n while (selected.size < repositories.length) {\n const choice = await prompt.select(\n \"Select repositories to scan (type to filter)\",\n [\n {\n label: selected.size\n ? `Done (${selected.size} selected)`\n : `All ${repositories.length} repositories`,\n value: \"\",\n },\n ...repositories\n .filter(({ fullName }) => !selected.has(fullName))\n .map(({ fullName }) => ({ label: fullName, value: fullName })),\n ],\n );\n if (!choice) break;\n selected.add(choice);\n }\n return selected.size\n ? repositories.filter(({ fullName }) => selected.has(fullName))\n : repositories;\n}\n\nasync function discoverGitHubRepositories(\n github: Octokit,\n host: string,\n owner: string,\n cutoff: number,\n signal?: AbortSignal,\n): Promise<GitHubRepository[]> {\n const repositories: GitHubRepository[] = [];\n let cursor: string | null = null;\n\n do {\n signal?.throwIfAborted();\n const result: GitHubRepositoriesResponse = await github.graphql(\n GITHUB_REPOSITORIES_QUERY,\n { owner, cursor, request: { signal } },\n );\n const connection = result.repositoryOwner?.repositories;\n if (connection === undefined) {\n throw new Error(\"GitHub could not list repositories for this account.\");\n }\n\n for (const repository of connection.nodes) {\n if (Date.parse(repository.pushedAt) < cutoff) return repositories;\n if (repository.defaultBranchRef === null) continue;\n repositories.push({\n fullName: repository.nameWithOwner,\n url: `https://${host}/${repository.nameWithOwner}.git`,\n revision: repository.defaultBranchRef.target.oid.toLowerCase(),\n });\n }\n cursor = connection.pageInfo.hasNextPage\n ? connection.pageInfo.endCursor\n : null;\n } while (cursor !== null);\n\n return repositories;\n}\n\nfunction repositoryId(fullName: string): string {\n const id = fullName.replace(\"/\", \"--\");\n if (id.length <= 128) return id;\n const hash = createHash(\"sha256\").update(fullName).digest(\"hex\").slice(0, 16);\n return `${id.slice(0, 111)}-${hash}`;\n}\n\nasync function validateWizardOutput(outputDir: string): Promise<void> {\n let metadata;\n try {\n metadata = await lstat(outputDir);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n throw error;\n }\n if (!metadata.isDirectory()) {\n throw new Error(\"The scan output must be a real directory.\");\n }\n\n for (const name of [\"repositories.csv\", \"manifest.json\"]) {\n try {\n await lstat(join(outputDir, name));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") continue;\n throw error;\n }\n throw new Error(\n \"The selected output directory already contains a repository list or scan. Choose a new directory or resume the existing scan.\",\n );\n }\n}\n\nfunction createTerminalPrompt(output: PromptOutput): BulkScanPrompt {\n const context = () => ({\n input: stdin,\n output: new Writable({\n write(chunk: Buffer, _encoding, callback) {\n output.write(chunk.toString(\"utf8\"));\n callback();\n },\n }),\n });\n\n return {\n isInteractive: () => stdin.isTTY === true && output.isTTY === true,\n write: (value) => {\n output.write(value);\n },\n confirm: (message, defaultValue = false) =>\n confirm({ message, default: defaultValue }, context()),\n input: (message, defaultValue) =>\n input({ message, default: defaultValue }, context()),\n select: (message, options) =>\n search(\n {\n message,\n source: (term) =>\n options\n .filter(({ label }) =>\n label.toLowerCase().includes(term?.toLowerCase() ?? \"\"),\n )\n .map(({ label, value }) => ({ name: label, value })),\n },\n context(),\n ),\n };\n}\n"]}
package/dist/cli.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ import type { ModelReasoningEffort } from "@openai/codex-sdk";
2
3
  import { CodexSecurity } from "./api.js";
3
4
  import { type BulkScanDiscoveryDependencies, type BulkScanPrompt } from "./bulk-scan-discovery.js";
4
5
  import { type CodexSecurityConfig, type JsonObject } from "./config.js";
5
6
  import { type CodexCommand } from "./runtime.js";
6
7
  import { matchScanFindings } from "./scan-comparison.js";
8
+ import { type UpdateNotice } from "./version.js";
7
9
  type Writable = Pick<NodeJS.WriteStream, "write"> & {
8
10
  readonly isTTY?: boolean;
9
11
  readonly fd?: number;
@@ -45,6 +47,7 @@ interface CliDependencies {
45
47
  bulkScan?: BulkScanDiscoveryDependencies;
46
48
  runWorkbench(args: readonly string[]): Promise<JsonObject>;
47
49
  matchFindings: typeof matchScanFindings;
50
+ checkForUpdate(): Promise<UpdateNotice | undefined>;
48
51
  }
49
52
  export declare function runCodexSkillCommand(args: readonly string[], output?: SkillCommandOutput, command?: CodexCommand): Promise<number>;
50
53
  export declare function exportEnvironment(environment?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
@@ -55,7 +58,7 @@ export declare function readSkillCommandOutput(stream: AsyncIterable<Buffer | st
55
58
  malformed: boolean;
56
59
  }>;
57
60
  export declare function skillCommandFailure(command: "validate" | "patch", status: number, detail: string): string;
58
- export declare function parseCodexOverrides(values: readonly string[], model?: string): JsonObject;
61
+ export declare function parseCodexOverrides(values: readonly string[], model?: string, effort?: ModelReasoningEffort): JsonObject;
59
62
  export declare class Progress {
60
63
  #private;
61
64
  constructor(stream?: Writable, dependencies?: Pick<CliDependencies, "now" | "setInterval" | "clearInterval">, interactive?: boolean);
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA6BA,OAAO,EAEL,aAAa,EAMd,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,KAAK,6BAA6B,EAClC,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAUrB,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EAElB,MAAM,sBAAsB,CAAC;AA4B9B,KAAK,QAAQ,GAAG,I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,CAC1C,MAAM,EAAE,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,GACrC,OAAO,CAAC;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CAqDnE;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,GAAG,OAAO,EAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb,MAAM,CAyBR;AA+lBD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,oBAAoB,GAC5B,UAAU,CAgEZ;AAwBD,qBAAa,QAAQ;;gBAajB,MAAM,GAAE,QAAyB,EACjC,YAAY,GAAE,IAAI,CAChB,eAAe,EACf,KAAK,GAAG,aAAa,GAAG,eAAe,CACjB,EACxB,WAAW,UAAO;IAQpB,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,cAAc,IAAI,MAAM,CAKlC;IAEM,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAcjC,SAAS,IAAI,IAAI;CA4BzB"}
package/dist/cli.js CHANGED
@@ -21,7 +21,7 @@ import { bundledPluginRoot, codexSecurityStateDirectory, expandHome, resolveCode
21
21
  import { matchScanFindings, } from "./scan-comparison.js";
22
22
  import { renderScanHistory, } from "./scan-history-renderer.js";
23
23
  import { DiffTarget } from "./targets.js";
24
- import { BUNDLED_PLUGIN_VERSION, CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION, VERSION, } from "./version.js";
24
+ import { BUNDLED_PLUGIN_VERSION, checkForUpdate, CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION, formatUpdateNotice, updateNoticeEnabled, VERSION, } from "./version.js";
25
25
  const PROGRESS_REFRESH_MILLISECONDS = 1_000;
26
26
  const MAX_CODEX_OVERRIDE_KEY_LENGTH = 1_024;
27
27
  const MAX_CODEX_OVERRIDE_VALUE_LENGTH = 64 * 1_024;
@@ -43,6 +43,14 @@ const DISPLAY_SEVERITIES = [
43
43
  ...REPORTABLE_SEVERITIES,
44
44
  "informational",
45
45
  ];
46
+ const MODEL_REASONING_EFFORTS = [
47
+ "minimal",
48
+ "low",
49
+ "medium",
50
+ "high",
51
+ "xhigh",
52
+ ];
53
+ const DEFAULT_SCAN_MODEL_CONFIGURATION = scanModelConfiguration(DEFAULT_CODEX_CONFIG);
46
54
  const EXPORT_DEFAULT_OUTPUTS = {
47
55
  csv: "findings.csv",
48
56
  json: "findings.json",
@@ -57,6 +65,7 @@ const VALUE_OPTIONS = new Set([
57
65
  "--base",
58
66
  "--mode",
59
67
  "--model",
68
+ "--effort",
60
69
  "--output-dir",
61
70
  "--plugin-path",
62
71
  "--python",
@@ -73,13 +82,23 @@ const VALUE_OPTIONS = new Set([
73
82
  "--token-limit",
74
83
  "--token-offset",
75
84
  "--scan-root",
85
+ "--reason",
76
86
  ]);
77
87
  function optionValue(flag) {
78
88
  return z.string().min(1, `${flag} must not be empty.`);
79
89
  }
90
+ function effortOption() {
91
+ return z
92
+ .enum(MODEL_REASONING_EFFORTS, {
93
+ error: "--effort must be minimal, low, medium, high, or xhigh.",
94
+ })
95
+ .optional()
96
+ .describe(`Model reasoning effort (default: ${DEFAULT_SCAN_MODEL_CONFIGURATION.reasoningEffort}).`);
97
+ }
80
98
  const DEFAULT_DEPENDENCIES = {
81
99
  createSecurity: (config) => new CodexSecurity(config),
82
100
  environment: process.env,
101
+ checkForUpdate: () => checkForUpdate({ environment: process.env }),
83
102
  hasStoredChatGPTSignIn: async () => {
84
103
  const environment = Object.fromEntries(Object.entries(process.env).filter(([name]) => name.toUpperCase() !== "OPENAI_API_KEY" &&
85
104
  name.toUpperCase() !== "CODEX_API_KEY"));
@@ -303,6 +322,21 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
303
322
  errorOutput.write(`codex-security: ${argumentError}\n`);
304
323
  return 2;
305
324
  }
325
+ const pendingUpdate = errorOutput.isTTY === true &&
326
+ argv.length > 0 &&
327
+ argv[0] !== "completions" &&
328
+ !argv.some((argument) => [
329
+ "--help",
330
+ "-h",
331
+ "--version",
332
+ "--llms",
333
+ "--llms-full",
334
+ "--schema",
335
+ "--dry-run",
336
+ ].includes(argument)) &&
337
+ updateNoticeEnabled(dependencies.environment)
338
+ ? dependencies.checkForUpdate().catch(() => undefined)
339
+ : undefined;
306
340
  let exitCode = 0;
307
341
  let frameworkExit;
308
342
  let frameworkOutput = "";
@@ -335,6 +369,43 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
335
369
  });
336
370
  return result;
337
371
  };
372
+ const findingFeedback = Cli.create("findings", {
373
+ description: "Review and manage saved Codex Security findings.",
374
+ }).command("false-positive", {
375
+ description: "Mark a finding as a false positive for future scans.",
376
+ destructive: true,
377
+ mcp: false,
378
+ args: z.object({
379
+ occurrenceId: z
380
+ .string()
381
+ .trim()
382
+ .min(1)
383
+ .max(256)
384
+ .describe("Finding occurrence identifier."),
385
+ }),
386
+ options: z.object({
387
+ reason: z
388
+ .string()
389
+ .trim()
390
+ .min(1, "--reason must not be empty.")
391
+ .max(2_400, "--reason must not exceed 2400 characters.")
392
+ .describe("Explanation for why the finding is a false positive."),
393
+ }),
394
+ output: z.record(z.string(), z.unknown()).optional(),
395
+ async run({ args, options }) {
396
+ return await history([
397
+ "set-finding-triage",
398
+ "--occurrence-id",
399
+ args.occurrenceId,
400
+ "--status",
401
+ "closed",
402
+ "--close-reason",
403
+ "false_positive",
404
+ "--note",
405
+ options.reason,
406
+ ]);
407
+ },
408
+ });
338
409
  const scanHistory = Cli.create("scans", {
339
410
  description: "List, inspect, rerun, match, and compare saved Codex Security scans.",
340
411
  })
@@ -574,7 +645,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
574
645
  .describe("Scan mode."),
575
646
  model: optionValue("--model")
576
647
  .optional()
577
- .describe("Model to use for the scan."),
648
+ .describe(`OpenAI model to use (default: ${DEFAULT_SCAN_MODEL_CONFIGURATION.model}).`),
649
+ effort: effortOption(),
578
650
  outputDir: optionValue("--output-dir")
579
651
  .optional()
580
652
  .describe("Write scan artifacts to DIR."),
@@ -591,7 +663,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
591
663
  codex: z
592
664
  .array(optionValue("--codex"))
593
665
  .default([])
594
- .describe("Override isolated Codex config with KEY=VALUE; repeat as needed."),
666
+ .describe('Override Codex settings; e.g. model_reasoning_effort="high".'),
595
667
  failOnSeverity: z
596
668
  .enum(REPORTABLE_SEVERITIES)
597
669
  .optional()
@@ -620,6 +692,10 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
620
692
  examples: [
621
693
  { args: { repository: "." } },
622
694
  { args: { repository: "." }, options: { model: "gpt-5.6-terra" } },
695
+ {
696
+ args: { repository: "." },
697
+ options: { model: "gpt-5.6-terra", effort: "high" },
698
+ },
623
699
  { args: { repository: "." }, options: { path: ["src", "tests"] } },
624
700
  { args: { repository: "." }, options: { diff: "origin/main" } },
625
701
  ],
@@ -641,6 +717,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
641
717
  base: options.base,
642
718
  mode: options.mode,
643
719
  model: options.model,
720
+ effort: options.effort,
644
721
  outputDir: options.outputDir,
645
722
  archiveExisting: options.archiveExisting,
646
723
  pluginPath: options.pluginPath,
@@ -658,6 +735,11 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
658
735
  exitCode,
659
736
  });
660
737
  }
738
+ if (!options.dryRun &&
739
+ format === "toon" &&
740
+ !argv.some((argument) => SCAN_HISTORY_OUTPUT_OPTION.test(argument))) {
741
+ return;
742
+ }
661
743
  return outcome.data;
662
744
  },
663
745
  })
@@ -727,6 +809,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
727
809
  },
728
810
  })
729
811
  .command(scanHistory)
812
+ .command(findingFeedback)
730
813
  .command("bulk-scan", {
731
814
  description: "Discover repositories and run resumable bulk security scans.",
732
815
  destructive: true,
@@ -748,7 +831,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
748
831
  mode: z.enum(["standard", "deep"]).default("standard"),
749
832
  model: optionValue("--model")
750
833
  .optional()
751
- .describe("Model to use for each repository."),
834
+ .describe(`OpenAI model for each repository (default: ${DEFAULT_SCAN_MODEL_CONFIGURATION.model}).`),
835
+ effort: effortOption(),
752
836
  maxAttempts: z
753
837
  .number()
754
838
  .int()
@@ -757,7 +841,10 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
757
841
  .describe("Maximum scan attempts per repository."),
758
842
  pluginPath: z.string().min(1).optional(),
759
843
  python: z.string().min(1).optional(),
760
- codex: z.array(z.string().min(1)).default([]),
844
+ codex: z
845
+ .array(z.string().min(1))
846
+ .default([])
847
+ .describe('Override Codex settings; e.g. model_reasoning_effort="high".'),
761
848
  }),
762
849
  output: z.record(z.string(), z.unknown()).optional(),
763
850
  async run({ args, options }) {
@@ -777,11 +864,25 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
777
864
  let outputDir;
778
865
  let githubHost;
779
866
  if (args.input === undefined) {
780
- if (argv[0] !== "bulk-scan" ||
781
- !(argv.length === 1 ||
782
- (argv.length === 3 && argv[1] === "--model") ||
783
- (argv.length === 2 && argv[1] === `--model=${options.model}`))) {
784
- throw new Error("Run 'codex-security bulk-scan [--model MODEL]' to discover repositories, or provide a CSV and --output-dir.");
867
+ let optionIndex = 1;
868
+ while (optionIndex < argv.length) {
869
+ const argument = argv[optionIndex];
870
+ if (argument === "--model" ||
871
+ argument === "--effort" ||
872
+ argument === "--codex") {
873
+ optionIndex += 2;
874
+ }
875
+ else if (argument.startsWith("--model=") ||
876
+ argument.startsWith("--effort=") ||
877
+ argument.startsWith("--codex=")) {
878
+ optionIndex += 1;
879
+ }
880
+ else {
881
+ break;
882
+ }
883
+ }
884
+ if (argv[0] !== "bulk-scan" || optionIndex !== argv.length) {
885
+ throw new Error("Run 'codex-security bulk-scan [--model MODEL] [--effort EFFORT] [--codex KEY=VALUE]' to discover repositories, or provide a CSV and --output-dir.");
785
886
  }
786
887
  const wizard = await runBulkScanWizard(dependencies.bulkScan ??
787
888
  createBulkScanDiscoveryDependencies({
@@ -812,7 +913,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
812
913
  config: {
813
914
  pluginPath: options.pluginPath,
814
915
  pythonPath: options.python,
815
- codexOverrides: parseCodexOverrides(options.codex, options.model),
916
+ codexOverrides: parseCodexOverrides(options.codex, options.model, options.effort),
816
917
  },
817
918
  createSecurity: dependencies.createSecurity,
818
919
  signal: controller.signal,
@@ -893,14 +994,15 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
893
994
  .describe("Finding text or a file containing findings."),
894
995
  }),
895
996
  options: z.object({
997
+ effort: effortOption(),
896
998
  codex: z
897
999
  .array(optionValue("--codex"))
898
1000
  .default([])
899
- .describe("Override model or model_reasoning_effort with KEY=VALUE."),
1001
+ .describe('Set model="gpt-5.6-terra" or model_reasoning_effort="high".'),
900
1002
  }),
901
1003
  async run({ options }) {
902
1004
  try {
903
- exitCode = await runSkill("validation", positionals, options.codex, output, errorOutput, dependencies);
1005
+ exitCode = await runSkill("validation", positionals, options.codex, options.effort, output, errorOutput, dependencies);
904
1006
  }
905
1007
  catch (error) {
906
1008
  exitCode = 2;
@@ -919,14 +1021,15 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
919
1021
  .describe("Issue text or a file containing issues."),
920
1022
  }),
921
1023
  options: z.object({
1024
+ effort: effortOption(),
922
1025
  codex: z
923
1026
  .array(optionValue("--codex"))
924
1027
  .default([])
925
- .describe("Override model or model_reasoning_effort with KEY=VALUE."),
1028
+ .describe('Set model="gpt-5.6-terra" or model_reasoning_effort="high".'),
926
1029
  }),
927
1030
  async run({ options }) {
928
1031
  try {
929
- exitCode = await runSkill("fix-finding", positionals, options.codex, output, errorOutput, dependencies);
1032
+ exitCode = await runSkill("fix-finding", positionals, options.codex, options.effort, output, errorOutput, dependencies);
930
1033
  }
931
1034
  catch (error) {
932
1035
  exitCode = 2;
@@ -974,9 +1077,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
974
1077
  errorOutput.write("To use a ChatGPT sign-in, unset OPENAI_API_KEY and CODEX_API_KEY.\n");
975
1078
  }
976
1079
  }
977
- else if (exitCode === 0 &&
978
- !options.withApiKey &&
979
- !options.withAccessToken) {
1080
+ else if (exitCode === 0 && !options.withApiKey) {
980
1081
  const authentication = scanAuthentication(dependencies.environment);
981
1082
  if (authentication.method === "api_key") {
982
1083
  const configuredApiKeyVariables = Object.entries(dependencies.environment)
@@ -984,9 +1085,15 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
984
1085
  (name.toUpperCase() === "OPENAI_API_KEY" ||
985
1086
  name.toUpperCase() === "CODEX_API_KEY"))
986
1087
  .map(([name]) => name);
987
- errorOutput.write("ChatGPT login succeeded. Interactive scans will ask which account to use; " +
988
- `noninteractive scans will use ${authentication.source}.\n` +
989
- "To use your ChatGPT sign-in, pass '--auth chatgpt' or run " +
1088
+ const loginWarning = options.withAccessToken
1089
+ ? `Access-token login succeeded, but noninteractive scans will use ${authentication.source}.\n`
1090
+ : "ChatGPT login succeeded. Interactive scans will ask which account to use; " +
1091
+ `noninteractive scans will use ${authentication.source}.\n`;
1092
+ const storedCredentials = options.withAccessToken
1093
+ ? "your stored credentials"
1094
+ : "your ChatGPT sign-in";
1095
+ errorOutput.write(loginWarning +
1096
+ `To use ${storedCredentials}, pass '--auth chatgpt' or run ` +
990
1097
  `'unset ${configuredApiKeyVariables.join(" ")}'.\n`);
991
1098
  }
992
1099
  }
@@ -1040,7 +1147,9 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1040
1147
  };
1041
1148
  },
1042
1149
  });
1043
- await cli.serve([...argv], {
1150
+ await cli.serve(argv.flatMap((argument) => argument.startsWith("--format=")
1151
+ ? ["--format", argument.slice("--format=".length)]
1152
+ : [argument]), {
1044
1153
  stdout: (value) => {
1045
1154
  frameworkOutput += value;
1046
1155
  },
@@ -1048,6 +1157,11 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1048
1157
  frameworkExit = code;
1049
1158
  },
1050
1159
  });
1160
+ if (pendingUpdate !== undefined) {
1161
+ const notice = await pendingUpdate;
1162
+ if (notice !== undefined)
1163
+ errorOutput.write(formatUpdateNotice(notice));
1164
+ }
1051
1165
  if (frameworkExit !== undefined) {
1052
1166
  if (exitCode !== 0)
1053
1167
  return exitCode;
@@ -1174,6 +1288,7 @@ function validateCliArguments(argv, positionals) {
1174
1288
  "install-hook",
1175
1289
  "bulk-scan",
1176
1290
  "scans",
1291
+ "findings",
1177
1292
  "export",
1178
1293
  "validate",
1179
1294
  "patch",
@@ -1213,7 +1328,8 @@ function validateCliArguments(argv, positionals) {
1213
1328
  return "Markdown output is not supported for scan results.";
1214
1329
  }
1215
1330
  }
1216
- const subcommand = command === "scans" ? argv[commandIndex + 1] : undefined;
1331
+ const nestedCommand = command === "scans" || command === "findings";
1332
+ const subcommand = nestedCommand ? argv[commandIndex + 1] : undefined;
1217
1333
  if (command === "info") {
1218
1334
  const metadataFields = new Set([
1219
1335
  "sdkVersion",
@@ -1242,7 +1358,7 @@ function validateCliArguments(argv, positionals) {
1242
1358
  }
1243
1359
  }
1244
1360
  }
1245
- for (let index = commandIndex + (command === "scans" ? 2 : 1); index < argv.length; index += 1) {
1361
+ for (let index = commandIndex + (nestedCommand ? 2 : 1); index < argv.length; index += 1) {
1246
1362
  const value = argv[index];
1247
1363
  if (!value.startsWith("-")) {
1248
1364
  positionals.push(value);
@@ -1346,11 +1462,11 @@ function staysWithinWindowsDeviceRoot(input, root) {
1346
1462
  }
1347
1463
  return true;
1348
1464
  }
1349
- async function runSkill(skill, inputs, codexOverrides, stdout, stderr, dependencies) {
1465
+ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, dependencies) {
1350
1466
  if (inputs.length > MAX_SKILL_INPUT_COUNT) {
1351
1467
  throw new CodexSecurityError("Skill inputs exceed the 64-item limit.");
1352
1468
  }
1353
- const overrides = parseCodexOverrides(codexOverrides);
1469
+ const overrides = parseCodexOverrides(codexOverrides, undefined, effort);
1354
1470
  if (Object.keys(overrides).some((key) => key !== "model" && key !== "model_reasoning_effort")) {
1355
1471
  throw new CodexSecurityError("Validation and patching only support model and model_reasoning_effort overrides.");
1356
1472
  }
@@ -1590,7 +1706,6 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1590
1706
  let firstSignalAt = 0;
1591
1707
  let progress = null;
1592
1708
  let lastWorkerUpdate = "";
1593
- let workerCapacity = null;
1594
1709
  let phase = null;
1595
1710
  const preparationAbortController = new AbortController();
1596
1711
  const signalListener = (signal) => () => {
@@ -1640,7 +1755,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1640
1755
  pluginPath: arguments_.pluginPath,
1641
1756
  pythonPath: arguments_.pythonPath,
1642
1757
  codexOverrides: arguments_.codexOverrides ??
1643
- parseCodexOverrides(arguments_.codex, arguments_.model),
1758
+ parseCodexOverrides(arguments_.codex, arguments_.model, arguments_.effort),
1644
1759
  };
1645
1760
  let auth = arguments_.auth;
1646
1761
  selectedAuthentication = scanAuthentication(dependencies.environment, auth);
@@ -1742,10 +1857,8 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1742
1857
  if (update === lastWorkerUpdate)
1743
1858
  return;
1744
1859
  lastWorkerUpdate = update;
1745
- if (status.kind === "dispatch") {
1746
- workerCapacity = { planned: status.planned, started: status.started };
1860
+ if (status.kind === "dispatch")
1747
1861
  phase = scanPhase(status.phase);
1748
- }
1749
1862
  const message = workerStatusMessage(status);
1750
1863
  if (message === null || progress === null)
1751
1864
  return;
@@ -1753,6 +1866,9 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1753
1866
  progress.stage(message);
1754
1867
  progress.startTimer(runningMessage());
1755
1868
  },
1869
+ onWarning: (warning) => {
1870
+ errorOutput.write(`codex-security: warning: ${cliErrorMessage(warning)}\n`);
1871
+ },
1756
1872
  onObserverError: (observer, error) => {
1757
1873
  errorOutput.write(`codex-security: warning: ${observer} observer failed: ${cliErrorMessage(error)}\n`);
1758
1874
  },
@@ -1821,7 +1937,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1821
1937
  const blockingCount = result.findings.findings.filter(({ severity }) => blockingSeverities.has(severity.level)).length;
1822
1938
  const incomplete = result.coverage.completeness !== "complete";
1823
1939
  progress?.stage("Scan complete");
1824
- printScanSummary(result, progress, errorOutput, workerCapacity);
1940
+ printScanSummary(result, progress, errorOutput);
1825
1941
  if (incomplete) {
1826
1942
  errorOutput.write(threshold === undefined
1827
1943
  ? `codex-security: Scan coverage is ${result.coverage.completeness}; results may be incomplete.\n`
@@ -1848,9 +1964,7 @@ function scanFailureMessage(error, authentication) {
1848
1964
  case "rate_limited":
1849
1965
  return "The configured account reached its rate limit. Wait and retry.";
1850
1966
  case "network_error":
1851
- return "The model service could not be reached. Check your network connection and try again.";
1852
1967
  case "timeout":
1853
- return "The connection timed out. Check your network connection and try again.";
1854
1968
  case "unknown":
1855
1969
  return cliErrorMessage(error);
1856
1970
  }
@@ -1882,7 +1996,7 @@ function scanPhase(value) {
1882
1996
  attack_path: "analyzing attack paths",
1883
1997
  }[value];
1884
1998
  }
1885
- function printScanSummary(result, progress, errorOutput, workers) {
1999
+ function printScanSummary(result, progress, errorOutput) {
1886
2000
  const severities = new Map();
1887
2001
  for (const finding of result.findings.findings) {
1888
2002
  severities.set(finding.severity.level, (severities.get(finding.severity.level) ?? 0) + 1);
@@ -1901,7 +2015,7 @@ function printScanSummary(result, progress, errorOutput, workers) {
1901
2015
  completed >= started
1902
2016
  ? Math.floor((completed - started) / 1_000)
1903
2017
  : progress?.elapsedSeconds ?? 0;
1904
- errorOutput.write(`codex-security: Elapsed: ${elapsed}s.${workers === null ? "" : ` Workers: ${workers.started}/${workers.planned}.`}\n`);
2018
+ errorOutput.write(`codex-security: Elapsed: ${elapsed}s.\n`);
1905
2019
  const tokenSummary = formatTokenUsage(result.turnResult.usage);
1906
2020
  if (tokenSummary !== null) {
1907
2021
  errorOutput.write(`codex-security: Tokens: ${tokenSummary}.\n`);
@@ -1909,11 +2023,8 @@ function printScanSummary(result, progress, errorOutput, workers) {
1909
2023
  if (result.cost !== null) {
1910
2024
  errorOutput.write(`codex-security: Estimated cost: ${formatUsd(result.cost.estimatedUsd)} USD.\n`);
1911
2025
  }
1912
- const scanDir = cliErrorMessage(result.scanDir);
1913
- errorOutput.write(`codex-security: Results: ${scanDir}\n`);
1914
- errorOutput.write(result.sarifPath === null
1915
- ? `codex-security: Next: codex-security export ${quoteCliPath(scanDir)} --export-format sarif\n`
1916
- : `codex-security: Next: review ${cliErrorMessage(result.reportPath)}\n`);
2026
+ errorOutput.write(`codex-security: Report: ${cliErrorMessage(result.reportPath)}\n`);
2027
+ errorOutput.write(`codex-security: Results: ${cliErrorMessage(result.scanDir)}\n`);
1917
2028
  }
1918
2029
  function formatTokenUsage(usage) {
1919
2030
  if (usage === null || typeof usage !== "object")
@@ -2009,10 +2120,12 @@ function targetFromArguments(arguments_) {
2009
2120
  }
2010
2121
  return "repository";
2011
2122
  }
2012
- export function parseCodexOverrides(values, model) {
2123
+ export function parseCodexOverrides(values, model, effort) {
2013
2124
  const result = Object.create(null);
2014
2125
  if (model !== undefined)
2015
2126
  result["model"] = model;
2127
+ if (effort !== undefined)
2128
+ result["model_reasoning_effort"] = effort;
2016
2129
  for (const value of values) {
2017
2130
  const separator = value.indexOf("=");
2018
2131
  const key = separator < 0 ? "" : value.slice(0, separator);
@@ -2056,9 +2169,13 @@ export function parseCodexOverrides(values, model) {
2056
2169
  }
2057
2170
  const final = parts.at(-1);
2058
2171
  if (Object.hasOwn(cursor, final)) {
2059
- throw new CodexSecurityError(model !== undefined && key === "model"
2060
- ? "--model conflicts with --codex model"
2061
- : "Duplicate --codex key");
2172
+ if (model !== undefined && key === "model") {
2173
+ throw new CodexSecurityError("--model conflicts with --codex model");
2174
+ }
2175
+ if (effort !== undefined && key === "model_reasoning_effort") {
2176
+ throw new CodexSecurityError("--effort conflicts with --codex model_reasoning_effort");
2177
+ }
2178
+ throw new CodexSecurityError("Duplicate --codex key");
2062
2179
  }
2063
2180
  cursor[final] = parsed;
2064
2181
  }