@openai/codex-security 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (396) hide show
  1. package/README.md +45 -57
  2. package/_bundled_plugin/.app.json +4 -0
  3. package/_bundled_plugin/.mcp.json +1 -0
  4. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
  7. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  13. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  14. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  15. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +46 -12
  16. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  17. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  18. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  19. package/_bundled_plugin/references/artifact-storage.md +1 -1
  20. package/_bundled_plugin/references/core-scan.md +14 -5
  21. package/_bundled_plugin/references/default-severity-rubric.md +28 -0
  22. package/_bundled_plugin/references/finding-detail-fields.md +1 -0
  23. package/_bundled_plugin/references/threat-model.md +1 -0
  24. package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
  25. package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
  26. package/_bundled_plugin/scripts/finding_preview.py +5 -29
  27. package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
  28. package/_bundled_plugin/scripts/report_projection.py +87 -136
  29. package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
  30. package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
  31. package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
  32. package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
  33. package/_bundled_plugin/scripts/workbench_cli.py +102 -13
  34. package/_bundled_plugin/scripts/workbench_constants.py +9 -0
  35. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
  36. package/_bundled_plugin/scripts/workbench_db.py +187 -363
  37. package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
  38. package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
  39. package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
  40. package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
  41. package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
  42. package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
  43. package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
  44. package/_bundled_plugin/scripts/workbench_schema.py +1 -1
  45. package/_bundled_plugin/scripts/workbench_setup.py +239 -0
  46. package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
  47. package/_bundled_plugin/scripts/workbench_target.py +120 -35
  48. package/_bundled_plugin/scripts/workbench_validation.py +1 -9
  49. package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
  50. package/_bundled_plugin/shared/workbench-migrations.json +19 -0
  51. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
  52. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
  53. package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
  54. package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
  55. package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
  56. package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
  57. package/_bundled_plugin/skills/publish-findings/SKILL.md +68 -35
  58. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
  59. package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
  60. package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
  61. package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
  62. package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
  63. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
  64. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
  65. package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
  66. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
  67. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
  68. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
  69. package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
  70. package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
  71. package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
  72. package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
  73. package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
  74. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +569 -0
  75. package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
  76. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
  77. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
  78. package/dist/api.d.ts +6 -1
  79. package/dist/api.d.ts.map +1 -1
  80. package/dist/api.js +414 -163
  81. package/dist/api.js.map +1 -1
  82. package/dist/auth.js +7 -2
  83. package/dist/auth.js.map +1 -1
  84. package/dist/blackduck-findings.d.ts +8 -0
  85. package/dist/blackduck-findings.d.ts.map +1 -0
  86. package/dist/blackduck-findings.js +305 -0
  87. package/dist/blackduck-findings.js.map +1 -0
  88. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  89. package/dist/bulk-scan-discovery.js +51 -36
  90. package/dist/bulk-scan-discovery.js.map +1 -1
  91. package/dist/classify-severity-records.d.ts +5 -0
  92. package/dist/classify-severity-records.d.ts.map +1 -1
  93. package/dist/classify-severity-records.js +6 -8
  94. package/dist/classify-severity-records.js.map +1 -1
  95. package/dist/classify-severity.d.ts +4 -1
  96. package/dist/classify-severity.d.ts.map +1 -1
  97. package/dist/classify-severity.js +28 -9
  98. package/dist/classify-severity.js.map +1 -1
  99. package/dist/cli.d.ts +3 -0
  100. package/dist/cli.d.ts.map +1 -1
  101. package/dist/cli.js +635 -266
  102. package/dist/cli.js.map +1 -1
  103. package/dist/codex-prompt.d.ts +2 -0
  104. package/dist/codex-prompt.d.ts.map +1 -1
  105. package/dist/codex-prompt.js +6 -0
  106. package/dist/codex-prompt.js.map +1 -1
  107. package/dist/component-scan.d.ts.map +1 -1
  108. package/dist/component-scan.js +6 -5
  109. package/dist/component-scan.js.map +1 -1
  110. package/dist/config.d.ts +2 -1
  111. package/dist/config.d.ts.map +1 -1
  112. package/dist/config.js +162 -40
  113. package/dist/config.js.map +1 -1
  114. package/dist/continuum-findings.d.ts +7 -0
  115. package/dist/continuum-findings.d.ts.map +1 -0
  116. package/dist/continuum-findings.js +157 -0
  117. package/dist/continuum-findings.js.map +1 -0
  118. package/dist/contract-values.d.ts +28 -0
  119. package/dist/contract-values.d.ts.map +1 -0
  120. package/dist/contract-values.js +75 -0
  121. package/dist/contract-values.js.map +1 -0
  122. package/dist/contract.d.ts +2 -20
  123. package/dist/contract.d.ts.map +1 -1
  124. package/dist/contract.js +58 -669
  125. package/dist/contract.js.map +1 -1
  126. package/dist/cost-model.d.ts.map +1 -1
  127. package/dist/cost-model.js +1 -4
  128. package/dist/cost-model.js.map +1 -1
  129. package/dist/cost.d.ts +19 -1
  130. package/dist/cost.d.ts.map +1 -1
  131. package/dist/cost.js +2120 -39
  132. package/dist/cost.js.map +1 -1
  133. package/dist/custom-validation-prompt.d.ts +1 -1
  134. package/dist/custom-validation-prompt.d.ts.map +1 -1
  135. package/dist/custom-validation-prompt.js +5 -0
  136. package/dist/custom-validation-prompt.js.map +1 -1
  137. package/dist/custom-validation.d.ts +2 -0
  138. package/dist/custom-validation.d.ts.map +1 -1
  139. package/dist/custom-validation.js +6 -2
  140. package/dist/custom-validation.js.map +1 -1
  141. package/dist/deduplication/deduplication-prompts.d.ts +4 -4
  142. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  143. package/dist/deduplication/deduplication-prompts.js +2 -2
  144. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  145. package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
  146. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  147. package/dist/deduplication/deduplication-reviewer.js +12 -5
  148. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  149. package/dist/deduplication/deduplication.js.map +1 -1
  150. package/dist/deduplication/finding-schema.d.ts +19 -1
  151. package/dist/deduplication/finding-schema.d.ts.map +1 -1
  152. package/dist/deduplication/finding-schema.js +25 -0
  153. package/dist/deduplication/finding-schema.js.map +1 -1
  154. package/dist/deduplication/local.d.ts.map +1 -1
  155. package/dist/deduplication/local.js +3 -8
  156. package/dist/deduplication/local.js.map +1 -1
  157. package/dist/deduplication/records.d.ts +11 -3
  158. package/dist/deduplication/records.d.ts.map +1 -1
  159. package/dist/deduplication/records.js +48 -16
  160. package/dist/deduplication/records.js.map +1 -1
  161. package/dist/deep-scan.d.ts +11 -0
  162. package/dist/deep-scan.d.ts.map +1 -1
  163. package/dist/deep-scan.js +235 -4
  164. package/dist/deep-scan.js.map +1 -1
  165. package/dist/default-severity-rubric.d.ts +1 -2
  166. package/dist/default-severity-rubric.d.ts.map +1 -1
  167. package/dist/default-severity-rubric.js +2 -66
  168. package/dist/default-severity-rubric.js.map +1 -1
  169. package/dist/endor-findings.d.ts.map +1 -1
  170. package/dist/endor-findings.js +44 -89
  171. package/dist/endor-findings.js.map +1 -1
  172. package/dist/errors.js +1 -1
  173. package/dist/errors.js.map +1 -1
  174. package/dist/external-findings-import.d.ts.map +1 -1
  175. package/dist/external-findings-import.js +11 -15
  176. package/dist/external-findings-import.js.map +1 -1
  177. package/dist/external-findings-local.d.ts +12 -1
  178. package/dist/external-findings-local.d.ts.map +1 -1
  179. package/dist/external-findings-local.js +411 -184
  180. package/dist/external-findings-local.js.map +1 -1
  181. package/dist/external-findings-publish.d.ts +15 -1
  182. package/dist/external-findings-publish.d.ts.map +1 -1
  183. package/dist/external-findings-publish.js +1238 -226
  184. package/dist/external-findings-publish.js.map +1 -1
  185. package/dist/external-findings-read.d.ts +10 -0
  186. package/dist/external-findings-read.d.ts.map +1 -1
  187. package/dist/external-findings-read.js +71 -51
  188. package/dist/external-findings-read.js.map +1 -1
  189. package/dist/external-findings.d.ts +13 -0
  190. package/dist/external-findings.d.ts.map +1 -1
  191. package/dist/external-findings.js +124 -1
  192. package/dist/external-findings.js.map +1 -1
  193. package/dist/external-import-contract.d.ts +29 -1
  194. package/dist/external-import-contract.d.ts.map +1 -1
  195. package/dist/external-import-contract.js +314 -44
  196. package/dist/external-import-contract.js.map +1 -1
  197. package/dist/external-import-models.d.ts +1 -1
  198. package/dist/external-import-models.d.ts.map +1 -1
  199. package/dist/external-import-models.js.map +1 -1
  200. package/dist/finding-normalization.d.ts +1 -1
  201. package/dist/finding-normalization.d.ts.map +1 -1
  202. package/dist/finding-normalization.js +46 -11
  203. package/dist/finding-normalization.js.map +1 -1
  204. package/dist/finding-retrieval.d.ts +3 -3
  205. package/dist/finding-retrieval.d.ts.map +1 -1
  206. package/dist/finding-retrieval.js.map +1 -1
  207. package/dist/finding-workflow.d.ts +6 -1
  208. package/dist/finding-workflow.d.ts.map +1 -1
  209. package/dist/finding-workflow.js +2 -2
  210. package/dist/finding-workflow.js.map +1 -1
  211. package/dist/git-remote.d.ts +4 -0
  212. package/dist/git-remote.d.ts.map +1 -1
  213. package/dist/git-remote.js +20 -0
  214. package/dist/git-remote.js.map +1 -1
  215. package/dist/github-advisories.d.ts +3 -12
  216. package/dist/github-advisories.d.ts.map +1 -1
  217. package/dist/github-advisories.js +9 -29
  218. package/dist/github-advisories.js.map +1 -1
  219. package/dist/github-dependabot-findings.d.ts.map +1 -1
  220. package/dist/github-dependabot-findings.js +7 -16
  221. package/dist/github-dependabot-findings.js.map +1 -1
  222. package/dist/github-findings.d.ts.map +1 -1
  223. package/dist/github-findings.js +344 -56
  224. package/dist/github-findings.js.map +1 -1
  225. package/dist/github.d.ts +17 -7
  226. package/dist/github.d.ts.map +1 -1
  227. package/dist/github.js +43 -30
  228. package/dist/github.js.map +1 -1
  229. package/dist/host-protocol.d.ts +7 -2
  230. package/dist/host-protocol.d.ts.map +1 -1
  231. package/dist/host-protocol.js +27 -3
  232. package/dist/host-protocol.js.map +1 -1
  233. package/dist/host-records-protocol.d.ts +10 -11
  234. package/dist/host-records-protocol.d.ts.map +1 -1
  235. package/dist/host-records-protocol.js +69 -9
  236. package/dist/host-records-protocol.js.map +1 -1
  237. package/dist/hosted-scan.d.ts +15 -0
  238. package/dist/hosted-scan.d.ts.map +1 -1
  239. package/dist/hosted-scan.js +55 -33
  240. package/dist/hosted-scan.js.map +1 -1
  241. package/dist/index.d.ts +8 -0
  242. package/dist/index.d.ts.map +1 -1
  243. package/dist/index.js +7 -0
  244. package/dist/index.js.map +1 -1
  245. package/dist/inspector-findings.d.ts +9 -0
  246. package/dist/inspector-findings.d.ts.map +1 -0
  247. package/dist/inspector-findings.js +512 -0
  248. package/dist/inspector-findings.js.map +1 -0
  249. package/dist/knowledge-base.js +18 -5
  250. package/dist/knowledge-base.js.map +1 -1
  251. package/dist/local-git-metadata.d.ts +5 -0
  252. package/dist/local-git-metadata.d.ts.map +1 -0
  253. package/dist/local-git-metadata.js +131 -0
  254. package/dist/local-git-metadata.js.map +1 -0
  255. package/dist/multiscan.d.ts.map +1 -1
  256. package/dist/multiscan.js +22 -12
  257. package/dist/multiscan.js.map +1 -1
  258. package/dist/opengrep-findings.d.ts.map +1 -1
  259. package/dist/opengrep-findings.js +34 -20
  260. package/dist/opengrep-findings.js.map +1 -1
  261. package/dist/patch-tui.d.ts +1 -1
  262. package/dist/patch-tui.d.ts.map +1 -1
  263. package/dist/patch-tui.js +94 -36
  264. package/dist/patch-tui.js.map +1 -1
  265. package/dist/private-finding-import.d.ts +246 -0
  266. package/dist/private-finding-import.d.ts.map +1 -0
  267. package/dist/private-finding-import.js +387 -0
  268. package/dist/private-finding-import.js.map +1 -0
  269. package/dist/project-config.d.ts.map +1 -1
  270. package/dist/project-config.js +2 -2
  271. package/dist/project-config.js.map +1 -1
  272. package/dist/provider-profile.d.ts +10 -2
  273. package/dist/provider-profile.d.ts.map +1 -1
  274. package/dist/provider-profile.js +72 -10
  275. package/dist/provider-profile.js.map +1 -1
  276. package/dist/publication.js +7 -1
  277. package/dist/publication.js.map +1 -1
  278. package/dist/reader-selection.d.ts +13 -0
  279. package/dist/reader-selection.d.ts.map +1 -0
  280. package/dist/reader-selection.js +81 -0
  281. package/dist/reader-selection.js.map +1 -0
  282. package/dist/record.d.ts +6 -1
  283. package/dist/record.d.ts.map +1 -1
  284. package/dist/record.js +53 -2
  285. package/dist/record.js.map +1 -1
  286. package/dist/remediation.d.ts +5 -0
  287. package/dist/remediation.d.ts.map +1 -1
  288. package/dist/remediation.js +30 -0
  289. package/dist/remediation.js.map +1 -1
  290. package/dist/result.d.ts +2 -0
  291. package/dist/result.d.ts.map +1 -1
  292. package/dist/result.js +3 -1
  293. package/dist/result.js.map +1 -1
  294. package/dist/runtime.d.ts +5 -3
  295. package/dist/runtime.d.ts.map +1 -1
  296. package/dist/runtime.js +110 -57
  297. package/dist/runtime.js.map +1 -1
  298. package/dist/scan-activity.js +40 -17
  299. package/dist/scan-activity.js.map +1 -1
  300. package/dist/scan-comparison.d.ts +1 -1
  301. package/dist/scan-comparison.d.ts.map +1 -1
  302. package/dist/scan-comparison.js +11 -13
  303. package/dist/scan-comparison.js.map +1 -1
  304. package/dist/scan-dashboard.d.ts +1 -0
  305. package/dist/scan-dashboard.d.ts.map +1 -1
  306. package/dist/scan-dashboard.js +37 -48
  307. package/dist/scan-dashboard.js.map +1 -1
  308. package/dist/scan-executor.d.ts +2 -0
  309. package/dist/scan-executor.d.ts.map +1 -1
  310. package/dist/scan-executor.js.map +1 -1
  311. package/dist/scan-history-renderer.d.ts.map +1 -1
  312. package/dist/scan-history-renderer.js +22 -9
  313. package/dist/scan-history-renderer.js.map +1 -1
  314. package/dist/scan-logs.d.ts.map +1 -1
  315. package/dist/scan-logs.js +5 -5
  316. package/dist/scan-logs.js.map +1 -1
  317. package/dist/scanner-import.d.ts +48 -3
  318. package/dist/scanner-import.d.ts.map +1 -1
  319. package/dist/scanner-import.js +214 -39
  320. package/dist/scanner-import.js.map +1 -1
  321. package/dist/scanner-repository-url.d.ts +14 -0
  322. package/dist/scanner-repository-url.d.ts.map +1 -0
  323. package/dist/scanner-repository-url.js +67 -0
  324. package/dist/scanner-repository-url.js.map +1 -0
  325. package/dist/semgrep-findings.d.ts.map +1 -1
  326. package/dist/semgrep-findings.js +50 -88
  327. package/dist/semgrep-findings.js.map +1 -1
  328. package/dist/semgrep-platform-findings.d.ts +12 -0
  329. package/dist/semgrep-platform-findings.d.ts.map +1 -0
  330. package/dist/semgrep-platform-findings.js +198 -0
  331. package/dist/semgrep-platform-findings.js.map +1 -0
  332. package/dist/severity-rubric.d.ts +20 -0
  333. package/dist/severity-rubric.d.ts.map +1 -0
  334. package/dist/severity-rubric.js +73 -0
  335. package/dist/severity-rubric.js.map +1 -0
  336. package/dist/severity-store.js +15 -5
  337. package/dist/severity-store.js.map +1 -1
  338. package/dist/snyk-findings.d.ts.map +1 -1
  339. package/dist/snyk-findings.js +97 -106
  340. package/dist/snyk-findings.js.map +1 -1
  341. package/dist/sonar-collector.d.ts +16 -0
  342. package/dist/sonar-collector.d.ts.map +1 -0
  343. package/dist/sonar-collector.js +383 -0
  344. package/dist/sonar-collector.js.map +1 -0
  345. package/dist/sonar-findings.d.ts +49 -0
  346. package/dist/sonar-findings.d.ts.map +1 -0
  347. package/dist/sonar-findings.js +288 -0
  348. package/dist/sonar-findings.js.map +1 -0
  349. package/dist/sonar-import.d.ts +111 -0
  350. package/dist/sonar-import.d.ts.map +1 -0
  351. package/dist/sonar-import.js +279 -0
  352. package/dist/sonar-import.js.map +1 -0
  353. package/dist/suggest-owners.d.ts.map +1 -1
  354. package/dist/suggest-owners.js +2 -1
  355. package/dist/suggest-owners.js.map +1 -1
  356. package/dist/targets.d.ts +3 -0
  357. package/dist/targets.d.ts.map +1 -1
  358. package/dist/targets.js +18 -12
  359. package/dist/targets.js.map +1 -1
  360. package/dist/terminal-columns.d.ts +4 -0
  361. package/dist/terminal-columns.d.ts.map +1 -0
  362. package/dist/terminal-columns.js +19 -0
  363. package/dist/terminal-columns.js.map +1 -0
  364. package/dist/validation-records.d.ts +0 -3
  365. package/dist/validation-records.d.ts.map +1 -1
  366. package/dist/validation-records.js +0 -16
  367. package/dist/validation-records.js.map +1 -1
  368. package/dist/veracode-findings.d.ts +7 -0
  369. package/dist/veracode-findings.d.ts.map +1 -0
  370. package/dist/veracode-findings.js +371 -0
  371. package/dist/veracode-findings.js.map +1 -0
  372. package/dist/windows-path.d.ts.map +1 -1
  373. package/dist/windows-path.js +1 -0
  374. package/dist/windows-path.js.map +1 -1
  375. package/dist/wiz-csv.d.ts +2 -2
  376. package/dist/wiz-csv.d.ts.map +1 -1
  377. package/dist/wiz-csv.js +1 -3
  378. package/dist/wiz-csv.js.map +1 -1
  379. package/dist/wiz-findings.d.ts +10 -2
  380. package/dist/wiz-findings.d.ts.map +1 -1
  381. package/dist/wiz-findings.js +88 -49
  382. package/dist/wiz-findings.js.map +1 -1
  383. package/docs/classify-severity-records.md +1 -1
  384. package/docs/cli.md +320 -481
  385. package/docs/dedupe-records.md +27 -4
  386. package/docs/findings-service.md +21 -8
  387. package/docs/hosted-scans.md +16 -1
  388. package/package.json +9 -10
  389. package/schemas/external-findings.schema.json +12 -1
  390. package/schemas/hosted-scan-v2.fixture.json +16 -1
  391. package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
  392. package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
  393. package/dist/deduplication/records-protocol.d.ts +0 -4
  394. package/dist/deduplication/records-protocol.d.ts.map +0 -1
  395. package/dist/deduplication/records-protocol.js +0 -35
  396. package/dist/deduplication/records-protocol.js.map +0 -1
