@openai/codex-security 0.9.1 → 0.10.1

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 (444) hide show
  1. package/README.md +37 -788
  2. package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
  3. package/_bundled_plugin/.mcp.json +3 -0
  4. package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
  5. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  6. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br +0 -0
  14. package/_bundled_plugin/references/access-advisory.md +1 -1
  15. package/_bundled_plugin/references/artifact-storage.md +1 -1
  16. package/_bundled_plugin/references/baseline-auditor.md +18 -0
  17. package/_bundled_plugin/references/core-scan.md +5 -42
  18. package/_bundled_plugin/references/final-report.md +1 -1
  19. package/_bundled_plugin/references/focused-investigator.md +13 -0
  20. package/_bundled_plugin/references/scan-prologue.md +2 -2
  21. package/_bundled_plugin/references/scan-runtime.md +4 -2
  22. package/_bundled_plugin/references/security-guidance.md +14 -1
  23. package/_bundled_plugin/references/threat-model.md +1 -0
  24. package/_bundled_plugin/references/validate-scan-findings.md +3 -0
  25. package/_bundled_plugin/scripts/deep_scan_workbench.py +30 -12
  26. package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
  27. package/_bundled_plugin/scripts/finalize_scan_contract.py +47 -9
  28. package/_bundled_plugin/scripts/launch_codex_security_mcp +54 -16
  29. package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +2 -0
  30. package/_bundled_plugin/scripts/posix_scan_local_files.py +26 -1
  31. package/_bundled_plugin/scripts/snapshot_sqlite.py +8 -2
  32. package/_bundled_plugin/scripts/windows_scan_local_files.py +216 -25
  33. package/_bundled_plugin/scripts/workbench/handoff.py +55 -25
  34. package/_bundled_plugin/scripts/workbench/storage.py +25 -5
  35. package/_bundled_plugin/scripts/workbench_cli.py +24 -2
  36. package/_bundled_plugin/scripts/workbench_constants.py +2 -0
  37. package/_bundled_plugin/scripts/workbench_db.py +257 -268
  38. package/_bundled_plugin/scripts/workbench_feedback.py +49 -4
  39. package/_bundled_plugin/scripts/workbench_native_indexes.py +226 -29
  40. package/_bundled_plugin/scripts/workbench_progress.py +159 -3
  41. package/_bundled_plugin/scripts/workbench_publication.py +2 -3
  42. package/_bundled_plugin/scripts/workbench_remediation.py +142 -2
  43. package/_bundled_plugin/scripts/workbench_saved_results.py +48 -8
  44. package/_bundled_plugin/scripts/workbench_scan_history.py +291 -134
  45. package/_bundled_plugin/scripts/workbench_scan_start.py +208 -11
  46. package/_bundled_plugin/scripts/workbench_scan_usage.py +36 -10
  47. package/_bundled_plugin/scripts/workbench_schema.py +220 -14
  48. package/_bundled_plugin/scripts/workbench_setup.py +1 -1
  49. package/_bundled_plugin/scripts/workbench_source_scopes.py +8 -0
  50. package/_bundled_plugin/scripts/workbench_target.py +486 -85
  51. package/_bundled_plugin/scripts/workbench_target_state.py +1108 -22
  52. package/_bundled_plugin/shared/workbench-history-repairs.json +64 -14
  53. package/_bundled_plugin/shared/workbench-migrations.json +66 -0
  54. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +4 -2
  55. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +2 -2
  56. package/_bundled_plugin/skills/fix-finding/SKILL.md +1 -0
  57. package/_bundled_plugin/skills/publish-findings/SKILL.md +26 -160
  58. package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
  59. package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +2 -2
  60. package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +3 -58
  61. package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
  62. package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
  63. package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
  64. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
  65. package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
  66. package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
  67. package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
  68. package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
  69. package/bin/codex-security.mjs +2 -2
  70. package/dist/api.d.ts +7 -1
  71. package/dist/api.d.ts.map +1 -1
  72. package/dist/api.js +459 -157
  73. package/dist/api.js.map +1 -1
  74. package/dist/armorcode-findings.d.ts +9 -0
  75. package/dist/armorcode-findings.d.ts.map +1 -0
  76. package/dist/armorcode-findings.js +145 -0
  77. package/dist/armorcode-findings.js.map +1 -0
  78. package/dist/artifact-export.d.ts +2 -0
  79. package/dist/artifact-export.d.ts.map +1 -1
  80. package/dist/artifact-export.js +29 -13
  81. package/dist/artifact-export.js.map +1 -1
  82. package/dist/auth.d.ts +6 -2
  83. package/dist/auth.d.ts.map +1 -1
  84. package/dist/auth.js +33 -12
  85. package/dist/auth.js.map +1 -1
  86. package/dist/batch-cost.d.ts +18 -0
  87. package/dist/batch-cost.d.ts.map +1 -0
  88. package/dist/batch-cost.js +41 -0
  89. package/dist/batch-cost.js.map +1 -0
  90. package/dist/blackduck-findings.d.ts +1 -1
  91. package/dist/blackduck-findings.d.ts.map +1 -1
  92. package/dist/blackduck-findings.js +5 -18
  93. package/dist/blackduck-findings.js.map +1 -1
  94. package/dist/bundled-plugin.d.ts +4 -0
  95. package/dist/bundled-plugin.d.ts.map +1 -0
  96. package/dist/bundled-plugin.js +23 -0
  97. package/dist/bundled-plugin.js.map +1 -0
  98. package/dist/classify-scan-severity.d.ts +1 -1
  99. package/dist/classify-scan-severity.d.ts.map +1 -1
  100. package/dist/classify-scan-severity.js +11 -3
  101. package/dist/classify-scan-severity.js.map +1 -1
  102. package/dist/classify-severity-diagnostics.d.ts +10 -0
  103. package/dist/classify-severity-diagnostics.d.ts.map +1 -0
  104. package/dist/classify-severity-diagnostics.js +57 -0
  105. package/dist/classify-severity-diagnostics.js.map +1 -0
  106. package/dist/classify-severity-records.d.ts +4 -0
  107. package/dist/classify-severity-records.d.ts.map +1 -1
  108. package/dist/classify-severity-records.js +35 -8
  109. package/dist/classify-severity-records.js.map +1 -1
  110. package/dist/classify-severity.d.ts.map +1 -1
  111. package/dist/classify-severity.js +9 -6
  112. package/dist/classify-severity.js.map +1 -1
  113. package/dist/cli-argument.d.ts +4 -0
  114. package/dist/cli-argument.d.ts.map +1 -0
  115. package/dist/cli-argument.js +17 -0
  116. package/dist/cli-argument.js.map +1 -0
  117. package/dist/cli-help.d.ts +1 -1
  118. package/dist/cli-help.d.ts.map +1 -1
  119. package/dist/cli-help.js +71 -29
  120. package/dist/cli-help.js.map +1 -1
  121. package/dist/cli-hook.d.ts +3 -0
  122. package/dist/cli-hook.d.ts.map +1 -0
  123. package/dist/cli-hook.js +87 -0
  124. package/dist/cli-hook.js.map +1 -0
  125. package/dist/cli-integrations.d.ts +13 -0
  126. package/dist/cli-integrations.d.ts.map +1 -0
  127. package/dist/cli-integrations.js +333 -0
  128. package/dist/cli-integrations.js.map +1 -0
  129. package/dist/cli-mcp.d.ts +15 -0
  130. package/dist/cli-mcp.d.ts.map +1 -0
  131. package/dist/cli-mcp.js +178 -0
  132. package/dist/cli-mcp.js.map +1 -0
  133. package/dist/cli-token-view.d.ts +10 -0
  134. package/dist/cli-token-view.d.ts.map +1 -0
  135. package/dist/cli-token-view.js +41 -0
  136. package/dist/cli-token-view.js.map +1 -0
  137. package/dist/cli.d.ts +8 -3
  138. package/dist/cli.d.ts.map +1 -1
  139. package/dist/cli.js +1860 -903
  140. package/dist/cli.js.map +1 -1
  141. package/dist/cloud-publish.d.ts.map +1 -1
  142. package/dist/cloud-publish.js +33 -31
  143. package/dist/cloud-publish.js.map +1 -1
  144. package/dist/codex-sdk-environment.d.ts +6 -0
  145. package/dist/codex-sdk-environment.d.ts.map +1 -1
  146. package/dist/codex-sdk-environment.js +19 -0
  147. package/dist/codex-sdk-environment.js.map +1 -1
  148. package/dist/command-words.d.ts +3 -0
  149. package/dist/command-words.d.ts.map +1 -0
  150. package/dist/command-words.js +46 -0
  151. package/dist/command-words.js.map +1 -0
  152. package/dist/component-plan.d.ts.map +1 -1
  153. package/dist/component-plan.js +3 -3
  154. package/dist/component-plan.js.map +1 -1
  155. package/dist/component-scan.d.ts +3 -1
  156. package/dist/component-scan.d.ts.map +1 -1
  157. package/dist/component-scan.js +40 -7
  158. package/dist/component-scan.js.map +1 -1
  159. package/dist/config.d.ts +1 -1
  160. package/dist/config.d.ts.map +1 -1
  161. package/dist/config.js +30 -1
  162. package/dist/config.js.map +1 -1
  163. package/dist/continuum-aws.d.ts +6 -0
  164. package/dist/continuum-aws.d.ts.map +1 -0
  165. package/dist/continuum-aws.js +202 -0
  166. package/dist/continuum-aws.js.map +1 -0
  167. package/dist/continuum-collector.d.ts +44 -0
  168. package/dist/continuum-collector.d.ts.map +1 -0
  169. package/dist/continuum-collector.js +266 -0
  170. package/dist/continuum-collector.js.map +1 -0
  171. package/dist/continuum-findings.d.ts +31 -2
  172. package/dist/continuum-findings.d.ts.map +1 -1
  173. package/dist/continuum-findings.js +497 -59
  174. package/dist/continuum-findings.js.map +1 -1
  175. package/dist/contract.d.ts +1 -0
  176. package/dist/contract.d.ts.map +1 -1
  177. package/dist/contract.js +3 -0
  178. package/dist/contract.js.map +1 -1
  179. package/dist/cost.d.ts.map +1 -1
  180. package/dist/cost.js +1 -45
  181. package/dist/cost.js.map +1 -1
  182. package/dist/crowdstrike-findings.d.ts +7 -0
  183. package/dist/crowdstrike-findings.d.ts.map +1 -0
  184. package/dist/crowdstrike-findings.js +210 -0
  185. package/dist/crowdstrike-findings.js.map +1 -0
  186. package/dist/custom-validation-prompt.d.ts +1 -1
  187. package/dist/custom-validation-prompt.d.ts.map +1 -1
  188. package/dist/custom-validation-prompt.js +29 -19
  189. package/dist/custom-validation-prompt.js.map +1 -1
  190. package/dist/deduplication/local.d.ts +3 -1
  191. package/dist/deduplication/local.d.ts.map +1 -1
  192. package/dist/deduplication/local.js +8 -1
  193. package/dist/deduplication/local.js.map +1 -1
  194. package/dist/deduplication/refusal.d.ts.map +1 -1
  195. package/dist/deduplication/refusal.js +2 -1
  196. package/dist/deduplication/refusal.js.map +1 -1
  197. package/dist/deduplication/scan.d.ts +2 -0
  198. package/dist/deduplication/scan.d.ts.map +1 -1
  199. package/dist/deduplication/scan.js +24 -7
  200. package/dist/deduplication/scan.js.map +1 -1
  201. package/dist/deep-scan.d.ts.map +1 -1
  202. package/dist/deep-scan.js +16 -15
  203. package/dist/deep-scan.js.map +1 -1
  204. package/dist/endor-findings.d.ts +2 -2
  205. package/dist/endor-findings.d.ts.map +1 -1
  206. package/dist/endor-findings.js +6 -23
  207. package/dist/endor-findings.js.map +1 -1
  208. package/dist/errors.d.ts +3 -1
  209. package/dist/errors.d.ts.map +1 -1
  210. package/dist/errors.js +7 -3
  211. package/dist/errors.js.map +1 -1
  212. package/dist/executable-path.d.ts +3 -0
  213. package/dist/executable-path.d.ts.map +1 -1
  214. package/dist/executable-path.js +26 -0
  215. package/dist/executable-path.js.map +1 -1
  216. package/dist/external-findings-import.d.ts.map +1 -1
  217. package/dist/external-findings-import.js +12 -1
  218. package/dist/external-findings-import.js.map +1 -1
  219. package/dist/external-findings-local.d.ts +66 -4
  220. package/dist/external-findings-local.d.ts.map +1 -1
  221. package/dist/external-findings-local.js +258 -59
  222. package/dist/external-findings-local.js.map +1 -1
  223. package/dist/external-findings-publish.d.ts +6 -1
  224. package/dist/external-findings-publish.d.ts.map +1 -1
  225. package/dist/external-findings-publish.js +330 -1633
  226. package/dist/external-findings-publish.js.map +1 -1
  227. package/dist/external-findings-read.d.ts +11 -2
  228. package/dist/external-findings-read.d.ts.map +1 -1
  229. package/dist/external-findings-read.js +56 -53
  230. package/dist/external-findings-read.js.map +1 -1
  231. package/dist/external-findings.d.ts +1 -1
  232. package/dist/external-findings.d.ts.map +1 -1
  233. package/dist/external-findings.js +12 -1
  234. package/dist/external-findings.js.map +1 -1
  235. package/dist/external-import-contract.d.ts +6 -11
  236. package/dist/external-import-contract.d.ts.map +1 -1
  237. package/dist/external-import-contract.js +35 -177
  238. package/dist/external-import-contract.js.map +1 -1
  239. package/dist/external-import-models.d.ts +1 -1
  240. package/dist/external-import-models.d.ts.map +1 -1
  241. package/dist/external-import-models.js.map +1 -1
  242. package/dist/finding-prompt.d.ts.map +1 -1
  243. package/dist/finding-prompt.js +2 -2
  244. package/dist/finding-prompt.js.map +1 -1
  245. package/dist/github-dependabot-findings.d.ts.map +1 -1
  246. package/dist/github-dependabot-findings.js +3 -4
  247. package/dist/github-dependabot-findings.js.map +1 -1
  248. package/dist/github-findings.d.ts.map +1 -1
  249. package/dist/github-findings.js +19 -287
  250. package/dist/github-findings.js.map +1 -1
  251. package/dist/host-protocol.d.ts +6 -0
  252. package/dist/host-protocol.d.ts.map +1 -1
  253. package/dist/host-protocol.js +11 -1
  254. package/dist/host-protocol.js.map +1 -1
  255. package/dist/host-records-protocol.d.ts +2 -0
  256. package/dist/host-records-protocol.d.ts.map +1 -1
  257. package/dist/host-records-protocol.js +4 -0
  258. package/dist/host-records-protocol.js.map +1 -1
  259. package/dist/hosted-remediation.d.ts +1 -0
  260. package/dist/hosted-remediation.d.ts.map +1 -1
  261. package/dist/hosted-remediation.js +23 -3
  262. package/dist/hosted-remediation.js.map +1 -1
  263. package/dist/index.d.ts +5 -3
  264. package/dist/index.d.ts.map +1 -1
  265. package/dist/index.js +3 -1
  266. package/dist/index.js.map +1 -1
  267. package/dist/inspector-findings.d.ts.map +1 -1
  268. package/dist/inspector-findings.js +19 -35
  269. package/dist/inspector-findings.js.map +1 -1
  270. package/dist/knowledge-base.d.ts +1 -1
  271. package/dist/knowledge-base.d.ts.map +1 -1
  272. package/dist/knowledge-base.js +34 -27
  273. package/dist/knowledge-base.js.map +1 -1
  274. package/dist/linear.d.ts +11 -0
  275. package/dist/linear.d.ts.map +1 -1
  276. package/dist/linear.js.map +1 -1
  277. package/dist/local-git-metadata.d.ts +5 -2
  278. package/dist/local-git-metadata.d.ts.map +1 -1
  279. package/dist/local-git-metadata.js +8 -4
  280. package/dist/local-git-metadata.js.map +1 -1
  281. package/dist/multiscan.d.ts +4 -0
  282. package/dist/multiscan.d.ts.map +1 -1
  283. package/dist/multiscan.js +83 -39
  284. package/dist/multiscan.js.map +1 -1
  285. package/dist/opengrep-findings.d.ts +4 -2
  286. package/dist/opengrep-findings.d.ts.map +1 -1
  287. package/dist/opengrep-findings.js +39 -22
  288. package/dist/opengrep-findings.js.map +1 -1
  289. package/dist/private-finding-import.d.ts +8 -13
  290. package/dist/private-finding-import.d.ts.map +1 -1
  291. package/dist/private-finding-import.js +69 -129
  292. package/dist/private-finding-import.js.map +1 -1
  293. package/dist/project-config-schema.d.ts +2 -0
  294. package/dist/project-config-schema.d.ts.map +1 -1
  295. package/dist/project-config-schema.js +1 -0
  296. package/dist/project-config-schema.js.map +1 -1
  297. package/dist/project-config.d.ts +1 -0
  298. package/dist/project-config.d.ts.map +1 -1
  299. package/dist/project-config.js +56 -13
  300. package/dist/project-config.js.map +1 -1
  301. package/dist/prompt-files.d.ts +7 -2
  302. package/dist/prompt-files.d.ts.map +1 -1
  303. package/dist/prompt-files.js +42 -20
  304. package/dist/prompt-files.js.map +1 -1
  305. package/dist/provider-profile.d.ts.map +1 -1
  306. package/dist/provider-profile.js +4 -9
  307. package/dist/provider-profile.js.map +1 -1
  308. package/dist/publication.d.ts +1 -1
  309. package/dist/publication.d.ts.map +1 -1
  310. package/dist/publication.js.map +1 -1
  311. package/dist/record.d.ts +1 -5
  312. package/dist/record.d.ts.map +1 -1
  313. package/dist/record.js +3 -51
  314. package/dist/record.js.map +1 -1
  315. package/dist/remediation.d.ts.map +1 -1
  316. package/dist/remediation.js +3 -1
  317. package/dist/remediation.js.map +1 -1
  318. package/dist/runtime.d.ts +35 -7
  319. package/dist/runtime.d.ts.map +1 -1
  320. package/dist/runtime.js +782 -153
  321. package/dist/runtime.js.map +1 -1
  322. package/dist/saved-scan-bootstrap.d.ts +6 -1
  323. package/dist/saved-scan-bootstrap.d.ts.map +1 -1
  324. package/dist/saved-scan-bootstrap.js +267 -115
  325. package/dist/saved-scan-bootstrap.js.map +1 -1
  326. package/dist/scan-archive-path.d.ts +2 -0
  327. package/dist/scan-archive-path.d.ts.map +1 -0
  328. package/dist/scan-archive-path.js +5 -0
  329. package/dist/scan-archive-path.js.map +1 -0
  330. package/dist/scan-comparison.d.ts +20 -2
  331. package/dist/scan-comparison.d.ts.map +1 -1
  332. package/dist/scan-comparison.js +26 -5
  333. package/dist/scan-comparison.js.map +1 -1
  334. package/dist/scan-dashboard.d.ts +1 -0
  335. package/dist/scan-dashboard.d.ts.map +1 -1
  336. package/dist/scan-dashboard.js +18 -2
  337. package/dist/scan-dashboard.js.map +1 -1
  338. package/dist/scan-executor.d.ts.map +1 -1
  339. package/dist/scan-executor.js +4 -2
  340. package/dist/scan-executor.js.map +1 -1
  341. package/dist/scan-history-renderer.d.ts +1 -0
  342. package/dist/scan-history-renderer.d.ts.map +1 -1
  343. package/dist/scan-history-renderer.js +25 -9
  344. package/dist/scan-history-renderer.js.map +1 -1
  345. package/dist/scan-logs.d.ts.map +1 -1
  346. package/dist/scan-logs.js +28 -4
  347. package/dist/scan-logs.js.map +1 -1
  348. package/dist/scan-settings.d.ts +1 -0
  349. package/dist/scan-settings.d.ts.map +1 -1
  350. package/dist/scan-settings.js +1 -0
  351. package/dist/scan-settings.js.map +1 -1
  352. package/dist/scanner-import.d.ts +5 -11
  353. package/dist/scanner-import.d.ts.map +1 -1
  354. package/dist/scanner-import.js +16 -89
  355. package/dist/scanner-import.js.map +1 -1
  356. package/dist/security-policy.d.ts.map +1 -1
  357. package/dist/security-policy.js +26 -6
  358. package/dist/security-policy.js.map +1 -1
  359. package/dist/semgrep-findings.d.ts.map +1 -1
  360. package/dist/semgrep-findings.js +14 -48
  361. package/dist/semgrep-findings.js.map +1 -1
  362. package/dist/semgrep-platform-findings.d.ts +20 -70
  363. package/dist/semgrep-platform-findings.d.ts.map +1 -1
  364. package/dist/semgrep-platform-findings.js +116 -333
  365. package/dist/semgrep-platform-findings.js.map +1 -1
  366. package/dist/severity-review.d.ts.map +1 -1
  367. package/dist/severity-review.js +1 -0
  368. package/dist/severity-review.js.map +1 -1
  369. package/dist/snyk-findings.d.ts +2 -0
  370. package/dist/snyk-findings.d.ts.map +1 -1
  371. package/dist/snyk-findings.js +5 -8
  372. package/dist/snyk-findings.js.map +1 -1
  373. package/dist/snyk-rest-findings.d.ts +3 -20
  374. package/dist/snyk-rest-findings.d.ts.map +1 -1
  375. package/dist/snyk-rest-findings.js +45 -217
  376. package/dist/snyk-rest-findings.js.map +1 -1
  377. package/dist/sonar-findings.d.ts +1 -1
  378. package/dist/sonar-findings.d.ts.map +1 -1
  379. package/dist/sonar-findings.js +2 -4
  380. package/dist/sonar-findings.js.map +1 -1
  381. package/dist/sonar-import.d.ts +3 -0
  382. package/dist/sonar-import.d.ts.map +1 -1
  383. package/dist/sonar-import.js +28 -30
  384. package/dist/sonar-import.js.map +1 -1
  385. package/dist/stored-finding-projection.d.ts +6 -0
  386. package/dist/stored-finding-projection.d.ts.map +1 -0
  387. package/dist/stored-finding-projection.js +129 -0
  388. package/dist/stored-finding-projection.js.map +1 -0
  389. package/dist/stored-findings-publication.d.ts +23 -0
  390. package/dist/stored-findings-publication.d.ts.map +1 -0
  391. package/dist/stored-findings-publication.js +169 -0
  392. package/dist/stored-findings-publication.js.map +1 -0
  393. package/dist/targets.d.ts +8 -1
  394. package/dist/targets.d.ts.map +1 -1
  395. package/dist/targets.js +103 -23
  396. package/dist/targets.js.map +1 -1
  397. package/dist/tenable-findings.d.ts +1 -4
  398. package/dist/tenable-findings.d.ts.map +1 -1
  399. package/dist/tenable-findings.js.map +1 -1
  400. package/dist/trivy-findings.d.ts.map +1 -1
  401. package/dist/trivy-findings.js +0 -11
  402. package/dist/trivy-findings.js.map +1 -1
  403. package/dist/trusted-executable.d.ts +7 -0
  404. package/dist/trusted-executable.d.ts.map +1 -1
  405. package/dist/trusted-executable.js +148 -37
  406. package/dist/trusted-executable.js.map +1 -1
  407. package/dist/value.js +3 -1
  408. package/dist/value.js.map +1 -1
  409. package/dist/veracode-findings.d.ts +1 -3
  410. package/dist/veracode-findings.d.ts.map +1 -1
  411. package/dist/veracode-findings.js +13 -38
  412. package/dist/veracode-findings.js.map +1 -1
  413. package/dist/version.d.ts +3 -1
  414. package/dist/version.d.ts.map +1 -1
  415. package/dist/version.js +184 -32
  416. package/dist/version.js.map +1 -1
  417. package/dist/wiz-findings.d.ts +2 -2
  418. package/dist/wiz-findings.d.ts.map +1 -1
  419. package/dist/wiz-findings.js +14 -92
  420. package/dist/wiz-findings.js.map +1 -1
  421. package/docs/classify-severity-records.md +30 -0
  422. package/docs/cli.md +537 -124
  423. package/docs/findings-service.md +22 -9
  424. package/docs/hosted-remediation.md +13 -4
  425. package/docs/sdk.md +918 -0
  426. package/package.json +15 -6
  427. package/schemas/external-findings.schema.json +2 -1
  428. package/schemas/project-config.schema.json +5 -0
  429. package/dist/hosted-scanner-v1.d.ts +0 -6
  430. package/dist/hosted-scanner-v1.d.ts.map +0 -1
  431. package/dist/hosted-scanner-v1.js +0 -60
  432. package/dist/hosted-scanner-v1.js.map +0 -1
  433. package/dist/reader-selection.d.ts +0 -15
  434. package/dist/reader-selection.d.ts.map +0 -1
  435. package/dist/reader-selection.js +0 -89
  436. package/dist/reader-selection.js.map +0 -1
  437. package/dist/semgrep-platform-v1.d.ts +0 -6
  438. package/dist/semgrep-platform-v1.d.ts.map +0 -1
  439. package/dist/semgrep-platform-v1.js +0 -83
  440. package/dist/semgrep-platform-v1.js.map +0 -1
  441. package/dist/snyk-rest-v1.d.ts +0 -28
  442. package/dist/snyk-rest-v1.d.ts.map +0 -1
  443. package/dist/snyk-rest-v1.js +0 -132
  444. package/dist/snyk-rest-v1.js.map +0 -1
