@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,9 +1,16 @@
1
1
  import type { ExternalFinding, ExternalSourceRepository } from "./external-findings.js";
2
2
  import type { Provider } from "./external-import-models.js";
3
- export type LocalFindingProvider = Provider | "tenable";
3
+ /** Readers whose findings Cloud does not accept, with their display names. */
4
+ export declare const LOCAL_ONLY_PROVIDERS: {
5
+ readonly tenable: "Tenable";
6
+ readonly crowdstrike: "CrowdStrike";
7
+ };
8
+ type LocalOnlyProvider = keyof typeof LOCAL_ONLY_PROVIDERS;
9
+ export type LocalFindingProvider = Provider | LocalOnlyProvider;
4
10
  /** File reader names mapped to the provider stored with each finding. */
5
11
  export declare const EXTERNAL_FINDINGS_PROVIDERS: {
6
12
  readonly wiz: "wiz";
13
+ readonly armorcode: "armorcode";
7
14
  readonly snyk: "snyk";
8
15
  readonly semgrep: "semgrep";
9
16
  readonly trivy: "trivy";
@@ -17,9 +24,10 @@ export declare const EXTERNAL_FINDINGS_PROVIDERS: {
17
24
  readonly continuum: "continuum";
18
25
  readonly checkmarx: "checkmarx";
19
26
  readonly tenable: "tenable";
27
+ readonly crowdstrike: "crowdstrike";
20
28
  };
21
29
  export type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;
22
- export type CloudFindingsReader = Exclude<ExternalFindingsReader, "tenable">;
30
+ export type CloudFindingsReader = Exclude<ExternalFindingsReader, LocalOnlyProvider>;
23
31
  export declare function requireCloudReader(options: ExternalFindingsReaderOptions): asserts options is ExternalFindingsReaderOptions & {
24
32
  provider: CloudFindingsReader;
25
33
  };
@@ -42,4 +50,5 @@ export declare function semgrepSarifRepositories({ evidence }: ExternalFinding,
42
50
  export declare function snykFileRepositories(input: unknown): {
43
51
  url: string;
44
52
  }[];
53
+ export {};
45
54
  //# sourceMappingURL=external-findings-read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings-read.d.ts","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAGf,wBAAwB,EACzB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAwD5D,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExD,yEAAyE;AACzE,eAAO,MAAM,2BAA2B;kBACjC,KAAK;mBACJ,MAAM;sBACH,SAAS;oBACX,OAAO;uBAEJ,SAAS;oBACZ,OAAO;qBACN,QAAQ;wBACL,WAAW;wBACX,WAAW;uBACZ,UAAU;oBACb,OAAO;wBACH,WAAW;wBACX,WAAW;sBACb,SAAS;CACqC,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,2BAA2B,CAAC;AAC9E,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;AAE7E,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,IAAI,6BAA6B,GAAG;IACpD,QAAQ,EAAE,mBAAmB,CAAC;CAC/B,CAKA;AAED,eAAO,MAAM,yBAAyB,EAEjC,sBAAsB,EAAE,CAAC;AAE9B,oFAAoF;AACpF,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,yEAAyE;AACzE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,e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mBAAmB,CAAC;CAC/B,CAKA;AAED,eAAO,MAAM,yBAAyB,EAEjC,sBAAsB,EAAE,CAAC;AAE9B,oFAAoF;AACpF,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,sBAAsB,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAQD,yEAAyE;AACzE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,eAAe,GACvB,wBAAwB,EAAE,CAiB5B;AAED,8DAA8D;AAC9D,wBAAgB,wBAAwB,CACtC,EAAE,QAAQ,EAAE,EAAE,eAAe,EAC7B,oBAAoB,UAAQ,GAC3B;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,CAkCpC;AAeD,sFAAsF;AACtF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO;;IAIlD"}
@@ -1,26 +1,33 @@
1
1
  import { readScannerJson, sarifRunRepositories } from "./scanner-import.js";
2
2
  import { CodexSecurityError } from "./errors.js";
3
3
  import { readTenableFindings } from "./tenable-findings.js";
4
+ import { readCrowdStrikeFindings } from "./crowdstrike-findings.js";
4
5
  import { dependabotRepository } from "./github-dependabot-findings.js";
5
- import { normalizeSnykFile, readSnykReport, emptySnykReportRepositories, snykRepositoryUrls, } from "./snyk-findings.js";
6
+ import { normalizeSnykFile, emptySnykReportRepositories, snykRepositoryUrls, } from "./snyk-findings.js";
6
7
  import { isSemgrepSarifDriver, normalizeSemgrepFindings, readSemgrepReport, } from "./semgrep-findings.js";
7
8
  import { semgrepPlatformReportRepository } from "./semgrep-platform-findings.js";
8
- import { normalizeTrivyFindings, needsPreviousTrivyProjection, normalizePreviousTrivyFindings, } from "./trivy-findings.js";
9
+ import { normalizeTrivyFindings } from "./trivy-findings.js";
9
10
  import { readOpenGrepFindings } from "./opengrep-findings.js";
10
- import { normalizeEndorFindings, normalizePreviousEndorFindings, endorRepositoryUrls, } from "./endor-findings.js";
11
+ import { normalizeEndorFindings, endorRepositoryUrls, } from "./endor-findings.js";
11
12
  import { readGitHubFindings } from "./github-findings.js";
12
13
  import { readSonarFindings } from "./sonar-findings.js";
13
- import { normalizeVeracodeFindings, normalizePreviousVeracodeFindings, } from "./veracode-findings.js";
14
- import { needsPreviousBlackDuckProjection, normalizeBlackDuckFindings, normalizePreviousBlackDuckFindings, } from "./blackduck-findings.js";
15
- import { normalizeContinuumFindings, normalizePreviousContinuumFindings, } from "./continuum-findings.js";
14
+ import { normalizeVeracodeFindings } from "./veracode-findings.js";
15
+ import { normalizeBlackDuckFindings } from "./blackduck-findings.js";
16
+ import { normalizeContinuumFindings } from "./continuum-findings.js";
16
17
  import { readCheckmarxFindings } from "./checkmarx-findings.js";
17
- import { normalizeInspectorFindings, normalizePreviousInspectorFindings, } from "./inspector-findings.js";
18
- import { hasPreviousCloudProjection } from "./reader-selection.js";
18
+ import { normalizeInspectorFindings } from "./inspector-findings.js";
19
19
  import { isRecord } from "./record.js";
20
- import { readLocalWizFindings, readVendorFindingsForPublication, wizFindingRepository, } from "./wiz-findings.js";
20
+ import { readWizSelection, wizFindingRepository } from "./wiz-findings.js";
21
+ import { normalizeArmorCodeFindings } from "./armorcode-findings.js";
22
+ /** Readers whose findings Cloud does not accept, with their display names. */
23
+ export const LOCAL_ONLY_PROVIDERS = {
24
+ tenable: "Tenable",
25
+ crowdstrike: "CrowdStrike",
26
+ };
21
27
  /** File reader names mapped to the provider stored with each finding. */
22
28
  export const EXTERNAL_FINDINGS_PROVIDERS = {
23
29
  wiz: "wiz",
30
+ armorcode: "armorcode",
24
31
  snyk: "snyk",
25
32
  semgrep: "semgrep",
26
33
  trivy: "trivy",
@@ -35,10 +42,11 @@ export const EXTERNAL_FINDINGS_PROVIDERS = {
35
42
  continuum: "continuum",
36
43
  checkmarx: "checkmarx",
37
44
  tenable: "tenable",
45
+ crowdstrike: "crowdstrike",
38
46
  };
39
47
  export function requireCloudReader(options) {
40
- if (options.provider === "tenable")
41
- throw new CodexSecurityError("Tenable findings require a local import (--to local).");
48
+ if (Object.hasOwn(LOCAL_ONLY_PROVIDERS, options.provider))
49
+ throw new CodexSecurityError(`${LOCAL_ONLY_PROVIDERS[options.provider]} findings require a local import (--to local).`);
42
50
  }
43
51
  export const EXTERNAL_FINDINGS_READERS = Object.keys(EXTERNAL_FINDINGS_PROVIDERS);
44
52
  /** Repository references retained by a provider's individual finding. */
@@ -108,18 +116,18 @@ export function snykFileRepositories(input) {
108
116
  export async function readExternalFindings(path, options, target = "cloud", references = []) {
109
117
  const { provider } = options;
110
118
  const url = options.sourceRepositoryUrl ?? "";
111
- // Both projections describe the same captured rows, including exclusions.
112
- function withReplay(findings, couldDiffer, previous) {
113
- return {
114
- findings,
115
- previousFindings: target === "cloud" && couldDiffer(findings) ? previous : undefined,
116
- };
117
- }
118
119
  if (provider === "tenable") {
119
120
  if (target === "cloud")
120
121
  requireCloudReader(options);
121
122
  return { findings: await readTenableFindings(path, url) };
122
123
  }
124
+ if (provider === "crowdstrike") {
125
+ if (target === "cloud")
126
+ requireCloudReader(options);
127
+ return {
128
+ findings: await readCrowdStrikeFindings(path, options.sourceRepositoryUrl),
129
+ };
130
+ }
123
131
  if (provider === "sonar") {
124
132
  const findings = await readSonarFindings(path, url, target);
125
133
  const binding = findings.report?.["repositoryUrl"];
@@ -135,7 +143,7 @@ export async function readExternalFindings(path, options, target = "cloud", refe
135
143
  return { findings, sourceRepositories: [{ url }] };
136
144
  }
137
145
  if (provider === "snyk") {
138
- const input = await readSnykReport(path);
146
+ const input = await readScannerJson(path);
139
147
  const findings = await normalizeSnykFile(input, target, references);
140
148
  return { findings, sourceRepositories: snykFileRepositories(input) };
141
149
  }
@@ -152,57 +160,52 @@ export async function readExternalFindings(path, options, target = "cloud", refe
152
160
  sourceRepositories.push({ url: options.sourceRepositoryUrl });
153
161
  return { findings, sourceRepositories };
154
162
  }
163
+ if (provider === "armorcode") {
164
+ const input = await readScannerJson(path);
165
+ return {
166
+ findings: normalizeArmorCodeFindings(input, target, options.sourceRepositoryUrl),
167
+ };
168
+ }
155
169
  if (provider === "github")
156
170
  return { findings: await readGitHubFindings(path, target) };
157
171
  if (provider === "wiz") {
158
- const wiz = target === "local"
159
- ? await readLocalWizFindings(path)
160
- : await readVendorFindingsForPublication(path, target);
161
- const sourceRepositories = wiz.current.findings.flatMap((finding) => localFindingRepositories("wiz", finding));
172
+ const wiz = await readWizSelection(path, target);
173
+ const sourceRepositories = wiz.findings.findings.flatMap((finding) => localFindingRepositories("wiz", finding));
162
174
  return {
163
- findings: wiz.current,
164
- ...("legacy" in wiz && { publication: wiz }),
175
+ findings: wiz.findings,
165
176
  sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],
166
177
  };
167
178
  }
168
179
  const input = await readScannerJson(path);
169
- if (provider === "trivy") {
170
- const args = [input, target, options.trivyScanRoot];
171
- return withReplay(normalizeTrivyFindings(...args), needsPreviousTrivyProjection, () => normalizePreviousTrivyFindings(...args));
172
- }
180
+ if (provider === "trivy")
181
+ return {
182
+ findings: normalizeTrivyFindings(input, target, options.trivyScanRoot),
183
+ };
173
184
  if (provider === "endor") {
174
185
  const findings = normalizeEndorFindings(input, target);
175
186
  return {
176
- ...withReplay(findings, hasPreviousCloudProjection, () => normalizePreviousEndorFindings(input, target)),
187
+ findings,
177
188
  sourceRepositories: sarifFileRepositories(input, "Endor") ??
178
189
  findings.findings.flatMap((row) => localFindingRepositories(provider, row)),
179
190
  };
180
191
  }
181
- const [normalize, previous, couldDiffer] = {
182
- inspector: [
183
- normalizeInspectorFindings,
184
- normalizePreviousInspectorFindings,
185
- () => true,
186
- ],
187
- continuum: [
188
- normalizeContinuumFindings,
189
- normalizePreviousContinuumFindings,
190
- () => !Array.isArray(input),
191
- ],
192
- blackduck: [
193
- normalizeBlackDuckFindings,
194
- normalizePreviousBlackDuckFindings,
195
- needsPreviousBlackDuckProjection,
196
- ],
197
- veracode: [
198
- normalizeVeracodeFindings,
199
- normalizePreviousVeracodeFindings,
200
- hasPreviousCloudProjection,
201
- ],
192
+ if (provider === "continuum") {
193
+ const findings = normalizeContinuumFindings(input, url, target);
194
+ const binding = findings.report?.["sourceRepositoryUrl"];
195
+ return {
196
+ findings,
197
+ sourceRepositories: [
198
+ { url: typeof binding === "string" ? binding : url },
199
+ ],
200
+ };
201
+ }
202
+ const normalize = {
203
+ inspector: normalizeInspectorFindings,
204
+ blackduck: normalizeBlackDuckFindings,
205
+ veracode: normalizeVeracodeFindings,
202
206
  }[provider];
203
- const args = [input, url, target, options.inspectorProjectMap];
204
207
  return {
205
- ...withReplay(normalize(...args), couldDiffer, () => previous(...args)),
208
+ findings: normalize(input, url, target, options.inspectorProjectMap),
206
209
  sourceRepositories: [{ url }],
207
210
  };
208
211
  }
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE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AAG,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAU,CAAC;IACxE,OAAO;QACL,GAAG,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;QACvE,kBAAkB,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFinding,\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport { readScannerJson, sarifRunRepositories } from \"./scanner-import.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { readTenableFindings } from \"./tenable-findings.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport {\n normalizeSnykFile,\n readSnykReport,\n emptySnykReportRepositories,\n snykRepositoryUrls,\n} from \"./snyk-findings.js\";\nimport {\n isSemgrepSarifDriver,\n normalizeSemgrepFindings,\n readSemgrepReport,\n} from \"./semgrep-findings.js\";\nimport { semgrepPlatformReportRepository } from \"./semgrep-platform-findings.js\";\nimport {\n normalizeTrivyFindings,\n needsPreviousTrivyProjection,\n normalizePreviousTrivyFindings,\n} from \"./trivy-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport {\n normalizeEndorFindings,\n normalizePreviousEndorFindings,\n endorRepositoryUrls,\n} from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { readSonarFindings } from \"./sonar-findings.js\";\nimport {\n normalizeVeracodeFindings,\n normalizePreviousVeracodeFindings,\n} from \"./veracode-findings.js\";\nimport {\n needsPreviousBlackDuckProjection,\n normalizeBlackDuckFindings,\n normalizePreviousBlackDuckFindings,\n} from \"./blackduck-findings.js\";\nimport {\n normalizeContinuumFindings,\n normalizePreviousContinuumFindings,\n} from \"./continuum-findings.js\";\nimport { readCheckmarxFindings } from \"./checkmarx-findings.js\";\nimport {\n normalizeInspectorFindings,\n normalizePreviousInspectorFindings,\n} from \"./inspector-findings.js\";\nimport { hasPreviousCloudProjection } from \"./reader-selection.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n readLocalWizFindings,\n readVendorFindingsForPublication,\n wizFindingRepository,\n} from \"./wiz-findings.js\";\n\nexport type LocalFindingProvider = Provider | \"tenable\";\n\n/** File reader names mapped to the provider stored with each finding. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n trivy: \"trivy\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n inspector: \"inspector\",\n blackduck: \"blackduck\",\n veracode: \"veracode\",\n sonar: \"sonar\",\n continuum: \"continuum\",\n checkmarx: \"checkmarx\",\n tenable: \"tenable\",\n} as const satisfies Record<string, LocalFindingProvider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\nexport type CloudFindingsReader = Exclude<ExternalFindingsReader, \"tenable\">;\n\nexport function requireCloudReader(\n options: ExternalFindingsReaderOptions,\n): asserts options is ExternalFindingsReaderOptions & {\n provider: CloudFindingsReader;\n} {\n if (options.provider === \"tenable\")\n throw new CodexSecurityError(\n \"Tenable findings require a local import (--to local).\",\n );\n}\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK. Cloud supports a subset of these readers. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n inspectorProjectMap?: ReadonlyMap<string, string>;\n trivyScanRoot?: string;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n previousFindings?: () => ExternalFindings;\n /** Preserve previous Wiz projections when resuming immutable Cloud requests. */\n publication?: ExternalPublicationInput;\n sourceRepositories?: ExternalSourceRepository[];\n}\n\n/** Repository references retained by a provider's individual finding. */\nexport function localFindingRepositories(\n provider: Provider,\n finding: ExternalFinding,\n): ExternalSourceRepository[] {\n const { evidence } = finding;\n if (provider === \"snyk\")\n return snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url }));\n if (provider === \"endor\")\n return endorRepositoryUrls(evidence.source_data).map((url) => ({ url }));\n if (provider === \"wiz\") {\n const repository = wizFindingRepository(evidence);\n return repository ? [repository] : [];\n }\n if (provider === \"github\") {\n const url = dependabotRepository(finding);\n if (url) return [{ url, platform: \"github\" }];\n }\n return [];\n}\n\n/** Repository claims retained by the Semgrep SARIF reader. */\nexport function semgrepSarifRepositories(\n { evidence }: ExternalFinding,\n allowPartialCloudUrl = false,\n): { url: string; branch?: string }[] {\n const data = evidence.source_data;\n const document = data?.[\"documentContext\"];\n const driver = data?.[\"driverContext\"];\n const partial = allowPartialCloudUrl && document === undefined;\n if (\n (!partial && (!isRecord(document) || document[\"version\"] !== \"2.1.0\")) ||\n !isRecord(driver) ||\n typeof driver[\"name\"] !== \"string\" ||\n !isSemgrepSarifDriver(driver[\"name\"]) ||\n !isRecord(data?.[\"result\"])\n )\n return [];\n const context = data[\"runContext\"];\n const references = isRecord(context)\n ? context[\"versionControlProvenance\"]\n : undefined;\n return Array.isArray(references)\n ? references.flatMap((reference) =>\n isRecord(reference) &&\n typeof reference[\"repositoryUri\"] === \"string\" &&\n reference[\"repositoryUri\"].trim()\n ? [\n {\n url: reference[\"repositoryUri\"],\n ...(!partial &&\n typeof reference[\"branch\"] === \"string\" && {\n branch: reference[\"branch\"],\n }),\n },\n ]\n : [],\n )\n : [];\n}\n\n/** A run may name a repository even when it produces no findings. */\nfunction sarifFileRepositories(\n input: unknown,\n producer: \"Endor\" | \"Semgrep\" | \"Snyk\",\n) {\n if (\n isRecord(input) &&\n input[\"version\"] === \"2.1.0\" &&\n Array.isArray(input[\"runs\"])\n )\n return input[\"runs\"].flatMap((run) => sarifRunRepositories(run, producer));\n}\n\n/** Repository claims from every project or SARIF run, even those with no findings. */\nexport function snykFileRepositories(input: unknown) {\n return (\n sarifFileRepositories(input, \"Snyk\") ?? emptySnykReportRepositories(input)\n );\n}\n\n/** @internal Read vendor evidence for the local and Cloud import entrypoints. */\nexport async function readExternalFindings(\n path: string,\n options: ExternalFindingsReaderOptions,\n target: ExternalImportTarget = \"cloud\",\n references: readonly ExternalSourceRepository[] = [],\n): Promise<ReadExternalFindings> {\n const { provider } = options;\n const url = options.sourceRepositoryUrl ?? \"\";\n // Both projections describe the same captured rows, including exclusions.\n function withReplay(\n findings: ExternalFindings,\n couldDiffer: (findings: ExternalFindings) => boolean,\n previous: () => ExternalFindings,\n ): ReadExternalFindings {\n return {\n findings,\n previousFindings:\n target === \"cloud\" && couldDiffer(findings) ? previous : undefined,\n };\n }\n if (provider === \"tenable\") {\n if (target === \"cloud\") requireCloudReader(options);\n return { findings: await readTenableFindings(path, url) };\n }\n if (provider === \"sonar\") {\n const findings = await readSonarFindings(path, url, target);\n const binding = findings.report?.[\"repositoryUrl\"];\n return {\n findings,\n sourceRepositories: typeof binding === \"string\" ? [{ url: binding }] : [],\n };\n }\n if (provider === \"opengrep\" || provider === \"checkmarx\") {\n const findings =\n provider === \"opengrep\"\n ? await readOpenGrepFindings(path, { sourceRepositoryUrl: url }, target)\n : await readCheckmarxFindings(path, url, target);\n return { findings, sourceRepositories: [{ url }] };\n }\n if (provider === \"snyk\") {\n const input = await readSnykReport(path);\n const findings = await normalizeSnykFile(input, target, references);\n return { findings, sourceRepositories: snykFileRepositories(input) };\n }\n if (provider === \"semgrep\") {\n const input = await readSemgrepReport(path);\n const findings = normalizeSemgrepFindings(\n input,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl,\n sourceRepositories: references,\n },\n target,\n );\n if (semgrepPlatformReportRepository(findings)) return { findings };\n const sourceRepositories = sarifFileRepositories(input, \"Semgrep\") ?? [];\n if (!sourceRepositories.length && options.sourceRepositoryUrl)\n sourceRepositories.push({ url: options.sourceRepositoryUrl });\n return { findings, sourceRepositories };\n }\n if (provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n if (provider === \"wiz\") {\n const wiz =\n target === \"local\"\n ? await readLocalWizFindings(path)\n : await readVendorFindingsForPublication(path, target);\n const sourceRepositories = wiz.current.findings.flatMap((finding) =>\n localFindingRepositories(\"wiz\", finding),\n );\n return {\n findings: wiz.current,\n ...(\"legacy\" in wiz && { publication: wiz }),\n sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],\n };\n }\n const input = await readScannerJson(path);\n if (provider === \"trivy\") {\n const args = [input, target, options.trivyScanRoot] as const;\n return withReplay(\n normalizeTrivyFindings(...args),\n needsPreviousTrivyProjection,\n () => normalizePreviousTrivyFindings(...args),\n );\n }\n if (provider === \"endor\") {\n const findings = normalizeEndorFindings(input, target);\n return {\n ...withReplay(findings, hasPreviousCloudProjection, () =>\n normalizePreviousEndorFindings(input, target),\n ),\n sourceRepositories:\n sarifFileRepositories(input, \"Endor\") ??\n findings.findings.flatMap((row) =>\n localFindingRepositories(provider, row),\n ),\n };\n }\n const [normalize, previous, couldDiffer] = (\n {\n inspector: [\n normalizeInspectorFindings,\n normalizePreviousInspectorFindings,\n () => true,\n ],\n continuum: [\n normalizeContinuumFindings,\n normalizePreviousContinuumFindings,\n () => !Array.isArray(input),\n ],\n blackduck: [\n normalizeBlackDuckFindings,\n normalizePreviousBlackDuckFindings,\n needsPreviousBlackDuckProjection,\n ],\n veracode: [\n normalizeVeracodeFindings,\n normalizePreviousVeracodeFindings,\n hasPreviousCloudProjection,\n ],\n } as const\n )[provider];\n const args = [input, url, target, options.inspectorProjectMap] as const;\n return {\n ...withReplay(normalize(...args), couldDiffer, () => previous(...args)),\n sourceRepositories: [{ url }],\n };\n}\n"]}
1
+ {"version":3,"file":"external-findings-read.js","s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EAAE,CAChC,wBAAwB,CAAC,QAAQ,EAAE,GAAG,CAAC,CACxC;SACJ,CAAC;IACJ,CAAC;IACD,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,0BAA0B,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,qBAAqB,CAAC,CAAC;QACzD,OAAO;YACL,QAAQ;YACR,kBAAkB,EAAE;gBAClB,EAAE,GAAG,EAAE,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE;aACrD;SACF,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG;QAChB,SAAS,EAAE,0BAA0B;QACrC,SAAS,EAAE,0BAA0B;QACrC,QAAQ,EAAE,yBAAyB;KACpC,CAAC,QAAQ,CAAC,CAAC;IACZ,OAAO;QACL,QAAQ,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC;QACpE,kBAAkB,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFinding,\n ExternalFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport { readScannerJson, sarifRunRepositories } from \"./scanner-import.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport { readTenableFindings } from \"./tenable-findings.js\";\nimport { readCrowdStrikeFindings } from \"./crowdstrike-findings.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport {\n normalizeSnykFile,\n emptySnykReportRepositories,\n snykRepositoryUrls,\n} from \"./snyk-findings.js\";\nimport {\n isSemgrepSarifDriver,\n normalizeSemgrepFindings,\n readSemgrepReport,\n} from \"./semgrep-findings.js\";\nimport { semgrepPlatformReportRepository } from \"./semgrep-platform-findings.js\";\nimport { normalizeTrivyFindings } from \"./trivy-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport {\n normalizeEndorFindings,\n endorRepositoryUrls,\n} from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { readSonarFindings } from \"./sonar-findings.js\";\nimport { normalizeVeracodeFindings } from \"./veracode-findings.js\";\nimport { normalizeBlackDuckFindings } from \"./blackduck-findings.js\";\nimport { normalizeContinuumFindings } from \"./continuum-findings.js\";\nimport { readCheckmarxFindings } from \"./checkmarx-findings.js\";\nimport { normalizeInspectorFindings } from \"./inspector-findings.js\";\nimport { isRecord } from \"./record.js\";\nimport { readWizSelection, wizFindingRepository } from \"./wiz-findings.js\";\nimport { normalizeArmorCodeFindings } from \"./armorcode-findings.js\";\n\n/** Readers whose findings Cloud does not accept, with their display names. */\nexport const LOCAL_ONLY_PROVIDERS = {\n tenable: \"Tenable\",\n crowdstrike: \"CrowdStrike\",\n} as const;\ntype LocalOnlyProvider = keyof typeof LOCAL_ONLY_PROVIDERS;\n\nexport type LocalFindingProvider = Provider | LocalOnlyProvider;\n\n/** File reader names mapped to the provider stored with each finding. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n armorcode: \"armorcode\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n trivy: \"trivy\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n inspector: \"inspector\",\n blackduck: \"blackduck\",\n veracode: \"veracode\",\n sonar: \"sonar\",\n continuum: \"continuum\",\n checkmarx: \"checkmarx\",\n tenable: \"tenable\",\n crowdstrike: \"crowdstrike\",\n} as const satisfies Record<string, LocalFindingProvider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\nexport type CloudFindingsReader = Exclude<\n ExternalFindingsReader,\n LocalOnlyProvider\n>;\n\nexport function requireCloudReader(\n options: ExternalFindingsReaderOptions,\n): asserts options is ExternalFindingsReaderOptions & {\n provider: CloudFindingsReader;\n} {\n if (Object.hasOwn(LOCAL_ONLY_PROVIDERS, options.provider))\n throw new CodexSecurityError(\n `${LOCAL_ONLY_PROVIDERS[options.provider as LocalOnlyProvider]} findings require a local import (--to local).`,\n );\n}\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK. Cloud supports a subset of these readers. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n inspectorProjectMap?: ReadonlyMap<string, string>;\n trivyScanRoot?: string;\n}\n\n/** @internal Normalized file contents and any repository claims supplied by its reader. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n sourceRepositories?: ExternalSourceRepository[];\n}\n\n/** Repository references retained by a provider's individual finding. */\nexport function localFindingRepositories(\n provider: Provider,\n finding: ExternalFinding,\n): ExternalSourceRepository[] {\n const { evidence } = finding;\n if (provider === \"snyk\")\n return snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url }));\n if (provider === \"endor\")\n return endorRepositoryUrls(evidence.source_data).map((url) => ({ url }));\n if (provider === \"wiz\") {\n const repository = wizFindingRepository(evidence);\n return repository ? [repository] : [];\n }\n if (provider === \"github\") {\n const url = dependabotRepository(finding);\n if (url) return [{ url, platform: \"github\" }];\n }\n return [];\n}\n\n/** Repository claims retained by the Semgrep SARIF reader. */\nexport function semgrepSarifRepositories(\n { evidence }: ExternalFinding,\n allowPartialCloudUrl = false,\n): { url: string; branch?: string }[] {\n const data = evidence.source_data;\n const document = data?.[\"documentContext\"];\n const driver = data?.[\"driverContext\"];\n const partial = allowPartialCloudUrl && document === undefined;\n if (\n (!partial && (!isRecord(document) || document[\"version\"] !== \"2.1.0\")) ||\n !isRecord(driver) ||\n typeof driver[\"name\"] !== \"string\" ||\n !isSemgrepSarifDriver(driver[\"name\"]) ||\n !isRecord(data?.[\"result\"])\n )\n return [];\n const context = data[\"runContext\"];\n const references = isRecord(context)\n ? context[\"versionControlProvenance\"]\n : undefined;\n return Array.isArray(references)\n ? references.flatMap((reference) =>\n isRecord(reference) &&\n typeof reference[\"repositoryUri\"] === \"string\" &&\n reference[\"repositoryUri\"].trim()\n ? [\n {\n url: reference[\"repositoryUri\"],\n ...(!partial &&\n typeof reference[\"branch\"] === \"string\" && {\n branch: reference[\"branch\"],\n }),\n },\n ]\n : [],\n )\n : [];\n}\n\n/** A run may name a repository even when it produces no findings. */\nfunction sarifFileRepositories(\n input: unknown,\n producer: \"Endor\" | \"Semgrep\" | \"Snyk\",\n) {\n if (\n isRecord(input) &&\n input[\"version\"] === \"2.1.0\" &&\n Array.isArray(input[\"runs\"])\n )\n return input[\"runs\"].flatMap((run) => sarifRunRepositories(run, producer));\n}\n\n/** Repository claims from every project or SARIF run, even those with no findings. */\nexport function snykFileRepositories(input: unknown) {\n return (\n sarifFileRepositories(input, \"Snyk\") ?? emptySnykReportRepositories(input)\n );\n}\n\n/** @internal Read vendor evidence for the local and Cloud import entrypoints. */\nexport async function readExternalFindings(\n path: string,\n options: ExternalFindingsReaderOptions,\n target: ExternalImportTarget = \"cloud\",\n references: readonly ExternalSourceRepository[] = [],\n): Promise<ReadExternalFindings> {\n const { provider } = options;\n const url = options.sourceRepositoryUrl ?? \"\";\n if (provider === \"tenable\") {\n if (target === \"cloud\") requireCloudReader(options);\n return { findings: await readTenableFindings(path, url) };\n }\n if (provider === \"crowdstrike\") {\n if (target === \"cloud\") requireCloudReader(options);\n return {\n findings: await readCrowdStrikeFindings(\n path,\n options.sourceRepositoryUrl,\n ),\n };\n }\n if (provider === \"sonar\") {\n const findings = await readSonarFindings(path, url, target);\n const binding = findings.report?.[\"repositoryUrl\"];\n return {\n findings,\n sourceRepositories: typeof binding === \"string\" ? [{ url: binding }] : [],\n };\n }\n if (provider === \"opengrep\" || provider === \"checkmarx\") {\n const findings =\n provider === \"opengrep\"\n ? await readOpenGrepFindings(path, { sourceRepositoryUrl: url }, target)\n : await readCheckmarxFindings(path, url, target);\n return { findings, sourceRepositories: [{ url }] };\n }\n if (provider === \"snyk\") {\n const input = await readScannerJson(path);\n const findings = await normalizeSnykFile(input, target, references);\n return { findings, sourceRepositories: snykFileRepositories(input) };\n }\n if (provider === \"semgrep\") {\n const input = await readSemgrepReport(path);\n const findings = normalizeSemgrepFindings(\n input,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl,\n sourceRepositories: references,\n },\n target,\n );\n if (semgrepPlatformReportRepository(findings)) return { findings };\n const sourceRepositories = sarifFileRepositories(input, \"Semgrep\") ?? [];\n if (!sourceRepositories.length && options.sourceRepositoryUrl)\n sourceRepositories.push({ url: options.sourceRepositoryUrl });\n return { findings, sourceRepositories };\n }\n if (provider === \"armorcode\") {\n const input = await readScannerJson(path);\n return {\n findings: normalizeArmorCodeFindings(\n input,\n target,\n options.sourceRepositoryUrl,\n ),\n };\n }\n if (provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n if (provider === \"wiz\") {\n const wiz = await readWizSelection(path, target);\n const sourceRepositories = wiz.findings.findings.flatMap((finding) =>\n localFindingRepositories(\"wiz\", finding),\n );\n return {\n findings: wiz.findings,\n sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],\n };\n }\n const input = await readScannerJson(path);\n if (provider === \"trivy\")\n return {\n findings: normalizeTrivyFindings(input, target, options.trivyScanRoot),\n };\n if (provider === \"endor\") {\n const findings = normalizeEndorFindings(input, target);\n return {\n findings,\n sourceRepositories:\n sarifFileRepositories(input, \"Endor\") ??\n findings.findings.flatMap((row) =>\n localFindingRepositories(provider, row),\n ),\n };\n }\n if (provider === \"continuum\") {\n const findings = normalizeContinuumFindings(input, url, target);\n const binding = findings.report?.[\"sourceRepositoryUrl\"];\n return {\n findings,\n sourceRepositories: [\n { url: typeof binding === \"string\" ? binding : url },\n ],\n };\n }\n const normalize = {\n inspector: normalizeInspectorFindings,\n blackduck: normalizeBlackDuckFindings,\n veracode: normalizeVeracodeFindings,\n }[provider];\n return {\n findings: normalize(input, url, target, options.inspectorProjectMap),\n sourceRepositories: [{ url }],\n };\n}\n"]}
@@ -35,7 +35,7 @@ export declare class NoPublishableFindingsError extends CodexSecurityError {
35
35
  export declare function reportForJson(report: ExternalFindings["report"]): Record<string, unknown> | undefined;
36
36
  export declare const nativeErrorStackGetter: (() => any) | undefined;
37
37
  /** Capture the caller's import settings before reading an export or resolving its destination. */
38
- export declare function snapshotImportOptions<P extends LocalExternalImportOptions["provider"]>({ repository, provider, sourceKey, sourceRepositoryUrl, trivyScanRoot, inspectorProjectMap, }: LocalExternalImportOptions & {
38
+ export declare function snapshotImportOptions<P extends string>({ repository, provider, sourceKey, sourceRepositoryUrl, trivyScanRoot, inspectorProjectMap, }: Omit<LocalExternalImportOptions, "provider"> & {
39
39
  provider: P;
40
40
  }): {
41
41
  repository: string;
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAQhF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,iFAAiF;AACjF,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,uBAAuB,CAAC;CACnC;AAED,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAChC;AAED,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,SAAS,wBAAwB,EAAO,GACnD,wBAAwB,EAAE,CAE5B;AAED,M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tD,UAAU,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GACpB,EAAE,IAAI,CAAC,0BAA0B,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,CAAC,CAAA;CAAE;;;;;;;EAqBhE"}
@@ -69,7 +69,7 @@ function cloneScannerDiagnostic(source) {
69
69
  }
70
70
  }
71
71
  /** @internal Capture fresh input once, so preview, limits and storage use the same JSON. */
72
- export function snapshotNormalizedFindings(input, checkEvidenceNumber = (value) => requireJsonNumber(value, "Evidence"), target = "local") {
72
+ export function snapshotNormalizedFindings(input, checkEvidenceNumber = (value) => requireJsonNumber(value, "Evidence"), target = "local", provider) {
73
73
  const fields = new Map();
74
74
  const errors = [];
75
75
  let root;
@@ -135,6 +135,17 @@ export function snapshotNormalizedFindings(input, checkEvidenceNumber = (value)
135
135
  Object.defineProperties(error, Object.getOwnPropertyDescriptors(parent[key]));
136
136
  parent[key] = error;
137
137
  }
138
+ // Reader scope can live on a getter. Do not evaluate enumerable getters twice.
139
+ if (provider !== undefined) {
140
+ const keys = ["sourceFormat", "semgrepPlatformScope", "snykRestContext"];
141
+ if (provider === "semgrep" || provider === "snyk")
142
+ keys.push("sourceRepositoryUrl", "sourceRepositoryPlatform");
143
+ for (const key of keys)
144
+ if (!(key in result) &&
145
+ key in input &&
146
+ !Object.prototype.propertyIsEnumerable.call(input, key))
147
+ result[key] = structuredClone(Reflect.get(input, key));
148
+ }
138
149
  return result;
139
150
  }
140
151
  /** @internal Clone owned values without serializing the evidence again in every preview view. */
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings.js","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB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,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC;AAUD,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAEnC,EACA,UAAU,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,mBAAmB,GAC0B;IAC7C,IAAI,QAAQ,KAAK,OAAO,IAAI,mBAAmB,KAAK,SAAS;QAC3D,MAAM,IAAI,kBAAkB,CAC1B,2FAA2F,CAC5F,CAAC;IACJ,IAAI,aAAa,KAAK,SAAS,IAAI,QAAQ,KAAK,OAAO;QACrD,MAAM,IAAI,kBAAkB,CAC1B,qDAAqD,CACtD,CAAC;IACJ,IAAI,mBAAmB,KAAK,SAAS,IAAI,QAAQ,KAAK,WAAW;QAC/D,MAAM,IAAI,kBAAkB,CAC1B,2DAA2D,CAC5D,CAAC;IACJ,OAAO;QACL,UAAU;QACV,QAAQ;QACR,SAAS;QACT,mBAAmB;QACnB,aAAa;QACb,mBAAmB,EAAE,mBAAmB,IAAI,IAAI,GAAG,CAAC,mBAAmB,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["import { isNativeError, isNumberObject } from \"node:util/types\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport type { LocalExternalImportOptions } from \"./external-findings-import.js\";\nimport {\n checkEmittedJsonNumber,\n checkReportNumber,\n requireCloudEvidenceDepth,\n requireJsonNumber,\n type ExternalImportTarget,\n} from \"./external-import-contract.js\";\nimport type { ExternalFindingEvidence } from \"./external-import-models.js\";\n\n/** A provider occurrence and its evidence, independent of a Codex assessment. */\nexport interface ExternalFinding {\n source_finding_id: string;\n evidence: ExternalFindingEvidence;\n}\n\n/** Repository provenance retained by a reader outside the published evidence. */\nexport interface ExternalSourceRepository {\n url: string;\n platform?: \"github\" | \"gitlab\";\n}\n\nexport function snapshotSourceRepositories(\n references: readonly ExternalSourceRepository[] = [],\n): ExternalSourceRepository[] {\n return references.map(({ url, platform }) => ({ url, platform }));\n}\n\nexport interface ExternalFindings {\n read: number;\n /** Reader-retained run metadata, including diagnostics for empty reports. */\n report?: Record<string, unknown>;\n findings: ExternalFinding[];\n excluded: {\n position: number;\n source_finding_id: string | null;\n reason: string;\n }[];\n}\n\nexport function hasNoExternalRecords(input: ExternalFindings): boolean {\n return input.read === 0 && !input.findings.length && !input.excluded.length;\n}\n\n/** Classify a reader selection before deciding whether to store, publish, or report it. */\nexport function externalImportDisposition(\n input: ExternalFindings,\n): \"ready\" | \"empty\" | \"excluded\" | \"failed\" {\n if (input.findings.length) return \"ready\";\n const errors = input.report?.[\"errors\"];\n if (Array.isArray(errors) && errors.length) return \"failed\";\n if (hasNoExternalRecords(input)) return \"empty\";\n return input.read === input.excluded.length ? \"excluded\" : \"failed\";\n}\n\n/** No findings can be imported. The selection retains every reader exclusion and diagnostic. */\nexport class NoPublishableFindingsError extends CodexSecurityError {\n readonly summary: string;\n\n constructor(public readonly selection: ExternalFindings) {\n const diagnostics = reportForJson(selection.report)?.[\"errors\"];\n const summary =\n externalImportDisposition(selection) === \"empty\"\n ? \"No supported findings are ready to publish: the report is empty.\"\n : `No supported findings are ready to publish (${selection.read} read, ${selection.excluded.length} excluded).${Array.isArray(diagnostics) && diagnostics.length ? ` Scanner diagnostics: ${JSON.stringify(diagnostics)}` : \"\"}`;\n const reasons = selection.excluded.map(\n (item) => `Item ${item.position}: ${item.reason}`,\n );\n super([summary, ...reasons].join(\" \"));\n this.summary = summary;\n }\n}\n\nexport function reportForJson(report: ExternalFindings[\"report\"]) {\n const errors = report?.[\"errors\"];\n if (!Array.isArray(errors)) return report;\n const json = JSON.stringify(errors, (_key, entry: unknown) =>\n entry instanceof Error ? { ...entry, message: entry.message } : entry,\n );\n return { ...report, errors: JSON.parse(json) as unknown[] };\n}\n\nconst isScannerError = Error.isError ?? isNativeError;\nexport const nativeErrorStackGetter = Object.getOwnPropertyDescriptor(\n new Error(),\n \"stack\",\n)?.get;\n\nfunction cloneScannerDiagnostic(source: Error): Error {\n const message = Object.getOwnPropertyDescriptor(source, \"message\");\n const stack = Object.getOwnPropertyDescriptor(source, \"stack\");\n try {\n if (\n (!message || Object.hasOwn(message, \"value\")) &&\n (!stack?.get || stack.get === nativeErrorStackGetter)\n )\n return structuredClone(source);\n // Keep the native error type and data-valued cause without running a\n // caller-supplied message or stack getter while restoring diagnostics.\n const cause = Object.getOwnPropertyDescriptor(source, \"cause\");\n const clean = new Error(message?.value, { cause: cause?.value });\n const name = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(source),\n \"name\",\n )?.value;\n if (typeof name === \"string\") clean.name = name;\n if (!message?.get && nativeErrorStackGetter) {\n const nativeStack: unknown = nativeErrorStackGetter.call(source);\n if (typeof nativeStack === \"string\") clean.stack = nativeStack;\n }\n return structuredClone(clean);\n } catch {\n // A noncloneable cause does not prevent JSON export.\n return new Error(message?.value);\n }\n}\n\n/** @internal Capture fresh input once, so preview, limits and storage use the same JSON. */\nexport function snapshotNormalizedFindings<T extends Partial<ExternalFindings>>(\n input: T,\n checkEvidenceNumber = (value: number) => requireJsonNumber(value, \"Evidence\"),\n target: ExternalImportTarget = \"local\",\n): T {\n const fields = new Map<string, unknown>();\n const errors: { path: string[]; error: Error }[] = [];\n let root: unknown;\n\n function captureField(field: string, observed: unknown): string | undefined {\n const parents: { key: string; value: object }[] = [];\n // The outer traversal already called this field's toJSON with its real key.\n // Returning that value from the wrapper keeps JSON from calling it twice.\n return JSON.stringify(\n { toJSON: () => observed },\n function (this: object, key, value: unknown) {\n while (parents.length && parents.at(-1)!.value !== this) parents.pop();\n const evidence = field === \"findings\" && parents[2]?.key === \"evidence\";\n if (evidence && target === \"cloud\")\n requireCloudEvidenceDepth(parents.length - 2, this, value);\n if (isNumberObject(value)) value = +value;\n if (field === \"report\") checkReportNumber(value);\n if (evidence) checkEmittedJsonNumber(value, checkEvidenceNumber);\n if (value !== null && typeof value === \"object\") {\n if (value === root) {\n const path = [field, ...parents.slice(1).map((p) => p.key)];\n if (parents.length) path.push(key);\n throw new TypeError(\n `Converting circular structure to JSON at ${JSON.stringify(path)}`,\n );\n }\n if (\n field === \"report\" &&\n parents[1]?.key === \"errors\" &&\n Array.isArray(parents[1].value) &&\n isScannerError(value)\n ) {\n errors.push({\n path: [field, ...parents.slice(1).map((p) => p.key), key],\n error: value,\n });\n }\n parents.push({ key, value });\n }\n return value;\n },\n );\n }\n\n // Capture each member in native property order. A report and a findings\n // payload can each fit in a string while their combined JSON does not.\n const envelope = JSON.stringify(\n input,\n function (this: object, field, value: unknown) {\n if (this !== root) {\n root = value;\n return value;\n }\n const json = captureField(field, value);\n if (json === undefined) return undefined;\n fields.set(field, JSON.parse(json));\n return null;\n },\n );\n const result = JSON.parse(envelope);\n for (const [key, value] of fields) result[key] = value;\n for (const { path, error: source } of errors) {\n const key = path.pop()!;\n let parent = result as unknown as Record<string, unknown>;\n for (const field of path) parent = parent[field] as Record<string, unknown>;\n const error = cloneScannerDiagnostic(source);\n Object.defineProperties(\n error,\n Object.getOwnPropertyDescriptors(parent[key] as object),\n );\n parent[key] = error;\n }\n return result;\n}\n\n/** @internal Clone owned values without serializing the evidence again in every preview view. */\nexport function cloneImportPreview<T extends ExternalFindings>(input: T): T {\n if (input.report === undefined) return structuredClone(input);\n return {\n ...structuredClone({ ...input, report: undefined }),\n ...snapshotNormalizedFindings({ report: input.report }),\n };\n}\n\n/** @internal Keep earlier provider projections only for immutable request replay. */\nexport interface ExternalPublicationInput {\n current: ExternalFindings;\n legacy: ExternalFindings;\n currentIdentity: unknown;\n legacyIdentity: unknown;\n}\n\n/** Capture the caller's import settings before reading an export or resolving its destination. */\nexport function snapshotImportOptions<\n P extends LocalExternalImportOptions[\"provider\"],\n>({\n repository,\n provider,\n sourceKey,\n sourceRepositoryUrl,\n trivyScanRoot,\n inspectorProjectMap,\n}: LocalExternalImportOptions & { provider: P }) {\n if (provider === \"trivy\" && sourceRepositoryUrl !== undefined)\n throw new CodexSecurityError(\n \"Trivy reads repository provenance from the report; do not supply --source-repository-url.\",\n );\n if (trivyScanRoot !== undefined && provider !== \"trivy\")\n throw new CodexSecurityError(\n \"--trivy-scan-root applies only to --provider trivy.\",\n );\n if (inspectorProjectMap !== undefined && provider !== \"inspector\")\n throw new CodexSecurityError(\n \"An Inspector project map requires the inspector provider.\",\n );\n return {\n repository,\n provider,\n sourceKey,\n sourceRepositoryUrl,\n trivyScanRoot,\n inspectorProjectMap: inspectorProjectMap && new Map(inspectorProjectMap),\n };\n}\n"]}
1
+ {"version":3,"file":"external-findings.js","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AAevC,MAAM,UAAU,0BAA0B,CACxC,UAAU,GAAwC,EAAE;IAEpD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC;AAcD,MAAM,UAAU,oBAAoB,CAAC,KAAuB;IAC1D,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC9E,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,yBAAyB,CACvC,KAAuB;IAEvB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM;QAAE,OAAO,QAAQ,CAAC;IAC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ACnB,aAAa,EACb,mBAAmB,GAC4C;IAC/D,IAAI,QAAQ,KAAK,OAAO,IAAI,mBAAmB,KAAK,SAAS;QAC3D,MAAM,IAAI,kBAAkB,CAC1B,2FAA2F,CAC5F,CAAC;IACJ,IAAI,aAAa,KAAK,SAAS,IAAI,QAAQ,KAAK,OAAO;QACrD,MAAM,IAAI,kBAAkB,CAC1B,qDAAqD,CACtD,CAAC;IACJ,IAAI,mBAAmB,KAAK,SAAS,IAAI,QAAQ,KAAK,WAAW;QAC/D,MAAM,IAAI,kBAAkB,CAC1B,2DAA2D,CAC5D,CAAC;IACJ,OAAO;QACL,UAAU;QACV,QAAQ;QACR,SAAS;QACT,mBAAmB;QACnB,aAAa;QACb,mBAAmB,EAAE,mBAAmB,IAAI,IAAI,GAAG,CAAC,mBAAmB,CAAC;KACzE,CAAC;AACJ,CAAC","sourcesContent":["import { isNativeError, isNumberObject } from \"node:util/types\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport type { LocalExternalImportOptions } from \"./external-findings-import.js\";\nimport {\n checkEmittedJsonNumber,\n checkReportNumber,\n requireCloudEvidenceDepth,\n requireJsonNumber,\n type ExternalImportTarget,\n} from \"./external-import-contract.js\";\nimport type { ExternalFindingEvidence } from \"./external-import-models.js\";\n\n/** A provider occurrence and its evidence, independent of a Codex assessment. */\nexport interface ExternalFinding {\n source_finding_id: string;\n evidence: ExternalFindingEvidence;\n}\n\n/** Repository provenance retained by a reader outside the published evidence. */\nexport interface ExternalSourceRepository {\n url: string;\n platform?: \"github\" | \"gitlab\";\n}\n\nexport function snapshotSourceRepositories(\n references: readonly ExternalSourceRepository[] = [],\n): ExternalSourceRepository[] {\n return references.map(({ url, platform }) => ({ url, platform }));\n}\n\nexport interface ExternalFindings {\n read: number;\n /** Reader-retained run metadata, including diagnostics for empty reports. */\n report?: Record<string, unknown>;\n findings: ExternalFinding[];\n excluded: {\n position: number;\n source_finding_id: string | null;\n reason: string;\n }[];\n}\n\nexport function hasNoExternalRecords(input: ExternalFindings): boolean {\n return input.read === 0 && !input.findings.length && !input.excluded.length;\n}\n\n/** Classify a reader selection before deciding whether to store, publish, or report it. */\nexport function externalImportDisposition(\n input: ExternalFindings,\n): \"ready\" | \"empty\" | \"excluded\" | \"failed\" {\n if (input.findings.length) return \"ready\";\n const errors = input.report?.[\"errors\"];\n if (Array.isArray(errors) && errors.length) return \"failed\";\n if (hasNoExternalRecords(input)) return \"empty\";\n return input.read === input.excluded.length ? \"excluded\" : \"failed\";\n}\n\n/** No findings can be imported. The selection retains every reader exclusion and diagnostic. */\nexport class NoPublishableFindingsError extends CodexSecurityError {\n readonly summary: string;\n\n constructor(public readonly selection: ExternalFindings) {\n const diagnostics = reportForJson(selection.report)?.[\"errors\"];\n const summary =\n externalImportDisposition(selection) === \"empty\"\n ? \"No supported findings are ready to publish: the report is empty.\"\n : `No supported findings are ready to publish (${selection.read} read, ${selection.excluded.length} excluded).${Array.isArray(diagnostics) && diagnostics.length ? ` Scanner diagnostics: ${JSON.stringify(diagnostics)}` : \"\"}`;\n const reasons = selection.excluded.map(\n (item) => `Item ${item.position}: ${item.reason}`,\n );\n super([summary, ...reasons].join(\" \"));\n this.summary = summary;\n }\n}\n\nexport function reportForJson(report: ExternalFindings[\"report\"]) {\n const errors = report?.[\"errors\"];\n if (!Array.isArray(errors)) return report;\n const json = JSON.stringify(errors, (_key, entry: unknown) =>\n entry instanceof Error ? { ...entry, message: entry.message } : entry,\n );\n return { ...report, errors: JSON.parse(json) as unknown[] };\n}\n\nconst isScannerError = Error.isError ?? isNativeError;\nexport const nativeErrorStackGetter = Object.getOwnPropertyDescriptor(\n new Error(),\n \"stack\",\n)?.get;\n\nfunction cloneScannerDiagnostic(source: Error): Error {\n const message = Object.getOwnPropertyDescriptor(source, \"message\");\n const stack = Object.getOwnPropertyDescriptor(source, \"stack\");\n try {\n if (\n (!message || Object.hasOwn(message, \"value\")) &&\n (!stack?.get || stack.get === nativeErrorStackGetter)\n )\n return structuredClone(source);\n // Keep the native error type and data-valued cause without running a\n // caller-supplied message or stack getter while restoring diagnostics.\n const cause = Object.getOwnPropertyDescriptor(source, \"cause\");\n const clean = new Error(message?.value, { cause: cause?.value });\n const name = Object.getOwnPropertyDescriptor(\n Object.getPrototypeOf(source),\n \"name\",\n )?.value;\n if (typeof name === \"string\") clean.name = name;\n if (!message?.get && nativeErrorStackGetter) {\n const nativeStack: unknown = nativeErrorStackGetter.call(source);\n if (typeof nativeStack === \"string\") clean.stack = nativeStack;\n }\n return structuredClone(clean);\n } catch {\n // A noncloneable cause does not prevent JSON export.\n return new Error(message?.value);\n }\n}\n\n/** @internal Capture fresh input once, so preview, limits and storage use the same JSON. */\nexport function snapshotNormalizedFindings<T extends Partial<ExternalFindings>>(\n input: T,\n checkEvidenceNumber = (value: number) => requireJsonNumber(value, \"Evidence\"),\n target: ExternalImportTarget = \"local\",\n provider?: string,\n): T {\n const fields = new Map<string, unknown>();\n const errors: { path: string[]; error: Error }[] = [];\n let root: unknown;\n\n function captureField(field: string, observed: unknown): string | undefined {\n const parents: { key: string; value: object }[] = [];\n // The outer traversal already called this field's toJSON with its real key.\n // Returning that value from the wrapper keeps JSON from calling it twice.\n return JSON.stringify(\n { toJSON: () => observed },\n function (this: object, key, value: unknown) {\n while (parents.length && parents.at(-1)!.value !== this) parents.pop();\n const evidence = field === \"findings\" && parents[2]?.key === \"evidence\";\n if (evidence && target === \"cloud\")\n requireCloudEvidenceDepth(parents.length - 2, this, value);\n if (isNumberObject(value)) value = +value;\n if (field === \"report\") checkReportNumber(value);\n if (evidence) checkEmittedJsonNumber(value, checkEvidenceNumber);\n if (value !== null && typeof value === \"object\") {\n if (value === root) {\n const path = [field, ...parents.slice(1).map((p) => p.key)];\n if (parents.length) path.push(key);\n throw new TypeError(\n `Converting circular structure to JSON at ${JSON.stringify(path)}`,\n );\n }\n if (\n field === \"report\" &&\n parents[1]?.key === \"errors\" &&\n Array.isArray(parents[1].value) &&\n isScannerError(value)\n ) {\n errors.push({\n path: [field, ...parents.slice(1).map((p) => p.key), key],\n error: value,\n });\n }\n parents.push({ key, value });\n }\n return value;\n },\n );\n }\n\n // Capture each member in native property order. A report and a findings\n // payload can each fit in a string while their combined JSON does not.\n const envelope = JSON.stringify(\n input,\n function (this: object, field, value: unknown) {\n if (this !== root) {\n root = value;\n return value;\n }\n const json = captureField(field, value);\n if (json === undefined) return undefined;\n fields.set(field, JSON.parse(json));\n return null;\n },\n );\n const result = JSON.parse(envelope);\n for (const [key, value] of fields) result[key] = value;\n for (const { path, error: source } of errors) {\n const key = path.pop()!;\n let parent = result as unknown as Record<string, unknown>;\n for (const field of path) parent = parent[field] as Record<string, unknown>;\n const error = cloneScannerDiagnostic(source);\n Object.defineProperties(\n error,\n Object.getOwnPropertyDescriptors(parent[key] as object),\n );\n parent[key] = error;\n }\n // Reader scope can live on a getter. Do not evaluate enumerable getters twice.\n if (provider !== undefined) {\n const keys = [\"sourceFormat\", \"semgrepPlatformScope\", \"snykRestContext\"];\n if (provider === \"semgrep\" || provider === \"snyk\")\n keys.push(\"sourceRepositoryUrl\", \"sourceRepositoryPlatform\");\n for (const key of keys)\n if (\n !(key in result) &&\n key in input &&\n !Object.prototype.propertyIsEnumerable.call(input, key)\n )\n result[key] = structuredClone(Reflect.get(input, key));\n }\n return result;\n}\n\n/** @internal Clone owned values without serializing the evidence again in every preview view. */\nexport function cloneImportPreview<T extends ExternalFindings>(input: T): T {\n if (input.report === undefined) return structuredClone(input);\n return {\n ...structuredClone({ ...input, report: undefined }),\n ...snapshotNormalizedFindings({ report: input.report }),\n };\n}\n\n/** Capture the caller's import settings before reading an export or resolving its destination. */\nexport function snapshotImportOptions<P extends string>({\n repository,\n provider,\n sourceKey,\n sourceRepositoryUrl,\n trivyScanRoot,\n inspectorProjectMap,\n}: Omit<LocalExternalImportOptions, \"provider\"> & { provider: P }) {\n if (provider === \"trivy\" && sourceRepositoryUrl !== undefined)\n throw new CodexSecurityError(\n \"Trivy reads repository provenance from the report; do not supply --source-repository-url.\",\n );\n if (trivyScanRoot !== undefined && provider !== \"trivy\")\n throw new CodexSecurityError(\n \"--trivy-scan-root applies only to --provider trivy.\",\n );\n if (inspectorProjectMap !== undefined && provider !== \"inspector\")\n throw new CodexSecurityError(\n \"An Inspector project map requires the inspector provider.\",\n );\n return {\n repository,\n provider,\n sourceKey,\n sourceRepositoryUrl,\n trivyScanRoot,\n inspectorProjectMap: inspectorProjectMap && new Map(inspectorProjectMap),\n };\n}\n"]}
@@ -18,7 +18,6 @@ export declare function requireJsonNumber(value: number, label: string): void;
18
18
  export declare function validateExternalReport(report: Record<string, unknown> | undefined): void;
19
19
  export declare function validateCodeLineRange(firstLine: number | null | undefined, endLine: number | null | undefined): void;
20
20
  export declare function validateExternalEvidenceFields(input: unknown, target?: ExternalImportTarget): ExternalFindingEvidence;
21
- export declare function previousAdmission(value: object): "uncertain" | import("./external-import-models.js").ImportedFindingEvidence | null | undefined;
22
21
  /** Keep a valid native record when its optional structured fields exceed the target's bounds. */
23
22
  export declare function validateEnrichedExternalEvidence(evidence: Record<string, unknown>, target: ExternalImportTarget, ...projections: (Record<string, unknown> | undefined)[]): ExternalFindingEvidence;
24
23
  export declare function validateExternalEvidence(input: unknown, target?: ExternalImportTarget): ExternalFindingEvidence;
@@ -31,21 +30,17 @@ export declare class CloudEvidenceDepthError extends Error {
31
30
  }
32
31
  /** JSON omits these object properties, but emits null for the same array elements. */
33
32
  export declare function requireCloudEvidenceDepth(depth: number, holder: object, value: unknown): void;
33
+ export declare const CLOUD_EVIDENCE_BYTES: number;
34
+ export declare class CloudEvidenceSizeError extends Error {
35
+ constructor();
36
+ }
34
37
  /** Return the validated Cloud wire size, or zero for local evidence. */
35
- export declare function validateExternalEvidenceJson(input: unknown, target: ExternalImportTarget, additionalCloudBytes?: number, observe?: (previousBytes: number, currentBytes: number) => void): number;
36
- /** Reproduce the released SDK's checks on a detached native finding. */
37
- export declare function validatePreviousCloudEvidence(input: unknown): ExternalFindingEvidence;
38
+ export declare function validateExternalEvidenceJson(input: unknown, target: ExternalImportTarget, additionalCloudBytes?: number): number;
38
39
  /** Use the array index as toJSON's key, as when saving the supplied GitHub records. */
39
- export declare function exportedGitHubRecord(value: unknown, index: number, target: ExternalImportTarget, checkPreviousLocal?: boolean): {
40
+ export declare function exportedGitHubRecord(value: unknown, index: number, target: ExternalImportTarget): {
40
41
  record: unknown;
41
- bytes: number;
42
- adjustment: number;
43
- previousInvalid: unknown;
44
- skippedRawValue: boolean;
45
42
  invalid: unknown;
46
43
  };
47
- /** Combine the observed vendor bytes with the old native mapping's typed fields. */
48
- export declare function previousGitHubExclusion(evidence: ExternalFindingEvidence, sourceBytes: number, adjustment: number): string | undefined;
49
44
  export declare function validateImportRequest(input: unknown): FindingImportRequest;
50
45
  export {};
51
46
  //# sourceMappingURL=external-import-contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-import-contract.d.ts","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACb,MAAM,6BAA6B,CAAC;AAQrC,qFAAqF;AACrF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC;AAOrD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAe9C;;kFAEkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAatD;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AA4JD,eAAO,MAAM,qBAAqB,UA/BjB,OAAO,yBAiCvB,CAAC;AACF,eAAO,MAAM,oBAAoB,UAlChB,OAAO,yBAoCvB,CAAC;AACF,eAAO,MAAM,qBAAqB,UArCjB,OAAO,qBAsCyB,CAAC;AAClD,eAAO,MAAM,oBAAoB,UAvChB,OAAO,iBAuCmD,CAAC;AAG5E,wBAAgB,eAAe,CAAC,KAAK,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;IAChD,cAEC;CACF;AAED,sFAAsF;AACtF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,IAAI,CASN;AA+GD,wEAAwE;AACxE,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,oBAAoB,EAC5B,oBAAoB,SAAI,EACxB,OAAO,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,GAC9D,MAAM,CAyCR;AAED,wEAAwE;AACxE,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,OAAO,GACb,uBAAuB,CAQzB;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,oBAAoB,EAC5B,kBAAkB,UAAQ;;;;;;;EA+C3B;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,uBAAuB,EACjC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CASpB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAgB1E"}
1
+ {"version":3,"file":"external-import-contract.d.ts","sourceRoot":"","sources":["../src/external-import-contract.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,YAAY,EACb,MAAM,6BAA6B,CAAC;AAQrC,qFAAqF;AACrF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC;AAOrD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAe9C;;kFAEkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAatD;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE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