@openai/codex-security 0.8.1 → 0.8.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 (396) hide show
  1. package/README.md +45 -57
  2. package/_bundled_plugin/.app.json +4 -0
  3. package/_bundled_plugin/.mcp.json +1 -0
  4. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
  7. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  13. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  14. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  15. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +46 -12
  16. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  17. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  18. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  19. package/_bundled_plugin/references/artifact-storage.md +1 -1
  20. package/_bundled_plugin/references/core-scan.md +14 -5
  21. package/_bundled_plugin/references/default-severity-rubric.md +28 -0
  22. package/_bundled_plugin/references/finding-detail-fields.md +1 -0
  23. package/_bundled_plugin/references/threat-model.md +1 -0
  24. package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
  25. package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
  26. package/_bundled_plugin/scripts/finding_preview.py +5 -29
  27. package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
  28. package/_bundled_plugin/scripts/report_projection.py +87 -136
  29. package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
  30. package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
  31. package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
  32. package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
  33. package/_bundled_plugin/scripts/workbench_cli.py +102 -13
  34. package/_bundled_plugin/scripts/workbench_constants.py +9 -0
  35. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
  36. package/_bundled_plugin/scripts/workbench_db.py +187 -363
  37. package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
  38. package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
  39. package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
  40. package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
  41. package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
  42. package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
  43. package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
  44. package/_bundled_plugin/scripts/workbench_schema.py +1 -1
  45. package/_bundled_plugin/scripts/workbench_setup.py +239 -0
  46. package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
  47. package/_bundled_plugin/scripts/workbench_target.py +120 -35
  48. package/_bundled_plugin/scripts/workbench_validation.py +1 -9
  49. package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
  50. package/_bundled_plugin/shared/workbench-migrations.json +19 -0
  51. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
  52. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
  53. package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
  54. package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
  55. package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
  56. package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
  57. package/_bundled_plugin/skills/publish-findings/SKILL.md +68 -35
  58. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
  59. package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
  60. package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
  61. package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
  62. package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
  63. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
  64. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
  65. package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
  66. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
  67. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
  68. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
  69. package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
  70. package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
  71. package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
  72. package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
  73. package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
  74. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +569 -0
  75. package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
  76. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
  77. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
  78. package/dist/api.d.ts +6 -1
  79. package/dist/api.d.ts.map +1 -1
  80. package/dist/api.js +414 -163
  81. package/dist/api.js.map +1 -1
  82. package/dist/auth.js +7 -2
  83. package/dist/auth.js.map +1 -1
  84. package/dist/blackduck-findings.d.ts +8 -0
  85. package/dist/blackduck-findings.d.ts.map +1 -0
  86. package/dist/blackduck-findings.js +305 -0
  87. package/dist/blackduck-findings.js.map +1 -0
  88. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  89. package/dist/bulk-scan-discovery.js +51 -36
  90. package/dist/bulk-scan-discovery.js.map +1 -1
  91. package/dist/classify-severity-records.d.ts +5 -0
  92. package/dist/classify-severity-records.d.ts.map +1 -1
  93. package/dist/classify-severity-records.js +6 -8
  94. package/dist/classify-severity-records.js.map +1 -1
  95. package/dist/classify-severity.d.ts +4 -1
  96. package/dist/classify-severity.d.ts.map +1 -1
  97. package/dist/classify-severity.js +28 -9
  98. package/dist/classify-severity.js.map +1 -1
  99. package/dist/cli.d.ts +3 -0
  100. package/dist/cli.d.ts.map +1 -1
  101. package/dist/cli.js +635 -266
  102. package/dist/cli.js.map +1 -1
  103. package/dist/codex-prompt.d.ts +2 -0
  104. package/dist/codex-prompt.d.ts.map +1 -1
  105. package/dist/codex-prompt.js +6 -0
  106. package/dist/codex-prompt.js.map +1 -1
  107. package/dist/component-scan.d.ts.map +1 -1
  108. package/dist/component-scan.js +6 -5
  109. package/dist/component-scan.js.map +1 -1
  110. package/dist/config.d.ts +2 -1
  111. package/dist/config.d.ts.map +1 -1
  112. package/dist/config.js +162 -40
  113. package/dist/config.js.map +1 -1
  114. package/dist/continuum-findings.d.ts +7 -0
  115. package/dist/continuum-findings.d.ts.map +1 -0
  116. package/dist/continuum-findings.js +157 -0
  117. package/dist/continuum-findings.js.map +1 -0
  118. package/dist/contract-values.d.ts +28 -0
  119. package/dist/contract-values.d.ts.map +1 -0
  120. package/dist/contract-values.js +75 -0
  121. package/dist/contract-values.js.map +1 -0
  122. package/dist/contract.d.ts +2 -20
  123. package/dist/contract.d.ts.map +1 -1
  124. package/dist/contract.js +58 -669
  125. package/dist/contract.js.map +1 -1
  126. package/dist/cost-model.d.ts.map +1 -1
  127. package/dist/cost-model.js +1 -4
  128. package/dist/cost-model.js.map +1 -1
  129. package/dist/cost.d.ts +19 -1
  130. package/dist/cost.d.ts.map +1 -1
  131. package/dist/cost.js +2120 -39
  132. package/dist/cost.js.map +1 -1
  133. package/dist/custom-validation-prompt.d.ts +1 -1
  134. package/dist/custom-validation-prompt.d.ts.map +1 -1
  135. package/dist/custom-validation-prompt.js +5 -0
  136. package/dist/custom-validation-prompt.js.map +1 -1
  137. package/dist/custom-validation.d.ts +2 -0
  138. package/dist/custom-validation.d.ts.map +1 -1
  139. package/dist/custom-validation.js +6 -2
  140. package/dist/custom-validation.js.map +1 -1
  141. package/dist/deduplication/deduplication-prompts.d.ts +4 -4
  142. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  143. package/dist/deduplication/deduplication-prompts.js +2 -2
  144. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  145. package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
  146. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  147. package/dist/deduplication/deduplication-reviewer.js +12 -5
  148. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  149. package/dist/deduplication/deduplication.js.map +1 -1
  150. package/dist/deduplication/finding-schema.d.ts +19 -1
  151. package/dist/deduplication/finding-schema.d.ts.map +1 -1
  152. package/dist/deduplication/finding-schema.js +25 -0
  153. package/dist/deduplication/finding-schema.js.map +1 -1
  154. package/dist/deduplication/local.d.ts.map +1 -1
  155. package/dist/deduplication/local.js +3 -8
  156. package/dist/deduplication/local.js.map +1 -1
  157. package/dist/deduplication/records.d.ts +11 -3
  158. package/dist/deduplication/records.d.ts.map +1 -1
  159. package/dist/deduplication/records.js +48 -16
  160. package/dist/deduplication/records.js.map +1 -1
  161. package/dist/deep-scan.d.ts +11 -0
  162. package/dist/deep-scan.d.ts.map +1 -1
  163. package/dist/deep-scan.js +235 -4
  164. package/dist/deep-scan.js.map +1 -1
  165. package/dist/default-severity-rubric.d.ts +1 -2
  166. package/dist/default-severity-rubric.d.ts.map +1 -1
  167. package/dist/default-severity-rubric.js +2 -66
  168. package/dist/default-severity-rubric.js.map +1 -1
  169. package/dist/endor-findings.d.ts.map +1 -1
  170. package/dist/endor-findings.js +44 -89
  171. package/dist/endor-findings.js.map +1 -1
  172. package/dist/errors.js +1 -1
  173. package/dist/errors.js.map +1 -1
  174. package/dist/external-findings-import.d.ts.map +1 -1
  175. package/dist/external-findings-import.js +11 -15
  176. package/dist/external-findings-import.js.map +1 -1
  177. package/dist/external-findings-local.d.ts +12 -1
  178. package/dist/external-findings-local.d.ts.map +1 -1
  179. package/dist/external-findings-local.js +411 -184
  180. package/dist/external-findings-local.js.map +1 -1
  181. package/dist/external-findings-publish.d.ts +15 -1
  182. package/dist/external-findings-publish.d.ts.map +1 -1
  183. package/dist/external-findings-publish.js +1238 -226
  184. package/dist/external-findings-publish.js.map +1 -1
  185. package/dist/external-findings-read.d.ts +10 -0
  186. package/dist/external-findings-read.d.ts.map +1 -1
  187. package/dist/external-findings-read.js +71 -51
  188. package/dist/external-findings-read.js.map +1 -1
  189. package/dist/external-findings.d.ts +13 -0
  190. package/dist/external-findings.d.ts.map +1 -1
  191. package/dist/external-findings.js +124 -1
  192. package/dist/external-findings.js.map +1 -1
  193. package/dist/external-import-contract.d.ts +29 -1
  194. package/dist/external-import-contract.d.ts.map +1 -1
  195. package/dist/external-import-contract.js +314 -44
  196. package/dist/external-import-contract.js.map +1 -1
  197. package/dist/external-import-models.d.ts +1 -1
  198. package/dist/external-import-models.d.ts.map +1 -1
  199. package/dist/external-import-models.js.map +1 -1
  200. package/dist/finding-normalization.d.ts +1 -1
  201. package/dist/finding-normalization.d.ts.map +1 -1
  202. package/dist/finding-normalization.js +46 -11
  203. package/dist/finding-normalization.js.map +1 -1
  204. package/dist/finding-retrieval.d.ts +3 -3
  205. package/dist/finding-retrieval.d.ts.map +1 -1
  206. package/dist/finding-retrieval.js.map +1 -1
  207. package/dist/finding-workflow.d.ts +6 -1
  208. package/dist/finding-workflow.d.ts.map +1 -1
  209. package/dist/finding-workflow.js +2 -2
  210. package/dist/finding-workflow.js.map +1 -1
  211. package/dist/git-remote.d.ts +4 -0
  212. package/dist/git-remote.d.ts.map +1 -1
  213. package/dist/git-remote.js +20 -0
  214. package/dist/git-remote.js.map +1 -1
  215. package/dist/github-advisories.d.ts +3 -12
  216. package/dist/github-advisories.d.ts.map +1 -1
  217. package/dist/github-advisories.js +9 -29
  218. package/dist/github-advisories.js.map +1 -1
  219. package/dist/github-dependabot-findings.d.ts.map +1 -1
  220. package/dist/github-dependabot-findings.js +7 -16
  221. package/dist/github-dependabot-findings.js.map +1 -1
  222. package/dist/github-findings.d.ts.map +1 -1
  223. package/dist/github-findings.js +344 -56
  224. package/dist/github-findings.js.map +1 -1
  225. package/dist/github.d.ts +17 -7
  226. package/dist/github.d.ts.map +1 -1
  227. package/dist/github.js +43 -30
  228. package/dist/github.js.map +1 -1
  229. package/dist/host-protocol.d.ts +7 -2
  230. package/dist/host-protocol.d.ts.map +1 -1
  231. package/dist/host-protocol.js +27 -3
  232. package/dist/host-protocol.js.map +1 -1
  233. package/dist/host-records-protocol.d.ts +10 -11
  234. package/dist/host-records-protocol.d.ts.map +1 -1
  235. package/dist/host-records-protocol.js +69 -9
  236. package/dist/host-records-protocol.js.map +1 -1
  237. package/dist/hosted-scan.d.ts +15 -0
  238. package/dist/hosted-scan.d.ts.map +1 -1
  239. package/dist/hosted-scan.js +55 -33
  240. package/dist/hosted-scan.js.map +1 -1
  241. package/dist/index.d.ts +8 -0
  242. package/dist/index.d.ts.map +1 -1
  243. package/dist/index.js +7 -0
  244. package/dist/index.js.map +1 -1
  245. package/dist/inspector-findings.d.ts +9 -0
  246. package/dist/inspector-findings.d.ts.map +1 -0
  247. package/dist/inspector-findings.js +512 -0
  248. package/dist/inspector-findings.js.map +1 -0
  249. package/dist/knowledge-base.js +18 -5
  250. package/dist/knowledge-base.js.map +1 -1
  251. package/dist/local-git-metadata.d.ts +5 -0
  252. package/dist/local-git-metadata.d.ts.map +1 -0
  253. package/dist/local-git-metadata.js +131 -0
  254. package/dist/local-git-metadata.js.map +1 -0
  255. package/dist/multiscan.d.ts.map +1 -1
  256. package/dist/multiscan.js +22 -12
  257. package/dist/multiscan.js.map +1 -1
  258. package/dist/opengrep-findings.d.ts.map +1 -1
  259. package/dist/opengrep-findings.js +34 -20
  260. package/dist/opengrep-findings.js.map +1 -1
  261. package/dist/patch-tui.d.ts +1 -1
  262. package/dist/patch-tui.d.ts.map +1 -1
  263. package/dist/patch-tui.js +94 -36
  264. package/dist/patch-tui.js.map +1 -1
  265. package/dist/private-finding-import.d.ts +246 -0
  266. package/dist/private-finding-import.d.ts.map +1 -0
  267. package/dist/private-finding-import.js +387 -0
  268. package/dist/private-finding-import.js.map +1 -0
  269. package/dist/project-config.d.ts.map +1 -1
  270. package/dist/project-config.js +2 -2
  271. package/dist/project-config.js.map +1 -1
  272. package/dist/provider-profile.d.ts +10 -2
  273. package/dist/provider-profile.d.ts.map +1 -1
  274. package/dist/provider-profile.js +72 -10
  275. package/dist/provider-profile.js.map +1 -1
  276. package/dist/publication.js +7 -1
  277. package/dist/publication.js.map +1 -1
  278. package/dist/reader-selection.d.ts +13 -0
  279. package/dist/reader-selection.d.ts.map +1 -0
  280. package/dist/reader-selection.js +81 -0
  281. package/dist/reader-selection.js.map +1 -0
  282. package/dist/record.d.ts +6 -1
  283. package/dist/record.d.ts.map +1 -1
  284. package/dist/record.js +53 -2
  285. package/dist/record.js.map +1 -1
  286. package/dist/remediation.d.ts +5 -0
  287. package/dist/remediation.d.ts.map +1 -1
  288. package/dist/remediation.js +30 -0
  289. package/dist/remediation.js.map +1 -1
  290. package/dist/result.d.ts +2 -0
  291. package/dist/result.d.ts.map +1 -1
  292. package/dist/result.js +3 -1
  293. package/dist/result.js.map +1 -1
  294. package/dist/runtime.d.ts +5 -3
  295. package/dist/runtime.d.ts.map +1 -1
  296. package/dist/runtime.js +110 -57
  297. package/dist/runtime.js.map +1 -1
  298. package/dist/scan-activity.js +40 -17
  299. package/dist/scan-activity.js.map +1 -1
  300. package/dist/scan-comparison.d.ts +1 -1
  301. package/dist/scan-comparison.d.ts.map +1 -1
  302. package/dist/scan-comparison.js +11 -13
  303. package/dist/scan-comparison.js.map +1 -1
  304. package/dist/scan-dashboard.d.ts +1 -0
  305. package/dist/scan-dashboard.d.ts.map +1 -1
  306. package/dist/scan-dashboard.js +37 -48
  307. package/dist/scan-dashboard.js.map +1 -1
  308. package/dist/scan-executor.d.ts +2 -0
  309. package/dist/scan-executor.d.ts.map +1 -1
  310. package/dist/scan-executor.js.map +1 -1
  311. package/dist/scan-history-renderer.d.ts.map +1 -1
  312. package/dist/scan-history-renderer.js +22 -9
  313. package/dist/scan-history-renderer.js.map +1 -1
  314. package/dist/scan-logs.d.ts.map +1 -1
  315. package/dist/scan-logs.js +5 -5
  316. package/dist/scan-logs.js.map +1 -1
  317. package/dist/scanner-import.d.ts +48 -3
  318. package/dist/scanner-import.d.ts.map +1 -1
  319. package/dist/scanner-import.js +214 -39
  320. package/dist/scanner-import.js.map +1 -1
  321. package/dist/scanner-repository-url.d.ts +14 -0
  322. package/dist/scanner-repository-url.d.ts.map +1 -0
  323. package/dist/scanner-repository-url.js +67 -0
  324. package/dist/scanner-repository-url.js.map +1 -0
  325. package/dist/semgrep-findings.d.ts.map +1 -1
  326. package/dist/semgrep-findings.js +50 -88
  327. package/dist/semgrep-findings.js.map +1 -1
  328. package/dist/semgrep-platform-findings.d.ts +12 -0
  329. package/dist/semgrep-platform-findings.d.ts.map +1 -0
  330. package/dist/semgrep-platform-findings.js +198 -0
  331. package/dist/semgrep-platform-findings.js.map +1 -0
  332. package/dist/severity-rubric.d.ts +20 -0
  333. package/dist/severity-rubric.d.ts.map +1 -0
  334. package/dist/severity-rubric.js +73 -0
  335. package/dist/severity-rubric.js.map +1 -0
  336. package/dist/severity-store.js +15 -5
  337. package/dist/severity-store.js.map +1 -1
  338. package/dist/snyk-findings.d.ts.map +1 -1
  339. package/dist/snyk-findings.js +97 -106
  340. package/dist/snyk-findings.js.map +1 -1
  341. package/dist/sonar-collector.d.ts +16 -0
  342. package/dist/sonar-collector.d.ts.map +1 -0
  343. package/dist/sonar-collector.js +383 -0
  344. package/dist/sonar-collector.js.map +1 -0
  345. package/dist/sonar-findings.d.ts +49 -0
  346. package/dist/sonar-findings.d.ts.map +1 -0
  347. package/dist/sonar-findings.js +288 -0
  348. package/dist/sonar-findings.js.map +1 -0
  349. package/dist/sonar-import.d.ts +111 -0
  350. package/dist/sonar-import.d.ts.map +1 -0
  351. package/dist/sonar-import.js +279 -0
  352. package/dist/sonar-import.js.map +1 -0
  353. package/dist/suggest-owners.d.ts.map +1 -1
  354. package/dist/suggest-owners.js +2 -1
  355. package/dist/suggest-owners.js.map +1 -1
  356. package/dist/targets.d.ts +3 -0
  357. package/dist/targets.d.ts.map +1 -1
  358. package/dist/targets.js +18 -12
  359. package/dist/targets.js.map +1 -1
  360. package/dist/terminal-columns.d.ts +4 -0
  361. package/dist/terminal-columns.d.ts.map +1 -0
  362. package/dist/terminal-columns.js +19 -0
  363. package/dist/terminal-columns.js.map +1 -0
  364. package/dist/validation-records.d.ts +0 -3
  365. package/dist/validation-records.d.ts.map +1 -1
  366. package/dist/validation-records.js +0 -16
  367. package/dist/validation-records.js.map +1 -1
  368. package/dist/veracode-findings.d.ts +7 -0
  369. package/dist/veracode-findings.d.ts.map +1 -0
  370. package/dist/veracode-findings.js +371 -0
  371. package/dist/veracode-findings.js.map +1 -0
  372. package/dist/windows-path.d.ts.map +1 -1
  373. package/dist/windows-path.js +1 -0
  374. package/dist/windows-path.js.map +1 -1
  375. package/dist/wiz-csv.d.ts +2 -2
  376. package/dist/wiz-csv.d.ts.map +1 -1
  377. package/dist/wiz-csv.js +1 -3
  378. package/dist/wiz-csv.js.map +1 -1
  379. package/dist/wiz-findings.d.ts +10 -2
  380. package/dist/wiz-findings.d.ts.map +1 -1
  381. package/dist/wiz-findings.js +88 -49
  382. package/dist/wiz-findings.js.map +1 -1
  383. package/docs/classify-severity-records.md +1 -1
  384. package/docs/cli.md +320 -481
  385. package/docs/dedupe-records.md +27 -4
  386. package/docs/findings-service.md +21 -8
  387. package/docs/hosted-scans.md +16 -1
  388. package/package.json +9 -10
  389. package/schemas/external-findings.schema.json +12 -1
  390. package/schemas/hosted-scan-v2.fixture.json +16 -1
  391. package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
  392. package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
  393. package/dist/deduplication/records-protocol.d.ts +0 -4
  394. package/dist/deduplication/records-protocol.d.ts.map +0 -1
  395. package/dist/deduplication/records-protocol.js +0 -35
  396. package/dist/deduplication/records-protocol.js.map +0 -1