@@ -1,12 +1,15 @@
1
- import { semgrepLegacyRepositoryWitnesses, semgrepPlatformFindingBinding, semgrepPlatformReportScope, semgrepPlatformRepositoryReference, isSemgrepPlatformEvidence, semgrepReferenceMatches, } from "./semgrep-platform-findings.js";
2
- import { gitPathToHttpPath, gitServiceHostname, isPublicGitHost, gitTransportBytes, hostedRepositoryMatches, } from "./hosted-git-repository.js";
1
+ import { resolve } from "node:path";
2
+ import { isDeepStrictEqual } from "node:util";
3
+ import { semgrepPlatformFindingBinding, semgrepPlatformReportScope, semgrepPlatformRepositoryReference, isSemgrepPlatformEvidence, semgrepReferenceMatches, } from "./semgrep-platform-findings.js";
4
+ import { gitPathToHttpPath, gitServiceHostname, isPublicGitHost, gitTransportBytes, hostedRepositoryMatches, normalizeHostedGitRepositoryUrl, } from "./hosted-git-repository.js";
3
5
  import { checkRetainedTrivyProvider, checkTrivyReportProvider, matchTrivyCheckout, } from "./trivy-import.js";
4
6
  import { readGitRemoteNames, readHostedGitRemotes, } from "./hosted-git-remotes.js";
