@openai/codex-security 0.8.2 → 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 (375) hide show
  1. package/README.md +43 -61
  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/darwin-arm64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  14. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +46 -12
  15. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  16. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  17. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  18. package/_bundled_plugin/references/artifact-storage.md +1 -1
  19. package/_bundled_plugin/references/core-scan.md +14 -5
  20. package/_bundled_plugin/references/default-severity-rubric.md +28 -0
  21. package/_bundled_plugin/references/finding-detail-fields.md +1 -0
  22. package/_bundled_plugin/references/threat-model.md +1 -0
  23. package/_bundled_plugin/scripts/deep_scan_workbench.py +23 -112
  24. package/_bundled_plugin/scripts/finalize_scan_contract.py +167 -153
  25. package/_bundled_plugin/scripts/finding_preview.py +5 -29
  26. package/_bundled_plugin/scripts/posix_scan_local_files.py +187 -0
  27. package/_bundled_plugin/scripts/report_projection.py +87 -136
  28. package/_bundled_plugin/scripts/validate_scan_contract.py +2 -6
  29. package/_bundled_plugin/scripts/windows_scan_local_files.py +212 -55
  30. package/_bundled_plugin/scripts/workbench/retained_coverage.py +8 -24
  31. package/_bundled_plugin/scripts/workbench/saved_coverage.py +143 -231
  32. package/_bundled_plugin/scripts/workbench_cli.py +102 -13
  33. package/_bundled_plugin/scripts/workbench_constants.py +9 -0
  34. package/_bundled_plugin/scripts/workbench_db.py +186 -360
  35. package/_bundled_plugin/scripts/workbench_finding_workflows.py +86 -4
  36. package/_bundled_plugin/scripts/workbench_native_indexes.py +17 -21
  37. package/_bundled_plugin/scripts/workbench_remediation.py +495 -11
  38. package/_bundled_plugin/scripts/workbench_scan_history.py +22 -25
  39. package/_bundled_plugin/scripts/workbench_scan_start.py +1 -1
  40. package/_bundled_plugin/scripts/workbench_scan_usage.py +25 -52
  41. package/_bundled_plugin/scripts/workbench_schema.py +1 -1
  42. package/_bundled_plugin/scripts/workbench_setup.py +239 -0
  43. package/_bundled_plugin/scripts/workbench_source_scopes.py +15 -23
  44. package/_bundled_plugin/scripts/workbench_target.py +213 -20
  45. package/_bundled_plugin/scripts/workbench_validation.py +1 -9
  46. package/_bundled_plugin/shared/workbench-history-repairs.json +7 -0
  47. package/_bundled_plugin/shared/workbench-migrations.json +19 -0
  48. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +1 -1
  49. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +4 -68
  50. package/_bundled_plugin/skills/check-skills/SKILL.md +43 -0
  51. package/_bundled_plugin/skills/check-skills/agents/openai.yaml +4 -0
  52. package/_bundled_plugin/skills/cloud-findings/SKILL.md +2 -0
  53. package/_bundled_plugin/skills/fix-finding/SKILL.md +18 -1
  54. package/_bundled_plugin/skills/publish-findings/SKILL.md +64 -35
  55. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +2 -21
  56. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +14 -8
  57. package/_bundled_plugin/skills/track-findings/SKILL.md +5 -3
  58. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +22 -68
  59. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -4
  60. package/dist/api.d.ts +6 -1
  61. package/dist/api.d.ts.map +1 -1
  62. package/dist/api.js +411 -160
  63. package/dist/api.js.map +1 -1
  64. package/dist/auth.js +6 -1
  65. package/dist/auth.js.map +1 -1
  66. package/dist/blackduck-findings.d.ts +8 -0
  67. package/dist/blackduck-findings.d.ts.map +1 -0
  68. package/dist/blackduck-findings.js +305 -0
  69. package/dist/blackduck-findings.js.map +1 -0
  70. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  71. package/dist/bulk-scan-discovery.js +51 -36
  72. package/dist/bulk-scan-discovery.js.map +1 -1
  73. package/dist/classify-severity-records.d.ts +5 -0
  74. package/dist/classify-severity-records.d.ts.map +1 -1
  75. package/dist/classify-severity-records.js +6 -8
  76. package/dist/classify-severity-records.js.map +1 -1
  77. package/dist/classify-severity.d.ts +4 -1
  78. package/dist/classify-severity.d.ts.map +1 -1
  79. package/dist/classify-severity.js +28 -9
  80. package/dist/classify-severity.js.map +1 -1
  81. package/dist/cli.d.ts +3 -0
  82. package/dist/cli.d.ts.map +1 -1
  83. package/dist/cli.js +608 -258
  84. package/dist/cli.js.map +1 -1
  85. package/dist/codex-prompt.d.ts +2 -0
  86. package/dist/codex-prompt.d.ts.map +1 -1
  87. package/dist/codex-prompt.js +6 -0
  88. package/dist/codex-prompt.js.map +1 -1
  89. package/dist/component-scan.d.ts.map +1 -1
  90. package/dist/component-scan.js +6 -5
  91. package/dist/component-scan.js.map +1 -1
  92. package/dist/config.d.ts +2 -1
  93. package/dist/config.d.ts.map +1 -1
  94. package/dist/config.js +162 -40
  95. package/dist/config.js.map +1 -1
  96. package/dist/continuum-findings.d.ts +7 -0
  97. package/dist/continuum-findings.d.ts.map +1 -0
  98. package/dist/continuum-findings.js +157 -0
  99. package/dist/continuum-findings.js.map +1 -0
  100. package/dist/contract-values.d.ts +28 -0
  101. package/dist/contract-values.d.ts.map +1 -0
  102. package/dist/contract-values.js +75 -0
  103. package/dist/contract-values.js.map +1 -0
  104. package/dist/contract.d.ts +2 -20
  105. package/dist/contract.d.ts.map +1 -1
  106. package/dist/contract.js +58 -669
  107. package/dist/contract.js.map +1 -1
  108. package/dist/cost-model.d.ts.map +1 -1
  109. package/dist/cost-model.js +1 -4
  110. package/dist/cost-model.js.map +1 -1
  111. package/dist/cost.d.ts +19 -1
  112. package/dist/cost.d.ts.map +1 -1
  113. package/dist/cost.js +2120 -39
  114. package/dist/cost.js.map +1 -1
  115. package/dist/custom-validation-prompt.d.ts +1 -1
  116. package/dist/custom-validation-prompt.d.ts.map +1 -1
  117. package/dist/custom-validation-prompt.js +5 -0
  118. package/dist/custom-validation-prompt.js.map +1 -1
  119. package/dist/custom-validation.d.ts +2 -0
  120. package/dist/custom-validation.d.ts.map +1 -1
  121. package/dist/custom-validation.js +4 -0
  122. package/dist/custom-validation.js.map +1 -1
  123. package/dist/deduplication/deduplication-prompts.d.ts +4 -4
  124. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  125. package/dist/deduplication/deduplication-prompts.js +2 -2
  126. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  127. package/dist/deduplication/deduplication-reviewer.d.ts +14 -11
  128. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  129. package/dist/deduplication/deduplication-reviewer.js +11 -4
  130. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  131. package/dist/deduplication/deduplication.js.map +1 -1
  132. package/dist/deduplication/finding-schema.d.ts +19 -1
  133. package/dist/deduplication/finding-schema.d.ts.map +1 -1
  134. package/dist/deduplication/finding-schema.js +25 -0
  135. package/dist/deduplication/finding-schema.js.map +1 -1
  136. package/dist/deduplication/local.d.ts.map +1 -1
  137. package/dist/deduplication/local.js +3 -8
  138. package/dist/deduplication/local.js.map +1 -1
  139. package/dist/deduplication/records.d.ts +8 -2
  140. package/dist/deduplication/records.d.ts.map +1 -1
  141. package/dist/deduplication/records.js +36 -8
  142. package/dist/deduplication/records.js.map +1 -1
  143. package/dist/deep-scan.d.ts +11 -0
  144. package/dist/deep-scan.d.ts.map +1 -1
  145. package/dist/deep-scan.js +235 -4
  146. package/dist/deep-scan.js.map +1 -1
  147. package/dist/default-severity-rubric.d.ts +1 -2
  148. package/dist/default-severity-rubric.d.ts.map +1 -1
  149. package/dist/default-severity-rubric.js +2 -66
  150. package/dist/default-severity-rubric.js.map +1 -1
  151. package/dist/endor-findings.d.ts.map +1 -1
  152. package/dist/endor-findings.js +7 -37
  153. package/dist/endor-findings.js.map +1 -1
  154. package/dist/errors.js +1 -1
  155. package/dist/errors.js.map +1 -1
  156. package/dist/external-findings-import.d.ts.map +1 -1
  157. package/dist/external-findings-import.js +5 -11
  158. package/dist/external-findings-import.js.map +1 -1
  159. package/dist/external-findings-local.d.ts +9 -0
  160. package/dist/external-findings-local.d.ts.map +1 -1
  161. package/dist/external-findings-local.js +325 -179
  162. package/dist/external-findings-local.js.map +1 -1
  163. package/dist/external-findings-publish.d.ts +12 -0
  164. package/dist/external-findings-publish.d.ts.map +1 -1
  165. package/dist/external-findings-publish.js +1202 -214
  166. package/dist/external-findings-publish.js.map +1 -1
  167. package/dist/external-findings-read.d.ts +8 -0
  168. package/dist/external-findings-read.d.ts.map +1 -1
  169. package/dist/external-findings-read.js +65 -54
  170. package/dist/external-findings-read.js.map +1 -1
  171. package/dist/external-findings.d.ts +2 -0
  172. package/dist/external-findings.d.ts.map +1 -1
  173. package/dist/external-findings.js +111 -0
  174. package/dist/external-findings.js.map +1 -1
  175. package/dist/external-import-contract.d.ts +29 -1
  176. package/dist/external-import-contract.d.ts.map +1 -1
  177. package/dist/external-import-contract.js +314 -44
  178. package/dist/external-import-contract.js.map +1 -1
  179. package/dist/external-import-models.d.ts +1 -1
  180. package/dist/external-import-models.d.ts.map +1 -1
  181. package/dist/external-import-models.js.map +1 -1
  182. package/dist/finding-normalization.d.ts +1 -1
  183. package/dist/finding-normalization.d.ts.map +1 -1
  184. package/dist/finding-normalization.js +46 -11
  185. package/dist/finding-normalization.js.map +1 -1
  186. package/dist/finding-retrieval.d.ts +3 -3
  187. package/dist/finding-retrieval.d.ts.map +1 -1
  188. package/dist/finding-retrieval.js.map +1 -1
  189. package/dist/finding-workflow.d.ts +6 -1
  190. package/dist/finding-workflow.d.ts.map +1 -1
  191. package/dist/finding-workflow.js +2 -2
  192. package/dist/finding-workflow.js.map +1 -1
  193. package/dist/git-remote.d.ts +4 -0
  194. package/dist/git-remote.d.ts.map +1 -1
  195. package/dist/git-remote.js +20 -0
  196. package/dist/git-remote.js.map +1 -1
  197. package/dist/github-advisories.d.ts +3 -12
  198. package/dist/github-advisories.d.ts.map +1 -1
  199. package/dist/github-advisories.js +9 -29
  200. package/dist/github-advisories.js.map +1 -1
  201. package/dist/github-dependabot-findings.d.ts.map +1 -1
  202. package/dist/github-dependabot-findings.js +7 -16
  203. package/dist/github-dependabot-findings.js.map +1 -1
  204. package/dist/github-findings.d.ts.map +1 -1
  205. package/dist/github-findings.js +344 -56
  206. package/dist/github-findings.js.map +1 -1
  207. package/dist/github.d.ts +17 -7
  208. package/dist/github.d.ts.map +1 -1
  209. package/dist/github.js +43 -30
  210. package/dist/github.js.map +1 -1
  211. package/dist/host-protocol.d.ts +2 -2
  212. package/dist/host-protocol.d.ts.map +1 -1
  213. package/dist/host-protocol.js.map +1 -1
  214. package/dist/host-records-protocol.d.ts +10 -11
  215. package/dist/host-records-protocol.d.ts.map +1 -1
  216. package/dist/host-records-protocol.js +69 -9
  217. package/dist/host-records-protocol.js.map +1 -1
  218. package/dist/hosted-scan.d.ts +15 -0
  219. package/dist/hosted-scan.d.ts.map +1 -1
  220. package/dist/hosted-scan.js +55 -33
  221. package/dist/hosted-scan.js.map +1 -1
  222. package/dist/index.d.ts +7 -0
  223. package/dist/index.d.ts.map +1 -1
  224. package/dist/index.js +6 -0
  225. package/dist/index.js.map +1 -1
  226. package/dist/inspector-findings.d.ts.map +1 -1
  227. package/dist/inspector-findings.js +13 -18
  228. package/dist/inspector-findings.js.map +1 -1
  229. package/dist/knowledge-base.js +18 -5
  230. package/dist/knowledge-base.js.map +1 -1
  231. package/dist/local-git-metadata.d.ts +5 -0
  232. package/dist/local-git-metadata.d.ts.map +1 -0
  233. package/dist/local-git-metadata.js +131 -0
  234. package/dist/local-git-metadata.js.map +1 -0
  235. package/dist/multiscan.d.ts.map +1 -1
  236. package/dist/multiscan.js +22 -12
  237. package/dist/multiscan.js.map +1 -1
  238. package/dist/opengrep-findings.d.ts.map +1 -1
  239. package/dist/opengrep-findings.js +34 -20
  240. package/dist/opengrep-findings.js.map +1 -1
  241. package/dist/patch-tui.d.ts.map +1 -1
  242. package/dist/patch-tui.js +90 -35
  243. package/dist/patch-tui.js.map +1 -1
  244. package/dist/private-finding-import.d.ts +246 -0
  245. package/dist/private-finding-import.d.ts.map +1 -0
  246. package/dist/private-finding-import.js +387 -0
  247. package/dist/private-finding-import.js.map +1 -0
  248. package/dist/project-config.d.ts.map +1 -1
  249. package/dist/project-config.js +2 -2
  250. package/dist/project-config.js.map +1 -1
  251. package/dist/provider-profile.d.ts +10 -2
  252. package/dist/provider-profile.d.ts.map +1 -1
  253. package/dist/provider-profile.js +72 -10
  254. package/dist/provider-profile.js.map +1 -1
  255. package/dist/publication.js +7 -1
  256. package/dist/publication.js.map +1 -1
  257. package/dist/reader-selection.d.ts +13 -0
  258. package/dist/reader-selection.d.ts.map +1 -0
  259. package/dist/reader-selection.js +81 -0
  260. package/dist/reader-selection.js.map +1 -0
  261. package/dist/record.d.ts +6 -1
  262. package/dist/record.d.ts.map +1 -1
  263. package/dist/record.js +53 -2
  264. package/dist/record.js.map +1 -1
  265. package/dist/remediation.d.ts +5 -0
  266. package/dist/remediation.d.ts.map +1 -1
  267. package/dist/remediation.js +30 -0
  268. package/dist/remediation.js.map +1 -1
  269. package/dist/result.d.ts +2 -0
  270. package/dist/result.d.ts.map +1 -1
  271. package/dist/result.js +3 -1
  272. package/dist/result.js.map +1 -1
  273. package/dist/runtime.d.ts +2 -1
  274. package/dist/runtime.d.ts.map +1 -1
  275. package/dist/runtime.js +95 -52
  276. package/dist/runtime.js.map +1 -1
  277. package/dist/scan-activity.js +40 -17
  278. package/dist/scan-activity.js.map +1 -1
  279. package/dist/scan-comparison.d.ts +1 -1
  280. package/dist/scan-comparison.d.ts.map +1 -1
  281. package/dist/scan-comparison.js +11 -13
  282. package/dist/scan-comparison.js.map +1 -1
  283. package/dist/scan-dashboard.d.ts +1 -0
  284. package/dist/scan-dashboard.d.ts.map +1 -1
  285. package/dist/scan-dashboard.js +16 -37
  286. package/dist/scan-dashboard.js.map +1 -1
  287. package/dist/scan-executor.d.ts +2 -0
  288. package/dist/scan-executor.d.ts.map +1 -1
  289. package/dist/scan-executor.js.map +1 -1
  290. package/dist/scan-history-renderer.d.ts.map +1 -1
  291. package/dist/scan-history-renderer.js +22 -9
  292. package/dist/scan-history-renderer.js.map +1 -1
  293. package/dist/scan-logs.d.ts.map +1 -1
  294. package/dist/scan-logs.js +5 -5
  295. package/dist/scan-logs.js.map +1 -1
  296. package/dist/scanner-import.d.ts +46 -6
  297. package/dist/scanner-import.d.ts.map +1 -1
  298. package/dist/scanner-import.js +208 -42
  299. package/dist/scanner-import.js.map +1 -1
  300. package/dist/scanner-repository-url.d.ts +14 -0
  301. package/dist/scanner-repository-url.d.ts.map +1 -0
  302. package/dist/scanner-repository-url.js +67 -0
  303. package/dist/scanner-repository-url.js.map +1 -0
  304. package/dist/semgrep-findings.d.ts.map +1 -1
  305. package/dist/semgrep-findings.js +20 -48
  306. package/dist/semgrep-findings.js.map +1 -1
  307. package/dist/semgrep-platform-findings.d.ts +12 -0
  308. package/dist/semgrep-platform-findings.d.ts.map +1 -0
  309. package/dist/semgrep-platform-findings.js +198 -0
  310. package/dist/semgrep-platform-findings.js.map +1 -0
  311. package/dist/severity-rubric.d.ts +20 -0
  312. package/dist/severity-rubric.d.ts.map +1 -0
  313. package/dist/severity-rubric.js +73 -0
  314. package/dist/severity-rubric.js.map +1 -0
  315. package/dist/severity-store.js +15 -5
  316. package/dist/severity-store.js.map +1 -1
  317. package/dist/snyk-findings.d.ts.map +1 -1
  318. package/dist/snyk-findings.js +21 -20
  319. package/dist/snyk-findings.js.map +1 -1
  320. package/dist/sonar-collector.d.ts +16 -0
  321. package/dist/sonar-collector.d.ts.map +1 -0
  322. package/dist/sonar-collector.js +383 -0
  323. package/dist/sonar-collector.js.map +1 -0
  324. package/dist/sonar-findings.d.ts +49 -0
  325. package/dist/sonar-findings.d.ts.map +1 -0
  326. package/dist/sonar-findings.js +288 -0
  327. package/dist/sonar-findings.js.map +1 -0
  328. package/dist/sonar-import.d.ts +111 -0
  329. package/dist/sonar-import.d.ts.map +1 -0
  330. package/dist/sonar-import.js +279 -0
  331. package/dist/sonar-import.js.map +1 -0
  332. package/dist/suggest-owners.d.ts.map +1 -1
  333. package/dist/suggest-owners.js +2 -1
  334. package/dist/suggest-owners.js.map +1 -1
  335. package/dist/targets.d.ts +3 -0
  336. package/dist/targets.d.ts.map +1 -1
  337. package/dist/targets.js +18 -12
  338. package/dist/targets.js.map +1 -1
  339. package/dist/terminal-columns.d.ts +4 -0
  340. package/dist/terminal-columns.d.ts.map +1 -0
  341. package/dist/terminal-columns.js +19 -0
  342. package/dist/terminal-columns.js.map +1 -0
  343. package/dist/validation-records.d.ts +0 -3
  344. package/dist/validation-records.d.ts.map +1 -1
  345. package/dist/validation-records.js +0 -16
  346. package/dist/validation-records.js.map +1 -1
  347. package/dist/veracode-findings.d.ts +7 -0
  348. package/dist/veracode-findings.d.ts.map +1 -0
  349. package/dist/veracode-findings.js +371 -0
  350. package/dist/veracode-findings.js.map +1 -0
  351. package/dist/windows-path.d.ts.map +1 -1
  352. package/dist/windows-path.js +1 -0
  353. package/dist/windows-path.js.map +1 -1
  354. package/dist/wiz-csv.d.ts +2 -2
  355. package/dist/wiz-csv.d.ts.map +1 -1
  356. package/dist/wiz-csv.js +1 -3
  357. package/dist/wiz-csv.js.map +1 -1
  358. package/dist/wiz-findings.d.ts +10 -2
  359. package/dist/wiz-findings.d.ts.map +1 -1
  360. package/dist/wiz-findings.js +88 -49
  361. package/dist/wiz-findings.js.map +1 -1
  362. package/docs/classify-severity-records.md +1 -1
  363. package/docs/cli.md +310 -477
  364. package/docs/dedupe-records.md +10 -0
  365. package/docs/findings-service.md +21 -8
  366. package/docs/hosted-scans.md +16 -1
  367. package/package.json +8 -9
  368. package/schemas/external-findings.schema.json +12 -1
  369. package/schemas/hosted-scan-v2.fixture.json +16 -1
  370. package/_bundled_plugin/scripts/validate_tracking_source.py +0 -82
  371. package/_bundled_plugin/scripts/workbench_local_dedupe.py +0 -136
  372. package/dist/deduplication/records-protocol.d.ts +0 -4
  373. package/dist/deduplication/records-protocol.d.ts.map +0 -1
  374. package/dist/deduplication/records-protocol.js +0 -49
  375. package/dist/deduplication/records-protocol.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { z } from "zod";