@@ -1,12 +1,16 @@
1
- import { wizCsvRepositoryUrl } from "./wiz-csv.js";
2
1
  import { readSnykFindings, snykRepositoryUrls } from "./snyk-findings.js";
3
2
  import { readSemgrepFindings } from "./semgrep-findings.js";
4
3
  import { readOpenGrepFindings } from "./opengrep-findings.js";
5
4
  import { readEndorFindings, endorRepositoryUrls } from "./endor-findings.js";
5
+ import { dependabotRepository } from "./github-dependabot-findings.js";
6
6
  import { readGitHubFindings } from "./github-findings.js";
7
- import { isGitHubCloudHost } from "./git-remote.js";
7
+ import { readSonarFindings } from "./sonar-findings.js";
8
+ import { readVeracodeFindings } from "./veracode-findings.js";
9
+ import { readBlackDuckFindings } from "./blackduck-findings.js";
10
+ import { readContinuumFindings } from "./continuum-findings.js";
11
+ import { readInspectorFindings } from "./inspector-findings.js";
8
12
  import { isRecord } from "./record.js";
9
- import { readVendorFindingsForPublication } from "./wiz-findings.js";
13
+ import { readLocalWizFindings, readVendorFindingsForPublication, wizFindingRepository, } from "./wiz-findings.js";
10
14
  /** File reader names mapped to their stored and Cloud source provider. */