5
7
  import { CodexSecurityError } from "./errors.js";
6
- import { externalImportDisposition, NoPublishableFindingsError, cloneImportPreview, snapshotImportOptions, snapshotNormalizedFindings, snapshotSourceRepositories, } from "./external-findings.js";
8
+ import { externalImportDisposition, NoPublishableFindingsError, cloneImportPreview, reportForJson, snapshotImportOptions, snapshotNormalizedFindings, snapshotSourceRepositories, } from "./external-findings.js";
7
9
  import { cloudRepositoryUrlKey, requireSafeJsonInteger, repositoryUrlKey, validateExternalEvidence, } from "./external-import-contract.js";
8
- import { localFindingRepositories, semgrepSarifRepositories, } from "./external-findings-read.js";
10
+ import { EXTERNAL_FINDINGS_PROVIDERS, EXTERNAL_FINDINGS_READERS, localFindingRepositories, semgrepSarifRepositories, LOCAL_ONLY_PROVIDERS, } from "./external-findings-read.js";
9
11
  import { tenableReportFormat, tenableSourceRepository, } from "./tenable-findings.js";
12
+ import { crowdstrikeCheckout, crowdstrikeReportFormat, } from "./crowdstrike-findings.js";
10
13
  import { guardianFindingRepository, guardianSelectionFormat, } from "./semgrep-guardian-findings.js";
