@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,21 +1,16 @@
1
- import { DEFAULT_CLOUD_STRING_BYTES, validateCodeLineRange, canonicalNumber, validateExternalEvidence, } from "./external-import-contract.js";
1
+ import { DEFAULT_CLOUD_STRING_BYTES, canonicalNumber, validateExternalEvidence, } from "./external-import-contract.js";
2
2
  import { hostedRepositoryMatches, normalizeHostedGitRepositoryUrl, hostedRepositoryUrlKey, isPublicGitHost as publicGitHost, gitServiceHostname, } from "./hosted-git-repository.js";
3
3
  import { isGitHubCloudHost } from "./git-remote.js";
4
4
  import { position, weaknessIds } from "./native-json-findings.js";
5
- import { array, hostedRepositoryPath, normalizeRecords, record, relativePath, repositoryFilePath, scannerSeverity, strings, requiredText, stableId, text, } from "./scanner-import.js";
5
+ import { array, normalizeRecords, record, relativePath, repositoryFilePath, scannerSeverity, strings, requiredText, stableId, text, } from "./scanner-import.js";
6
6
  import { hostedNumberToken, hostedNativeRepositoryUrl, hostedRepositoryUrl, } from "./hosted-scanner-http.js";
7
7
  import { isRecord } from "./record.js";
8
8
  import { declaredScannerRepositoryUrl, validScannerRepositoryUrl, } from "./scanner-repository-url.js";
9
- import { legacyDecimalInteger, restoreLegacyHostedNumbers, } from "./hosted-scanner-v1.js";
10
- import { semgrepV1Id, upgradeSemgrepPlatformReport, } from "./semgrep-platform-v1.js";
11
9
  export const semgrepPlatformFormat = "semgrep-platform-findings/v2";
12
- export const semgrepPlatformLegacyFormat = "semgrep-platform-findings/v1";
13
10
  export const SEMGREP_PLATFORM_PRODUCTS = ["sast", "sca", "ai_sast"];
14
11
  export const semgrepSelectionFormat = "semgrep-platform-selection/v1";
15
12
  export function isSemgrepPlatformFormat(format) {
16
- return (format === semgrepSelectionFormat ||
17
- format === semgrepPlatformFormat ||
18
- format === semgrepPlatformLegacyFormat);
13
+ return format === semgrepSelectionFormat || format === semgrepPlatformFormat;
19
14
  }
20
15
  function selectedProjectUrl(value, label) {
21
16
  return declaredScannerRepositoryUrl(value, label, "local");
@@ -27,19 +22,13 @@ export function semgrepPlatformReportScope(input, provider, references = []) {
27
22
  input.semgrepPlatformScope !== undefined &&
28
23
  !isSemgrepPlatformFormat(format))
29
24
  throw new Error("A normalized Semgrep Platform report scope requires its source format.");
30
- if (format === undefined &&
31
- provider === "semgrep" &&
32
- "sourceRepositoryUrl" in input &&
33
- input.sourceRepositoryUrl !== undefined &&
34
- (input.findings.length === 0 ||
35
- input.findings.some((row) => isSemgrepPlatformEvidence(row, provider)))) {
36
- // The object-row SDK retained only the binding on the envelope, including empty reports.
37
- return {
38
- url: hostedRepositoryUrl(input.sourceRepositoryUrl, "Semgrep Platform"),
39
- };
40
- }
41
- if (!isSemgrepPlatformFormat(format))
25
+ if (!isSemgrepPlatformFormat(format)) {
26
+ if (provider === "semgrep" &&
27
+ typeof format === "string" &&
28
+ format.startsWith("semgrep-platform-"))
29
+ throw new Error("Unsupported Semgrep Platform format. Recollect the findings.");
42
30
  return;
31
+ }
43
32
  const scope = record("semgrepPlatformScope" in input ? input.semgrepPlatformScope : undefined, "Normalized Semgrep report scope");
44
33
  const readUrl = format === semgrepSelectionFormat
45
34
  ? selectedProjectUrl
@@ -56,8 +45,8 @@ export function semgrepPlatformReportScope(input, provider, references = []) {
56
45
  url,
57
46
  };
58
47
  }