package/dist/cli.js CHANGED
@@ -8,14 +8,16 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
8
8
  return path;
9
9
  };
10
10
  import { classificationRunsSchema } from "./severity-review.js";
11
+ import { severityRubricSchema } from "./severity-rubric.js";
11
12
  import { workbenchArgs } from "./workbench-arguments.js";
12
13
  import { listenForAbort } from "./cli-signals.js";
13
14
  import { appServerCyberAccessProgram } from "./cli-daybreak.js";
14
- import { withCodexPreflightLock } from "./provider-profile.js";
15
+ import { restoreProviderProfile, withCodexPreflightLock, } from "./provider-profile.js";
15
16
  import { isNonEmptyString, notify, parseJson } from "./value.js";
16
17
  import { compareTimestamps } from "./timestamps.js";
17
18
  import { execFile as execFileCallback, execFileSync, spawn, } from "node:child_process";
18
19
  import { createHash, randomUUID } from "node:crypto";
20
+ import { errorMonitor } from "node:events";
19
21
  import { accessSync, constants, createReadStream, existsSync, lstatSync, realpathSync, writeSync, } from "node:fs";
20
22
  import { chmod, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rm, writeFile, } from "node:fs/promises";
21
23
  import { tmpdir } from "node:os";
@@ -26,6 +28,7 @@ import { Readable, Writable as NodeWritable } from "node:stream";
26
28
  import { fileURLToPath, pathToFileURL } from "node:url";
27
29
  import { isDeepStrictEqual, parseArgs, promisify, stripVTControlCharacters, } from "node:util";
28
30
  import { Cli, z } from "incur";
31
+ import stringWidth from "string-width";
29
32
  import Ajv2020 from "ajv/dist/2020.js";
30
33
  import { formatCliHelp } from "./cli-help.js";
31
34
  import { formatCoverageScope } from "./coverage-presentation.js";
@@ -34,7 +37,6 @@ import { scanLogsJson } from "./cli-scan-logs-json.js";
34
37
  import { ARTIFACT_EXPORT_FILENAMES, exportEnvironment, resolveArtifactFormat, resolveArtifactExportOutput, resolveSavedArtifactDirectory, runArtifactExport, writeArtifactOutput as writeCliOutput, } from "./artifact-export.js";
35
38
  export { exportEnvironment } from "./artifact-export.js";
36
39
  import { parse as parseToml } from "smol-toml";
37
- import { parse as parseYaml } from "yaml";
38
40
  import { classifyConnectionFailure, CodexSecurity, environmentValue, formatEnvironmentVariableRemovalGuidance, initialCredentialsAvailable, scanCodexHome, listRepositoryFindings, SCAN_AUTH_MODES, scanAuthentication, runtimeScanAuthentication, selectedScanEnvironment, } from "./api.js";
39
41
  import { accountStatus, CODEX_AUTH_CONFIG_KEYS, NO_CREDENTIALS_MESSAGE, configuredCodexHome, environmentEntry, readCodexHomeConfig, } from "./auth.js";
40
42
  import { loadContract, sha256Text } from "./contract.js";
@@ -44,25 +46,24 @@ import { parseImportedFindings } from "./findings-import.js";
44
46
  import { publishScanToCustom } from "./custom-publish.js";
45
47
  import { ExternalPublicationError, prepareExternalPublication, } from "./external-findings-publish.js";
46
48
  import { prepareLocalExternalImport } from "./external-findings-import.js";
49
+ import { validateInspectorProjectMapping } from "./inspector-findings.js";
47
50
  import { externalImportsDisabledMessage, externalImportsEnabled, } from "./external-imports-feature.js";
48
51
  import { listLocalExternalFindings } from "./external-findings-local.js";
52
+ import { prepareSonarImport } from "./sonar-import.js";
49
53
  import { EXTERNAL_FINDINGS_READERS } from "./external-findings-read.js";
50
54
  import { publishPatchReview, resolvePatchReviewPublisher, } from "./patch-publication.js";
51
55
  import { DEFAULT_DEDUPE_CONCURRENCY } from "./deduplication/deduplication.js";
52
56
  import { savedScanWorkbench } from "./saved-scan-bootstrap.js";
53
57
  import { deduplicateScanInternal } from "./deduplication/scan.js";
54
- import { runRecordsProtocol } from "./deduplication/records-protocol.js";
55
58
  import { runHostRecordsProtocol } from "./host-records-protocol.js";
56
- import { classifySeverityRecords, } from "./classify-severity-records.js";
57
59
  import { runHostedScanProtocol } from "./hosted-scan-protocol.js";
58
60
  import { runHostedRemediationProtocol } from "./hosted-remediation-protocol.js";
59
- import { runValidationRecordsProtocol } from "./validation-records.js";
60
- import { FindingPatchSchema as findingPatchSchema, parseFindingVerifications, remediationPrompt, VerificationModeSchema, } from "./remediation.js";
61
+ import { FindingPatchSchema as findingPatchSchema, parseFindingVerifications, remediationPrompt, verificationBatches, VerificationFindingTooLargeError, VerificationModeSchema, } from "./remediation.js";
61
62
  import { classifyScanSeverityInternal, classifyScanDirectorySeverityInternal, } from "./classify-scan-severity.js";
62
63
  import { resolveCompletedScan, resolveWorkflowScan, } from "./saved-scan.js";
63
64
  import { publishFindingsCsvToCloud, publishScanToCloud, } from "./cloud-publish.js";
64
65
  import { createBulkScanDiscoveryDependencies, createTerminalPrompt, runBulkScanWizard, } from "./bulk-scan-discovery.js";
65
- import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergeCodexOverrides, hasCommandAuth, inlineToml, quoteTomlString, modelProviderConfigOverride, resolveCommandAuthConfig, resolveCodexProfile, mergedCodexConfig, scanModel, scanModelConfiguration, scanModelProvider, writeCodexConfig, } from "./config.js";
66
+ import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergeCodexOverrides, hasCommandAuth, inlineToml, quoteTomlString, modelProviderConfigOverride, resolveCommandAuthConfig, resolveCodexProfile, mergedCodexConfig, readCodexFileProfile, scanModel, scanModelConfiguration, scanModelProvider, scanProviderEnvKey, writeCodexConfig, } from "./config.js";
66
67
  import { formatUsd } from "./cost.js";
67
68
  import { formatScanCost, formatScanCostTokens, formatTokenUsage, } from "./cost-model.js";
68
69
  import { readRegularInputFile, resolveScanPrompts } from "./prompt-files.js";
@@ -70,7 +71,7 @@ import { standaloneValidationPrompt } from "./standalone-validation-prompt.js";
70
71
  import { prepareKnowledgeBase, readKnowledgeBaseSnapshot, } from "./knowledge-base.js";
71
72
  import { restoreScanKnowledge, scanInputIdentity } from "./scan-inputs.js";
72
73
  import { workflowDigest } from "./finding-workflow.js";