11
14
  import { hasGitMetadata, localGitProtectionRoots, commandGitProtectionRoots, } from "./local-git-metadata.js";
12
15
  import { blackDuckReportRepositories, projectedBlackDuckRepositoryUrl, } from "./blackduck-findings.js";
@@ -16,16 +19,33 @@ import { continuumReportRepositories } from "./continuum-findings.js";
16
19
  import { veracodeReportRepositories } from "./veracode-findings.js";
17
20
  import { inspectorReportRepository } from "./inspector-findings.js";
18
21
  import { declaredScannerRepositoryUrl } from "./scanner-repository-url.js";
22
+ import { armorCodeRepositoryUrl } from "./armorcode-findings.js";
19
23
  import { sonarRepositoryUrls } from "./sonar-findings.js";
20
24
  import { isRecord } from "./record.js";
21
25
  import { dependabotRepository } from "./github-dependabot-findings.js";
22
26
  import { retainedGitHubRepository } from "./github-findings.js";
23
27
  import { snykRestImportRepository, snykRestCheckoutMatches, } from "./snyk-rest-findings.js";
24
- import { bundledPluginRoot, canonicalConfigPath, canonicalizeModelSafePath, expandHome, requireOutputOutsideRepositories, runWorkbench, workbenchEnvironment, } from "./runtime.js";
28
+ import { bundledPluginRoot, canonicalConfigPath, canonicalizeModelSafePath, resolveInputPath, resolveParentTraversal, requireOutputOutsideRepositories, runWorkbench, workbenchEnvironment, } from "./runtime.js";
25
29
  import { abortable, enclosingGitWorktreeRoot, gitOutput, normalizeRepository, } from "./targets.js";