11
15
  export const EXTERNAL_FINDINGS_PROVIDERS = {
12
16
  wiz: "wiz",
@@ -16,10 +20,44 @@ export const EXTERNAL_FINDINGS_PROVIDERS = {
16
20
  opengrep: "semgrep",
17
21
  endor: "endor",
18
22
  github: "github",
23
+ inspector: "inspector",
24
+ blackduck: "blackduck",
25
+ veracode: "veracode",
26
+ sonar: "sonar",
27
+ continuum: "continuum",
19
28
  };
20
29
  export const EXTERNAL_FINDINGS_READERS = Object.keys(EXTERNAL_FINDINGS_PROVIDERS);
30
+ /** Repository references retained by a provider's individual finding. */
31
+ export function localFindingRepositories(provider, finding) {
32
+ const { evidence } = finding;
33
+ if (provider === "snyk")
34
+ return snykRepositoryUrls(evidence.source_data, {
35
+ normalizeGitRemote: false,
36
+ }).map((url) => ({ url }));
37
+ if (provider === "endor")
38
+ return endorRepositoryUrls(evidence.source_data).map((url) => ({ url }));
39
+ if (provider === "wiz") {
40
+ const repository = wizFindingRepository(evidence);
41
+ return repository ? [repository] : [];
42
+ }
43
+ if (provider === "github") {
44
+ const url = dependabotRepository(finding);
45
+ if (url)
46
+ return [{ url, platform: "github" }];
47
+ }
48
+ return [];
49
+ }
21
50
  /** @internal Read vendor evidence for the local and Cloud import entrypoints. */
22
51
  export async function readExternalFindings(path, options, target = "cloud") {
52
+ if (options.provider === "sonar") {
53
+ const url = options.sourceRepositoryUrl;
54
+ const findings = await readSonarFindings(path, url ?? "", target);
55
+ const binding = findings.report?.["repositoryUrl"];
56
+ return {
57
+ findings,
58
+ sourceRepositories: typeof binding === "string" ? [{ url: binding }] : [],
59
+ };
60
+ }
23
61
  if (options.provider === "opengrep") {
24
62
  const sourceRepositoryUrl = options.sourceRepositoryUrl ?? "";
25
63
  return {
@@ -27,13 +65,14 @@ export async function readExternalFindings(path, options, target = "cloud") {
27
65
  sourceRepositories: [{ url: sourceRepositoryUrl }],
28
66
  };
29
67
  }
30
- if (options.provider === "snyk") {
31
- const findings = await readSnykFindings(path, target);
68
+ if (options.provider === "snyk" || options.provider === "endor") {
69
+ const provider = options.provider;
70
+ const findings = provider === "snyk"
71
+ ? await readSnykFindings(path, target)
72
+ : await readEndorFindings(path, target);
32
73
  return {
33
74
  findings,
34
- sourceRepositories: findings.findings.flatMap(({ evidence }) => snykRepositoryUrls(evidence.source_data, {
35
- normalizeGitRemote: false,
36
- }).map((url) => ({ url }))),
75
+ sourceRepositories: findings.findings.flatMap((finding) => localFindingRepositories(provider, finding)),
37
76
  };
38
77
  }
39
78
  if (options.provider === "semgrep") {
@@ -55,53 +94,34 @@ export async function readExternalFindings(path, options, target = "cloud") {
55
94
  });
56
95
  return { findings, sourceRepositories };
57
96
  }
58
- if (options.provider === "endor") {
59
- const parsed = await readEndorFindings(path, target);
97
+ if (options.provider === "github")
98
+ return { findings: await readGitHubFindings(path, target) };
99
+ if (options.provider === "inspector" ||
100
+ options.provider === "continuum" ||
101
+ options.provider === "blackduck" ||
102
+ options.provider === "veracode") {
103
+ const url = options.sourceRepositoryUrl ?? "";
104
+ const read = {
105
+ inspector: readInspectorFindings,
106
+ continuum: readContinuumFindings,
107
+ blackduck: readBlackDuckFindings,
108
+ veracode: readVeracodeFindings,
109
+ }[options.provider];
60
110
  return {
61
- findings: parsed,
62
- sourceRepositories: parsed.findings.flatMap((finding) => endorRepositoryUrls(finding.evidence.source_data).map((url) => ({
63
- url,
64
- }))),
111
+ findings: await read(path, url, target, options.inspectorProjectMap),
112
+ sourceRepositories: [{ url }],
65
113
  };
66
114
  }
67
- if (options.provider === "github")
68
- return { findings: await readGitHubFindings(path, target) };
69
- const publication = await readVendorFindingsForPublication(path, target);
70
- // Raw package exports keep repository-branch URLs in retained source data.
71
- const sourceRepositories = publication.current.findings.flatMap(({ evidence }) => {
72
- const csvUrl = wizCsvRepositoryUrl(evidence);
73
- if (csvUrl)
74
- return [{ url: csvUrl, platform: "github" }];
75
- const asset = evidence.source_data?.["vulnerableAsset"];
76
- if (!isRecord(asset) || typeof asset["cloudProviderURL"] !== "string")
77
- return [];
78
- const url = URL.parse(asset["cloudProviderURL"]);
79
- if (!url)
80
- return [];
81
- const github = asset["nativeType"] === "github#repositoryBranch" ||
82
- (asset["type"] === "REPOSITORY_BRANCH" &&
83
- isGitHubCloudHost(url.hostname));
84
- if (!github)
85
- return asset["type"] === "REPOSITORY_BRANCH"
86
- ? [{ url: asset["cloudProviderURL"] }]
87
- : [];
88
- const [, owner, repository] = url.pathname.split("/");
89
- return owner && repository
90
- ? [
91
- {
92
- url: `${url.origin}/${owner}/${repository}`,
93
- platform: "github",
94
- },
95
- ]
96
- : [];
97
- });
115
+ // A new reader must choose its parser before reaching the Wiz replay path.
116
+ options.provider;
117
+ const wiz = target === "local"
118
+ ? await readLocalWizFindings(path)
119
+ : await readVendorFindingsForPublication(path, target);
120
+ const sourceRepositories = wiz.current.findings.flatMap((finding) => localFindingRepositories("wiz", finding));
98
121
  return {
99
- findings: publication.current,
100
- publication,
101
- sourceRepositories: [
102
- ...publication.sourceRepositories,
103
- ...sourceRepositories,
104
- ],
122
+ findings: wiz.current,
123
+ ...("legacy" in wiz && { publication: wiz }),
124
+ sourceRepositories: [...wiz.sourceRepositories, ...sourceRepositories],
105
125
  };
106
126
  }
107
127
  //# sourceMappingURL=external-findings-read.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAErE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,iFAAiF;IACjF,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C,GAAG,CAAC,CAAC;QACtD,OAAO,KAAK,IAAI,UAAU;YACxB,CAAC,CAAC;gBACE;oBACE,GAAG,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,KAAK,IAAI,UAAU,EAAE;oBAC3C,QAAQ,EAAE,QAAiB;iBAC5B;aACF;YACH,CAAC,CAAC,EAAE,CAAC;IACT,CAAC,CACF,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,WAAW,CAAC,OAAO;QAC7B,WAAW;QACX,kBAAkB,EAAE;YAClB,GAAG,WAAW,CAAC,kBAAkB;YACjC,GAAG,kBAAkB;SACtB;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { wizCsvRepositoryUrl } from \"./wiz-csv.js\";\nimport { readSnykFindings, snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { readSemgrepFindings } from \"./semgrep-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport { readEndorFindings, endorRepositoryUrls } from \"./endor-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport { readVendorFindingsForPublication } from \"./wiz-findings.js\";\n\n/** File reader names mapped to their stored and Cloud source provider. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\n // OpenGrep uses the existing SAST contract; evidence retains its scanner origin.\n opengrep: \"semgrep\",\n endor: \"endor\",\n github: \"github\",\n} as const satisfies Record<string, Provider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK, shared by local and Cloud imports. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: ExternalFindings;\n /** Preserve previous Wiz projections when resuming immutable Cloud requests. */\n publication?: ExternalPublicationInput;\n sourceRepositories?: ExternalSourceRepository[];\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): Promise<ReadExternalFindings> {\n if (options.provider === \"opengrep\") {\n const sourceRepositoryUrl = options.sourceRepositoryUrl ?? \"\";\n return {\n findings: await readOpenGrepFindings(\n path,\n { sourceRepositoryUrl },\n target,\n ),\n sourceRepositories: [{ url: sourceRepositoryUrl }],\n };\n }\n if (options.provider === \"snyk\") {\n const findings = await readSnykFindings(path, target);\n return {\n findings,\n sourceRepositories: findings.findings.flatMap(({ evidence }) =>\n snykRepositoryUrls(evidence.source_data, {\n normalizeGitRemote: false,\n }).map((url) => ({ url })),\n ),\n };\n }\n if (options.provider === \"semgrep\") {\n const findings = await readSemgrepFindings(\n path,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl ?? \"\",\n },\n target,\n );\n const sourceRepositories = findings.findings.flatMap(({ evidence }) => {\n const context = evidence.source_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 ? [{ url: reference[\"repositoryUri\"] }]\n : [],\n )\n : [];\n });\n return { findings, sourceRepositories };\n }\n if (options.provider === \"endor\") {\n const parsed = await readEndorFindings(path, target);\n return {\n findings: parsed,\n sourceRepositories: parsed.findings.flatMap((finding) =>\n endorRepositoryUrls(finding.evidence.source_data).map((url) => ({\n url,\n })),\n ),\n };\n }\n if (options.provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n const publication = await readVendorFindingsForPublication(path, target);\n // Raw package exports keep repository-branch URLs in retained source data.\n const sourceRepositories = publication.current.findings.flatMap(\n ({ evidence }) => {\n const csvUrl = wizCsvRepositoryUrl(evidence);\n if (csvUrl) return [{ url: csvUrl, platform: \"github\" as const }];\n const asset = evidence.source_data?.[\"vulnerableAsset\"];\n if (!isRecord(asset) || typeof asset[\"cloudProviderURL\"] !== \"string\")\n return [];\n const url = URL.parse(asset[\"cloudProviderURL\"]);\n if (!url) return [];\n const github =\n asset[\"nativeType\"] === \"github#repositoryBranch\" ||\n (asset[\"type\"] === \"REPOSITORY_BRANCH\" &&\n isGitHubCloudHost(url.hostname));\n if (!github)\n return asset[\"type\"] === \"REPOSITORY_BRANCH\"\n ? [{ url: asset[\"cloudProviderURL\"] }]\n : [];\n const [, owner, repository] = url.pathname.split(\"/\");\n return owner && repository\n ? [\n {\n url: `${url.origin}/${owner}/${repository}`,\n platform: \"github\" as const,\n },\n ]\n : [];\n },\n );\n return {\n findings: publication.current,\n publication,\n sourceRepositories: [\n ...publication.sourceRepositories,\n ...sourceRepositories,\n ],\n };\n}\n"]}
1
+ {"version":3,"file":"external-findings-read.js","sourceRoot":"","sources":["../src/external-findings-read.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,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,IAAI,CAAC;QAClC,CAAC,CAAC,MAAM,gCAAgC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAClE,wBAAwB,CAAC,KAAK,EAAE,OAAO,CAAC,CACzC,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,GAAG,CAAC,OAAO;QACrB,GAAG,CAAC,QAAQ,IAAI,GAAG,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;QAC5C,kBAAkB,EAAE,CAAC,GAAG,GAAG,CAAC,kBAAkB,EAAE,GAAG,kBAAkB,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ExternalFinding,\n ExternalFindings,\n ExternalPublicationInput,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\nimport type { Provider } from \"./external-import-models.js\";\nimport type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { readSnykFindings, snykRepositoryUrls } from \"./snyk-findings.js\";\nimport { readSemgrepFindings } from \"./semgrep-findings.js\";\nimport { readOpenGrepFindings } from \"./opengrep-findings.js\";\nimport { readEndorFindings, endorRepositoryUrls } from \"./endor-findings.js\";\nimport { dependabotRepository } from \"./github-dependabot-findings.js\";\nimport { readGitHubFindings } from \"./github-findings.js\";\nimport { readSonarFindings } from \"./sonar-findings.js\";\nimport { readVeracodeFindings } from \"./veracode-findings.js\";\nimport { readBlackDuckFindings } from \"./blackduck-findings.js\";\nimport { readContinuumFindings } from \"./continuum-findings.js\";\nimport { readInspectorFindings } from \"./inspector-findings.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n readLocalWizFindings,\n readVendorFindingsForPublication,\n wizFindingRepository,\n} from \"./wiz-findings.js\";\n\n/** File reader names mapped to their stored and Cloud source provider. */\nexport const EXTERNAL_FINDINGS_PROVIDERS = {\n wiz: \"wiz\",\n snyk: \"snyk\",\n semgrep: \"semgrep\",\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} as const satisfies Record<string, Provider>;\n\nexport type ExternalFindingsReader = keyof typeof EXTERNAL_FINDINGS_PROVIDERS;\n\nexport const EXTERNAL_FINDINGS_READERS = Object.keys(\n EXTERNAL_FINDINGS_PROVIDERS,\n) as ExternalFindingsReader[];\n\n/** File readers available in this SDK, shared by local and Cloud imports. */\nexport interface ExternalFindingsReaderOptions {\n provider: ExternalFindingsReader;\n sourceRepositoryUrl?: string;\n inspectorProjectMap?: ReadonlyMap<string, string>;\n}\n\n/** @internal Shared parser output, including immutable Cloud retry projections. */\nexport interface ReadExternalFindings {\n findings: 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/** @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): Promise<ReadExternalFindings> {\n if (options.provider === \"sonar\") {\n const url = options.sourceRepositoryUrl;\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 (options.provider === \"opengrep\") {\n const sourceRepositoryUrl = options.sourceRepositoryUrl ?? \"\";\n return {\n findings: await readOpenGrepFindings(\n path,\n { sourceRepositoryUrl },\n target,\n ),\n sourceRepositories: [{ url: sourceRepositoryUrl }],\n };\n }\n if (options.provider === \"snyk\" || options.provider === \"endor\") {\n const provider = options.provider;\n const findings =\n provider === \"snyk\"\n ? await readSnykFindings(path, target)\n : await readEndorFindings(path, target);\n return {\n findings,\n sourceRepositories: findings.findings.flatMap((finding) =>\n localFindingRepositories(provider, finding),\n ),\n };\n }\n if (options.provider === \"semgrep\") {\n const findings = await readSemgrepFindings(\n path,\n {\n sourceRepositoryUrl: options.sourceRepositoryUrl ?? \"\",\n },\n target,\n );\n const sourceRepositories = findings.findings.flatMap(({ evidence }) => {\n const context = evidence.source_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 ? [{ url: reference[\"repositoryUri\"] }]\n : [],\n )\n : [];\n });\n return { findings, sourceRepositories };\n }\n if (options.provider === \"github\")\n return { findings: await readGitHubFindings(path, target) };\n if (\n options.provider === \"inspector\" ||\n options.provider === \"continuum\" ||\n options.provider === \"blackduck\" ||\n options.provider === \"veracode\"\n ) {\n const url = options.sourceRepositoryUrl ?? \"\";\n const read = {\n inspector: readInspectorFindings,\n continuum: readContinuumFindings,\n blackduck: readBlackDuckFindings,\n veracode: readVeracodeFindings,\n }[options.provider];\n return {\n findings: await read(path, url, target, options.inspectorProjectMap),\n sourceRepositories: [{ url }],\n };\n }\n // A new reader must choose its parser before reaching the Wiz replay path.\n options.provider satisfies \"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"]}
@@ -1,3 +1,4 @@
1
+ import type { ExternalPublicationOptions } from "./external-findings-publish.js";
1
2
  import type { ExternalFindingEvidence } from "./external-import-models.js";
2
3
  /** A provider occurrence and its evidence, independent of a Codex assessment. */
3
4
  export interface ExternalFinding {
@@ -9,6 +10,7 @@ export interface ExternalSourceRepository {
9
10
  url: string;
10
11
  platform?: "github";
11
12
  }
13
+ export declare function snapshotSourceRepositories(references?: readonly ExternalSourceRepository[]): ExternalSourceRepository[];
12
14
  export interface ExternalFindings {
13
15
  read: number;
14
16
  /** Reader-retained run metadata, including diagnostics for empty reports. */
@@ -20,4 +22,15 @@ export interface ExternalFindings {
20
22
  reason: string;
21
23
  }[];
22
24
  }
25
+ export declare const nativeErrorStackGetter: (() => any) | undefined;
26
+ /** Capture the caller's import settings before reading an export or resolving its destination. */
27
+ export declare function snapshotImportOptions<P extends ExternalPublicationOptions["provider"]>({ repository, provider, sourceKey, sourceRepositoryUrl, inspectorProjectMap, }: ExternalPublicationOptions & {
28
+ provider: P;
29
+ }): {
30
+ repository: string;
31
+ provider: P;
32
+ sourceKey: string;
33
+ sourceRepositoryUrl: string | undefined;
34
+ inspectorProjectMap: Map<string, string> | undefined;
35
+ };
23
36
  //# sourceMappingURL=external-findings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings.d.ts","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"AAAA,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,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,EAAE,CAAC;CACL;AAGD,eAAO,MAAM,sBAAsB,yBAG7B,CAAC;AAiIP,kGAAkG;AAClG,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,0BAA0B,CAAC,UAAU,CAAC,EAChD,EACA,UAAU,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,mBAAmB,GACpB,EAAE,0BAA0B,GAAG;IAAE,QAAQ,EAAE,CAAC,CAAA;CAAE;;;;;;EAY9C"}
@@ -1,2 +1,125 @@
1
- export {};
1
+ import { isNativeError, isNumberObject } from "node:util/types";
2
+ import { CodexSecurityError } from "./errors.js";
3
+ import { checkEmittedJsonNumber, checkReportNumber, requireCloudEvidenceDepth, requireJsonNumber, } from "./external-import-contract.js";
4
+ export function snapshotSourceRepositories(references = []) {
5
+ return references.map(({ url, platform }) => ({ url, platform }));
6
+ }
7
+ const isScannerError = Error.isError ?? isNativeError;
8
+ export const nativeErrorStackGetter = Object.getOwnPropertyDescriptor(new Error(), "stack")?.get;
9
+ function cloneScannerDiagnostic(source) {
10
+ const message = Object.getOwnPropertyDescriptor(source, "message");
11
+ const stack = Object.getOwnPropertyDescriptor(source, "stack");
12
+ try {
13
+ if ((!message || Object.hasOwn(message, "value")) &&
14
+ (!stack?.get || stack.get === nativeErrorStackGetter))
15
+ return structuredClone(source);
16
+ // Keep the native error type and data-valued cause without running a
17
+ // caller-supplied message or stack getter while restoring diagnostics.
18
+ const cause = Object.getOwnPropertyDescriptor(source, "cause");
19
+ const clean = new Error(message?.value, { cause: cause?.value });
20
+ const name = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(source), "name")?.value;
21
+ if (typeof name === "string")
22
+ clean.name = name;
23
+ if (!message?.get && nativeErrorStackGetter) {
24
+ const nativeStack = nativeErrorStackGetter.call(source);
25
+ if (typeof nativeStack === "string")
26
+ clean.stack = nativeStack;
27
+ }
28
+ return structuredClone(clean);
29
+ }
30
+ catch {
31
+ // A noncloneable cause does not prevent JSON export.
32
+ return new Error(message?.value);
33
+ }
34
+ }
35
+ /** @internal Capture fresh input once, so preview, limits and storage use the same JSON. */
36
+ export function snapshotNormalizedFindings(input, checkEvidenceNumber = (value) => requireJsonNumber(value, "Evidence"), target = "local") {
37
+ const fields = new Map();
38
+ const errors = [];
39
+ let root;
40
+ function captureField(field, observed) {
41
+ const parents = [];
42
+ // The outer traversal already called this field's toJSON with its real key.
43
+ // Returning that value from the wrapper keeps JSON from calling it twice.
44
+ return JSON.stringify({ toJSON: () => observed }, function (key, value) {
45
+ while (parents.length && parents.at(-1).value !== this)
46
+ parents.pop();
47
+ const evidence = field === "findings" && parents[2]?.key === "evidence";
48
+ if (evidence && target === "cloud")
49
+ requireCloudEvidenceDepth(parents.length - 2, this, value);
50
+ if (isNumberObject(value))
51
+ value = +value;
52
+ if (field === "report")
53
+ checkReportNumber(value);
54
+ if (evidence)
55
+ checkEmittedJsonNumber(value, checkEvidenceNumber);
56
+ if (value !== null && typeof value === "object") {
57
+ if (value === root) {
58
+ const path = [field, ...parents.slice(1).map((p) => p.key)];
59
+ if (parents.length)
60
+ path.push(key);
61
+ throw new TypeError(`Converting circular structure to JSON at ${JSON.stringify(path)}`);
62
+ }
63
+ if (field === "report" &&
64
+ parents[1]?.key === "errors" &&
65
+ Array.isArray(parents[1].value) &&
66
+ isScannerError(value)) {
67
+ errors.push({
68
+ path: [field, ...parents.slice(1).map((p) => p.key), key],
69
+ error: value,
70
+ });
71
+ }
72
+ parents.push({ key, value });
73
+ }
74
+ return value;
75
+ });
76
+ }
77
+ // Capture each member in native property order. A report and a findings
78
+ // payload can each fit in a string while their combined JSON does not.
79
+ const envelope = JSON.stringify(input, function (field, value) {
80
+ if (this !== root) {
81
+ root = value;
82
+ return value;
83
+ }
84
+ const json = captureField(field, value);
85
+ if (json === undefined)
86
+ return undefined;
87
+ fields.set(field, JSON.parse(json));
88
+ return null;
89
+ });
90
+ const result = JSON.parse(envelope);
91
+ for (const [key, value] of fields)
92
+ result[key] = value;
93
+ for (const { path, error: source } of errors) {
94
+ const key = path.pop();
95
+ let parent = result;
96
+ for (const field of path)
97
+ parent = parent[field];
98
+ const error = cloneScannerDiagnostic(source);
99
+ Object.defineProperties(error, Object.getOwnPropertyDescriptors(parent[key]));
100
+ parent[key] = error;
101
+ }
102
+ return result;
103
+ }
104
+ /** @internal Clone owned values without serializing the evidence again in every preview view. */
105
+ export function cloneImportPreview(input) {
106
+ if (input.report === undefined)
107
+ return structuredClone(input);
108
+ return {
109
+ ...structuredClone({ ...input, report: undefined }),
110
+ ...snapshotNormalizedFindings({ report: input.report }),
111
+ };
112
+ }
113
+ /** Capture the caller's import settings before reading an export or resolving its destination. */
114
+ export function snapshotImportOptions({ repository, provider, sourceKey, sourceRepositoryUrl, inspectorProjectMap, }) {
115
+ if (inspectorProjectMap !== undefined && provider !== "inspector")
116
+ throw new CodexSecurityError("An Inspector project map requires the inspector provider.");
117
+ return {
118
+ repository,
119
+ provider,
120
+ sourceKey,
121
+ sourceRepositoryUrl,
122
+ inspectorProjectMap: inspectorProjectMap && new Map(inspectorProjectMap),
123
+ };
124
+ }
2
125
  //# sourceMappingURL=external-findings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-findings.js","sourceRoot":"","sources":["../src/external-findings.ts"],"names":[],"mappings":"","sourcesContent":["import 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\";\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\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"]}
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,cAAc,GAAG,KAAK,CAAC,OAAO,IAAI,aAAa,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CACnE,IAAI,KAAK,EAAE,EACX,OAAO,CACR,EAAE,GAAG,CAAC;AAEP,SAAS,sBAAsB,CAAC,MAAa;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/D,IAAI,CAAC;QACH,IACE,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,sBAAsB,CAAC;YAErD,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,qEAAqE;QACrE,uEAAuE;QACvE,MAAM,KAAK,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC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IAAI,MAAM,GAAG,MAA4C,CAAC;QAC1D,KAAK,MAAM,KAAK,IAAI,IAAI;YAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAA4B,CAAC;QAC5E,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,CAAC,gBAAgB,CACrB,KAAK,EACL,MAAM,CAAC,yBAAyB,CAAC,MAAM,CAAC,GAAG,CAAW,CAAC,CACxD,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,kBAAkB,CAA6B,KAAQ;IACrE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO;QACL,GAAG,eAAe,CAAC,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QACnD,GAAG,0BAA0B,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC;AAUD,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAEnC,EACA,UAAU,EACV,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,mBAAmB,GAC0B;IAC7C,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,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 { ExternalPublicationOptions } from \"./external-findings-publish.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\";\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\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 ExternalPublicationOptions[\"provider\"],\n>({\n repository,\n provider,\n sourceKey,\n sourceRepositoryUrl,\n inspectorProjectMap,\n}: ExternalPublicationOptions & { provider: P }) {\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 inspectorProjectMap: inspectorProjectMap && new Map(inspectorProjectMap),\n };\n}\n"]}
@@ -10,10 +10,38 @@ export declare const validateImportReceipt: (input: unknown) => FindingImportRec
10
10
  export declare const validateRepositories: (input: unknown) => ImportRepositoryPage;
11
11
  export declare const validateSourceReports: (input: unknown) => SourceReportPage;
12
12
  export declare const validateSourceReport: (input: unknown) => SourceReport;
13
+ export declare function canonicalNumber(token: string): string;
14
+ export declare function requireSafeJsonInteger(value: number, label: string): void;
15
+ export declare function requireJsonNumber(value: number, label: string): void;
13
16
  /** Report metadata is retained in previews and receipts without Cloud evidence size limits. */
14
17
  export declare function validateExternalReport(report: Record<string, unknown> | undefined): void;
18
+ export declare function validateExternalEvidenceFields(input: unknown, target?: ExternalImportTarget): ExternalFindingEvidence;
19
+ export declare function previousAdmission(value: object): "uncertain" | import("./external-import-models.js").ImportedFindingEvidence | null | undefined;
15
20
  export declare function validateExternalEvidence(input: unknown, target?: ExternalImportTarget): ExternalFindingEvidence;
21
+ type ValidateNumber = (value: number) => void;
22
+ /** Check the numeric value JSON emits before parsing can round a raw decimal. */
23
+ export declare function checkEmittedJsonNumber(value: unknown, check: ValidateNumber): number | undefined;
24
+ export declare function checkReportNumber(value: unknown): void;
25
+ export declare class CloudEvidenceDepthError extends Error {
26
+ constructor();
27
+ }
28
+ /** JSON omits these object properties, but emits null for the same array elements. */
29
+ export declare function requireCloudEvidenceDepth(depth: number, holder: object, value: unknown): void;
16
30
  /** Return the validated Cloud wire size, or zero for local evidence. */
17
- export declare function validateExternalEvidenceJson(input: unknown, target: ExternalImportTarget, additionalCloudBytes?: number): number;
31
+ export declare function validateExternalEvidenceJson(input: unknown, target: ExternalImportTarget, additionalCloudBytes?: number, observe?: (previousBytes: number, currentBytes: number) => void): number;
32
+ /** Reproduce the released SDK's checks on a detached native finding. */
33
+ export declare function validatePreviousCloudEvidence(input: unknown): ExternalFindingEvidence;
34
+ /** Use the array index as toJSON's key, as when saving the supplied GitHub records. */
35
+ export declare function exportedGitHubRecord(value: unknown, index: number, target: ExternalImportTarget, checkPreviousLocal?: boolean): {
36
+ record: unknown;
37
+ bytes: number;
38
+ adjustment: number;
39
+ previousInvalid: unknown;
40
+ skippedRawValue: boolean;
41
+ invalid: unknown;
42
+ };
43
+ /** Combine the observed vendor bytes with the old native mapping's typed fields. */
44
+ export declare function previousGitHubExclusion(evidence: ExternalFindingEvidence, sourceBytes: number, adjustment: number): string | undefined;
18
45
  export declare function validateImportRequest(input: unknown): FindingImportRequest;
46
+ export {};
19
47
  //# 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;AAqBrD;;kFAEkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAatD;AAID,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AA2JD,eAAO,MAAM,qBAAqB,UA3BjB,OAAO,yBA6BvB,CAAC;AACF,eAAO,MAAM,oBAAoB,UA9BhB,OAAO,yBAgCvB,CAAC;AACF,eAAO,MAAM,qBAAqB,UAjCjB,OAAO,qBAkCyB,CAAC;AAClD,eAAO,MAAM,oBAAoB,UAnChB,OAAO,iBAmCmD,CAAC;AAW5E,+FAA+F;AAC/F,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC1C,IAAI,CAON;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,MAAM,GAAE,oBAA8B,GACrC,uBAAuB,CA6EzB;AAED,wEAAwE;AACxE,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,oBAAoB,EAC5B,oBAAoB,SAAI,GACvB,MAAM,CAiCR;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;AAqBrD;;kFAEkF;AAClF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MA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