73
- import { CodexSecurityError, AuthenticationRequiredError, ConfigurationError, InvalidTargetError, IncompleteScanError, LocalPluginBootstrapError, OutputDirectoryError, OutputInsideProtectedRootError, PluginPythonUnavailableError, errorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
74
+ import { CodexSecurityError, AuthenticationRequiredError, ConfigurationError, InvalidTargetError, IncompleteScanError, LocalPluginBootstrapError, OutputDirectoryError, OutputInsideProtectedRootError, PluginBootstrapError, PluginPythonUnavailableError, SandboxUnavailableError, errorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
74
75
  import { GHSA_ID } from "./github-identifiers.js";
75
76
  import { GITHUB_ADVISORY_STATES, importGitHubAdvisories, } from "./github-advisories.js";
76
77
  import { GITHUB_ALERT_STATES, importGitHubCodeScanningAlerts, } from "./github.js";
@@ -89,6 +90,7 @@ import { findScanSession, readSavedScanLogs, } from "./scan-logs.js";
89
90
  import { sendFeedback } from "./feedback.js";
90
91
  import { renderScanHistory, } from "./scan-history-renderer.js";
91
92
  import { ScanDashboard } from "./scan-dashboard.js";
93
+ import { graphemes } from "./terminal-columns.js";
92
94
  import { ACCOUNT_LIMITS_UNAVAILABLE, formatAccountLimits, formatUsageFreshness, isChatGptAuthentication, USAGE_TIME_UNAVAILABLE, } from "./scan-usage-display.js";
93
95
  import { policyDisplayData, runPolicyCommand, } from "./security-policy-cli.js";
94
96
  import { scanPhaseLabel as scanPhase, scanProgressCount, } from "./worker-progress.js";
@@ -117,14 +119,12 @@ const FRAMEWORK_VALUE_OPTIONS = new Set([
117
119
  "--token-limit",
118
120
  "--token-offset",
119
121
  ]);
122
+ const TOKEN_OUTPUT_OPTION = /^--token-(?:count|limit|offset)(?:=|$)/u;
120
123
  const OUTPUT_OPTION = /^--(?:format|filter-output|full-output|token-count|token-limit|token-offset)(?:=|$)/u;
121
124
  const HIDE_CURSOR = "\u001B[?25l";
122
125
  const SHOW_CURSOR = "\u001B[?25h";
123
126
  const CHILD_TERMINATION_GRACE_MS = 1_000;
124
127
  const DUPLICATE_SIGNAL_WINDOW_MS = 500;
125
- const PUBLICATION_GRAPHEME_SEGMENTER = new Intl.Segmenter(undefined, {
126
- granularity: "grapheme",
127
- });
128
128
  const DEFAULT_SCAN_MODEL_CONFIGURATION = scanModelConfiguration(DEFAULT_CODEX_CONFIG);
129
129
  const MODEL_OPTIONS = modelOptions();
130
130
  const MATCHING_MODEL_OPTIONS = modelOptions("Model for finding matching (default: Codex's configured model).", "Matching reasoning effort (default: medium).");
@@ -183,6 +183,30 @@ const ASSESS_PATCH_RISK_OPTION = z
183
183
  function optionValue(flag) {
184
184
  return z.string().min(1, `${flag} must not be empty.`);
185
185
  }
186
+ function remediationInputOptions(verb) {
187
+ return z.object({
188
+ scan: optionValue("--scan")
189
+ .optional()
190
+ .describe(`${verb} open findings from a saved scan ID or the latest completed scan.`),
191
+ severity: z
192
+ .enum(REPORTABLE_SEVERITIES)
193
+ .optional()
194
+ .describe(`${verb} saved findings at or above LEVEL.`),
195
+ linearIssue: z
196
+ .array(optionValue("--linear-issue"))
197
+ .default([])
198
+ .describe("Linear issue identifier or URL; repeat for more issues."),
199
+ linearProject: optionValue("--linear-project")
200
+ .optional()
201
+ .describe(verb === "Patch"
202
+ ? "Patch every open issue in this Linear project."
203
+ : "Verify issues in this Linear project."),
204
+ linearFilter: optionValue("--linear-filter")
205
+ .optional()
206
+ .describe("JSON Linear issue filter for --linear-project."),
207
+ linearApiKey: linearApiKeyOption(),
208
+ });
209
+ }
186
210
  function linearApiKeyOption() {
187
211
  return z
188
212
  .string()
@@ -266,7 +290,7 @@ function publicationScanAge(timestamp, now) {
266
290
  return "just now";
267
291
  }
268
292
  function publicationDisplayWidth(value) {
269
- const segments = PUBLICATION_GRAPHEME_SEGMENTER.segment(stripVTControlCharacters(value));
293
+ const segments = graphemes.segment(stripVTControlCharacters(value));
270
294
  let width = 0;
271
295
  for (const { segment } of segments) {
272
296
  if (/^[\p{Mark}\p{Cf}]+$/u.test(segment))
@@ -281,6 +305,19 @@ function publicationDisplayWidth(value) {
281
305
  function padPublicationColumn(value, width) {
282
306
  return `${value}${" ".repeat(width - publicationDisplayWidth(value))}`;
283
307
  }
308
+ function fitProgressLine(line, width) {
309
+ const plain = stripVTControlCharacters(line);
310
+ let ellipsisIndex = 0;
311
+ let used = 0;
312
+ for (const { index, segment } of graphemes.segment(plain)) {
313
+ used += stringWidth(segment.toWellFormed());
314
+ if (used > width)
315
+ return width > 0 ? `${plain.slice(0, ellipsisIndex)}…` : "";
316
+ if (used < width)
317
+ ellipsisIndex = index + segment.length;
318
+ }
319
+ return line;
320
+ }
284
321
  function publicationIssueUrl(value) {
285
322
  if (value === undefined ||
286
323
  value !== value.trim() ||
@@ -307,9 +344,16 @@ function publicationIssueUrl(value) {
307
344
  }
308
345
  function renderExternalPublicationSummary(result) {
309
346
  return [
310
- `Import ${result.status}.`,
347
+ result.privateJob
348
+ ? `Private inbox import ${result.privateJob.status}. Job: ${diagnosticValue(result.privateJob.id)}`
349
+ : `Import ${result.status}.`,
311
350
  `Submission totals — Created: ${result.counts.created} Updated: ${result.counts.updated} Unchanged: ${result.counts.unchanged} Failed: ${result.counts.error}`,
312
- `Excluded: ${result.excluded.length} Awaiting acknowledgement: ${result.unacknowledged} Verified: ${result.verified}`,
351
+ result.privateJob
352
+ ? `Excluded: ${result.excluded.length} Unprocessed: ${result.privateJob.counts.unprocessed}`
353
+ : `Excluded: ${result.excluded.length} Awaiting acknowledgement: ${result.unacknowledged} Verified: ${result.verified}`,
354
+ ...(result.privateJob?.error
355
+ ? [diagnosticValue(result.privateJob.error.message)]
356
+ : []),
313
357
  ...result.failures.map((item) => `Failed ${diagnosticValue(item.source_finding_id)} (${item.code}): ${diagnosticValue(item.message)}`),
314
358
  ...result.excluded.map((item) => `Excluded item ${item.position}${item.source_finding_id ? ` (${diagnosticValue(item.source_finding_id)})` : ""}: ${diagnosticValue(item.reason)}`),
315
359
  ...(result.savedSubmission
@@ -319,9 +363,11 @@ function renderExternalPublicationSummary(result) {
319
363
  ? []
320
364
  : [
321
365
  "Imported evidence remains not assessed by Codex.",
322
- result.cloudUrl
323
- ? `View Cloud repository: ${diagnosticValue(result.cloudUrl)}`
324
- : "Open the repository in Codex Security Cloud.",
366
+ result.privateJob
367
+ ? "Open the private inbox in Codex Security Cloud to assess a finding and choose whether to publish it."
368
+ : result.cloudUrl
369
+ ? `View Cloud repository: ${diagnosticValue(result.cloudUrl)}`
370
+ : "Open the repository in Codex Security Cloud.",
325
371
  ]),
326
372
  "",
327
373
  ].join("\n");
@@ -405,11 +451,8 @@ class PublicationProgressPresenter {
405
451
  return;
406
452
  }
407
453
  if (event.type === "codex_event") {
408
- if (typeof event.event !== "object" ||
409
- event.event === null ||
410
- Array.isArray(event.event)) {
454
+ if (!isJsonObject(event.event))
411
455
  return;
412
- }
413
456
  for (const activity of scanActivitiesFromEvent(event.event, this.#repository)) {
414
457
  const item = event.event["item"];
415
458
  const tool = isJsonObject(item) ? item["tool"] : undefined;
@@ -432,11 +475,10 @@ class PublicationProgressPresenter {
432
475
  if (this.#seenActivities.has(key))
433
476
  continue;
434
477
  this.#seenActivities.add(key);
435
- const label = visibleActivity.kind === "reasoning"
478
+ const label = visibleActivity.kind === "reasoning" ||
479
+ visibleActivity.kind === "message"
436
480
  ? "Codex"
437
- : visibleActivity.kind === "message"
438
- ? "Codex"
439
- : "Tool";
481
+ : "Tool";
440
482
  this.#write(`${label}: ${visibleActivity.description}`, true);
441
483
  }
442
484
  return;
@@ -479,9 +521,7 @@ class PublicationProgressPresenter {
479
521
  return;
480
522
  }
481
523
  const width = Math.max(24, Math.min(this.#stream.columns ?? 120, 160));
482
- const visible = sanitized.length <= width
483
- ? sanitized
484
- : `${sanitized.slice(0, width - 1)}…`;
524
+ const visible = fitProgressLine(sanitized, width);
485
525
  this.#stream.write(`${visible}\n`);
486
526
  }
487
527
  }
@@ -797,11 +837,10 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
797
837
  const directory = await realpath(output.directory ?? output.appServer?.directory ?? process.cwd());
798
838
  const protectedRoots = [
799
839
  directory,
800
- ...(await enclosingGitWorktreeRoots(directory)),
840
+ ...(await enclosingGitWorktreeRoots(directory, output.signal)),
801
841
  ];
802
842
  const codexHome = await prepareCodexSecurityCredentialHome(selected, (path) => requireOutputOutsideRepositories(protectedRoots, path, "runtime"));
803
- releaseCredentialHome =
804
- await acquireCodexSecurityCredentialHomeLock(codexHome);
843
+ releaseCredentialHome = await acquireCodexSecurityCredentialHomeLock(codexHome, output.signal);
805
844
  let credentialsAvailable;
806
845
  const ambientAuthConfig = await readCodexHomeConfig(selected);
807
846
  credentialConfig = await readCodexHomeConfig({
@@ -838,27 +877,31 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
838
877
  CODEX_HOME: codexHome,
839
878
  CODEX_SECURITY_STATE_DIR: codexSecurityStateDirectory(selected),
840
879
  };
880
+ output.signal?.throwIfAborted();
841
881
  if (!credentialsAvailable &&
842
- !(await accountStatus(command, selected)).authenticated) {
882
+ !(await accountStatus(command, selected, output.signal)).authenticated) {
843
883
  throw new AuthenticationRequiredError(NO_CREDENTIALS_MESSAGE);
844
884
  }
845
- authentication = await runtimeScanAuthentication(selected, codexHome, output.auth, provider);
885
+ authentication = await runtimeScanAuthentication(selected, codexHome, output.auth, provider, providerEnvKey);
846
886
  if (output.appServer !== undefined) {
847
887
  const controller = new AbortController();
848
- const removeSignals = listenForAbort(DEFAULT_DEPENDENCIES, controller);
888
+ const signal = output.signal ?? controller.signal;
889
+ const removeSignals = output.signal
890
+ ? undefined
891
+ : listenForAbort(DEFAULT_DEPENDENCIES, controller);
849
892
  try {
850
893
  args = [
851
894
  ...args,
852
- ...(await skillDaybreakConfigOverrides(args, command, selected, directory, ambientConfig, controller.signal)),
895
+ ...(await skillDaybreakConfigOverrides(args, command, selected, directory, ambientConfig, signal)),
853
896
  ];
854
897
  }
855
898
  catch (error) {
856
- if (controller.signal.aborted)
857
- return controller.signal.reason === "SIGINT" ? 130 : 143;
899
+ if (signal.aborted)
900
+ return signal.reason === "SIGINT" ? 130 : 143;
858
901
  throw error;
859
902
  }
860
903
  finally {
861
- removeSignals();
904
+ removeSignals?.();
862
905
  }
863
906
  }
864
907
  }
@@ -907,6 +950,7 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
907
950
  if (configuredHome?.trim()) {
908
951
  environment["CODEX_HOME"] = resolve(expandHome(configuredHome, processEnvironment));
909
952
  }
953
+ output?.signal?.throwIfAborted();
910
954
  const invocation = spawn(executablePathForSpawn(command.command), [...args], {
911
955
  env: environment,
912
956
  cwd: output?.appServer?.directory ?? parse(process.execPath).root,
@@ -942,10 +986,12 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
942
986
  if (invocation.exitCode === null && invocation.signalCode === null) {
943
987
  invocation.kill("SIGKILL");
944
988
  }
989
+ else {
990
+ forceStatusCompletion?.();
991
+ }
945
992
  forceCaptureCompletion?.();
946
993
  invocation.stdout?.destroy();
947
994
  invocation.stderr?.destroy();
948
- forceStatusCompletion?.();
949
995
  }, CHILD_TERMINATION_GRACE_MS);
950
996
  };
951
997
  const onInterrupt = () => {
@@ -954,6 +1000,16 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
954
1000
  const onTerminate = () => {
955
1001
  requestTermination("SIGTERM");
956
1002
  };
1003
+ const signal = output?.signal;
1004
+ const onAbort = () => {
1005
+ // A process signal also invokes the handlers below in the same turn.
1006
+ queueMicrotask(() => {
1007
+ if (requestedSignal === null && forceStatusCompletion !== null) {
1008
+ requestTermination(signal?.reason === "SIGINT" ? "SIGINT" : "SIGTERM");
1009
+ }
1010
+ });
1011
+ };
1012
+ signal?.addEventListener("abort", onAbort, { once: true });
957
1013
  process.on("SIGINT", onInterrupt);
958
1014
  process.on("SIGTERM", onTerminate);
959
1015
  try {
@@ -1032,6 +1088,7 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
1032
1088
  clearTimeout(forcedTermination);
1033
1089
  forceStatusCompletion = null;
1034
1090
  forceCaptureCompletion = null;
1091
+ signal?.removeEventListener("abort", onAbort);
1035
1092
  process.off("SIGINT", onInterrupt);
1036
1093
  process.off("SIGTERM", onTerminate);
1037
1094
  }
@@ -1104,6 +1161,42 @@ async function skillDaybreakConfigOverrides(args, command, environment, director
1104
1161
  }
1105
1162
  return overrides;
1106
1163
  }
1164
+ function writeOptionalVerificationDiagnostic(stream, message) {
1165
+ try {
1166
+ if (!(stream instanceof NodeWritable)) {
1167
+ stream.write(message);
1168
+ }
1169
+ else if (stream.writable) {
1170
+ stream.write(message, (error) => {
1171
+ // Node calls the write callback before emitting its error. A stalled
1172
+ // write needs no listener, and other consumers still receive the event.
1173
+ if (error &&
1174
+ !stream.closed &&
1175
+ stream.errored === error &&
1176
+ !stream.listenerCount("error"))
1177
+ stream.once("error", () => { });
1178
+ });
1179
+ }
1180
+ }
1181
+ catch { }
1182
+ }
1183
+ function guardDisconnectedVerificationTerminal(stream) {
1184
+ if (stream !== process.stderr || !stream.isTTY)
1185
+ return;
1186
+ const stderr = process.stderr;
1187
+ if (!stderr.listeners(errorMonitor).includes(handleDisconnectedResize)) {
1188
+ stderr.on(errorMonitor, handleDisconnectedResize);
1189
+ }
1190
+ }
1191
+ // Node refreshes the TTY size on SIGWINCH even after main() returns. Handle
1192
+ // only a disconnected terminal's resize when no other consumer handles it.
1193
+ function handleDisconnectedResize(error) {
1194
+ if (error.code === "EIO" &&
1195
+ error.syscall === "getWindowSize" &&
1196
+ process.stderr.listenerCount("error") === 0) {
1197
+ process.stderr.once("error", () => { });
1198
+ }
1199
+ }
1107
1200
  export async function main(argv = process.argv.slice(2), output = process.stdout, errorOutput = process.stderr, dependencies = DEFAULT_DEPENDENCIES) {
1108
1201
  const importsEnabled = externalImportsEnabled(dependencies.environment);
1109
1202
  const remediationOperation = argv[0] === "patch"
@@ -1111,11 +1204,13 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1111
1204
  : argv[0] === "verify-fix"
1112
1205
  ? "verify"
1113
1206
  : undefined;
1114
- const hostedCommand = argv[0] === "scan" || remediationOperation !== undefined;
1115
- if ((((argv[0] === "dedupe" ||
1207
+ const recordsCommand = argv[0] === "dedupe" ||
1116
1208
  argv[0] === "validate" ||
1117
- argv[0] === "classify-severity") &&
1118
- argv.includes("--records")) ||
1209
+ argv[0] === "classify-severity"
1210
+ ? argv[0]
1211
+ : undefined;
1212
+ const hostedCommand = argv[0] === "scan" || remediationOperation !== undefined;
1213
+ if (((recordsCommand !== undefined && argv.includes("--records")) ||
1119
1214
  (hostedCommand &&
1120
1215
  argv.some((arg) => arg === "--host" || arg.startsWith("--host=")))) &&
1121
1216
  !argv.includes("--help") &&
@@ -1148,19 +1243,15 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1148
1243
  const removeSignals = listenForAbort(dependencies, controller);
1149
1244
  let exitCode;
1150
1245
  try {
1151
- const runProtocol = argv[0] === "scan"
1152
- ? runHostedScanProtocol
1153
- : argv[0] === "validate"
1154
- ? runValidationRecordsProtocol
1155
- : runRecordsProtocol;
1156
- const code = argv[0] === "classify-severity"
1157
- ? await runHostRecordsProtocol(dependencies.recordsInput ?? process.stdin, output, (value, options) => classifySeverityRecords(value, {
1158
- ...options,
1246
+ const input = dependencies.recordsInput ?? process.stdin;
1247
+ const code = recordsCommand !== undefined
1248
+ ? await runHostRecordsProtocol(recordsCommand, input, output, {
1249
+ signal: controller.signal,
1159
1250
  classificationRuns,
1160
- }), controller.signal)
1251
+ })
1161
1252
  : remediationOperation !== undefined
1162
- ? await runHostedRemediationProtocol(dependencies.recordsInput ?? process.stdin, output, controller.signal, remediationOperation)
1163
- : await runProtocol(dependencies.recordsInput ?? process.stdin, output, controller.signal);
1253
+ ? await runHostedRemediationProtocol(input, output, controller.signal, remediationOperation)
1254
+ : await runHostedScanProtocol(input, output, controller.signal);
1164
1255
  exitCode =
1165
1256
  controller.signal.reason === "SIGINT"
1166
1257
  ? 130
@@ -1181,6 +1272,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1181
1272
  let frameworkExit;
1182
1273
  const frameworkCapture = captureOutput();
1183
1274
  let rawExportOutput = false;
1275
+ let batchedVerification = false;
1276
+ let deferredVerificationDiagnostic;
1184
1277
  let streamedLogs;
1185
1278
  let renderedOutput;
1186
1279
  let structuredError = false;
@@ -1613,7 +1706,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1613
1706
  scanPrompt: typeof saved["userContext"] === "string"
1614
1707
  ? saved["userContext"]
1615
1708
  : undefined,
1616
- }, dependencies.currentDirectory());
1709
+ }, dependencies.currentDirectory(), dependencies.environment);
1617
1710
  scanArguments.resumeScanId = saved["scanId"];
1618
1711
  scanArguments.outputDir = resolveCliPath(dependencies.currentDirectory(), saved["scanDir"]);
1619
1712
  if (scanArguments.knowledgeBasePaths.length > 0) {
@@ -1716,7 +1809,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1716
1809
  validationPromptFile: options.validationPromptFile === undefined
1717
1810
  ? undefined
1718
1811
  : resolveCliPath(dependencies.currentDirectory(), options.validationPromptFile),
1719
- }, dependencies.currentDirectory());
1812
+ }, dependencies.currentDirectory(), dependencies.environment);
1720
1813
  scanArguments.verbose = options.verbose;
1721
1814
  scanArguments.showCost = options.showCost;
1722
1815
  scanArguments.parentScanId = parentScanId;
@@ -2047,8 +2140,6 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2047
2140
  const repositories = new Map();
2048
2141
  const scansById = new Map();
2049
2142
  const rows = scans.flatMap((scan) => {
2050
- if (!isJsonObject(scan))
2051
- return [];
2052
2143
  const progress = scan["progress"];
2053
2144
  const scanId = scan["scanId"];
2054
2145
  const directory = scan["scanDir"];
@@ -2104,9 +2195,10 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2104
2195
  if (rows.length === 0) {
2105
2196
  throw new CodexSecurityError("No completed Codex Security scans are available to publish.");
2106
2197
  }
2107
- const repositoryWidth = Math.max(publicationDisplayWidth("REPOSITORY"), ...rows.map(({ repository }) => publicationDisplayWidth(repository)));
2108
- const findingsWidth = Math.max(publicationDisplayWidth("FINDINGS"), ...rows.map(({ findings }) => publicationDisplayWidth(findings)));
2109
- const ageWidth = Math.max(publicationDisplayWidth("AGE"), ...rows.map(({ age }) => publicationDisplayWidth(age)));
2198
+ const columnWidth = (heading, field) => Math.max(publicationDisplayWidth(heading), ...rows.map((row) => publicationDisplayWidth(row[field])));
2199
+ const repositoryWidth = columnWidth("REPOSITORY", "repository");
2200
+ const findingsWidth = columnWidth("FINDINGS", "findings");
2201
+ const ageWidth = columnWidth("AGE", "age");
2110
2202
  const header = [
2111
2203
  padPublicationColumn("REPOSITORY", repositoryWidth),
2112
2204
  padPublicationColumn("FINDINGS", findingsWidth),
@@ -2317,7 +2409,10 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2317
2409
  .describe("Select the file reader for this report. OpenGrep findings use the semgrep storage provider."),
2318
2410
  sourceRepositoryUrl: optionValue("--source-repository-url")
2319
2411
  .optional()
2320
- .describe("Required for Semgrep and OpenGrep: source repository URL, checked against the Cloud destination or configured local Git remotes."),
2412
+ .describe("Source repository URL when required by the selected reader. Checked against the Cloud destination or configured local Git remotes."),
2413
+ inspectorProjectArn: optionValue("--inspector-project-arn")
2414
+ .optional()
2415
+ .describe("Full Inspector project ARN independently verified for --source-repository-url. Required when the report does not identify its repository by URL."),
2321
2416
  sourceKey: optionValue("--source-key").describe("Stable vendor tenant and finding namespace; not a project selection filter."),
2322
2417
  dryRun: z
2323
2418
  .boolean()
@@ -2398,12 +2493,27 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2398
2493
  try {
2399
2494
  if (!importsEnabled)
2400
2495
  throw new CodexSecurityError(externalImportsDisabledMessage);
2496
+ const { inspectorProjectArn, ...readerOptions } = options;
2497
+ let inspectorProjectMap;
2498
+ if (inspectorProjectArn !== undefined) {
2499
+ if (options.provider !== "inspector")
2500
+ throw new CodexSecurityError("--inspector-project-arn requires --provider inspector.");
2501
+ const url = validateInspectorProjectMapping(inspectorProjectArn, options.sourceRepositoryUrl);
2502
+ inspectorProjectMap = new Map([[inspectorProjectArn, url]]);
2503
+ }
2504
+ const directory = dependencies.currentDirectory();
2505
+ const report = resolveCliPath(directory, args.file);
2506
+ const repository = options.to === "local"
2507
+ ? resolveCliPath(directory, options.repository)
2508
+ : options.repository;
2509
+ const publicationOptions = {
2510
+ ...readerOptions,
2511
+ repository,
2512
+ inspectorProjectMap,
2513
+ };
2401
2514
  if (options.to === "local") {
2402
2515
  const prepared = await (dependencies.prepareLocalExternalImport ??
2403
- prepareLocalExternalImport)(resolveCliPath(dependencies.currentDirectory(), args.file), {
2404
- ...options,
2405
- repository: resolveCliPath(dependencies.currentDirectory(), options.repository),
2406
- }, {
2516
+ prepareLocalExternalImport)(report, publicationOptions, {
2407
2517
  environment: dependencies.environment,
2408
2518
  signal: controller.signal,
2409
2519
  });
@@ -2439,7 +2549,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2439
2549
  writeDiagnostic(summary);
2440
2550
  return { ...result };
2441
2551
  }
2442
- const prepared = await prepareExternalPublication(resolveCliPath(dependencies.currentDirectory(), args.file), options, {
2552
+ const prepared = await prepareExternalPublication(report, publicationOptions, {
2443
2553
  environment: dependencies.environment,
2444
2554
  fetch: dependencies.cloudFetch,
2445
2555
  signal: controller.signal,
@@ -2448,7 +2558,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2448
2558
  const { preview } = prepared;
2449
2559
  const showPreview = () => {
2450
2560
  showScannerReport(preview);
2451
- writeDiagnostic(`Cloud API: ${diagnosticValue(preview.cloudApiUrl)}\nAccount: ${diagnosticValue(preview.accountId)}\nDestination: ${diagnosticValue(preview.destination.url)} (${diagnosticValue(preview.destination.id)})\nEnvironment: ${[...new Set(preview.requests.map((request) => request.repository.environment_id))].map(diagnosticValue).join(", ")}\nSource: ${preview.source.provider} / ${diagnosticValue(preview.source.source_key)}\nRead: ${preview.read} Ready: ${preview.findings.length} Excluded: ${preview.excluded.length}${preview.resumed ? "\nResuming the saved submission." : ""}\n`);
2561
+ writeDiagnostic(`Cloud API: ${diagnosticValue(preview.cloudApiUrl)}\nAccount: ${diagnosticValue(preview.accountId)}\nDestination: ${diagnosticValue(preview.destination.url)} (${diagnosticValue(preview.destination.id)})\n${preview.privateImport ? `Visibility: Private inbox\nReport: ${preview.privateImport.format} (${preview.privateImport.bytes} bytes)\nReport SHA-256: ${preview.privateImport.sha256}${preview.privateImport.retryOfJobId ? `\nRetrying private job: ${diagnosticValue(preview.privateImport.retryOfJobId)}` : ""}` : `Environment: ${[...new Set(preview.requests.map((request) => request.repository.environment_id))].map(diagnosticValue).join(", ")}`}\nSource: ${preview.source.provider} / ${diagnosticValue(preview.source.source_key)}\nRead: ${preview.read} Ready: ${preview.findings.length} Excluded: ${preview.excluded.length}${preview.resumed ? "\nResuming the saved submission." : ""}\n`);
2452
2562
  if (preview.cloudUrl)
2453
2563
  writeDiagnostic(`Cloud app: ${diagnosticValue(preview.cloudUrl)}\n`);
2454
2564
  for (const excluded of preview.excluded)
@@ -2546,7 +2656,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2546
2656
  });
2547
2657
  const imports = Cli.create("import", {
2548
2658
  description: importsEnabled
2549
- ? "Read GitHub code scanning alerts and security advisories."
2659
+ ? "Import Sonar security issues or read GitHub security findings."
2550
2660
  : "Read GitHub code scanning alerts.",
2551
2661
  }).command("github", {
2552
2662
  description: "Read GitHub code scanning alerts without changing GitHub.",
@@ -2693,8 +2803,193 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2693
2803
  },
2694
2804
  });
2695
2805
  }
2696
- if (importsEnabled)
2806
+ function registerSonarImport() {
2807
+ imports.command("sonar", {
2808
+ description: "Collect Sonar security findings or replay a saved capture into the local workbench.",
2809
+ hint: "Uses the active sonar CLI login. --to cloud also publishes the locally imported selection to the connected Cloud repository. --dry-run saves a live capture for review without importing findings.",
2810
+ destructive: true,
2811
+ mcp: false,
2812
+ args: z.object({
2813
+ capture: z
2814
+ .string()
2815
+ .min(1)
2816
+ .optional()
2817
+ .describe("Replay a saved sonar-issues/v1 capture without connecting to Sonar."),
2818
+ }),
2819
+ options: z.object({
2820
+ sonarProject: optionValue("--sonar-project")
2821
+ .optional()
2822
+ .describe("Sonar project key (defaults to the checkout’s project binding)."),
2823
+ sonarBranch: optionValue("--sonar-branch")
2824
+ .optional()
2825
+ .describe("Analyzed Sonar branch (default: the project's main branch)."),
2826
+ sonarPullRequest: optionValue("--sonar-pull-request")
2827
+ .optional()
2828
+ .describe("Sonar pull request key, instead of a branch."),
2829
+ sonarIssue: z
2830
+ .array(optionValue("--sonar-issue"))
2831
+ .default([])
2832
+ .describe("Exact Sonar security issue key. Repeat to import a selection. Defaults to open and confirmed security issues."),
2833
+ sourceRepositoryUrl: optionValue("--source-repository-url")
2834
+ .optional()
2835
+ .describe("Verified repository URL when Sonar has no SCM binding."),
2836
+ to: z
2837
+ .enum(["local", "cloud"])
2838
+ .default("local")
2839
+ .describe("Store locally, or also publish to Codex Security Cloud."),
2840
+ dryRun: z
2841
+ .boolean()
2842
+ .default(false)
2843
+ .describe("Preview destinations and evidence without storing or publishing findings."),
2844
+ yes: z
2845
+ .boolean()
2846
+ .default(false)
2847
+ .describe("Confirm import of the reviewed selection."),
2848
+ }),
2849
+ output: z.record(z.string(), z.unknown()).optional(),
2850
+ async run({ args, options, format, formatExplicit, error: incurError }) {
2851
+ return await withTerminalErrorsHandled(errorOutput, async () => {
2852
+ const humanSummary = format === "toon" &&
2853
+ !formatExplicit &&
2854
+ !argv.some((arg) => OUTPUT_OPTION.test(arg));
2855
+ const controller = new AbortController();
2856
+ const removeSignals = listenForAbort(dependencies, controller);
2857
+ const note = (line) => notify(() => errorOutput.write(line + "\n"));
2858
+ const cloudFailure = (message) => {
2859
+ const reason = controller.signal.reason;
2860
+ exitCode =
2861
+ reason === "SIGINT" ? 130 : reason === "SIGTERM" ? 143 : 2;
2862
+ if (argv.includes("--full-output") &&
2863
+ (format === "json" || format === "jsonl"))
2864
+ failedResultOutput = {
2865
+ format,
2866
+ code: "SONAR_IMPORT_FAILED",
2867
+ message,
2868
+ };
2869
+ };
2870
+ try {
2871
+ if (importsEnabled &&
2872
+ argv.includes("--full-output") &&
2873
+ format !== "json" &&
2874
+ format !== "jsonl") {
2875
+ structuredError = true;
2876
+ exitCode = 2;
2877
+ return incurError({
2878
+ code: "INVALID_ARGUMENTS",
2879
+ message: "Sonar imports support --full-output with --format json or --format jsonl. Choose one of those formats or omit --full-output.",
2880
+ exitCode,
2881
+ });
2882
+ }
2883
+ const prepared = await prepareSonarImport({
2884
+ cwd: dependencies.currentDirectory(),
2885
+ capture: args.capture,
2886
+ project: options.sonarProject,
2887
+ branch: options.sonarBranch,
2888
+ pullRequest: options.sonarPullRequest,
2889
+ issueKeys: options.sonarIssue,
2890
+ sourceRepositoryUrl: options.sourceRepositoryUrl,
2891
+ to: options.to,
2892
+ dryRun: options.dryRun,
2893
+ yes: options.yes,
2894
+ }, {
2895
+ environment: dependencies.environment,
2896
+ signal: controller.signal,
2897
+ fetch: dependencies.cloudFetch,
2898
+ collect: dependencies.collectSonarIssues,
2899
+ onCapture: (path) => note("Evidence file: " + diagnosticValue(path)),
2900
+ });
2901
+ const { info, local, cloud, cloudError } = prepared;
2902
+ const ref = info.pullRequest
2903
+ ? `pull request ${info.pullRequest}`
2904
+ : (info.branch ?? "unspecified ref");
2905
+ note(`Sonar project: ${diagnosticValue(info.organization)}/${diagnosticValue(info.project)} (${diagnosticValue(ref)}) on ${diagnosticValue(info.server)}`);
2906
+ note(`Local repository: ${diagnosticValue(info.repository)}`);
2907
+ note(`Local: ${local.findings.length} ready, ${local.excluded.length} excluded.`);
2908
+ if (cloud) {
2909
+ const environments = new Set(cloud.requests.map((request) => request.repository.environment_id));
2910
+ note(`Cloud account: ${diagnosticValue(cloud.accountId)} on ${diagnosticValue(cloud.cloudApiUrl)}`);
2911
+ note(`Cloud repository: ${diagnosticValue(cloud.destination.url)} · ${cloud.privateImport ? `Private inbox · ${cloud.privateImport.format} (${cloud.privateImport.bytes} bytes)` : `Environments: ${[...environments].map(diagnosticValue).join(", ")}`}`);
2912
+ note(`Cloud: ${cloud.findings.length} ready, ${cloud.excluded.length} excluded.`);
2913
+ }
2914
+ if (options.to === "cloud" && local.read === 0)
2915
+ note("No Sonar findings to publish to Cloud.");
2916
+ if (cloudError)
2917
+ note(`Cloud unavailable: ${diagnosticValue(cloudError)}`);
2918
+ for (const { source_finding_id, evidence } of local.findings.slice(0, 5))
2919
+ note(` ${diagnosticValue(source_finding_id)} [${evidence.severity}] ${diagnosticValue(evidence.title)}`);
2920
+ if (local.findings.length > 5)
2921
+ note(` Showing the first 5 of ${local.findings.length} ready findings. Use --dry-run --format json for the full selection.`);
2922
+ const exclusions = new Set([...local.excluded, ...(cloud?.excluded ?? [])].map((item) => `Excluded ${diagnosticValue(item.source_finding_id ?? `item ${item.position}`)}: ${diagnosticValue(item.reason)}`));
2923
+ for (const line of exclusions)
2924
+ note(line);
2925
+ if (options.dryRun) {
2926
+ if (cloudError)
2927
+ cloudFailure(cloudError);
2928
+ if (humanSummary)
2929
+ renderedOutput = cloudError
2930
+ ? "Evidence saved. Retry with the saved file and --to cloud --dry-run to review the Cloud destination.\n"
2931
+ : "Preview complete. Use the saved evidence file to import this selection.\n";
2932
+ return { ...info, local, cloud, cloudError, dryRun: true };
2933
+ }
2934
+ if (!options.yes) {
2935
+ const prompt = dependencies.externalPublicationPrompt ??
2936
+ createTerminalPrompt(errorOutput);
2937
+ if (!prompt.isInteractive())
2938
+ throw new Error("Review the saved capture with --dry-run, then pass its path and --yes to confirm.");
2939
+ const action = cloud
2940
+ ? " and publish " +
2941
+ cloud.findings.length +
2942
+ " to the displayed Cloud destination"
2943
+ : " locally";
2944
+ if (!(await prompt.confirm("Import " +
2945
+ local.findings.length +
2946
+ " Sonar findings" +
2947
+ action +
2948
+ "?", false, controller.signal))) {
2949
+ if (humanSummary)
2950
+ renderedOutput = "Import canceled.\n";
2951
+ return { ...info, imported: false };
2952
+ }
2953
+ }
2954
+ const result = await prepared.import();
2955
+ if (result.cloudError) {
2956
+ cloudFailure(result.cloudError);
2957
+ note("Stored locally. Cloud: " + diagnosticValue(result.cloudError));
2958
+ }
2959
+ else if (result.local.excluded.length ||
2960
+ result.cloud?.status === "partial")
2961
+ exitCode = 1;
2962
+ if (result.cloud?.cloudUrl)
2963
+ note("Cloud repository: " + diagnosticValue(result.cloud.cloudUrl));
2964
+ if (humanSummary) {
2965
+ const { created, updated, unchanged } = result.local.counts;
2966
+ renderedOutput = `Local import: ${created} created, ${updated} updated, ${unchanged} unchanged.\n`;
2967
+ if (result.cloud)
2968
+ renderedOutput += renderExternalPublicationSummary(result.cloud);
2969
+ }
2970
+ return { ...result };
2971
+ }
2972
+ catch (error) {
2973
+ reportPublicationError(error, controller.signal.reason);
2974
+ if (argv.includes("--full-output"))
2975
+ structuredError = true;
2976
+ return incurError({
2977
+ code: "SONAR_IMPORT_FAILED",
2978
+ message: diagnosticValue(error),
2979
+ exitCode,
2980
+ });
2981
+ }
2982
+ finally {
2983
+ removeSignals();
2984
+ }
2985
+ });
2986
+ },
2987
+ });
2988
+ }
2989
+ if (importsEnabled) {
2697
2990
  registerGitHubAdvisories();
2991
+ registerSonarImport();
2992
+ }
2698
2993
  const infoOutput = z.object({
2699
2994
  sdkVersion: z.string(),
2700
2995
  bundledPluginVersion: z.string(),
@@ -2782,12 +3077,13 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2782
3077
  if (argumentError !== undefined)
2783
3078
  return fail(argumentError, 2);
2784
3079
  const directory = dependencies.currentDirectory();
3080
+ const codexOverrides = await parseScanCodexOverrides(options.codex, options.model, options.effort, options.provider, undefined, scanCodexHome(dependencies.environment));
2785
3081
  const outcome = await withTerminalErrorsHandled(errorOutput, () => runPolicyCommand({
2786
3082
  repository: resolveCliPath(directory, args.repository ?? "."),
2787
3083
  config: {
2788
3084
  pluginPath: options.pluginPath,
2789
3085
  pythonPath: options.python,
2790
- codexOverrides: parseCodexOverrides(options.codex, options.model, options.effort, options.provider),
3086
+ codexOverrides,
2791
3087
  },
2792
3088
  generation: {
2793
3089
  auth: options.auth,
@@ -2805,15 +3101,17 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2805
3101
  }, {
2806
3102
  createSecurity: dependencies.createPolicySecurity ??
2807
3103
  ((config) => new CodexSecurity(config, undefined, { surface: "cli" })),
2808
- chooseAuthentication: (config, auth, signal) => chooseInteractiveAuthentication({
2809
- auth,
2810
- provider: scanModelProvider({
2811
- ...DEFAULT_CODEX_CONFIG,
2812
- ...config.codexOverrides,
2813
- }),
2814
- command: "policy",
2815
- signal,
2816
- }, errorOutput, dependencies),
3104
+ chooseAuthentication: async (config, auth, signal) => {
3105
+ const effectiveConfig = await mergedCodexConfig(config, scanCodexHome(dependencies.environment));
3106
+ if (hasCommandAuth(effectiveConfig))
3107
+ return auth;
3108
+ return await chooseInteractiveAuthentication({
3109
+ auth,
3110
+ provider: scanModelProvider(effectiveConfig),
3111
+ command: "policy",
3112
+ signal,
3113
+ }, errorOutput, dependencies);
3114
+ },
2817
3115
  prompt: dependencies.policyPrompt ??
2818
3116
  createTerminalPrompt(errorOutput),
2819
3117
  environment: dependencies.environment,
@@ -2901,6 +3199,9 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
2901
3199
  .optional()
2902
3200
  .meta({ default: [] })
2903
3201
  .describe("Add security-context files or directories; repeat for multiple paths."),
3202
+ rubric: optionValue("--rubric")
3203
+ .optional()
3204
+ .describe("Use this Markdown file to grade findings. Takes precedence over the default severity rubric."),
2904
3205
  scanPromptFile: optionValue("--scan-prompt-file")
2905
3206
  .optional()
2906
3207
  .describe("Append scan instructions from FILE."),
@@ -3011,7 +3312,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3011
3312
  failureSeverity: options.failOnSeverity,
3012
3313
  maxCostUsd: options.maxCost,
3013
3314
  maxTimeMinutes: options.maxTime,
3014
- codexOverrides: parseCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex),
3315
+ codexOverrides: await parseScanCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex, scanCodexHome(dependencies.environment)),
3015
3316
  }, directory, scope.sources);
3016
3317
  if (options.archiveExisting && settings.outputDir === undefined) {
3017
3318
  throw new CodexSecurityError("--archive-existing requires --output-dir.");
@@ -3021,6 +3322,9 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3021
3322
  }
3022
3323
  outcome = await runScan({
3023
3324
  ...settings,
3325
+ rubricPath: options.rubric === undefined
3326
+ ? undefined
3327
+ : resolveCliPath(directory, options.rubric),
3024
3328
  codexOverrides: config.codexOverrides,
3025
3329
  projectConfig: provenance,
3026
3330
  workflowId: options.workflowId,
@@ -3178,7 +3482,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3178
3482
  })
3179
3483
  .command("classify-severity", {
3180
3484
  description: "Assess severity for saved findings or canonical records.",
3181
- hint: "Use --rubric to override the built-in policy or --records for host-provided classification.",
3485
+ hint: "For saved findings, use --rubric for your own policy or set CODEX_SECURITY_ENABLE_REMOTE_SEVERITY_RUBRIC=1 for the Statsig default. For host-provided reviews, use --records.",
3182
3486
  destructive: true,
3183
3487
  mcp: false,
3184
3488
  options: z.object({
@@ -3201,7 +3505,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3201
3505
  .describe("External completed scan directory."),
3202
3506
  rubric: optionValue("--rubric")
3203
3507
  .optional()
3204
- .describe("Classification policy document; omit to classify with the built-in severity rubric."),
3508
+ .describe("Classification policy document. Takes precedence over the default rubric."),
3205
3509
  knowledgeBase: z
3206
3510
  .array(optionValue("--knowledge-base"))
3207
3511
  .default([])
@@ -3497,7 +3801,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3497
3801
  ...pickScanSettings({ ...options, workers: undefined }),
3498
3802
  knowledgeBasePaths: options.knowledgeBase,
3499
3803
  maxCostUsd: options.maxCost,
3500
- codexOverrides: parseCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex),
3804
+ codexOverrides: await parseScanCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex, scanCodexHome(dependencies.environment)),
3501
3805
  }, directory);
3502
3806
  const settings = resolved.options;
3503
3807
  deepScanOptions(settings);
@@ -3510,7 +3814,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3510
3814
  };
3511
3815
  const components = options.componentsFile === undefined
3512
3816
  ? options.component.map((path) => ({ name: path, paths: [path] }))
3513
- : componentPlanSchema.parse(JSON.parse(await readRegularInputFile(resolveCliPath(directory, options.componentsFile), repository))).components;
3817
+ : componentPlanSchema.parse(JSON.parse((await readRegularInputFile(resolveCliPath(directory, options.componentsFile), repository)).replace(/^\uFEFF/u, ""))).components;
3514
3818
  if (!options.headless &&
3515
3819
  !options.planOnly &&
3516
3820
  errorOutput.isTTY === true &&
@@ -3519,7 +3823,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3519
3823
  const candidate = new ScanDashboard(errorOutput, {
3520
3824
  repository,
3521
3825
  presentation: "components",
3522
- model: scanModelConfiguration(await mergedCodexConfig(config)),
3826
+ model: scanModelConfiguration(await mergedCodexConfig(config, scanCodexHome(dependencies.environment))),
3523
3827
  mode: settings.mode,
3524
3828
  maxCostUsd: settings.maxCostUsd,
3525
3829
  showCost: options.showCost,
@@ -3740,7 +4044,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3740
4044
  validationPromptFile: settings.validationPromptFile,
3741
4045
  postScanPromptFile: settings.postScanPromptFile,
3742
4046
  config: {
3743
- codexOverrides: mergeCodexOverrides(resolved.config.codexOverrides, parseCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex)),
4047
+ codexOverrides: mergeCodexOverrides(resolved.config.codexOverrides, await parseScanCodexOverrides(options.codex, options.model, options.effort, options.provider, project?.input.codex, scanCodexHome(dependencies.environment))),
3744
4048
  pluginPath: options.pluginPath,
3745
4049
  pythonPath: options.python,
3746
4050
  },
@@ -3787,7 +4091,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
3787
4091
  scanPrompt: typeof saved["userContext"] === "string"
3788
4092
  ? saved["userContext"]
3789
4093
  : undefined,
3790
- }, currentDirectory);
4094
+ }, currentDirectory, dependencies.environment);
3791
4095
  const security = dependencies.createSecurity({
3792
4096
  pluginPath: options.pluginPath,
3793
4097
  pythonPath: options.python,
@@ -4021,24 +4325,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4021
4325
  verificationMode: VERIFICATION_MODE_OPTION,
4022
4326
  auth: SKILL_AUTH_OPTION,
4023
4327
  ...MODEL_OPTIONS.shape,
4024
- scan: optionValue("--scan")
4025
- .optional()
4026
- .describe("Verify open findings from a saved scan ID or the latest completed scan."),
4027
- severity: z
4028
- .enum(REPORTABLE_SEVERITIES)
4029
- .optional()
4030
- .describe("Verify saved findings at or above LEVEL."),
4031
- linearIssue: z
4032
- .array(optionValue("--linear-issue"))
4033
- .default([])
4034
- .describe("Linear issue identifier or URL; repeat for more issues."),
4035
- linearProject: optionValue("--linear-project")
4036
- .optional()
4037
- .describe("Verify issues in this Linear project."),
4038
- linearFilter: optionValue("--linear-filter")
4039
- .optional()
4040
- .describe("JSON Linear issue filter for --linear-project."),
4041
- linearApiKey: linearApiKeyOption(),
4328
+ ...remediationInputOptions("Verify").shape,
4042
4329
  codex: SKILL_CONFIG_OPTIONS.shape.codex,
4043
4330
  }),
4044
4331
  examples: [
@@ -4053,41 +4340,35 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4053
4340
  ],
4054
4341
  output: z.record(z.string(), z.unknown()).optional(),
4055
4342
  async run({ format, options, error: incurError }) {
4056
- const diagnostics = captureOutput();
4057
- let failureReported = false;
4343
+ let workerDiagnostic;
4344
+ const structured = format === "json" || format === "jsonl";
4345
+ const reportDiagnostic = async (chunk) => {
4346
+ if (structured) {
4347
+ if (!batchedVerification || frameworkFlags.tokenOutput)
4348
+ deferredVerificationDiagnostic = chunk;
4349
+ }
4350
+ else {
4351
+ await writeCliOutput(errorOutput, chunk).catch(() => { });
4352
+ }
4353
+ };
4058
4354
  try {
4059
4355
  if (options.host)
4060
4356
  throw new CodexSecurityError("Use verify-fix --host alone.");
4061
- const linear = options.linearIssue.length > 0 || !!options.linearProject;
4062
- if (options.linearIssue.length > 0 && options.linearProject) {
4063
- throw new CodexSecurityError("Use either --linear-issue or --linear-project, not both.");
4064
- }
4065
- if (options.linearFilter && !options.linearProject) {
4066
- throw new CodexSecurityError("--linear-filter requires --linear-project.");
4067
- }
4068
- if (options.linearApiKey !== undefined && !linear) {
4069
- throw new CodexSecurityError("--linear-api-key requires --linear-issue or --linear-project.");
4070
- }
4071
- const savedFindings = options.scan !== undefined ||
4072
- (positionals.length > 0 && positionals.every(isFindingIdentifier));
4073
- if (savedFindings && linear) {
4074
- throw new CodexSecurityError("Saved findings cannot be combined with Linear issues or projects.");
4075
- }
4357
+ const { savedFindings, linear } = resolveRemediationInputs(options, positionals);
4076
4358
  if (options.severity !== undefined && !savedFindings) {
4077
4359
  throw new CodexSecurityError("--severity requires a saved finding identifier or --scan.");
4078
4360
  }
4079
4361
  if (positionals.length === 0 && !linear && !savedFindings) {
4080
4362
  throw new CodexSecurityError("Verify-fix requires a finding, --scan, --linear-issue, or --linear-project.");
4081
4363
  }
4364
+ if (savedFindings)
4365
+ guardDisconnectedVerificationTerminal(errorOutput);
4082
4366
  const selected = savedFindings
4083
4367
  ? await selectSavedFindings(positionals, options.scan, options.severity, dependencies)
4084
4368
  : undefined;
4085
4369
  const imports = linear
4086
4370
  ? await importLinearIssues({
4087
- issues: options.linearIssue,
4088
- project: options.linearProject,
4089
- filter: options.linearFilter,
4090
- apiKey: options.linearApiKey,
4371
+ ...linear,
4091
4372
  environment: dependencies.environment,
4092
4373
  linearClient: dependencies.linearClient,
4093
4374
  })
@@ -4102,55 +4383,88 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4102
4383
  throw new CodexSecurityError("Verification inputs must have unique finding or issue identifiers.");
4103
4384
  }
4104
4385
  const repository = selected?.repository ?? dependencies.currentDirectory();
4105
- let results = [];
4386
+ const results = [];
4106
4387
  if (identifiers.length > 0) {
4107
4388
  const environment = imports.length === 0
4108
4389
  ? undefined
4109
4390
  : withoutLinearCredentials(dependencies.environment);
4110
- const response = captureOutput();
4111
- const progress = new FindingProgressPresenter(errorOutput, dependencies, repository, identifiers.length);
4112
- progress.startVerification();
4113
- const verificationErrors = new NodeWritable({
4114
- write(chunk, _encoding, callback) {
4115
- diagnostics.stream.write(chunk);
4116
- progress.stop();
4117
- void writeCliOutput(errorOutput, chunk).then(() => callback(), callback);
4118
- },
4119
- });
4391
+ const batches = selected
4392
+ ? await verificationBatches(selected.findings, await bundledPluginRoot(), options.verificationMode)
4393
+ : [undefined];
4394
+ // Multi-batch verification can outlive its stderr reader. Keep
4395
+ // optional progress off that execution path so terminal failures
4396
+ // and backpressure cannot prevent a complete stdout result.
4397
+ batchedVerification = batches.length > 1;
4398
+ const progress = batchedVerification
4399
+ ? undefined
4400
+ : new FindingProgressPresenter(errorOutput, dependencies, repository, identifiers.length);
4401
+ const controller = batchedVerification
4402
+ ? new AbortController()
4403
+ : undefined;
4404
+ const removeSignals = controller && listenForAbort(dependencies, controller);
4120
4405
  try {
4121
- exitCode = await runSkill("verify-fix", selected === undefined ? [...positionals, ...imports] : [], options, response.stream, verificationErrors, dependencies, {
4122
- directory: repository,
4123
- ...(selected === undefined
4124
- ? {}
4125
- : { findings: selected.findings }),
4126
- auth: options.auth,
4127
- verificationIds: identifiers,
4128
- verificationMode: options.verificationMode,
4129
- environment,
4130
- onEvent: progress.observe.bind(progress),
4131
- });
4132
- if (exitCode !== 0) {
4406
+ progress?.startVerification();
4407
+ for (const findings of batches) {
4408
+ const batchIds = findings?.map(({ occurrenceId }) => occurrenceId) ??
4409
+ identifiers;
4410
+ const response = captureOutput();
4411
+ const diagnostics = captureOutput();
4412
+ const verificationErrors = progress
4413
+ ? new NodeWritable({
4414
+ write(chunk, _encoding, callback) {
4415
+ diagnostics.stream.write(chunk);
4416
+ progress.stop();
4417
+ void writeCliOutput(errorOutput, chunk).then(() => callback(), callback);
4418
+ },
4419
+ })
4420
+ : diagnostics.stream;
4421
+ exitCode = await runSkill("verify-fix", selected === undefined ? [...positionals, ...imports] : [], options, response.stream, verificationErrors, dependencies, {
4422
+ directory: repository,
4423
+ findings,
4424
+ auth: options.auth,
4425
+ verificationIds: batchIds,
4426
+ signal: controller?.signal,
4427
+ verificationMode: options.verificationMode,
4428
+ environment,
4429
+ onEvent: progress?.observe.bind(progress),
4430
+ });
4133
4431
  if (exitCode === 130 || exitCode === 143) {
4134
4432
  frameworkExit = exitCode;
4135
4433
  return undefined;
4136
4434
  }
4137
- failureReported = diagnostics.text().trim().length > 0;
4138
- throw new CodexSecurityError(diagnostics.text().trim() ||
4139
- `Codex verification failed with exit code ${exitCode}.`);
4435
+ controller?.signal.throwIfAborted();
4436
+ if (exitCode !== 0) {
4437
+ const diagnostic = diagnostics.text();
4438
+ const message = diagnostic.trim();
4439
+ if (message)
4440
+ workerDiagnostic = diagnostic;
4441
+ throw new CodexSecurityError(message ||
4442
+ `Codex verification failed with exit code ${exitCode}.`);
4443
+ }
4444
+ results.push(...parseFindingVerifications(response.text(), batchIds));
4445
+ progress?.complete(results);
4140
4446
  }
4141
- results = parseFindingVerifications(response.text(), identifiers);
4142
- progress.complete(results);
4143
4447
  exitCode = results.some(({ status }) => status === "inconclusive")
4144
4448
  ? 2
4145
4449
  : results.some(({ status }) => status === "still_vulnerable")
4146
4450
  ? 1
4147
4451
  : 0;
4148
4452
  }
4453
+ catch (error) {
4454
+ if (!controller?.signal.aborted)
4455
+ throw error;
4456
+ }
4149
4457
  finally {
4150
- progress.stop();
4458
+ progress?.stop();
4459
+ removeSignals?.();
4460
+ }
4461
+ if (controller?.signal.aborted) {
4462
+ exitCode = controller.signal.reason === "SIGINT" ? 130 : 143;
4463
+ frameworkExit = exitCode;
4464
+ return undefined;
4151
4465
  }
4152
4466
  }
4153
- if (format === "json" || format === "jsonl") {
4467
+ if (structured) {
4154
4468
  return {
4155
4469
  repository,
4156
4470
  ...(selected === undefined ? {} : { scanId: selected.scanId }),
@@ -4164,9 +4478,12 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4164
4478
  }
4165
4479
  catch (error) {
4166
4480
  exitCode = 2;
4481
+ if (error instanceof VerificationFindingTooLargeError)
4482
+ batchedVerification = true;
4167
4483
  const message = errorMessage(error);
4168
- if (!failureReported)
4169
- errorOutput.write(`codex-security: ${diagnosticValue(message)}\n`);
4484
+ if (workerDiagnostic === undefined || batchedVerification)
4485
+ await reportDiagnostic(workerDiagnostic ??
4486
+ `codex-security: ${diagnosticValue(message)}\n`);
4170
4487
  return finishScan({ exitCode, error: message }, format, incurError, "VERIFICATION_FAILED");
4171
4488
  }
4172
4489
  },
@@ -4194,24 +4511,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4194
4511
  .boolean()
4195
4512
  .default(false)
4196
4513
  .describe("Use the container's isolation instead of the Codex sandbox (default: false)."),
4197
- scan: optionValue("--scan")
4198
- .optional()
4199
- .describe("Patch open findings from a saved scan ID or the latest completed scan."),
4200
- severity: z
4201
- .enum(REPORTABLE_SEVERITIES)
4202
- .optional()
4203
- .describe("Patch saved findings at or above LEVEL."),
4204
- linearIssue: z
4205
- .array(optionValue("--linear-issue"))
4206
- .default([])
4207
- .describe("Linear issue identifier or URL; repeat for more issues."),
4208
- linearProject: optionValue("--linear-project")
4209
- .optional()
4210
- .describe("Patch every open issue in this Linear project."),
4211
- linearFilter: optionValue("--linear-filter")
4212
- .optional()
4213
- .describe("JSON Linear issue filter for --linear-project."),
4214
- linearApiKey: linearApiKeyOption(),
4514
+ ...remediationInputOptions("Patch").shape,
4215
4515
  createPr: CREATE_PR_OPTION,
4216
4516
  assessPatchRisk: ASSESS_PATCH_RISK_OPTION,
4217
4517
  validationPromptFile: optionValue("--validation-prompt-file")
@@ -4245,7 +4545,6 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4245
4545
  try {
4246
4546
  if (options.host)
4247
4547
  throw new CodexSecurityError("Use patch --host alone.");
4248
- const linear = options.linearIssue.length > 0 || !!options.linearProject;
4249
4548
  if (options.resumePr !== undefined) {
4250
4549
  if (positionals.length > 0 ||
4251
4550
  options.scan !== undefined ||
@@ -4255,7 +4554,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4255
4554
  options.validationPromptFile !== undefined ||
4256
4555
  options.externalSandbox ||
4257
4556
  options.verificationMode !== undefined ||
4258
- linear ||
4557
+ options.linearIssue.length > 0 ||
4558
+ options.linearProject ||
4259
4559
  options.linearFilter !== undefined ||
4260
4560
  options.linearApiKey !== undefined ||
4261
4561
  options.model !== undefined ||
@@ -4270,20 +4570,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4270
4570
  }
4271
4571
  return;
4272
4572
  }
4273
- if (options.linearIssue.length > 0 && options.linearProject) {
4274
- throw new CodexSecurityError("Use either --linear-issue or --linear-project, not both.");
4275
- }
4276
- if (options.linearFilter && !options.linearProject) {
4277
- throw new CodexSecurityError("--linear-filter requires --linear-project.");
4278
- }
4279
- if (options.linearApiKey !== undefined && !linear) {
4280
- throw new CodexSecurityError("--linear-api-key requires --linear-issue or --linear-project.");
4281
- }
4282
- const savedFindings = options.scan !== undefined ||
4283
- (positionals.length > 0 && positionals.every(isFindingIdentifier));
4284
- if (savedFindings && linear) {
4285
- throw new CodexSecurityError("Saved findings cannot be combined with Linear issues or projects.");
4286
- }
4573
+ const { savedFindings, linear } = resolveRemediationInputs(options, positionals);
4287
4574
  if (options.externalSandbox) {
4288
4575
  errorOutput.write("WARNING: --external-sandbox disables Codex sandbox enforcement for patching. The container must provide isolation.\n");
4289
4576
  }
@@ -4329,7 +4616,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4329
4616
  }
4330
4617
  }
4331
4618
  const pullRequest = options.createPr
4332
- ? await createPatchPullRequest(selected.repository, selected.scanId, verifiedPatchFiles(selected, patches), errorOutput, dependencies, patchRisk?.summary)
4619
+ ? await createPatchPullRequest(selected.repository, selected.scanId, verifiedPatchFiles(selected, patches), errorOutput, dependencies, patchRisk)
4333
4620
  : undefined;
4334
4621
  if (structuredOutput) {
4335
4622
  return {
@@ -4352,10 +4639,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4352
4639
  const validationPrompt = await resolvePatchValidationPrompt(options.validationPromptFile, repository, repository);
4353
4640
  const imports = linear
4354
4641
  ? await importLinearIssues({
4355
- issues: options.linearIssue,
4356
- project: options.linearProject,
4357
- filter: options.linearFilter,
4358
- apiKey: options.linearApiKey,
4642
+ ...linear,
4359
4643
  environment: dependencies.environment,
4360
4644
  linearClient: dependencies.linearClient,
4361
4645
  })
@@ -4408,7 +4692,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4408
4692
  let pullRequest;
4409
4693
  if (options.createPr) {
4410
4694
  const identifier = directPatchIdentifier(positionals, imports);
4411
- pullRequest = await createPatchPullRequest(repository, identifier ?? directPatchDigest(positionals, imports), files, errorOutput, dependencies, patchRisk?.summary, identifier === undefined
4695
+ pullRequest = await createPatchPullRequest(repository, identifier ?? directPatchDigest(positionals, imports), files, errorOutput, dependencies, patchRisk, identifier === undefined
4412
4696
  ? "Applies a security fix generated from supplied issue data."
4413
4697
  : `Applies a security fix generated for ${identifier}.`);
4414
4698
  }
@@ -4661,7 +4945,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4661
4945
  const project = await selectedProjectConfig(options.config, dependencies);
4662
4946
  const resolved = resolveScanSettings(project, {}, directory);
4663
4947
  deepScanOptions(resolved.options);
4664
- const codex = await mergedCodexConfig(resolved.config);
4948
+ const codex = await mergedCodexConfig(resolved.config, scanCodexHome(dependencies.environment));
4665
4949
  const deep = resolved.options.mode === "deep"
4666
4950
  ? await resolveDeepScanConfig(resolved.options, join(scanCodexHome(dependencies.environment), "codex-security", "config.toml"))
4667
4951
  : undefined;
@@ -4795,7 +5079,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4795
5079
  if (!importsEnabled &&
4796
5080
  ((command === "publish" && subcommand === "findings") ||
4797
5081
  (command === "findings" && subcommand === "imported") ||
4798
- (command === "import" && subcommand === "github-advisories"))) {
5082
+ (command === "import" &&
5083
+ (subcommand === "github-advisories" || subcommand === "sonar")))) {
4799
5084
  if (process.env["COMPLETE"] ||
4800
5085
  argv.some((value) => FRAMEWORK_ACTIONS.has(value))) {
4801
5086
  return externalImportsDisabledMessage;
@@ -4811,6 +5096,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4811
5096
  cliOptions.sync = false;
4812
5097
  if (command === "publish")
4813
5098
  registerFindingPublication();
5099
+ else if (subcommand === "sonar")
5100
+ registerSonarImport();
4814
5101
  else
4815
5102
  registerGitHubAdvisories();
4816
5103
  valueOptions = cliValueOptions(commands);
@@ -4998,7 +5285,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
4998
5285
  const failureArguments = ["render", "--format", filteredScanFailure.format];
4999
5286
  for (let index = 0; index < argv.length; index += 1) {
5000
5287
  const argument = argv[index];
5001
- if (!/^--token-(?:count|limit|offset)(?:=|$)/u.test(argument))
5288
+ if (!TOKEN_OUTPUT_OPTION.test(argument))
5002
5289
  continue;
5003
5290
  const separator = argument.indexOf("=");
5004
5291
  if (separator !== -1)
@@ -5019,12 +5306,16 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
5019
5306
  renderedOutput = failureOutput.text();
5020
5307
  }
5021
5308
  let frameworkOutput = frameworkCapture.text();
5022
- if (notice !== undefined) {
5309
+ const writeUpdateNotice = () => {
5310
+ if (notice === undefined || batchedVerification)
5311
+ return;
5023
5312
  try {
5024
5313
  errorOutput.write(formatUpdateNotice(notice));
5025
5314
  }
5026
5315
  catch { }
5027
- }
5316
+ };
5317
+ if (deferredVerificationDiagnostic === undefined)
5318
+ writeUpdateNotice();
5028
5319
  if (frameworkExit !== undefined) {
5029
5320
  if (disabledImportInvocation && exitCode === 0) {
5030
5321
  reportPublicationError(externalImportsDisabledMessage, undefined);
@@ -5037,7 +5328,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
5037
5328
  else {
5038
5329
  if (exitCode !== 0)
5039
5330
  return exitCode;
5040
- errorOutput.write(`codex-security: ${diagnosticLines(incurErrorMessage(frameworkOutput))}\n`);
5331
+ errorOutput.write(`codex-security: ${diagnosticLines(await incurErrorMessage(frameworkOutput))}\n`);
5041
5332
  return 2;
5042
5333
  }
5043
5334
  }
@@ -5045,7 +5336,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
5045
5336
  return exitCode;
5046
5337
  if (frameworkOutput.length === 0 &&
5047
5338
  streamedLogs === undefined &&
5048
- filteredScanFailure === undefined)
5339
+ filteredScanFailure === undefined &&
5340
+ deferredVerificationDiagnostic === undefined)
5049
5341
  return exitCode;
5050
5342
  try {
5051
5343
  // Incur can add a stale-skills CTA after the logs handler returns.
@@ -5075,6 +5367,19 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
5075
5367
  errorOutput.write(`codex-security: ${diagnosticLines(error)}\n`);
5076
5368
  return 2;
5077
5369
  }
5370
+ finally {
5371
+ if (deferredVerificationDiagnostic !== undefined) {
5372
+ // Token output can omit the diagnostic. Otherwise a buffered stderr
5373
+ // write is optional once the complete structured failure is on stdout.
5374
+ if (frameworkFlags.tokenOutput) {
5375
+ await writeCliOutput(errorOutput, deferredVerificationDiagnostic).catch(() => { });
5376
+ }
5377
+ else {
5378
+ writeOptionalVerificationDiagnostic(errorOutput, deferredVerificationDiagnostic);
5379
+ }
5380
+ writeUpdateNotice();
5381
+ }
5382
+ }
5078
5383
  }
5079
5384
  async function runScanImport(options, errorOutput, dependencies) {
5080
5385
  const controller = new AbortController();
@@ -5110,7 +5415,7 @@ async function runScanImport(options, errorOutput, dependencies) {
5110
5415
  removeSignals();
5111
5416
  }
5112
5417
  }
5113
- async function prepareScanArgumentsFromRecipe(recipe, operation, { scanPrompt, scanPromptFile, validationPromptFile, }, directory) {
5418
+ async function prepareScanArgumentsFromRecipe(recipe, operation, { scanPrompt, scanPromptFile, validationPromptFile, }, directory, environment) {
5114
5419
  if (recipe === undefined || !isJsonObject(recipe)) {
5115
5420
  throw new CodexSecurityError("This scan does not have a saved launch recipe.");
5116
5421
  }
@@ -5203,6 +5508,9 @@ async function prepareScanArgumentsFromRecipe(recipe, operation, { scanPrompt, s
5203
5508
  }
5204
5509
  const safetyIdentifier = recipe["safetyIdentifier"];
5205
5510
  const postScanPrompt = recipe["postScanPrompt"];
5511
+ const severityRubric = operation === "rerun"
5512
+ ? severityRubricSchema.optional().parse(recipe["severityRubric"])
5513
+ : undefined;
5206
5514
  if ((safetyIdentifier !== undefined && typeof safetyIdentifier !== "string") ||
5207
5515
  (postScanPrompt !== undefined && typeof postScanPrompt !== "string")) {
5208
5516
  throw new CodexSecurityError("The saved scan recipe contains invalid launch settings.");
@@ -5211,11 +5519,13 @@ async function prepareScanArgumentsFromRecipe(recipe, operation, { scanPrompt, s
5211
5519
  if (requiresRerunPrompt && !prompts.scanPrompt?.trim()) {
5212
5520
  throw new CodexSecurityError("This scan used additional instructions. The --scan-prompt-file must not be empty.");
5213
5521
  }
5522
+ const replayConfig = await restoreProviderProfile(config, recipe["providerProfile"], environment);
5214
5523
  return {
5215
5524
  repository,
5216
5525
  auth: auth.data ?? DEFAULT_SCAN_AUTH,
5217
5526
  cyberAccessProgram: cyberAccessProgram.data,
5218
5527
  ownerSuggestions: ownerSuggestions.data,
5528
+ ...(severityRubric === undefined ? {} : { severityRubric }),
5219
5529
  // Saved scopes contain literal repository names, not home-relative inputs.
5220
5530
  target: paths.length > 0
5221
5531
  ? paths.map((path) => path === "~" || path.startsWith("~/") || path.startsWith("~\\")
@@ -5233,9 +5543,9 @@ async function prepareScanArgumentsFromRecipe(recipe, operation, { scanPrompt, s
5233
5543
  mode,
5234
5544
  ...deepScan.data,
5235
5545
  archiveExisting: false,
5236
- codexOverrides: Object.hasOwn(config, "approval_policy")
5237
- ? config
5238
- : { ...config, approval_policy: "never" },
5546
+ codexOverrides: Object.hasOwn(replayConfig, "approval_policy")
5547
+ ? replayConfig
5548
+ : { ...replayConfig, approval_policy: "never" },
5239
5549
  failureSeverity: threshold.data,
5240
5550
  maxCostUsd,
5241
5551
  maxTimeMinutes: maxTimeMinutes.data,
@@ -5250,6 +5560,7 @@ function frameworkOutputFlags(argv) {
5250
5560
  let hideDisabledRoute = false;
5251
5561
  let fullOutput = false;
5252
5562
  let rawCollector = false;
5563
+ let tokenOutput = false;
5253
5564
  for (let index = 0; index < argv.length; index++) {
5254
5565
  const value = argv[index];
5255
5566
  if (FRAMEWORK_ACTIONS.has(value) ||
@@ -5261,6 +5572,8 @@ function frameworkOutputFlags(argv) {
5261
5572
  fullOutput = true;
5262
5573
  if (value === "--json")
5263
5574
  rawCollector = true;
5575
+ if (TOKEN_OUTPUT_OPTION.test(value))
5576
+ tokenOutput = true;
5264
5577
  if (FRAMEWORK_VALUE_OPTIONS.has(value)) {
5265
5578
  const operand = argv[++index];
5266
5579
  if (value === "--format")
@@ -5268,7 +5581,11 @@ function frameworkOutputFlags(argv) {
5268
5581
  operand === "json" || operand === "jsonl" || operand === "yaml";
5269
5582
  }
5270
5583
  }
5271
- return { hideDisabledRoute, rawCollector: rawCollector && !fullOutput };
5584
+ return {
5585
+ hideDisabledRoute,
5586
+ rawCollector: rawCollector && !fullOutput,
5587
+ tokenOutput,
5588
+ };
5272
5589
  }
5273
5590
  function cliValueOptions(commands) {
5274
5591
  const options = new Set(FRAMEWORK_VALUE_OPTIONS);
@@ -5366,6 +5683,26 @@ function staysWithinWindowsDeviceRoot(input, root) {
5366
5683
  function isFindingIdentifier(value) {
5367
5684
  return /^(?:occ|csf)_[A-Za-z0-9_-]+$/u.test(value);
5368
5685
  }
5686
+ function resolveRemediationInputs({ scan, linearIssue: issues, linearProject: project, linearFilter: filter, linearApiKey: apiKey, }, positionals) {
5687
+ if (issues.length > 0 && project) {
5688
+ throw new CodexSecurityError("Use either --linear-issue or --linear-project, not both.");
5689
+ }
5690
+ if (filter && !project) {
5691
+ throw new CodexSecurityError("--linear-filter requires --linear-project.");
5692
+ }
5693
+ const linear = issues.length > 0 || project
5694
+ ? { issues, project, filter, apiKey }
5695
+ : undefined;
5696
+ if (apiKey !== undefined && !linear) {
5697
+ throw new CodexSecurityError("--linear-api-key requires --linear-issue or --linear-project.");
5698
+ }
5699
+ const savedFindings = scan !== undefined ||
5700
+ (positionals.length > 0 && positionals.every(isFindingIdentifier));
5701
+ if (savedFindings && linear) {
5702
+ throw new CodexSecurityError("Saved findings cannot be combined with Linear issues or projects.");
5703
+ }
5704
+ return { savedFindings, linear };
5705
+ }
5369
5706
  async function* workbenchFindings(arguments_, dependencies) {
5370
5707
  let offset;
5371
5708
  do {
@@ -5504,15 +5841,6 @@ function patchCommitKey(branch) {
5504
5841
  function patchPullRequestBodyKey(branch) {
5505
5842
  return `branch.${branch}.codexSecurityPatchPullRequestBody`;
5506
5843
  }
5507
- function patchPullRequestBody(patchRiskSummary, introduction = PATCH_PR_BODY) {
5508
- if (patchRiskSummary === undefined)
5509
- return introduction;
5510
- const summary = safePatchReport(patchRiskSummary);
5511
- if (!summary) {
5512
- throw new CodexSecurityError("Patch risk assessment returned an empty pull request summary.");
5513
- }
5514
- return `${introduction}\n\n## Patch risk assessment\n\n${summary}`;
5515
- }
5516
5844
  function directPatchIdentifier(positionals, imports) {
5517
5845
  if (imports.length === 1)
5518
5846
  return imports[0].id;
@@ -5584,13 +5912,15 @@ function verifiedPatchFiles(selected, patches) {
5584
5912
  return path;
5585
5913
  });
5586
5914
  }
5587
- async function createPatchPullRequest(repository, patchId, files, stderr, dependencies, patchRiskSummary, introduction = PATCH_PR_BODY) {
5915
+ async function createPatchPullRequest(repository, patchId, files, stderr, dependencies, patchRisk, introduction = PATCH_PR_BODY) {
5588
5916
  if (files.length === 0) {
5589
5917
  stderr.write("No verified patch changes to publish.\n");
5590
5918
  return;
5591
5919
  }
5592
5920
  const branch = `codex-security/patch-${patchId.replaceAll(/[^a-z\d._-]/giu, "-")}`;
5593
- const body = patchPullRequestBody(patchRiskSummary, introduction);
5921
+ const body = patchRisk === undefined
5922
+ ? introduction
5923
+ : `${introduction}\n\n## Patch risk assessment\n\n${patchRisk.summary}`;
5594
5924
  const run = (args) => dependencies.runRepositoryCommand("git", args, repository);
5595
5925
  stderr.write("Creating a draft pull request or merge request for verified patches...\n");
5596
5926
  await run(["switch", "-c", branch]);
@@ -5960,7 +6290,7 @@ async function runSkill(skill, inputs, configuration, stdout, stderr, dependenci
5960
6290
  ...(providerConfiguration === undefined
5961
6291
  ? {}
5962
6292
  : { model_providers: { [provider]: providerConfiguration } }),
5963
- }), configuredCodexHome(options.environment ?? dependencies.environment));
6293
+ }), scanCodexHome(options.environment ?? dependencies.environment));
5964
6294
  const directory = options.directory ?? dependencies.currentDirectory();
5965
6295
  const contextFile = options.contextFile === undefined
5966
6296
  ? undefined
@@ -6107,6 +6437,7 @@ async function runSkill(skill, inputs, configuration, stdout, stderr, dependenci
6107
6437
  pluginVersion,
6108
6438
  providerResolved: provider !== undefined || validate,
6109
6439
  });
6440
+ options.signal?.throwIfAborted();
6110
6441
  return dependencies.runCodex([
6111
6442
  ...(appServer
6112
6443
  ? ["app-server"]
@@ -6169,6 +6500,7 @@ async function runSkill(skill, inputs, configuration, stdout, stderr, dependenci
6169
6500
  ]),
6170
6501
  ], {
6171
6502
  command: verify ? "verify-fix" : patch || assess ? "patch" : "validate",
6503
+ signal: options.signal,
6172
6504
  auth: options.auth ?? "auto",
6173
6505
  directory,
6174
6506
  modelProvider: provider,
@@ -6505,11 +6837,12 @@ export function skillCommandFailure(command, status, detail, authentication = nu
6505
6837
  }
6506
6838
  return detail || `${command} failed with exit code ${status}.`;
6507
6839
  }
6508
- function incurErrorMessage(output) {
6840
+ async function incurErrorMessage(output) {
6509
6841
  // YAML folds long strings across lines; JSON output keeps its serialized form.
6510
6842
  if (!output.startsWith("{")) {
6843
+ const { parse } = await import("yaml");
6511
6844
  try {
6512
- const parsed = parseYaml(output);
6845
+ const parsed = parse(output);
6513
6846
  if (isJsonObject(parsed) && typeof parsed["message"] === "string")
6514
6847
  return parsed["message"];
6515
6848
  }
@@ -6708,10 +7041,15 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
6708
7041
  codexOverrides: arguments_.codexOverrides,
6709
7042
  };
6710
7043
  const selectedProfileName = config.codexOverrides?.["profile"];
6711
- const effectiveConfiguration = {
6712
- ...DEFAULT_CODEX_CONFIG,
6713
- ...config.codexOverrides,
6714
- };
7044
+ const inlineProfiles = config.codexOverrides?.["profiles"];
7045
+ // Saved recipes keep their existing validation path; file profiles need
7046
+ // an early merge so CLI reporting reflects the selected file.
7047
+ const effectiveConfiguration = typeof selectedProfileName === "string" &&
7048
+ (inlineProfiles === undefined ||
7049
+ !isJsonObject(inlineProfiles) ||
7050
+ !isJsonObject(inlineProfiles[selectedProfileName] ?? null))
7051
+ ? await mergedCodexConfig(config, scanCodexHome(dependencies.environment))
7052
+ : { ...DEFAULT_CODEX_CONFIG, ...config.codexOverrides };
6715
7053
  ({ model: effectiveModel, reasoningEffort: effectiveReasoningEffort } =
6716
7054
  scanModelConfiguration(effectiveConfiguration));
6717
7055
  const resolvedConfiguration = resolveCodexProfile(effectiveConfiguration);
@@ -6761,7 +7099,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
6761
7099
  }
6762
7100
  selectedAuthentication = arguments_.mock
6763
7101
  ? null
6764
- : scanAuthentication(dependencies.environment, auth, provider, hasCommandAuth(effectiveConfiguration), arguments_.dryRun);
7102
+ : scanAuthentication(dependencies.environment, auth, provider, hasCommandAuth(effectiveConfiguration), arguments_.dryRun, scanProviderEnvKey(effectiveConfiguration));
6765
7103
  diagnostic("scan.configuration", {
6766
7104
  cli_version: VERSION,
6767
7105
  bundled_plugin_version: BUNDLED_PLUGIN_VERSION,
@@ -6791,10 +7129,10 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
6791
7129
  dependencies.environment["TERM"] !== "dumb");
6792
7130
  if (progress.interactive && !arguments_.dryRun && !verbose) {
6793
7131
  dashboard = new ScanDashboard(errorOutput, {
6794
- repository,
7132
+ repository: resolveCliPath(directory, repository),
6795
7133
  mode: arguments_.mode,
6796
7134
  showCost,
6797
- model: scanModelConfiguration(await mergedCodexConfig(config)),
7135
+ model: scanModelConfiguration(effectiveConfiguration),
6798
7136
  ...(arguments_.maxCostUsd === undefined
6799
7137
  ? {}
6800
7138
  : { maxCostUsd: arguments_.maxCostUsd }),
@@ -6857,6 +7195,12 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
6857
7195
  }
6858
7196
  const options = {
6859
7197
  ...pickScanSettings(arguments_),
7198
+ ...(arguments_.rubricPath === undefined
7199
+ ? {}
7200
+ : { rubricPath: arguments_.rubricPath }),
7201
+ ...(arguments_.severityRubric === undefined
7202
+ ? {}
7203
+ : { severityRubric: arguments_.severityRubric }),
6860
7204
  knowledgeBaseSnapshot: arguments_.knowledgeBaseSnapshot,
6861
7205
  ...(arguments_.resumeScanId === undefined
6862
7206
  ? {}
@@ -7258,7 +7602,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7258
7602
  validation = { ...validation, status: "failed", message };
7259
7603
  errorOutput.write(`codex-security: Validation failed: ${diagnosticValue(message)}\n`);
7260
7604
  if (validation["reportPath"] !== undefined) {
7261
- errorOutput.write(`Partial validation report: ${diagnosticValue(validation["reportPath"])}\n`);
7605
+ errorOutput.write(`Validation report opened at ${diagnosticValue(validation["reportPath"])}\n`);
7262
7606
  }
7263
7607
  }
7264
7608
  }
@@ -7313,11 +7657,11 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7313
7657
  if (requestedSignal !== null) {
7314
7658
  diagnostic("scan.interrupted", {
7315
7659
  signal: requestedSignal,
7316
- partial_output: scanDir !== null,
7317
7660
  });
7318
7661
  if (result !== null && arguments_.validate) {
7319
7662
  const exitCode = requestedSignal === "SIGINT" ? 130 : 143;
7320
- const message = `Validation interrupted. Completed scan output was kept at ${errorMessage(result.scanDir)}.`;
7663
+ const scanId = quoteCliPath(diagnosticValue(result.manifest.scan.id));
7664
+ const message = `Validation interrupted. Original output directory: ${errorMessage(result.scanDir)}. Run codex-security scans show ${scanId} to inspect the completed scan.`;
7321
7665
  errorOutput.write(`codex-security: ${message}\n`);
7322
7666
  return {
7323
7667
  exitCode,
@@ -7328,6 +7672,8 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7328
7672
  },
7329
7673
  };
7330
7674
  }
7675
+ if (failure instanceof ScanInterruptedError)
7676
+ scanDir ??= failure.scanDir;
7331
7677
  const exitCode = interruptedExit(requestedSignal, scanDir, errorOutput);
7332
7678
  printFailedScanReference(registeredScan, phase, arguments_, errorOutput);
7333
7679
  return {
@@ -7340,16 +7686,12 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7340
7686
  }
7341
7687
  if (failed) {
7342
7688
  const costLimitFailure = failure instanceof ScanCostLimitExceededError ? failure : undefined;
7689
+ const classification = classifyScanFailure(failure);
7343
7690
  const message = failure instanceof OutputInsideProtectedRootError
7344
7691
  ? errorMessage(protectedRootErrorMessage(failure))
7345
- : scanFailureMessage(failure, selectedAuthentication, providerOptions.provider);
7692
+ : scanFailureMessage(failure, classification, selectedAuthentication, providerOptions.provider);
7346
7693
  diagnostic("scan.failed", {
7347
- classification: costLimitFailure !== undefined
7348
- ? "cost_limit_exceeded"
7349
- : isLocalScanFailure(failure)
7350
- ? "local"
7351
- : classifyConnectionFailure(failure),
7352
- partial_output: scanDir !== null,
7694
+ classification: costLimitFailure !== undefined ? "cost_limit_exceeded" : classification,
7353
7695
  max_cost_usd: costLimitFailure?.maxCostUsd,
7354
7696
  estimated_usd: costLimitFailure?.cost.estimatedUsd,
7355
7697
  cost_estimate: costLimitFailure === undefined
@@ -7358,7 +7700,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7358
7700
  });
7359
7701
  errorOutput.write(`${message}\n`);
7360
7702
  if (!(failure instanceof ScanInterruptedError) && scanDir !== null) {
7361
- errorOutput.write(`Partial output was kept at ${errorMessage(scanDir)}.\n`);
7703
+ errorOutput.write(`Output directory: ${errorMessage(scanDir)}\n`);
7362
7704
  }
7363
7705
  printFailedScanReference(registeredScan, phase, arguments_, errorOutput);
7364
7706
  return { exitCode: 2, error: message, data: failureData };
@@ -7469,7 +7811,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
7469
7811
  (dependencies.patchEditor !== undefined || process.stdin.isTTY === true)) {
7470
7812
  const confirmed = arguments_.patch ||
7471
7813
  (await (dependencies.confirmPatchReview ??
7472
- createTerminalPrompt(errorOutput).confirm)("Review and patch these findings?"));
7814
+ createTerminalPrompt(errorOutput).confirm)("Open findings for review?"));
7473
7815
  if (confirmed) {
7474
7816
  const selectPatches = dependencies.patchEditor ??
7475
7817
  (async (target, candidates) => {
@@ -7569,7 +7911,8 @@ function isLocalScanFailure(error) {
7569
7911
  error instanceof OutputDirectoryError ||
7570
7912
  error instanceof ConfigurationError ||
7571
7913
  error instanceof LocalPluginBootstrapError ||
7572
- error instanceof PluginPythonUnavailableError) {
7914
+ error instanceof PluginPythonUnavailableError ||
7915
+ error instanceof SandboxUnavailableError) {
7573
7916
  return true;
7574
7917
  }
7575
7918
  return (typeof error === "object" &&
@@ -7578,6 +7921,15 @@ function isLocalScanFailure(error) {
7578
7921
  typeof error.code === "string" &&
7579
7922
  LOCAL_SYSCALL_CODES.has(error.code));
7580
7923
  }
7924
+ function classifyScanFailure(error) {
7925
+ if (isLocalScanFailure(error))
7926
+ return "local";
7927
+ const classification = classifyConnectionFailure(error);
7928
+ // Installing the plugin can be denied filesystem access before any model request.
7929
+ if (classification === "forbidden" && error instanceof PluginBootstrapError)
7930
+ return "plugin_bootstrap";
7931
+ return classification;
7932
+ }
7581
7933
  function authenticationFailureMessage(authentication) {
7582
7934
  if (authentication?.method === "command") {
7583
7935
  return "Native Codex command authentication failed. Check the configured provider auth command.";
@@ -7607,13 +7959,12 @@ function authenticationFailureMessage(authentication) {
7607
7959
  }
7608
7960
  return "Authentication failed. Check the selected provider's credentials and retry.";
7609
7961
  }
7610
- function scanFailureMessage(error, authentication, provider) {
7962
+ function scanFailureMessage(error, classification, authentication, provider) {
7611
7963
  // A local failure keeps its own message. Classification matches bare words
7612
7964
  // such as "permission denied" anywhere in the text, so an EACCES from a
7613
7965
  // read-only TMPDIR would otherwise be reported as a credential problem.
7614
- if (isLocalScanFailure(error))
7966
+ if (classification === "local")
7615
7967
  return diagnosticValue(error);
7616
- const classification = classifyConnectionFailure(error);
7617
7968
  if (provider === "amazon-bedrock" ||
7618
7969
  authentication?.method === "aws_credentials") {
7619
7970
  const detail = diagnosticValue(error);
@@ -7671,6 +8022,7 @@ function scanFailureMessage(error, authentication, provider) {
7671
8022
  case "rate_limited":
7672
8023
  return `${detail}The configured account reached its rate limit. Wait and retry.`;
7673
8024
  case "network_error":
8025
+ case "plugin_bootstrap":
7674
8026
  case "timeout":
7675
8027
  case "unknown":
7676
8028
  return diagnosticValue(error);
@@ -7775,7 +8127,7 @@ function printFailedScanReference(scan, phase, arguments_, output) {
7775
8127
  printScanReference(scan, output);
7776
8128
  if (phase !== null)
7777
8129
  output.write(`Last observed phase: ${diagnosticValue(phase)}\n`);
7778
- output.write(`Retained results: ${diagnosticValue(scan["scanDir"])}\n` +
8130
+ output.write(`Output directory: ${diagnosticValue(scan["scanDir"])}\n` +
7779
8131
  "Inspect the saved scan status before choosing resume or rerun.\n");
7780
8132
  const prompts = [
7781
8133
  ...(arguments_.scanPromptFile !== undefined ||
@@ -7916,7 +8268,7 @@ function protectedRootErrorMessage(error) {
7916
8268
  ` Reason: ${reason}`,
7917
8269
  error.pathKind === "output"
7918
8270
  ? suggestion === undefined
7919
- ? "Choose a private output directory outside the protected root."
8271
+ ? "Choose an output directory outside the protected root."
7920
8272
  : `Re-run with --output-dir ${quoteCliPath(suggestion)}.`
7921
8273
  : suggestion === undefined
7922
8274
  ? "Set TMPDIR (or TEMP on Windows) to a writable directory outside the protected root."
@@ -8018,6 +8370,35 @@ function resolveCliScope(configured, overrides) {
8018
8370
  sources,
8019
8371
  };
8020
8372
  }
8373
+ async function parseScanCodexOverrides(values, model, effort, provider, defaults, profileHome) {
8374
+ if (!isExternalModelProvider(provider) && provider !== "amazon-bedrock") {
8375
+ return parseCodexOverrides(values, model, effort, provider, defaults);
8376
+ }
8377
+ const explicit = parseCodexOverrides(values, model, effort);
8378
+ const overrides = mergeCodexOverrides(defaults ?? {}, explicit);
8379
+ const profile = await readCodexFileProfile(overrides, profileHome);
8380
+ const result = parseCodexOverrides(values, model, effort, provider, mergeCodexOverrides(profile, defaults ?? {}));
8381
+ const providers = profile["model_providers"];
8382
+ if (isExternalModelProvider(provider) &&
8383
+ isJsonObject(providers) &&
8384
+ isJsonObject(providers[provider])) {
8385
+ // Fill missing defaults without replacing file settings or combining
8386
+ // native command auth with the generated env-key definition.
8387
+ const generated = { ...EXTERNAL_CODEX_PROVIDERS[provider] };
8388
+ for (const key of Object.keys(providers[provider]))
8389
+ delete generated[key];
8390
+ if (providers[provider]["auth"] !== undefined)
8391
+ delete generated["env_key"];
8392
+ delete result["model_providers"];
8393
+ if (Object.keys(generated).length > 0) {
8394
+ result["model_providers"] = { [provider]: generated };
8395
+ }
8396
+ if (explicit["model_providers"] !== undefined) {
8397
+ result["model_providers"] = mergeCodexOverrides(result["model_providers"] ?? {}, explicit["model_providers"]);
8398
+ }
8399
+ }
8400
+ return result;
8401
+ }
8021
8402
  export function parseCodexOverrides(values, model, effort, provider, defaults) {
8022
8403
  const result = Object.create(null);
8023
8404
  if (model !== undefined)
@@ -8213,20 +8594,8 @@ export class Progress {
8213
8594
  }
8214
8595
  }
8215
8596
  #renderTimer(message) {
8216
- let line = this.#line(message);
8217
8597
  const width = Math.max(0, (this.#stream.columns ?? 80) - 1);
8218
- if (publicationDisplayWidth(line) > width) {
8219
- let visible = "";
8220
- let used = 0;
8221
- for (const { segment } of PUBLICATION_GRAPHEME_SEGMENTER.segment(line)) {
8222
- const segmentWidth = publicationDisplayWidth(segment);
8223
- if (used + segmentWidth >= width)
8224
- break;
8225
- visible += segment;
8226
- used += segmentWidth;
8227
- }
8228
- line = width > 0 ? `${visible}…` : "";
8229
- }
8598
+ const line = fitProgressLine(this.#line(message), width);
8230
8599
  this.#stream.write(`${this.#timerLineActive ? "\r\u001B[K" : ""}${line}`);
8231
8600
  this.#timerLineActive = true;
8232
8601
  }
@@ -8234,9 +8603,9 @@ export class Progress {
8234
8603
  function interruptedExit(signal, scanDir, errorOutput) {
8235
8604
  const ctrlC = signal === "SIGINT";
8236
8605
  errorOutput.write(`codex-security: Scan ${ctrlC ? "canceled by Ctrl-C" : "terminated by SIGTERM"}.\n`);
8237
- errorOutput.write(scanDir === null
8238
- ? "codex-security: No partial output was kept.\n"
8239
- : `codex-security: Partial output was kept at ${errorMessage(scanDir)}.\n`);
8606
+ if (scanDir) {
8607
+ errorOutput.write(`codex-security: Output directory: ${errorMessage(scanDir)}\n`);
8608
+ }
8240
8609
  return ctrlC ? 130 : 143;
8241
8610
  }
8242
8611
  function invokedAsMain() {