26
30
  function requireIdentity(value, field) {
27
31
  if (typeof value !== "string" || !value.trim() || value.includes("\0"))
28
32
  throw new CodexSecurityError(`${field} must be nonempty and contain no NUL characters.`);
33
+ if (!value.isWellFormed())
34
+ throw new CodexSecurityError(`${field} must contain valid Unicode.`);
35
+ }
36
+ function validateFindingIds(current) {
37
+ const identities = new Set();
38
+ for (const finding of current.findings) {
39
+ requireIdentity(finding.source_finding_id, "Source finding id");
40
+ if (identities.has(finding.source_finding_id))
41
+ throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`);
42
+ identities.add(finding.source_finding_id);
43
+ if (!isRecord(finding.evidence))
44
+ throw new CodexSecurityError("Imported evidence must be an object.");
45
+ if (typeof finding.evidence.title !== "string" ||
46
+ typeof finding.evidence.severity !== "string")
47
+ throw new CodexSecurityError("Imported evidence requires a title and severity.");
48
+ }
29
49
  }
30
50
  function checkStoredNumber(value) {
31
51
  if (!Number.isFinite(value))
@@ -289,17 +309,17 @@ export async function configuredFetchRemotes(repository, provider, protectedRoot
289
309
  }
290
310
  return remotes;
291
311
  }
312
+ async function hostedCheckoutRemotes(repository, protectedRoots, environment, signal) {
313
+ if (!(await hasGitMetadata(repository, signal)))
314
+ return undefined;
315
+ return readHostedGitRemotes(repository, [...protectedRoots, await canonicalConfigPath(process.cwd())], environment, signal);
316
+ }
292
317
  async function requireMatchingRepository(repository, provider, sources, strictSources, hostedSources, platformFor, snyk, protectedRoots, environment, signal, possibleSshHost, fetchRemotes, isCheckmarxSource) {
293
318
  if (!snyk && sources.length === 0 && hostedSources.length === 0)
294
319
  return false;
295
320
  let allSourcesMatched = true;
296
321
  if (snyk || hostedSources.length) {
297
- if (!(await hasGitMetadata(repository, signal)))
298
- return false;
299
- const remotes = await readHostedGitRemotes(repository, [
300
- ...protectedRoots,
301
- await abortable(() => canonicalConfigPath(process.cwd()), signal),
302
- ], environment, signal);
322
+ const remotes = await hostedCheckoutRemotes(repository, protectedRoots, environment, signal);
303
323
  if (snyk) {
304
324
  if (remotes &&
305
325
  !remotes.some((remote) => snykRestCheckoutMatches(snyk, remote)))
@@ -356,22 +376,32 @@ async function requireMatchingRepository(repository, provider, sources, strictSo
356
376
  export function sonarCheckoutMatchesSource(repository, url, protectedRoots, environment, signal) {
357
377
  return requireMatchingRepository(repository, "sonar", [{ url }], new Map(), [], () => "sonar", undefined, [...protectedRoots], environment, signal);
358
378
  }
379
+ /** @internal Resolve and protect the local checkout and workbench state directory. */
359
380
  async function localContext(selectedRepository, dependencies, mode = "import") {
360
381
  dependencies.signal?.throwIfAborted();
361
382
  const environment = workbenchEnvironment(dependencies.environment ?? process.env);
362
- const path = expandHome(selectedRepository, environment);
383
+ const requested = resolveInputPath(selectedRepository, process.cwd(), environment);
384
+ const path = await abortable(() => resolveParentTraversal(requested), dependencies.signal);
363
385
  const repository = mode === "read"
364
386
  ? await abortable(() => canonicalConfigPath(path), dependencies.signal)
365
387
  : await normalizeRepository(path, dependencies.signal);
388
+ const lexicalPath = resolve(requested);
389
+ const lexicalRepository = lexicalPath === resolve(path)
390
+ ? repository
391
+ : await abortable(() => canonicalConfigPath(lexicalPath), dependencies.signal);
366
392
  const protectedRoot = [
367
393
  ...new Set([
368
394
  repository,
369
- ...(await abortable(() => commandGitProtectionRoots(path, environment, dependencies.signal), dependencies.signal)),
395
+ ...(mode === "read" ? [lexicalRepository] : []),
396
+ ...(await abortable(() => commandGitProtectionRoots(path, environment, dependencies.signal, {
397
+ requestedPaths: [lexicalPath, lexicalRepository],
398
+ }), dependencies.signal)),
370
399
  ]),
371
400
  ];
372
401
  requireOutputOutsideRepositories(protectedRoot, await abortable(() => canonicalizeModelSafePath(environment.CODEX_SECURITY_STATE_DIR), dependencies.signal), "runtime");
373
402
  return {
374
403
  repository,
404
+ selectedPath: path,
375
405
  options: {
376
406
  pluginRoot: await abortable(() => bundledPluginRoot(), dependencies.signal),
377
407
  environment,
@@ -383,8 +413,63 @@ async function localContext(selectedRepository, dependencies, mode = "import") {
383
413
  }
384
414
  /** Prepare scanner evidence without writing state or performing a security assessment. */
385
415
  export async function prepareNormalizedLocalImport(input, options, dependencies = {}) {
386
- dependencies.signal?.throwIfAborted();
387
- return prepareLocalImport(input, snapshotImportOptions(options), dependencies);
416
+ const { signal } = dependencies;
417
+ signal?.throwIfAborted();
418
+ const settings = snapshotImportOptions(options);
419
+ const reader = EXTERNAL_FINDINGS_READERS.find((name) => name === settings.provider);
420
+ if (reader)
421
+ return prepareLocalImport(input, { ...settings, provider: EXTERNAL_FINDINGS_PROVIDERS[reader] }, dependencies);
422
+ const references = snapshotSourceRepositories(dependencies.sourceRepositories);
423
+ requireIdentity(settings.provider, "Provider");
424
+ requireIdentity(settings.sourceKey, "Source key");
425
+ const current = snapshotNormalizedFindings(input, checkStoredNumber);
426
+ validateFindingIds(current);
427
+ if (current.report !== undefined && !isRecord(current.report))
428
+ throw new CodexSecurityError("Report metadata must be an object.");
429
+ if (current.read !== current.findings.length + current.excluded.length)
430
+ throw new CodexSecurityError("Every source record must be accounted for by a finding or exclusion.");
431
+ const positions = new Set();
432
+ for (const { position, source_finding_id, reason } of current.excluded) {
433
+ if (!Number.isSafeInteger(position) ||
434
+ position < 1 ||
435
+ position > current.read ||
436
+ positions.has(position))
437
+ throw new CodexSecurityError("An excluded position must be unique and within the reported record count.");
438
+ positions.add(position);
439
+ requireIdentity(reason, "Exclusion reason");
440
+ if (source_finding_id !== null)
441
+ requireIdentity(source_finding_id, "Excluded source finding id");
442
+ }
443
+ const platform = references.find((ref) => ref.platform)?.platform;
444
+ const urls = new Set(references.map(({ url }) => url));
445
+ if (settings.sourceRepositoryUrl !== undefined)
446
+ urls.add(settings.sourceRepositoryUrl);
447
+ for (const finding of current.findings) {
448
+ finding.evidence = validateExternalEvidence(finding.evidence, "local");
449
+ const repository = finding.evidence.details?.repository;
450
+ if (repository)
451
+ urls.add(repository.url);
452
+ }
453
+ const sources = Array.from(urls, (url) => ({
454
+ url: declaredScannerRepositoryUrl(url, settings.provider, "local"),
455
+ platform,
456
+ }));
457
+ const [source] = sources;
458
+ const context = await localContext(settings.repository, dependencies);
459
+ let matched = false;
460
+ if (source) {
461
+ if (references.some((ref) => ref.platform && ref.platform !== platform) ||
462
+ sources.some(({ url }) => !hostedRepositoryMatches(source, url)))
463
+ throw new CodexSecurityError("The findings declare conflicting source repositories.");
464
+ const remotes = await hostedCheckoutRemotes(context.repository, context.options.protectedRoot, context.options.environment, signal);
465
+ matched =
466
+ remotes?.some((remote) => hostedRepositoryMatches(source, remote)) ??
467
+ false;
468
+ if (!matched &&
469
+ remotes?.some((remote) => /^https?:\/\//iu.test(normalizeHostedGitRepositoryUrl(remote, undefined, platform !== undefined))))
470
+ throw new CodexSecurityError(`Imported repository ${JSON.stringify(source.url)} does not match a configured fetch remote of ${context.repository}.`);
471
+ }
472
+ return preparedLocalStorage(current, settings, context, dependencies, matched, { sourceRepositories: sources });
388
473
  }
389
474
  // A scanner can repeat the same repository reference for every finding in a run.
390
475
  export function distinctSourceRepositories(sources) {
@@ -399,35 +484,27 @@ export function distinctSourceRepositories(sources) {
399
484
  });
400
485
  }
401
486
  /** @internal Prepare evidence using settings captured by either local import entrypoint. */
402
- export async function prepareLocalImport(input, options, dependencies, readerSources = distinctSourceRepositories(snapshotSourceRepositories(dependencies.sourceRepositories)), parsedInput = [], fetchRemotes) {
487
+ export async function prepareLocalImport(input, options, dependencies, readerSources = distinctSourceRepositories(snapshotSourceRepositories(dependencies.sourceRepositories)), parsedInput, fetchRemotes) {
403
488
  requireIdentity(options.sourceKey, "Source key");
404
- const parsedSources = distinctSourceRepositories(parsedInput);
405
- const current = snapshotNormalizedFindings(input, checkStoredNumber);
406
- if (options.provider !== "tenable" &&
407
- (current.report?.["format"] === tenableReportFormat ||
408
- current.findings.some((row) => row.evidence?.source_data?.["format"] === tenableReportFormat)))
409
- throw new CodexSecurityError("Retained Tenable evidence requires the tenable provider.");
489
+ const parsedSources = distinctSourceRepositories(parsedInput ?? []);
490
+ // File readers interpret their source option while parsing. For normalized
491
+ // input the caller declares one repository for the whole selection.
492
+ const normalizedSource = parsedInput === undefined && options.sourceRepositoryUrl !== undefined
493
+ ? declaredScannerRepositoryUrl(options.sourceRepositoryUrl, options.provider, "local")
494
+ : undefined;
495
+ const current = snapshotNormalizedFindings(input, checkStoredNumber, "local", options.provider);
496
+ for (const [provider, format] of [
497
+ ["tenable", tenableReportFormat],
498
+ ["crowdstrike", crowdstrikeReportFormat],
499
+ ])
500
+ if (options.provider !== provider &&
501
+ (current.report?.["format"] === format ||
502
+ current.findings.some((row) => row.evidence?.source_data?.["format"] === format)))
503
+ throw new CodexSecurityError(`Retained ${LOCAL_ONLY_PROVIDERS[provider]} evidence requires the ${provider} provider.`);
410
504
  checkTrivyReportProvider(options.provider, current.report);
411
- // The JSON snapshot omits inherited or non-enumerable SDK reader properties.
412
- if (!("snykRestContext" in current) && "snykRestContext" in input)
413
- current.snykRestContext = structuredClone(input.snykRestContext);
414
- if (options.provider === "snyk" || current.snykRestContext !== undefined) {
415
- for (const key of [
416
- "sourceRepositoryUrl",
417
- "sourceRepositoryPlatform",
418
- ])
419
- if (key in input && !(key in current))
420
- Object.assign(current, { [key]: structuredClone(input[key]) });
421
- }
422
505
  let dependabotSource;
423
- const identities = new Set();
506
+ validateFindingIds(current);
424
507
  for (const finding of current.findings) {
425
- requireIdentity(finding.source_finding_id, "Source finding id");
426
- if (identities.has(finding.source_finding_id))
427
- throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}.`);
428
- identities.add(finding.source_finding_id);
429
- if (!isRecord(finding.evidence))
430
- throw new CodexSecurityError("Imported evidence must be an object.");
431
508
  checkRetainedTrivyProvider(options.provider, finding, "local");
432
509
  if (options.provider !== "github")
433
510
  continue;
@@ -443,15 +520,27 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
443
520
  dependabotSource = native;
444
521
  }