59
- export function semgrepPlatformReportRepository(input, provider) {
60
- return semgrepPlatformReportScope(input, provider)?.url;
48
+ export function semgrepPlatformReportRepository(input) {
49
+ return semgrepPlatformReportScope(input)?.url;
61
50
  }
62
51
  // Raw JSON numbers are represented as JavaScript objects during lossless parsing.
63
52
  export function responseRecord(value, label) {
@@ -90,7 +79,7 @@ function sourceLine(value, coerceStrings) {
90
79
  const token = hostedNumberToken(value);
91
80
  // A long fraction can round to an integer if it is converted before checking its decimal value.
92
81
  if (token !== undefined)
93
- return position(Number(legacyDecimalInteger(token)), "Semgrep source line");
82
+ return position(Number(semgrepPlatformIdOrUndefined(wireJson.rawJSON(token))), "Semgrep source line");
94
83
  return position(coerceStrings ? Number(semgrepPlatformId(value)) : value, "Semgrep source line");
95
84
  }
96
85
  export function parseSemgrepResponse(json) {
@@ -119,15 +108,6 @@ export function semgrepPlatformId(value) {
119
108
  throw new Error("Expected an exact, positive Semgrep Platform ID.");
120
109
  return id;
121
110
  }
122
- // Older selections retained full decimal ID tokens beyond Semgrep's native int64 range.
123
- function archivedPlatformId(value) {
124
- const token = wireJson.isRawJSON(value)
125
- ? canonicalNumber(value.rawJSON, Math.max(21, value.rawJSON.length))
126
- : value;
127
- return typeof token === "string" && /^[1-9][0-9]*$/u.test(token)
128
- ? token
129
- : semgrepPlatformId(value);
130
- }
131
111
  function savedPlatformId(value) {
132
112
  if (typeof value !== "string")
133
113
  return semgrepPlatformId(value);
@@ -150,7 +130,7 @@ function scopeOf(deployment, project, ref, readId = semgrepPlatformId, readUrl =
150
130
  product: "sast",
151
131
  };
152
132
  }
153
- export function projectAliases(name, url, references = [], earlyV1 = false) {
133
+ export function projectAliases(name, url, references = []) {
154
134
  const { hostname, pathname } = new URL(url);
155
135
  const path = pathname.slice(1).replace(/\/$/u, "");
156
136
  const decodePath = (decode) => path
@@ -177,39 +157,10 @@ export function projectAliases(name, url, references = [], earlyV1 = false) {
177
157
  key(path.slice(path.lastIndexOf("/") + 1)),
178
158
  ]));
179
159
  const shortName = name.slice(name.lastIndexOf("/") + 1);
180
- const historicalPaths = [];
181
- if (earlyV1) {
182
- // Older exports used decodeURI, which preserves escaped reserved delimiters.
183
- for (const historical of [path, decodePath(decodeURI)]) {
184
- if (!publicGitHost(hostname))
185
- historicalPaths.push(historical);
186
- if (publicHost || source.platform === "github")
187
- historicalPaths.push(historical.replace(/\.git$/u, ""));
188
- }
189
- }
190
- const hasHistoricalPath = (label) => historicalPaths.some((path) => label === path || label === path.slice(path.lastIndexOf("/") + 1));
191
160
  return {
192
- hasHistoricalPath,
193
- has: (label) => label === name ||
194
- label === shortName ||
195
- pathKeys.has(key(label)) ||
196
- hasHistoricalPath(label),
161
+ has: (label) => label === name || label === shortName || pathKeys.has(key(label)),
197
162
  };
198
163
  }
199
- /** Older captures could derive a row label from their verified HTTP mapping for an SSH project. */
200
- export function legacyProjectAliases(name, url, references, mapping) {
201
- const native = projectAliases(name, url, references, true);
202
- const mapped = mapping && mapping !== url
203
- ? projectAliases(name, mapping, references, true)
204
- : undefined;
205
- return {
206
- has: (label) => native.has(label) || !!mapped?.hasHistoricalPath(label),
207
- };
208
- }
209
- /** Compare HTTP origins canonically without folding paths on independent custom Git hosts. */
210
- export function semgrepRepositoryUrlKey(value) {
211
- return hostedRepositoryUrlKey(nativeHttp(value));
212
- }
213
164
  /** A real HTTP URL can elide its default port. Git transport serializations retain explicit ports. */
214
165
  function nativeHttp(url) {
215
166
  return URL.parse(url)?.href ?? url;
@@ -279,9 +230,6 @@ export function semgrepNativeProjectUrl(value, references) {
279
230
  }
280
231
  return hostedNativeRepositoryUrl(value, label);
281
232
  }
282
- function referenceRepositoryKey(references, target = "local") {
283
- return (url) => repositoryContext(url, references, target).key(url);
284
- }
285
233
  function repositoryContext(projectUrl, references = [], target = "local") {
286
234
  const source = semgrepPlatformRepositoryReference(projectUrl, typeof references === "function" ? [] : references);
287
235
  const github = source.platform === "github";
@@ -466,18 +414,18 @@ export function normalizeSelectedSemgrepPlatformFindings(options) {
466
414
  }, hostedRepositoryUrl);
467
415
  return {
468
416
  ...normalizePlatformRows(rows.map((finding) => ({ finding, selectable: true })), scope, "local"),
469
- sourceRepositoryUrl: scope.project.url,
417
+ ...reportScope(semgrepSelectionFormat, scope),
470
418
  };
471
419
  }
472
- function sourceId(scope, finding, readId = semgrepPlatformId) {
420
+ function sourceId(scope, finding) {
473
421
  // Keep the same tuple for a selected import and a subsequent scoped Platform collection.
474
422
  const exact = (id) => Number.isSafeInteger(Number(id)) ? Number(id) : id;
475
423
  return stableId("semgrep-platform", [
476
424
  scope.deployment,
477
- exact(readId(wireJson.rawJSON(scope.project.id))),
425
+ exact(semgrepPlatformId(wireJson.rawJSON(scope.project.id))),
478
426
  scope.product,
479
427
  scope.ref,
480
- exact(readId(finding["id"])),
428
+ exact(semgrepPlatformId(finding["id"])),
481
429
  ]);
482
430
  }
483
431
  function scopeProduct(native, complete) {
@@ -487,8 +435,7 @@ function scopeProduct(native, complete) {
487
435
  return product;
488
436
  }
489
437
  function readScope(input, references, target = "local") {
490
- const complete = input["format"] === semgrepPlatformFormat ||
491
- input["format"] === semgrepPlatformLegacyFormat;
438
+ const complete = input["format"] === semgrepPlatformFormat;
492
439
  const product = scopeProduct(input["product"], complete);
493
440
  const project = responseRecord(input["project"], "Semgrep project");
494
441
  if (input["format"] === semgrepPlatformFormat &&
@@ -537,10 +484,10 @@ function matchesNativeInteger(value, expected) {
537
484
  return value === expected;
538
485
  return expected === 0
539
486
  ? /^-?0(?:\.0+)?(?:e[+-]?\d+)?$/iu.test(token)
540
- : legacyDecimalInteger(token) === String(expected);
487
+ : canonicalNumber(token) === String(expected);
541
488
  }
542
489
  const generatedId = /^semgrep-platform:[0-9a-f]{64}$/u;
543
- /** Current occurrences carry a provider-specific key; older v1 rows retain their native scope and finding. */
490
+ /** Recognize reserved Platform IDs and native scope before accepting normalized evidence. */
544
491
  export function isSemgrepPlatformEvidence(finding, provider) {
545
492
  const data = finding.evidence.source_data;
546
493
  if (generatedId.test(finding.source_finding_id))
@@ -564,91 +511,38 @@ export function isSemgrepPlatformEvidence(finding, provider) {
564
511
  typeof data["deployment"] === "string" &&
565
512
  SEMGREP_PLATFORM_PRODUCTS.some((product) => product === data["product"]));
566
513
  }
567
- function upgradeOriginalSemgrepFinding(data, references, target) {
568
- const { numericFields: _witness, finding: original, ...context } = restoreLegacyHostedNumbers(data);
569
- const converted = upgradeSemgrepPlatformReport({ ...context, findings: [original], findingCount: 1 }, undefined, typeof references === "function"
570
- ? references
571
- : referenceRepositoryKey(references, target), references);
572
- return {
573
- ...converted,
574
- semgrepPlatformFindingJson: array(converted["findings"], "Semgrep findings")[0],
575
- };
576
- }
577
- /** Keep caller-supplied metadata while replacing the scanner's old wire representation. */
578
- function canonicalSourceDataWithExtensions(retained, canonical, original) {
579
- const extensions = (original, verified, replaced = []) => Object.fromEntries(Object.entries(original).filter(([key]) => !Object.hasOwn(verified, key) && !replaced.includes(key)));
580
- return {
581
- ...canonical,
582
- ...extensions(retained, canonical, [
583
- ...(original ? ["finding", "numericFields", "sourceRepositoryUrl"] : []),
584
- "nativeProjectUrl",
585
- "repositoryAliases",
586
- "repositoryWitnessJson",
587
- "idEncoding",
588
- ]),
589
- project: {
590
- ...canonical.project,
591
- ...extensions(record(retained["project"], "Semgrep project"), canonical.project),
592
- },
593
- };
594
- }
595
- function legacyWitnessKey(scope, projectUrlKey, label) {
596
- return JSON.stringify([
597
- scope.deployment,
598
- scope.project.id,
599
- scope.product,
600
- scope.ref,
601
- projectUrlKey,
602
- label,
603
- ]);
604
- }
605
- function nativeOccurrence(retained, references, target) {
606
- let data = !isSemgrepPlatformFormat(retained["format"])
607
- ? {
608
- ...retained,
609
- format: (!Object.hasOwn(retained, "semgrepPlatformFindingJson") &&
610
- "finding" in retained) ||
611
- retained["idEncoding"] === "v1-decimal"
612
- ? semgrepPlatformLegacyFormat
613
- : "repositoryAliases" in retained
614
- ? semgrepPlatformFormat
615
- : semgrepSelectionFormat,
616
- }
617
- : retained;
618
- const legacy = data["format"] === semgrepPlatformLegacyFormat;
619
- const original = legacy && !Object.hasOwn(data, "semgrepPlatformFindingJson");
620
- if (original)
621
- data = upgradeOriginalSemgrepFinding(data, references, target);
514
+ function nativeOccurrence(data, references, target) {
515
+ if (!isSemgrepPlatformFormat(data["format"]))
516
+ throw new Error("Unsupported Semgrep finding format. Recollect the Platform findings.");
622
517
  const { scope, aliases } = readScope(data, references, target);
623
518
  const repository = repositoryContext(scope.project.url, references, target);
624
519
  const row = parseSemgrepResponse(requiredText(data["semgrepPlatformFindingJson"], "Semgrep finding JSON"));
625
- return { data, legacy, original, scope, aliases, repository, row };
626
- }
627
- /** Original v1 occurrences could keep only the observed repository label on a row. */
628
- export function semgrepLegacyRepositoryWitnesses(findings, provider, references = [], target = "local") {
629
- const witnesses = new Map();
630
- // Current occurrences carry their own witness. Only original rows need a sibling lookup.
631
- if (!findings.some(({ evidence }) => isRecord(evidence.source_data?.["finding"])))
632
- return witnesses;
633
- for (const finding of findings) {
634
- const data = finding.evidence.source_data;
635
- if (!data || !isSemgrepPlatformEvidence(finding, provider))
636
- continue;
637
- const { scope, aliases, repository, row, legacy } = nativeOccurrence(data, references, target);
638
- const repo = row["repository"];
639
- if (!isRecord(repo))
640
- continue;
641
- const label = text(repo["name"]);
642
- if (!label || (repo["id"] == null && !text(repo["url"])))
643
- continue;
644
- checkSemgrepPlatformRow(row, scope, aliases, repository, legacy ? semgrepV1Id : semgrepPlatformId);
645
- witnesses.set(legacyWitnessKey(scope, repository.key(scope.project.url), label), JSON.stringify({ id: scope.project.id, name: label }));
646
- }
647
- return witnesses;
520
+ return { scope, aliases, repository, row };
521
+ }
522
+ /** Reproduce the native Cloud title fallback for an unmodified Platform message title. */
523
+ export function storedSemgrepCloudEvidence(finding, references = []) {
524
+ const { evidence } = finding;
525
+ if (evidence.title !== evidence.description ||
526
+ Buffer.byteLength(evidence.title) <= DEFAULT_CLOUD_STRING_BYTES ||
527
+ !evidence.source_data ||
528
+ !isSemgrepPlatformEvidence(finding, "semgrep"))
529
+ return;
530
+ const { row, scope, aliases, repository } = nativeOccurrence(evidence.source_data, references, "local");
531
+ if (sourceId(scope, row) !== finding.source_finding_id)
532
+ return;
533
+ const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository);
534
+ const projectNames = aliases &&
535
+ projectAliases(scope.project.name, scope.project.url, references);
536
+ const title = (target) => normalizePlatformRows([{ finding: row, selectable }], scope, target, projectNames).findings[0]?.evidence.title;
537
+ if (title("local") !== evidence.title)
538
+ return;
539
+ const cloud = title("cloud");
540
+ if (cloud && cloud !== evidence.title)
541
+ return { ...evidence, title: cloud };
648
542
  }
649
543
  /** Recheck the source repository when an SDK caller supplies normalized evidence directly. */
650
- export function semgrepPlatformFindingRepository(finding, provider, references = [], legacyWitnesses) {
651
- return semgrepPlatformFindingBinding(finding, provider, references, legacyWitnesses)?.url;
544
+ export function semgrepPlatformFindingRepository(finding, provider, references = []) {
545
+ return semgrepPlatformFindingBinding(finding, provider, references)?.url;
652
546
  }
653
547
  export function platformLocationPath(value) {
654
548
  const path = text(value);
@@ -657,79 +551,20 @@ export function platformLocationPath(value) {
657
551
  ? path
658
552
  : null;
659
553
  }
660
- function platformLocation(location, product, selectable, bulk) {
554
+ function platformLocation(location, product, coerceStrings) {
661
555
  const path = platformLocationPath(location["file_path"]);
662
- const oldPath = bulk?.legacy
663
- ? hostedRepositoryPath(location["file_path"])
556
+ if (!path)
557
+ return { locations: [], endLine: null };
558
+ const line = sourceLine(location["line"], coerceStrings);
559
+ const endLine = line !== null && product !== "sca"
560
+ ? sourceLine(location["end_line"], coerceStrings)
664
561
  : null;
665
- const unprojected = { locations: [], endLine: null };
666
- if (!path && !oldPath)
667
- return unprojected;
668
- // V1 retained coordinates for unprojected paths without validating them.
669
- const newlyProjectable = !!bulk?.legacy && !oldPath;
670
- const coerce = newlyProjectable || (!!bulk && !bulk.legacy && !selectable);
671
- try {
672
- const line = sourceLine(location["line"], coerce);
673
- const endLine = line !== null && product !== "sca"
674
- ? sourceLine(location["end_line"], coerce)
675
- : null;
676
- if (bulk?.legacy && oldPath !== path)
677
- validateCodeLineRange(line, endLine);
678
- return path ? { locations: [{ path, line }], endLine } : unprojected;
679
- }
680
- catch (error) {
681
- if (newlyProjectable)
682
- return unprojected;
683
- throw error;
684
- }
562
+ return { locations: [{ path, line }], endLine };
685
563
  }
686
564
  function platformSeverity(value, selectable) {
687
565
  const severity = text(value)?.toLowerCase();
688
566
  return scannerSeverity(selectable && severity === "informational" ? null : severity);
689
567
  }
690
- /** Upgrade only values produced by the original object-row reader; keep SDK-authored evidence. */
691
- function migrateLegacyProjection(evidence, row, scope, selectable, references) {
692
- const severity = text(row["severity"]);
693
- const oldSeverity = scannerSeverity(severity === "informational" ? null : severity);
694
- const upgradeSeverity = evidence.severity === oldSeverity &&
695
- oldSeverity !== scannerSeverity(severity?.toLowerCase());
696
- const location = isRecord(row["location"]) ? row["location"] : {};
697
- const oldPath = hostedRepositoryPath(location["file_path"]);
698
- const first = evidence.locations?.[0];
699
- // Only replace the exact location and end line produced by the original object-row reader.
700
- const oldLocation = oldPath !== platformLocationPath(location["file_path"]) &&
701
- (oldPath
702
- ? evidence.locations?.length === 1 &&
703
- first?.path === oldPath &&
704
- matchesNativeInteger(location["line"], first.line)
705
- : evidence.locations?.length === 0) &&
706
- matchesNativeInteger(oldPath && scope.product !== "sca" && first?.line != null
707
- ? location["end_line"]
708
- : null, evidence.details?.code?.end_line);
709
- if (!upgradeSeverity && !oldLocation)
710
- return;
711
- const projected = normalizePlatformRows([{ finding: row, selectable }], scope, "local", {
712
- legacy: true,
713
- projectNames: projectAliases(scope.project.name, scope.project.url, references),
714
- }).findings[0]?.evidence;
715
- if (!projected)
716
- return;
717
- return {
718
- ...(upgradeSeverity && { severity: projected.severity }),
719
- ...(oldLocation && { locations: projected.locations }),
720
- ...(oldLocation &&
721
- evidence.details?.code &&
722
- projected.details?.code && {
723
- details: {
724
- ...evidence.details,
725
- code: {
726
- ...evidence.details.code,
727
- end_line: projected.details.code.end_line,
728
- },
729
- },
730
- }),
731
- };
732
- }
733
568
  function qualifiedBranch(ref) {
734
569
  return ref.startsWith("refs/") ? ref : `refs/heads/${ref}`;
735
570
  }
@@ -759,12 +594,10 @@ export function hasRetainedSemgrepScope(finding) {
759
594
  SEMGREP_PLATFORM_PRODUCTS.some((known) => known === product));
760
595
  });
761
596
  }
762
- export function semgrepPlatformFindingBinding(finding, provider, references = [], legacyWitnesses, reportScope, projectedSources = [], target = "local", replayApprovedRequest = false) {
597
+ export function semgrepPlatformFindingBinding(finding, provider, references = [], reportScope, projectedSources = [], target = "local") {
763
598
  const retained = finding.evidence.source_data;
764
599
  if (!isSemgrepPlatformEvidence(finding, provider)) {
765
- // Previously approved Cloud requests keep the released projection and native checks below.
766
- if (!replayApprovedRequest &&
767
- provider === "semgrep" &&
600
+ if (provider === "semgrep" &&
768
601
  reportScope?.format !== undefined &&
769
602
  hasRetainedSemgrepScope(retained?.["finding"]))
770
603
  throw new Error("Retained Semgrep finding scope requires the original collection scope in a marked Platform report.");
@@ -789,7 +622,7 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
789
622
  }
790
623
  if (!retained)
791
624
  throw new Error("Missing the original Semgrep finding evidence.");
792
- const { data, legacy, original, scope, aliases, repository, row } = nativeOccurrence(retained, references, target);
625
+ const { scope, aliases, repository, row } = nativeOccurrence(retained, references, target);
793
626
  checkProjectedProduct(finding, scope.product, true);
794
627
  if (reportScope?.deployment !== undefined &&
795
628
  (scope.deployment !== reportScope.deployment ||
@@ -797,54 +630,36 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
797
630
  scope.ref !== reportScope.ref ||
798
631
  scope.product !== reportScope.product))
799
632
  throw new Error("The Semgrep report repository scope does not match the finding's deployment, project ID, ref, or product.");
800
- const other = data["finding"];
801
- if ((legacy && Object.hasOwn(data, "finding")) ||
802
- (isRecord(other) && Object.hasOwn(other, "id"))) {
803
- const restored = restoreLegacyHostedNumbers(data)["finding"];
804
- const originalRow = parseSemgrepResponse(JSON.stringify(restored));
805
- const id = originalRow["id"];
806
- const nativeId = semgrepPlatformIdOrUndefined(id) ??
807
- (typeof id === "string" ? legacyDecimalInteger(id) : undefined);
808
- if ((legacy || nativeId !== undefined) &&
809
- stringifySemgrepFinding(originalRow) !== stringifySemgrepFinding(row))
633
+ const other = retained["finding"];
634
+ if (isRecord(other) && Object.hasOwn(other, "id")) {
635
+ const original = parseSemgrepResponse(JSON.stringify(other));
636
+ if (semgrepPlatformIdOrUndefined(original["id"]) !== undefined &&
637
+ stringifySemgrepFinding(original) !== stringifySemgrepFinding(row))
810
638
  throw new Error("The retained Semgrep finding representations disagree.");
811
639
  }
812
- const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository, legacy ? semgrepV1Id : semgrepPlatformId);
640
+ const selectable = checkSemgrepPlatformRow(row, scope, aliases, repository);
813
641
  if (reportScope?.format === semgrepSelectionFormat && !selectable)
814
642
  throw new Error("Semgrep finding does not belong to the selected project and ref.");
815
- let occurrenceId = legacy ? semgrepV1Id : semgrepPlatformId;
816
- const nativeId = sourceId(scope, row, occurrenceId);
643
+ const nativeId = sourceId(scope, row);
817
644
  if (generatedId.test(finding.source_finding_id) &&
818
- finding.source_finding_id !== nativeId) {
819
- if (legacy ||
820
- finding.source_finding_id !== sourceId(scope, row, archivedPlatformId))
821
- throw new Error("The generated Semgrep finding ID does not match its native occurrence.");
822
- occurrenceId = archivedPlatformId;
823
- }
645
+ finding.source_finding_id !== nativeId)
646
+ throw new Error("The generated Semgrep finding ID does not match its native occurrence.");
824
647
  const { name, url } = scope.project;
825
648
  let namedOnly = aliases && repositoryWithOnlyAlias(row, projectAliases(name, url));
826
- const raw = original
827
- ? namedOnly &&
828
- legacyWitnesses?.get(legacyWitnessKey(scope, repository.key(url), namedOnly))
829
- : data["repositoryWitnessJson"];
649
+ const raw = retained["repositoryWitnessJson"];
830
650
  // Only rely on the reader's platform hint when there is no independent proof.
831
651
  if (namedOnly &&
832
652
  raw === undefined &&
833
653
  projectAliases(name, url, references).has(namedOnly))
834
654
  namedOnly = undefined;
835
- const legacyPath = original &&
836
- namedOnly &&
837
- legacyProjectAliases(name, url, references, scope.sourceRepositoryUrl).has(namedOnly);
838
- if (raw !== undefined || (namedOnly && !legacyPath)) {
655
+ if (raw !== undefined || namedOnly) {
839
656
  const label = text(record(row["repository"], "Semgrep finding repository")["name"]);
840
657
  const witness = parseSemgrepResponse(requiredText(raw, "Semgrep repository alias witness"));
841
658
  if (!label ||
842
659
  witness["name"] !== label ||
843
660
  (witness["id"] == null && !text(witness["url"])))
844
661
  throw new Error("Semgrep repository alias lacks a matching project ID or URL.");
845
- checkSemgrepPlatformRow({ repository: witness }, scope, aliases ?? new Set([label]), repository, legacy
846
- ? semgrepV1Id
847
- : (id) => semgrepPlatformId(wireJson.rawJSON(savedPlatformId(id))));
662
+ checkSemgrepPlatformRow({ repository: witness }, scope, aliases ?? new Set([label]), repository, (id) => semgrepPlatformId(wireJson.rawJSON(savedPlatformId(id))));
848
663
  }
849
664
  const claimed = finding.evidence.details?.repository?.url;
850
665
  if (finding.evidence.branch !== scope.ref ||
@@ -852,38 +667,28 @@ export function semgrepPlatformFindingBinding(finding, provider, references = []
852
667
  (!!claimed &&
853
668
  repository.key(hostedRepositoryUrl(claimed, "Semgrep evidence repository")) !== repository.key(scope.project.url)))
854
669
  throw new Error("The normalized finding does not match its original Semgrep repository and ref.");
855
- const canonical = platformSourceData(row, scope, selectable, aliases ? { legacy } : undefined, namedOnly, occurrenceId);
856
- let migration = original
857
- ? migrateLegacyProjection(finding.evidence, row, scope, selectable, references)
858
- : undefined;
859
- if (!original &&
860
- data["format"] === semgrepPlatformFormat &&
861
- canonical.format === semgrepSelectionFormat) {
862
- const selectedSeverity = platformSeverity(row["severity"], true);
863
- if (selectedSeverity !== finding.evidence.severity &&
864
- finding.evidence.severity === platformSeverity(row["severity"], false))
865
- migration = { severity: selectedSeverity };
866
- }
867
- // The original reader projected the HTTP mapping when the native project URL used SSH.
868
- const oldMappedUrl = original &&
869
- scope.product !== "sca" &&
870
- scope.nativeProjectUrl !== undefined &&
871
- claimed === scope.sourceRepositoryUrl &&
872
- claimed !== scope.project.url;
873
- const details = migration?.details ?? finding.evidence.details;
670
+ const canonical = platformSourceData(row, scope, selectable, aliases !== undefined, namedOnly);
671
+ const { repositoryAliases: _aliases, repositoryWitnessJson: _witness, nativeProjectUrl: _native, ...metadata } = retained;
672
+ const selectedSeverity = platformSeverity(row["severity"], true);
673
+ const previousSeverity = platformSeverity(row["severity"], false);
874
674
  return {
875
- url: scope.project.url,
675
+ url,
876
676
  nativeId,
877
- migration: oldMappedUrl && details?.repository
878
- ? {
879
- ...migration,
880
- details: {
881
- ...details,
882
- repository: { ...details.repository, url: scope.project.url },
883
- },
884
- }
885
- : migration,
886
- sourceData: canonicalSourceDataWithExtensions(retained, canonical, original),
677
+ // A reader-provided repository binding can promote a backlog row to a selected SAST row.
678
+ migration: retained["format"] === semgrepPlatformFormat &&
679
+ canonical.format === semgrepSelectionFormat &&
680
+ finding.evidence.severity === previousSeverity &&
681
+ previousSeverity !== selectedSeverity
682
+ ? { severity: selectedSeverity }
683
+ : undefined,
684
+ sourceData: {
685
+ ...metadata,
686
+ ...canonical,
687
+ project: {
688
+ ...record(retained["project"], "Semgrep project"),
689
+ ...canonical.project,
690
+ },
691
+ },
887
692
  };
888
693
  }
889
694
  /** Normalize a saved selection or Platform project export. The default target is local. */
@@ -891,15 +696,10 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
891
696
  ? (options.sourceRepositories ?? [])
892
697
  : []) {
893
698
  const declaredUrl = typeof options === "string" ? options : options.sourceRepositoryUrl;
894
- const saved = record(report, "Semgrep Platform report");
895
- const sourceFormat = saved["format"];
699
+ const input = record(report, "Semgrep Platform report");
700
+ const sourceFormat = input["format"];
896
701
  if (!isSemgrepPlatformFormat(sourceFormat))
897
702
  throw new Error("Expected a Semgrep Platform selection or project export.");
898
- const legacy = sourceFormat === semgrepPlatformLegacyFormat;
899
- const readId = legacy ? semgrepV1Id : semgrepPlatformId;
900
- const input = legacy
901
- ? upgradeSemgrepPlatformReport(saved, declaredUrl, referenceRepositoryKey(references, target), references)
902
- : saved;
903
703
  const { scope, aliases } = readScope(input, references, target);
904
704
  const repository = selectionRepository(scope.project.url, references, target);
905
705
  if (declaredUrl &&
@@ -914,7 +714,7 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
914
714
  const rows = entries.map((value) => {
915
715
  const raw = requiredText(value, "Semgrep finding JSON");
916
716
  const finding = parseSemgrepResponse(raw);
917
- const selectable = checkSemgrepPlatformRow(finding, scope, aliases, repository, readId);
717
+ const selectable = checkSemgrepPlatformRow(finding, scope, aliases, repository);
918
718
  if (aliases) {
919
719
  const repo = record(finding["repository"] ?? {}, "Semgrep finding repository");
920
720
  const label = text(repo["name"]);
@@ -926,27 +726,20 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
926
726
  if (aliases && !matchesNativeInteger(input["findingCount"], rows.length))
927
727
  throw new Error("Incomplete Semgrep Platform export: finding count does not match.");
928
728
  if (aliases) {
929
- // v1 also accepted decodeURI path labels. Keep a witness for their current-format replay.
930
- const archiveNames = legacy
931
- ? legacyProjectAliases(scope.project.name, scope.project.url, references, scope.sourceRepositoryUrl)
932
- : projectNames;
933
729
  for (const { finding } of rows) {
934
- const name = repositoryWithOnlyAlias(finding, archiveNames);
730
+ const name = repositoryWithOnlyAlias(finding, projectNames);
935
731
  if (name && !verifiedLabels.has(name))
936
732
  throw new Error("Semgrep finding repository lacks a matching project name, ID or URL.");
937
733
  }
938
734
  }
939
735
  const unhintedNames = projectAliases(scope.project.name, scope.project.url);
940
- const result = normalizePlatformRows(rows, scope, target, aliases
941
- ? {
942
- legacy,
943
- projectNames: {
944
- has: (name) => (verifiedLabels.has(name) ? unhintedNames : projectNames).has(name),
945
- },
946
- }
947
- : undefined, aliases ? readId : archivedPlatformId);
736
+ const result = normalizePlatformRows(rows, scope, target, aliases && {
737
+ has: (name) => (verifiedLabels.has(name) ? unhintedNames : projectNames).has(name),
738
+ });
739
+ return { ...result, ...reportScope(sourceFormat, scope) };
740
+ }
741
+ function reportScope(sourceFormat, scope) {
948
742
  return {
949
- ...result,
950
743
  sourceFormat,
951
744
  sourceRepositoryUrl: scope.project.url,
952
745
  semgrepPlatformScope: {
@@ -957,12 +750,14 @@ export function normalizeSemgrepPlatformFindings(report, options = {}, target =
957
750
  },
958
751
  };
959
752
  }
960
- export function stringifySemgrepFinding(finding, idOf = semgrepPlatformIdOrUndefined) {
753
+ export function stringifySemgrepFinding(finding) {
961
754
  const repo = finding["repository"];
962
755
  const nativeIds = [finding["id"], isRecord(repo) ? repo["id"] : undefined];
963
756
  return JSON.stringify(finding, (_key, value) => {
964
757
  if (wireJson.isRawJSON(value)) {
965
- const id = nativeIds.includes(value) ? idOf(value) : undefined;
758
+ const id = nativeIds.includes(value)
759
+ ? semgrepPlatformIdOrUndefined(value)
760
+ : undefined;
966
761
  return wireJson.rawJSON(id ?? canonicalNumber(value.rawJSON));
967
762
  }
968
763
  if (isRecord(value))
@@ -972,33 +767,22 @@ export function stringifySemgrepFinding(finding, idOf = semgrepPlatformIdOrUndef
972
767
  return value;
973
768
  });
974
769
  }
975
- function platformSourceData(finding, scope, selectable, bulk, namedOnly, idOf = semgrepPlatformId) {
770
+ function platformSourceData(finding, scope, selectable, bulk, namedOnly) {
976
771
  const repo = record(finding["repository"] ?? {}, "Semgrep finding repository");
977
772
  const label = text(repo["name"]);
978
- // Ordinary v1 and v2 rows share one stored representation on replay.
979
- // Preserve the legacy discriminator only when reopening the raw IDs needs it.
980
773
  const { nativeProjectUrl, ...evidenceScope } = scope;
981
774
  const nativeBulkScope = !selectable ||
982
775
  scope.sourceRepositoryUrl !== undefined ||
983
776
  nativeProjectUrl !== undefined;
984
- const needsLegacyId = bulk?.legacy &&
985
- [finding["id"], repo["id"]].some((id) => typeof id === "string" &&
986
- semgrepPlatformIdOrUndefined(id) === undefined);
987
- // Native SAST rows with their own repository and ref replay identically in either import mode.
988
- const needsBulkScope = bulk && (nativeBulkScope || needsLegacyId);
777
+ const needsBulkScope = bulk && nativeBulkScope;
989
778
  return {
990
- format: needsLegacyId
991
- ? semgrepPlatformLegacyFormat
992
- : needsBulkScope
993
- ? semgrepPlatformFormat
994
- : semgrepSelectionFormat,
779
+ format: needsBulkScope ? semgrepPlatformFormat : semgrepSelectionFormat,
995
780
  ...evidenceScope,
996
781
  project: {
997
782
  ...scope.project,
998
783
  url: nativeProjectUrl ??
999
784
  (scope.sourceRepositoryUrl ? null : scope.project.url),
1000
785
  },
1001
- ...(needsLegacyId && { idEncoding: "v1-decimal" }),
1002
786
  ...(needsBulkScope && { repositoryAliases: label ? [label] : [] }),
1003
787
  // Store the verified binding independently of the native fields retained on its proving row.
1004
788
  ...(namedOnly && {
@@ -1007,35 +791,34 @@ function platformSourceData(finding, scope, selectable, bulk, namedOnly, idOf =
1007
791
  name: namedOnly,
1008
792
  }),
1009
793
  }),
1010
- semgrepPlatformFindingJson: stringifySemgrepFinding(finding, idOf),
794
+ semgrepPlatformFindingJson: stringifySemgrepFinding(finding),
1011
795
  };
1012
796
  }
1013
797
  // Selected rows and complete captures share their evidence projection and identity tuple.
1014
- function normalizePlatformRows(rows, scope, target, bulk, readId = bulk?.legacy ? semgrepV1Id : semgrepPlatformId) {
1015
- const legacy = bulk?.legacy;
798
+ function normalizePlatformRows(rows, scope, target, projectNames) {
1016
799
  return normalizeRecords(rows, ({ finding, selectable }) => {
1017
800
  const rule = responseRecord(finding["rule"] ?? {}, "Semgrep rule");
1018
801
  const name = text(rule["name"]) ?? text(finding["rule_name"]);
1019
802
  const description = text(rule["message"]) ?? text(finding["rule_message"]);
1020
803
  const location = responseRecord(finding["location"] ?? {}, "Semgrep location");
1021
- const { locations, endLine } = platformLocation(location, scope.product, selectable, bulk);
1022
- const namedOnly = bulk && repositoryWithOnlyAlias(finding, bulk.projectNames);
804
+ const { locations, endLine } = platformLocation(location, scope.product, !!projectNames && !selectable);
805
+ const namedOnly = projectNames && repositoryWithOnlyAlias(finding, projectNames);
1023
806
  const common = {
1024
807
  description,
1025
808
  severity: platformSeverity(finding["severity"], selectable),
1026
809
  locations,
1027
810
  branch: scope.ref,
1028
- source_data: platformSourceData(finding, scope, selectable, bulk, namedOnly, readId),
811
+ source_data: platformSourceData(finding, scope, selectable, projectNames !== undefined, namedOnly),
1029
812
  };
1030
813
  let messageTitle = description ??
1031
- (legacy || scope.product === "sast"
814
+ (scope.product === "sast"
1032
815
  ? null
1033
- : `Semgrep finding ${readId(finding["id"])}`);
816
+ : `Semgrep finding ${semgrepPlatformId(finding["id"])}`);
1034
817
  if (target === "cloud" &&
1035
818
  description &&
1036
819
  Buffer.byteLength(description) > DEFAULT_CLOUD_STRING_BYTES) {
1037
820
  const id = finding["id"];
1038
- messageTitle = `Semgrep finding ${text(id) ?? readId(id)}`;
821
+ messageTitle = `Semgrep finding ${text(id) ?? semgrepPlatformId(id)}`;
1039
822
  }
1040
823
  if (scope.product === "sca") {
1041
824
  const dependency = responseRecord(finding["found_dependency"] ?? {}, "Semgrep found dependency");
@@ -1073,6 +856,6 @@ function normalizePlatformRows(rows, scope, target, bulk, readId = bulk?.legacy
1073
856
  code: { end_line: endLine },
1074
857
  },
1075
858
  }, target);
1076
- }, ({ finding }) => sourceId(scope, finding, readId), target);
859
+ }, ({ finding }) => sourceId(scope, finding), target);
1077
860
  }
1078
861
  //# sourceMappingURL=semgrep-platform-findings.js.map