2
2
  import { GHSA_ID, githubRepositoryParts } from "./github-identifiers.js";
3
- import { CodexSecurityError, errorMessage } from "./errors.js";
3
+ import { CodexSecurityError } from "./errors.js";
4
4
  import { validateExternalEvidence, } from "./external-import-contract.js";
5
5
  import { isGitHubCloudHost } from "./git-remote.js";
6
6
  import { isRecord } from "./record.js";
7
- import { record, relativePath, requiredText, text } from "./scanner-import.js";
7
+ import { trackReaderSelection, record, relativePath, requiredText, text, } from "./scanner-import.js";
8
8
  export function isGitHubDependabotAlert(value) {
9
9
  return (isRecord(value) &&
10
10
  ("security_vulnerability" in value ||
@@ -215,6 +215,7 @@ export function normalizeGitHubDependabotAlerts(input, target = "cloud") {
215
215
  findings: [],
216
216
  excluded: [],
217
217
  };
218
+ const selection = trackReaderSelection(result);
218
219
  const ids = new Set();
219
220
  let sourceRepository;
220
221
  for (const [index, alert] of alerts.entries()) {
@@ -226,22 +227,12 @@ export function normalizeGitHubDependabotAlerts(input, target = "cloud") {
226
227
  throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(sourceId)}. Select each Dependabot alert once.`);
227
228
  ids.add(sourceId);
228
229
  const inputEvidence = evidence(alert, url);
229
- try {
230
+ selection.append(index + 1, sourceId, () => {
230
231
  if (target === "cloud" && Buffer.byteLength(sourceId) > 512)
231
232
  throw new Error("Source finding ID exceeds the Cloud limit of 512 UTF-8 bytes.");
232
- result.findings.push({
233
- source_finding_id: sourceId,
234
- evidence: validateExternalEvidence(inputEvidence, target),
235
- });
236
- }
237
- catch (error) {
238
- result.excluded.push({
239
- position: index + 1,
240
- source_finding_id: sourceId,
241
- reason: errorMessage(error),
242
- });
243
- }
233
+ return validateExternalEvidence(inputEvidence, target);
234
+ });
244
235
  }
245
- return result;
236
+ return selection.finish();
246
237
  }
247
238
  //# sourceMappingURL=github-dependabot-findings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"github-dependabot-findings.js","sourceRoot":"","sources":["../src/github-dependabot-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAEL,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,UAAU,uBAAuB,CACrC,KAAc;IAEd,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,CAAC,wBAAwB,IAAI,KAAK;YAChC,CAAC,YAAY,IAAI,KAAK,IAAI,mBAAmB,IAAI,KAAK,CAAC;YACvD,CAAC,KAAK,CAAC,KAAK,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AC1B,+BAA+B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,sCAAsC,CAC9F,CAAC;QACJ,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAClB,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3C,IAAI,CAAC;YACH,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,GAAG;gBACzD,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;YACJ,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,iBAAiB,EAAE,QAAQ;gBAC3B,QAAQ,EAAE,wBAAwB,CAAC,aAAa,EAAE,MAAM,CAAC;aAC1D,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,QAAQ,EAAE,KAAK,GAAG,CAAC;gBACnB,iBAAiB,EAAE,QAAQ;gBAC3B,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { GHSA_ID, githubRepositoryParts } from \"./github-identifiers.js\";\nimport { CodexSecurityError, errorMessage } from \"./errors.js\";\nimport {\n type ExternalImportTarget,\n validateExternalEvidence,\n} from \"./external-import-contract.js\";\nimport type { ExternalFinding, ExternalFindings } from \"./external-findings.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport { record, relativePath, requiredText, text } from \"./scanner-import.js\";\n\nexport function isGitHubDependabotAlert(\n value: unknown,\n): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (\"security_vulnerability\" in value ||\n (\"dependency\" in value && \"security_advisory\" in value) ||\n [value[\"url\"], value[\"html_url\"]].some(\n (url) =>\n typeof url === \"string\" &&\n /^\\/(?:[^/]+\\/[^/]+\\/security\\/dependabot|(?:api\\/v3\\/)?repos\\/[^/]+\\/[^/]+\\/dependabot\\/alerts)\\/\\d+$/iu.test(\n URL.parse(url)?.pathname ?? \"\",\n ),\n ))\n );\n}\n\nfunction webIdentity(url: string) {\n const match =\n /^(https?):\\/\\/([^/?#@\\\\\\s]+)\\/([^/?#]+\\/[^/?#]+)\\/security\\/dependabot\\/([1-9]\\d*)$/iu.exec(\n url,\n );\n if (!match || !githubRepositoryParts(match[3]!)) return null;\n const parsed = URL.parse(url);\n if (\n !parsed ||\n (parsed.protocol === \"http:\" && isGitHubCloudHost(parsed.hostname))\n )\n return null;\n const host = match[2]!.toLowerCase();\n const repository = match[3]!.toLowerCase();\n const origin = `${parsed.protocol}//${host}`;\n const number = match[4]!;\n const apiBase = isGitHubCloudHost(parsed.hostname)\n ? `https://api.${host}`\n : `${origin}/api/v3`;\n const repositoryUrl = `${origin}/${repository}`;\n const apiRepo = `${apiBase}/repos/${repository}`;\n return {\n repository,\n repositoryUrl,\n apiRepo,\n number,\n sourceId: `${host}/${repository}/dependabot/${number}`,\n htmlUrl: `${repositoryUrl}/security/dependabot/${number}`,\n apiUrl: `${apiRepo}/dependabot/alerts/${number}`,\n };\n}\n\n// Normalized SDK evidence may link to either REST or the web UI.\nfunction alertUrlIdentity(url: unknown) {\n if (typeof url !== \"string\") return null;\n const web = webIdentity(url);\n if (web) return web;\n const api =\n /^(https?:\\/\\/)([^/?#@\\\\\\s]+)\\/(api\\/v3\\/)?repos\\/([^/]+\\/[^/]+)\\/dependabot\\/alerts\\/([1-9]\\d*)$/iu.exec(\n url,\n );\n if (!api) return null;\n const host = api[3] ? api[2] : api[2]!.replace(/^api\\./iu, \"\");\n const parsed = webIdentity(\n `${api[1]}${host}/${api[4]}/security/dependabot/${api[5]}`,\n );\n return parsed?.apiUrl === url.toLowerCase() ? parsed : null;\n}\n\nfunction checkSourceFamily(alert: Record<string, unknown>) {\n if (\n alert[\"source\"] === \"github-code-scanning\" ||\n alert[\"source\"] === \"github-security-advisory\"\n )\n throw new Error(\n \"Dependabot alert conflicts with its GitHub source family.\",\n );\n}\n\nfunction checkNativeClaims(\n alert: Record<string, unknown>,\n occurrence: NonNullable<ReturnType<typeof webIdentity>>,\n) {\n if (\"number\" in alert && alert[\"number\"] !== Number(occurrence.number))\n throw new Error(\n \"Dependabot alert number must match the repository alert URL.\",\n );\n if (\n (\"url\" in alert &&\n text(alert[\"url\"])?.toLowerCase() !== occurrence.apiUrl) ||\n (\"html_url\" in alert &&\n text(alert[\"html_url\"])?.toLowerCase() !== occurrence.htmlUrl)\n )\n throw new Error(\n \"Dependabot API url and html_url must identify the same host, repository and alert number.\",\n );\n if (\"repository\" in alert) {\n const declared = record(alert[\"repository\"], \"Dependabot repository\");\n if (\n text(declared[\"full_name\"])?.toLowerCase() !== occurrence.repository ||\n (\"html_url\" in declared &&\n text(declared[\"html_url\"])?.toLowerCase() !==\n occurrence.repositoryUrl) ||\n (\"url\" in declared &&\n text(declared[\"url\"])?.toLowerCase() !== occurrence.apiRepo)\n )\n throw new Error(\n \"Dependabot repository metadata conflicts with its alert URLs.\",\n );\n }\n}\n\nfunction identity(alert: Record<string, unknown>) {\n checkSourceFamily(alert);\n const number = alert[\"number\"];\n if (typeof number !== \"number\" || !Number.isSafeInteger(number) || number < 1)\n throw new Error(\"Dependabot alert number must be a positive safe integer.\");\n const url = requiredText(alert[\"html_url\"], \"Dependabot html_url\");\n const parsed = webIdentity(url);\n if (!parsed || parsed.number !== String(number))\n throw new Error(\n \"Dependabot html_url must identify the repository and alert number.\",\n );\n requiredText(alert[\"url\"], \"Dependabot API url\");\n checkNativeClaims(alert, parsed);\n return {\n repositoryUrl: parsed.repositoryUrl,\n sourceId: parsed.sourceId,\n url,\n };\n}\n\nexport function dependabotRepository({\n source_finding_id: id,\n evidence: { source_data: sourceData, url },\n}: ExternalFinding): string | undefined {\n const native = isGitHubDependabotAlert(sourceData) ? sourceData : null;\n const raw =\n native &&\n (alertUrlIdentity(native[\"html_url\"]) ?? alertUrlIdentity(native[\"url\"]));\n const projected = alertUrlIdentity(url);\n const occurrence = raw ?? projected;\n const structuredId =\n /^[^/]+\\/[^/]+\\/[^/]+\\/(?:dependabot|code-scanning|security-advisory)\\//u.test(\n id,\n );\n if (!occurrence) {\n if (/^[^/]+\\/[^/]+\\/[^/]+\\/dependabot\\/[1-9]\\d*$/u.test(id))\n throw new CodexSecurityError(\n \"The normalized Dependabot occurrence needs the original alert or its repository alert URL.\",\n );\n return;\n }\n if (isRecord(sourceData)) checkSourceFamily(sourceData);\n if (native) checkNativeClaims(native, occurrence);\n // A caller may have stored this occurrence under an opaque ID before native imports existed.\n if ((structuredId || id === \"\") && id !== occurrence.sourceId)\n throw new CodexSecurityError(\n \"The normalized source finding ID does not match the original Dependabot alert.\",\n );\n if (raw && projected && raw.htmlUrl !== projected.htmlUrl)\n throw new CodexSecurityError(\n \"The normalized alert URL does not match the original Dependabot alert.\",\n );\n return occurrence.repositoryUrl;\n}\n\nfunction selectedAlerts(input: unknown) {\n const selection = Array.isArray(input) ? input : [input];\n const hasPages = selection.some(Array.isArray);\n if (hasPages && !selection.every(Array.isArray))\n throw new Error(\n \"Dependabot input must not mix alert records and page arrays.\",\n );\n const rows: unknown[] = hasPages ? selection.flat() : selection;\n if (!rows.every(isGitHubDependabotAlert))\n throw new Error(\n \"Expected complete native Dependabot repository alerts, not mixed families, page shapes or API envelopes.\",\n );\n return rows;\n}\n\n// Parse only the matched vulnerability projection. Keep the complete upstream alert as evidence.\nconst nonblank = z.string().regex(/\\S/u);\nconst matchedVulnerability = z.object({\n package: z.object({ name: nonblank, ecosystem: nonblank }),\n vulnerable_version_range: nonblank,\n first_patched_version: z.object({ identifier: nonblank }).nullable(),\n severity: z.enum([\"critical\", \"high\", \"medium\", \"low\"]),\n});\n\nfunction evidence(alert: Record<string, unknown>, url: string) {\n const dependency = record(alert[\"dependency\"], \"Dependabot dependency\");\n const advisory = record(\n alert[\"security_advisory\"],\n \"Dependabot security_advisory\",\n );\n const {\n package: { name, ecosystem },\n vulnerable_version_range: range,\n first_patched_version: patch,\n severity,\n } = matchedVulnerability.parse(alert[\"security_vulnerability\"]);\n if (\"package\" in dependency) {\n const observed = record(\n dependency[\"package\"],\n \"Dependabot dependency package\",\n );\n if (observed[\"name\"] !== name || observed[\"ecosystem\"] !== ecosystem)\n throw new Error(\n \"Dependabot dependency and matched vulnerability packages disagree.\",\n );\n }\n const path = dependency[\"manifest_path\"] ?? null;\n if (path !== null) {\n const filename = relativePath(path)?.split(\"/\").at(-1);\n if (\n typeof path !== \"string\" ||\n /^[a-z][a-z\\d+.-]*:/iu.test(path) ||\n !filename ||\n filename === \".\"\n )\n throw new Error(\n \"Dependabot manifest_path must identify a repository-relative file.\",\n );\n }\n const ghsa = requiredText(advisory[\"ghsa_id\"], \"Dependabot GHSA ID\");\n if (!GHSA_ID.test(ghsa))\n throw new Error(\"Dependabot security_advisory must identify a GHSA.\");\n const affected = advisory[\"vulnerabilities\"];\n if (\n !Array.isArray(affected) ||\n !affected.some(\n (entry) =>\n isRecord(entry) &&\n isRecord(entry[\"package\"]) &&\n entry[\"package\"][\"name\"] === name &&\n entry[\"package\"][\"ecosystem\"] === ecosystem &&\n entry[\"vulnerable_version_range\"] === range,\n )\n )\n throw new Error(\n \"Dependabot advisory does not cover the matched package and vulnerable range.\",\n );\n const state = alert[\"state\"];\n if (\n typeof state !== \"string\" ||\n ![\"open\", \"dismissed\", \"auto_dismissed\", \"fixed\"].includes(state)\n )\n throw new Error(\n \"Dependabot alert state must be open, dismissed, auto_dismissed or fixed.\",\n );\n const updated =\n Date.parse(requiredText(alert[\"updated_at\"], \"Dependabot updated_at\")) /\n 1000;\n if (!Number.isFinite(updated) || updated < 0)\n throw new Error(\"Dependabot updated_at must be a valid timestamp.\");\n const advisoryIds = new Set([ghsa]);\n const cve = text(advisory[\"cve_id\"]);\n if (cve) advisoryIds.add(cve);\n const identifiers = advisory[\"identifiers\"];\n if (Array.isArray(identifiers)) {\n for (const item of identifiers) {\n const value = isRecord(item) && text(item[\"value\"]);\n if (!value) continue;\n if (\n (item[\"type\"] === \"GHSA\" || /^GHSA-/iu.test(value)) &&\n value.toUpperCase() !== ghsa.toUpperCase()\n )\n throw new Error(\n \"Dependabot advisory identifiers disagree on the GHSA.\",\n );\n advisoryIds.add(value);\n }\n }\n return {\n title: requiredText(advisory[\"summary\"], \"Dependabot advisory summary\"),\n description: text(advisory[\"description\"]),\n severity,\n url,\n advisory_ids: [...advisoryIds],\n packages: [\n {\n name,\n ecosystem,\n manifest_path: path,\n vulnerable_version_range: range,\n fixed_versions: patch ? [patch.identifier] : [],\n },\n ],\n locations: path ? [{ path }] : [],\n source_updated_at: Math.floor(updated),\n source_data: structuredClone(alert),\n };\n}\n\nexport function normalizeGitHubDependabotAlerts(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const alerts = selectedAlerts(input);\n const result: ExternalFindings = {\n read: alerts.length,\n findings: [],\n excluded: [],\n };\n const ids = new Set<string>();\n let sourceRepository: string | undefined;\n for (const [index, alert] of alerts.entries()) {\n const { repositoryUrl, sourceId, url } = identity(alert);\n if (sourceRepository !== undefined && sourceRepository !== repositoryUrl)\n throw new CodexSecurityError(\n \"Select Dependabot alerts from only one GitHub host and repository.\",\n );\n sourceRepository = repositoryUrl;\n if (ids.has(sourceId))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(sourceId)}. Select each Dependabot alert once.`,\n );\n ids.add(sourceId);\n const inputEvidence = evidence(alert, url);\n try {\n if (target === \"cloud\" && Buffer.byteLength(sourceId) > 512)\n throw new Error(\n \"Source finding ID exceeds the Cloud limit of 512 UTF-8 bytes.\",\n );\n result.findings.push({\n source_finding_id: sourceId,\n evidence: validateExternalEvidence(inputEvidence, target),\n });\n } catch (error) {\n result.excluded.push({\n position: index + 1,\n source_finding_id: sourceId,\n reason: errorMessage(error),\n });\n }\n }\n return result;\n}\n"]}
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AAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { GHSA_ID, githubRepositoryParts } from \"./github-identifiers.js\";\nimport { CodexSecurityError } from \"./errors.js\";\nimport {\n type ExternalImportTarget,\n validateExternalEvidence,\n} from \"./external-import-contract.js\";\nimport type { ExternalFinding, ExternalFindings } from \"./external-findings.js\";\nimport { isGitHubCloudHost } from \"./git-remote.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n trackReaderSelection,\n record,\n relativePath,\n requiredText,\n text,\n} from \"./scanner-import.js\";\n\nexport function isGitHubDependabotAlert(\n value: unknown,\n): value is Record<string, unknown> {\n return (\n isRecord(value) &&\n (\"security_vulnerability\" in value ||\n (\"dependency\" in value && \"security_advisory\" in value) ||\n [value[\"url\"], value[\"html_url\"]].some(\n (url) =>\n typeof url === \"string\" &&\n /^\\/(?:[^/]+\\/[^/]+\\/security\\/dependabot|(?:api\\/v3\\/)?repos\\/[^/]+\\/[^/]+\\/dependabot\\/alerts)\\/\\d+$/iu.test(\n URL.parse(url)?.pathname ?? \"\",\n ),\n ))\n );\n}\n\nfunction webIdentity(url: string) {\n const match =\n /^(https?):\\/\\/([^/?#@\\\\\\s]+)\\/([^/?#]+\\/[^/?#]+)\\/security\\/dependabot\\/([1-9]\\d*)$/iu.exec(\n url,\n );\n if (!match || !githubRepositoryParts(match[3]!)) return null;\n const parsed = URL.parse(url);\n if (\n !parsed ||\n (parsed.protocol === \"http:\" && isGitHubCloudHost(parsed.hostname))\n )\n return null;\n const host = match[2]!.toLowerCase();\n const repository = match[3]!.toLowerCase();\n const origin = `${parsed.protocol}//${host}`;\n const number = match[4]!;\n const apiBase = isGitHubCloudHost(parsed.hostname)\n ? `https://api.${host}`\n : `${origin}/api/v3`;\n const repositoryUrl = `${origin}/${repository}`;\n const apiRepo = `${apiBase}/repos/${repository}`;\n return {\n repository,\n repositoryUrl,\n apiRepo,\n number,\n sourceId: `${host}/${repository}/dependabot/${number}`,\n htmlUrl: `${repositoryUrl}/security/dependabot/${number}`,\n apiUrl: `${apiRepo}/dependabot/alerts/${number}`,\n };\n}\n\n// Normalized SDK evidence may link to either REST or the web UI.\nfunction alertUrlIdentity(url: unknown) {\n if (typeof url !== \"string\") return null;\n const web = webIdentity(url);\n if (web) return web;\n const api =\n /^(https?:\\/\\/)([^/?#@\\\\\\s]+)\\/(api\\/v3\\/)?repos\\/([^/]+\\/[^/]+)\\/dependabot\\/alerts\\/([1-9]\\d*)$/iu.exec(\n url,\n );\n if (!api) return null;\n const host = api[3] ? api[2] : api[2]!.replace(/^api\\./iu, \"\");\n const parsed = webIdentity(\n `${api[1]}${host}/${api[4]}/security/dependabot/${api[5]}`,\n );\n return parsed?.apiUrl === url.toLowerCase() ? parsed : null;\n}\n\nfunction checkSourceFamily(alert: Record<string, unknown>) {\n if (\n alert[\"source\"] === \"github-code-scanning\" ||\n alert[\"source\"] === \"github-security-advisory\"\n )\n throw new Error(\n \"Dependabot alert conflicts with its GitHub source family.\",\n );\n}\n\nfunction checkNativeClaims(\n alert: Record<string, unknown>,\n occurrence: NonNullable<ReturnType<typeof webIdentity>>,\n) {\n if (\"number\" in alert && alert[\"number\"] !== Number(occurrence.number))\n throw new Error(\n \"Dependabot alert number must match the repository alert URL.\",\n );\n if (\n (\"url\" in alert &&\n text(alert[\"url\"])?.toLowerCase() !== occurrence.apiUrl) ||\n (\"html_url\" in alert &&\n text(alert[\"html_url\"])?.toLowerCase() !== occurrence.htmlUrl)\n )\n throw new Error(\n \"Dependabot API url and html_url must identify the same host, repository and alert number.\",\n );\n if (\"repository\" in alert) {\n const declared = record(alert[\"repository\"], \"Dependabot repository\");\n if (\n text(declared[\"full_name\"])?.toLowerCase() !== occurrence.repository ||\n (\"html_url\" in declared &&\n text(declared[\"html_url\"])?.toLowerCase() !==\n occurrence.repositoryUrl) ||\n (\"url\" in declared &&\n text(declared[\"url\"])?.toLowerCase() !== occurrence.apiRepo)\n )\n throw new Error(\n \"Dependabot repository metadata conflicts with its alert URLs.\",\n );\n }\n}\n\nfunction identity(alert: Record<string, unknown>) {\n checkSourceFamily(alert);\n const number = alert[\"number\"];\n if (typeof number !== \"number\" || !Number.isSafeInteger(number) || number < 1)\n throw new Error(\"Dependabot alert number must be a positive safe integer.\");\n const url = requiredText(alert[\"html_url\"], \"Dependabot html_url\");\n const parsed = webIdentity(url);\n if (!parsed || parsed.number !== String(number))\n throw new Error(\n \"Dependabot html_url must identify the repository and alert number.\",\n );\n requiredText(alert[\"url\"], \"Dependabot API url\");\n checkNativeClaims(alert, parsed);\n return {\n repositoryUrl: parsed.repositoryUrl,\n sourceId: parsed.sourceId,\n url,\n };\n}\n\nexport function dependabotRepository({\n source_finding_id: id,\n evidence: { source_data: sourceData, url },\n}: ExternalFinding): string | undefined {\n const native = isGitHubDependabotAlert(sourceData) ? sourceData : null;\n const raw =\n native &&\n (alertUrlIdentity(native[\"html_url\"]) ?? alertUrlIdentity(native[\"url\"]));\n const projected = alertUrlIdentity(url);\n const occurrence = raw ?? projected;\n const structuredId =\n /^[^/]+\\/[^/]+\\/[^/]+\\/(?:dependabot|code-scanning|security-advisory)\\//u.test(\n id,\n );\n if (!occurrence) {\n if (/^[^/]+\\/[^/]+\\/[^/]+\\/dependabot\\/[1-9]\\d*$/u.test(id))\n throw new CodexSecurityError(\n \"The normalized Dependabot occurrence needs the original alert or its repository alert URL.\",\n );\n return;\n }\n if (isRecord(sourceData)) checkSourceFamily(sourceData);\n if (native) checkNativeClaims(native, occurrence);\n // A caller may have stored this occurrence under an opaque ID before native imports existed.\n if ((structuredId || id === \"\") && id !== occurrence.sourceId)\n throw new CodexSecurityError(\n \"The normalized source finding ID does not match the original Dependabot alert.\",\n );\n if (raw && projected && raw.htmlUrl !== projected.htmlUrl)\n throw new CodexSecurityError(\n \"The normalized alert URL does not match the original Dependabot alert.\",\n );\n return occurrence.repositoryUrl;\n}\n\nfunction selectedAlerts(input: unknown) {\n const selection = Array.isArray(input) ? input : [input];\n const hasPages = selection.some(Array.isArray);\n if (hasPages && !selection.every(Array.isArray))\n throw new Error(\n \"Dependabot input must not mix alert records and page arrays.\",\n );\n const rows: unknown[] = hasPages ? selection.flat() : selection;\n if (!rows.every(isGitHubDependabotAlert))\n throw new Error(\n \"Expected complete native Dependabot repository alerts, not mixed families, page shapes or API envelopes.\",\n );\n return rows;\n}\n\n// Parse only the matched vulnerability projection. Keep the complete upstream alert as evidence.\nconst nonblank = z.string().regex(/\\S/u);\nconst matchedVulnerability = z.object({\n package: z.object({ name: nonblank, ecosystem: nonblank }),\n vulnerable_version_range: nonblank,\n first_patched_version: z.object({ identifier: nonblank }).nullable(),\n severity: z.enum([\"critical\", \"high\", \"medium\", \"low\"]),\n});\n\nfunction evidence(alert: Record<string, unknown>, url: string) {\n const dependency = record(alert[\"dependency\"], \"Dependabot dependency\");\n const advisory = record(\n alert[\"security_advisory\"],\n \"Dependabot security_advisory\",\n );\n const {\n package: { name, ecosystem },\n vulnerable_version_range: range,\n first_patched_version: patch,\n severity,\n } = matchedVulnerability.parse(alert[\"security_vulnerability\"]);\n if (\"package\" in dependency) {\n const observed = record(\n dependency[\"package\"],\n \"Dependabot dependency package\",\n );\n if (observed[\"name\"] !== name || observed[\"ecosystem\"] !== ecosystem)\n throw new Error(\n \"Dependabot dependency and matched vulnerability packages disagree.\",\n );\n }\n const path = dependency[\"manifest_path\"] ?? null;\n if (path !== null) {\n const filename = relativePath(path)?.split(\"/\").at(-1);\n if (\n typeof path !== \"string\" ||\n /^[a-z][a-z\\d+.-]*:/iu.test(path) ||\n !filename ||\n filename === \".\"\n )\n throw new Error(\n \"Dependabot manifest_path must identify a repository-relative file.\",\n );\n }\n const ghsa = requiredText(advisory[\"ghsa_id\"], \"Dependabot GHSA ID\");\n if (!GHSA_ID.test(ghsa))\n throw new Error(\"Dependabot security_advisory must identify a GHSA.\");\n const affected = advisory[\"vulnerabilities\"];\n if (\n !Array.isArray(affected) ||\n !affected.some(\n (entry) =>\n isRecord(entry) &&\n isRecord(entry[\"package\"]) &&\n entry[\"package\"][\"name\"] === name &&\n entry[\"package\"][\"ecosystem\"] === ecosystem &&\n entry[\"vulnerable_version_range\"] === range,\n )\n )\n throw new Error(\n \"Dependabot advisory does not cover the matched package and vulnerable range.\",\n );\n const state = alert[\"state\"];\n if (\n typeof state !== \"string\" ||\n ![\"open\", \"dismissed\", \"auto_dismissed\", \"fixed\"].includes(state)\n )\n throw new Error(\n \"Dependabot alert state must be open, dismissed, auto_dismissed or fixed.\",\n );\n const updated =\n Date.parse(requiredText(alert[\"updated_at\"], \"Dependabot updated_at\")) /\n 1000;\n if (!Number.isFinite(updated) || updated < 0)\n throw new Error(\"Dependabot updated_at must be a valid timestamp.\");\n const advisoryIds = new Set([ghsa]);\n const cve = text(advisory[\"cve_id\"]);\n if (cve) advisoryIds.add(cve);\n const identifiers = advisory[\"identifiers\"];\n if (Array.isArray(identifiers)) {\n for (const item of identifiers) {\n const value = isRecord(item) && text(item[\"value\"]);\n if (!value) continue;\n if (\n (item[\"type\"] === \"GHSA\" || /^GHSA-/iu.test(value)) &&\n value.toUpperCase() !== ghsa.toUpperCase()\n )\n throw new Error(\n \"Dependabot advisory identifiers disagree on the GHSA.\",\n );\n advisoryIds.add(value);\n }\n }\n return {\n title: requiredText(advisory[\"summary\"], \"Dependabot advisory summary\"),\n description: text(advisory[\"description\"]),\n severity,\n url,\n advisory_ids: [...advisoryIds],\n packages: [\n {\n name,\n ecosystem,\n manifest_path: path,\n vulnerable_version_range: range,\n fixed_versions: patch ? [patch.identifier] : [],\n },\n ],\n locations: path ? [{ path }] : [],\n source_updated_at: Math.floor(updated),\n source_data: structuredClone(alert),\n };\n}\n\nexport function normalizeGitHubDependabotAlerts(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const alerts = selectedAlerts(input);\n const result: ExternalFindings = {\n read: alerts.length,\n findings: [],\n excluded: [],\n };\n const selection = trackReaderSelection(result);\n const ids = new Set<string>();\n let sourceRepository: string | undefined;\n for (const [index, alert] of alerts.entries()) {\n const { repositoryUrl, sourceId, url } = identity(alert);\n if (sourceRepository !== undefined && sourceRepository !== repositoryUrl)\n throw new CodexSecurityError(\n \"Select Dependabot alerts from only one GitHub host and repository.\",\n );\n sourceRepository = repositoryUrl;\n if (ids.has(sourceId))\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(sourceId)}. Select each Dependabot alert once.`,\n );\n ids.add(sourceId);\n const inputEvidence = evidence(alert, url);\n selection.append(index + 1, sourceId, () => {\n if (target === \"cloud\" && Buffer.byteLength(sourceId) > 512)\n throw new Error(\n \"Source finding ID exceeds the Cloud limit of 512 UTF-8 bytes.\",\n );\n return validateExternalEvidence(inputEvidence, target);\n });\n }\n return selection.finish();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"github-findings.d.ts","sourceRoot":"","sources":["../src/github-findings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAK1E,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AA4SrE,uFAAuF;AACvF,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,SAAS,+BAA+B,EAAE,EAClD,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CAElB;AAED,qFAAqF;AACrF,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,SAAS,sBAAsB,EAAE,EAC7C,MAAM,GAAE,oBAA8B,GACrC,gBAAgB,CAElB;AAED,uFAAuF;AACvF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,oBAA8B,GACrC,OAAO,CAAC,gBAAgB,CAAC,CAoB3B"}
1
+ {"version":3,"file":"github-findings.d.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