445
522
  const context = await localContext(options.repository, dependencies);
523
+ // Neither report records the checkout, so check the operator's URL against its remotes.
524
+ const requireFetchRemote = async (source, provider) => {
525
+ const remotes = await hostedCheckoutRemotes(context.repository, context.options.protectedRoot, context.options.environment, dependencies.signal);
526
+ if (!remotes?.some((remote) => hostedRepositoryMatches(source, remote)))
527
+ throw new CodexSecurityError(`${LOCAL_ONLY_PROVIDERS[provider]}'s source repository must match a configured Git fetch remote of the selected checkout.`);
528
+ };
446
529
  if (options.provider === "tenable") {
447
530
  const source = tenableSourceRepository(current, options.sourceRepositoryUrl, [...readerSources, ...parsedSources]);
448
- const remotes = await readHostedGitRemotes(context.repository, [
449
- ...context.options.protectedRoot,
450
- await abortable(() => canonicalConfigPath(process.cwd()), dependencies.signal),
451
- ], context.options.environment, dependencies.signal);
452
- if (!remotes?.some((remote) => hostedRepositoryMatches(source, remote)))
453
- throw new CodexSecurityError("Tenable's source repository must match a configured Git fetch remote of the selected checkout.");
454
- return preparedLocalStorage(current, options, context, dependencies, true);
531
+ await requireFetchRemote(source, "tenable");
532
+ return preparedLocalStorage(current, options, context, dependencies, true, {
533
+ sourceRepositories: [source],
534
+ });
535
+ }
536
+ if (options.provider === "crowdstrike") {
537
+ const source = await crowdstrikeCheckout(current, options.sourceRepositoryUrl, [...readerSources, ...parsedSources], context.repository);
538
+ // FCS scans plain directories; only a Git checkout has remotes to compare.
539
+ const bound = source !== undefined &&
540
+ (await hasGitMetadata(context.repository, dependencies.signal));
541
+ if (bound)
542
+ await requireFetchRemote(source, "crowdstrike");
543
+ return preparedLocalStorage(current, options, context, dependencies, bound, source ? { sourceRepositories: [source] } : {});
455
544
  }
456
545
  const { repository, options: workbenchOptions } = context;
457
546
  const sources = new Map();
@@ -462,7 +551,7 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
462
551
  projectedBlackDuckRepositoryUrl(finding, "local")) ||
463
552
  checkmarx.projections.has(finding));
464
553
  const mixed = projected.length > 0 && readerSources.length > 0;
465
- const nativeSources = new Map((mixed ? current.findings : projected)
554
+ const nativeSources = new Map((mixed || normalizedSource ? current.findings : projected)
466
555
  .filter(({ evidence }) => options.provider !== "endor" ||
467
556
  isRecord(evidence.source_data?.["runContext"]))
468
557
  .map((finding) => [
@@ -523,7 +612,6 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
523
612
  if (semgrepPlatformRepositoryUrl)
524
613
  addSemgrepSource(semgrepPlatformRepositoryUrl);
525
614
  const known = new Set(parsedSources.map(({ url }) => url));
526
- const legacyWitnesses = semgrepLegacyRepositoryWitnesses(current.findings, options.provider, readerSources);
527
615
  const hasPlatformEvidence = options.provider === "semgrep" &&
528
616
  (semgrepReportScope !== undefined ||
529
617
  current.findings.some((row) => isSemgrepPlatformEvidence(row, options.provider)));
@@ -532,8 +620,14 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
532
620
  for (const finding of current.findings) {
533
621
  const retained = bound.get(finding.source_finding_id) ?? checkmarxRepository(finding);
534
622
  const native = nativeSources.get(finding) ?? [];
535
- const sarif = hasPlatformEvidence ? semgrepSarifRepositories(finding) : [];
536
- const semgrep = semgrepPlatformFindingBinding(finding, options.provider, readerSources, legacyWitnesses, semgrepReportScope, [retained, ...native, ...sarif]);
623
+ const sarif = hasPlatformEvidence ||
624
+ (normalizedSource && options.provider === "semgrep")
625
+ ? semgrepSarifRepositories(finding)
626
+ : [];
627
+ if (normalizedSource)
628
+ for (const source of sarif)
629
+ known.add(source.url);
630
+ const semgrep = semgrepPlatformFindingBinding(finding, options.provider, readerSources, semgrepReportScope, [retained, ...native, ...sarif]);
537
631
  if (semgrep) {
538
632
  addSemgrepSource(semgrep.url);
539
633
  if (semgrep.sourceData)
@@ -542,6 +636,11 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
542
636
  Object.assign(finding.evidence, semgrep.migration);
543
637
  }
544
638
  const { evidence } = finding;
639
+ if (options.provider === "armorcode") {
640
+ const nativeUrl = armorCodeRepositoryUrl(evidence.source_data, "local");
641
+ if (nativeUrl)
642
+ sources.set(nativeUrl, { url: nativeUrl });
643
+ }
545
644
  if (options.provider === "github") {
546
645
  const source = retainedGitHubRepository(finding, (url) => identify(url).key);
547
646
  if (source)
@@ -712,6 +811,14 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
712
811
  (reportUrl &&
713
812
  hosted.some((source) => !semgrepReferenceMatches(source, reportUrl))))
714
813
  throw new Error("The retained Checkmarx report repository does not match the finding repository.");
814
+ if (options.provider === "armorcode") {
815
+ if (options.sourceRepositoryUrl !== undefined) {
816
+ const url = declaredScannerRepositoryUrl(options.sourceRepositoryUrl, "ArmorCode", "local");
817
+ sources.set(url, { url });
818
+ }
819
+ if (!sameRepositories(sources.keys()))
820
+ throw new CodexSecurityError("ArmorCode findings must belong to a single source repository.");
821
+ }
715
822
  const sonarSources = sonarRepositoryUrls(options.provider, current.findings, current.report, "local");
716
823
  const manualSource = options.provider === "sonar" && options.sourceRepositoryUrl
717
824
  ? declaredScannerRepositoryUrl(options.sourceRepositoryUrl, "Sonar", "local")
@@ -757,6 +864,13 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
757
864
  if (!sameRepositories(sources.keys()))
758
865
  throw new CodexSecurityError("The normalized repository does not match the Snyk reader's repository.");
759
866
  }
867
+ if (normalizedSource && !snyk) {
868
+ if (!sameRepositories([normalizedSource, ...sources.keys(), ...known]) ||
869
+ hosted.some((source) => !semgrepReferenceMatches(source, normalizedSource)))
870
+ throw new CodexSecurityError("The declared repository does not match the normalized finding source.");
871
+ if (!hosted.length && !sources.size)
872
+ sources.set(normalizedSource, { url: normalizedSource });
873
+ }
760
874
  const ordinarySources = [...sources.values()];
761
875
  // A reader can identify the VCS for both a hosted project and an ordinary row.
762
876
  const loosePlatformFor = localRepositoryPlatform(options.provider, [...ordinarySources, ...hostedReferences], false);
@@ -766,19 +880,67 @@ export async function prepareLocalImport(input, options, dependencies, readerSou
766
880
  : await requireMatchingRepository(repository, options.provider, ordinarySources, strictSources, hosted, (source, bound) => bound ? platformFor(source) : loosePlatformFor(source), snyk, workbenchOptions.protectedRoot, workbenchOptions.environment, dependencies.signal, selected?.protocol === "https:" ? selected.hostname : undefined, fetchRemotes, checkmarx.projections.size
767
881
  ? (url) => checkmarxKeys.has(identify(url).key)
768
882
  : undefined);
769
- return preparedLocalStorage(current, options, context, dependencies, matchesRepositoryRemote);
883
+ let storedSources = [...references, ...ordinarySources, ...hosted];
884
+ const [project] = hosted;
885
+ if (options.provider === "semgrep" &&
886
+ !hasOrdinaryRows &&
887
+ !ordinarySources.length &&
888
+ hosted.length === 1 &&
889
+ project &&
890
+ references.every(({ url }) => url === project.url)) {
891
+ // A typed hint and a bare URL can be two witnesses for the same native
892
+ // project. Keep the hint if any stored occurrence needs it to verify its scope.
893
+ storedSources = [project];
894
+ const native = semgrepPlatformRepositoryReference(project.url, []);
895
+ if (native.platform !== project.platform) {
896
+ try {
897
+ if (current.findings.every((finding) => {
898
+ const binding = semgrepPlatformFindingBinding(finding, "semgrep", [
899
+ native,
900
+ ]);
901
+ return (binding?.url === native.url &&
902
+ !binding.migration &&
903
+ isDeepStrictEqual(binding.sourceData, finding.evidence.source_data));
904
+ }))
905
+ storedSources = [native];
906
+ }
907
+ catch {
908
+ // A private SCM alias or SSH mapping can require the reader's platform.
909
+ }
910
+ }
911
+ }
912
+ if (snyk)
913
+ storedSources.push({
914
+ url: snyk.url,
915
+ platform: snyk.platform === "github"
916
+ ? "github"
917
+ : snyk.gitlab
918
+ ? "gitlab"
919
+ : undefined,
920
+ });
921
+ return preparedLocalStorage(current, options, context, dependencies, matchesRepositoryRemote, {
922
+ sourceRepositories: distinctSourceRepositories(storedSources),
923
+ inspectorProjectMap: options.inspectorProjectMap
924
+ ? [...options.inspectorProjectMap]
925
+ : undefined,
926
+ });
770
927
  }
771
- function preparedLocalStorage(current, options, { repository, options: workbenchOptions, }, dependencies, matchesRepositoryRemote) {
928
+ /** @internal Prepare the transactional write after validating the report and repository. */
929
+ function preparedLocalStorage(current, { provider, sourceKey }, { repository, options: workbenchOptions, }, dependencies, matchesRepositoryRemote, provenance) {
772
930
  dependencies.signal?.throwIfAborted();
773
931
  const preview = {
774
932
  ...cloneImportPreview(current),
775
933
  repository,
776
- source: { provider: options.provider, source_key: options.sourceKey },
934
+ source: { provider, source_key: sourceKey },
777
935
  };
778
936
  const payload = JSON.stringify({
779
937
  repository,
780
- provider: options.provider,
781
- sourceKey: options.sourceKey,
938
+ provider,
939
+ sourceKey,
940
+ read: current.read,
941
+ excluded: current.excluded,
942
+ report: reportForJson(current.report),
943
+ provenance,
782
944
  findings: current.findings.map(({ source_finding_id, evidence }) => ({
783
945
  source_finding_id,
784
946
  evidence,
@@ -821,6 +983,7 @@ function preparedLocalStorage(current, options, { repository, options: workbench
821
983
  }, dependencies.signal);
822
984
  return {
823
985
  ...summary,
986
+ importId: result["importId"],
824
987
  findings: result["findings"],
825
988
  counts: result["counts"],
826
989
  };
@@ -829,14 +992,50 @@ function preparedLocalStorage(current, options, { repository, options: workbench
829
992
  }
830
993
  /** Read imported source records, including evidence that has not been assessed by Codex. */
831
994
  export async function listLocalExternalFindings(selection, dependencies = {}) {
995
+ return (await readLocalExternalFindings(selection, dependencies)).findings;
996
+ }
997
+ export async function readLocalExternalFindings(selection, dependencies) {
832
998
  dependencies.signal?.throwIfAborted();
833
999
  if (selection.id !== undefined)
834
1000
  requireIdentity(selection.id, "Finding id");
835
- const { repository, options } = await localContext(selection.repository, dependencies, "read");
1001
+ const { selectedPath, result } = await runLocalFindingWorkbench(selection.repository, "read-external-findings", { id: selection.id }, dependencies);
1002
+ return {
1003
+ repository: selectedPath,
1004
+ findings: result["findings"],
1005
+ };
1006
+ }
1007
+ /** Read the precise versions selected by the caller or captured by an earlier import. */
1008
+ export async function selectLocalExternalFindings(selection, dependencies = {}) {
1009
+ const { repository, importId, findings } = selection;
1010
+ if ((importId === undefined) === (findings === undefined))
1011
+ throw new CodexSecurityError("Select one import ID or a list of versioned findings.");
1012
+ const { result } = await runLocalFindingWorkbench(repository, "read-external-findings", importId !== undefined
1013
+ ? { importId, ifCurrent: selection.ifCurrent }
1014
+ : { findings: findings.map(({ id, version }) => ({ id, version })) }, dependencies);
1015
+ return result;
1016
+ }
1017
+ /** List this checkout's nonempty imports, most recent first. */
1018
+ export async function listLocalExternalImports({ repository }, dependencies = {}) {
1019
+ const { result } = await runLocalFindingWorkbench(repository, "list-external-imports", {}, dependencies);
1020
+ return result["imports"];
1021
+ }
1022
+ /** @internal Attach Cloud acknowledgements to the versions that were submitted. */
1023
+ export async function recordExternalFindingPublications(input, dependencies = {}) {
1024
+ const { repository, ...receipt } = input;
1025
+ await runLocalFindingWorkbench(repository, "record-external-finding-publications", receipt, dependencies);
1026
+ }
1027
+ /** Read the destination and receipt for each acknowledged finding version. */
1028
+ export async function listLocalFindingPublications({ repository, id }, dependencies = {}) {
1029
+ const { result } = await runLocalFindingWorkbench(repository, "list-external-finding-publications", { id }, dependencies);
1030
+ return result["publications"];
1031
+ }
1032
+ /** @internal Run a command against the workbench for the selected checkout. */
1033
+ async function runLocalFindingWorkbench(path, command, selection, dependencies) {
1034
+ const { repository, selectedPath, options } = await localContext(path, dependencies, "read");
836
1035
  const result = await abortable(() => {
837
1036
  dependencies.signal?.throwIfAborted();
838
- return (dependencies.runWorkbench ?? runWorkbench)(options, ["list-external-findings"], JSON.stringify({ repository, id: selection.id }));
1037
+ return (dependencies.runWorkbench ?? runWorkbench)(options, [command], JSON.stringify({ repository, ...selection }));
839
1038
  }, dependencies.signal);
840
- return result["findings"];
1039
+ return { selectedPath, result };
841
1040
  }
842
1041
  //# sourceMappingURL=external-findings-local.js.map