@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,14 +1,13 @@
1
1
  import { hash } from "node:crypto";
2
+ import { isDeepStrictEqual } from "node:util";
3
+ import { isBoxedPrimitive, isDate, isProxy } from "node:util/types";
2
4
  import { GHSA_ID, githubRepositoryParts } from "./github-identifiers.js";
3
5
  import { CodexSecurityError, errorMessage } from "./errors.js";
4
- import { validateExternalEvidence } from "./external-import-contract.js";
6
+ import { CloudEvidenceDepthError, exportedGitHubRecord, previousGitHubExclusion, validateExternalEvidenceFields, validateExternalEvidenceJson, validateExternalEvidence, } from "./external-import-contract.js";
5
7
  import { isGitHubDependabotAlert, normalizeGitHubDependabotAlerts, } from "./github-dependabot-findings.js";
8
+ import { asRecord, canSnapshotWithoutGetters, cloneWithoutGetters, } from "./record.js";
6
9
  import { parseJsonOrJsonl, readScannerText, text } from "./scanner-import.js";
7
- function object(value) {
8
- return value !== null && typeof value === "object" && !Array.isArray(value)
9
- ? value
10
- : undefined;
11
- }
10
+ import { rememberPreviousSelection, } from "./reader-selection.js";
12
11
  function repositoryName(value) {
13
12
  const repository = text(value);
14
13
  if (!repository || !githubRepositoryParts(repository))
@@ -38,9 +37,16 @@ function severity(value) {
38
37
  ? value
39
38
  : "unknown";
40
39
  }
41
- function codeScanningFinding(record, target = "cloud") {
40
+ function codeScanningPrefix({ parsed, host }, repository, number) {
41
+ const name = repository.toLowerCase();
42
+ const path = parsed.pathname.toLowerCase();
43
+ const alert = `code-scanning/${number}`;
44
+ if (path === `/${name}/${alert}` || path === `/${name}/security/${alert}`)
45
+ return `${host}/${name}/${alert}/`;
46
+ }
47
+ function codeScanningFinding(record) {
42
48
  const repository = repositoryName(record["repository"]);
43
- const alert = object(record["alert"]);
49
+ const alert = asRecord(record["alert"]);
44
50
  const number = record["number"];
45
51
  if (!alert ||
46
52
  typeof number !== "number" ||
@@ -51,18 +57,18 @@ function codeScanningFinding(record, target = "cloud") {
51
57
  const url = text(record["url"]);
52
58
  if (!url || url !== alert["html_url"])
53
59
  throw new Error("GitHub alert URL must match the original alert.");
54
- const { parsed: parsedUrl, host, origin } = sourceUrl(url);
55
- if (!["security/code-scanning", "code-scanning"].some((route) => parsedUrl.pathname.toLowerCase() ===
56
- `/${repository}/${route}/${number}`.toLowerCase()))
60
+ const link = sourceUrl(url);
61
+ const prefix = codeScanningPrefix(link, repository, number);
62
+ if (!prefix)
57
63
  throw new Error("GitHub alert URL does not match the selected repository and alert.");
58
- const rule = object(alert["rule"]);
59
- const instance = object(alert["most_recent_instance"]);
64
+ const rule = asRecord(alert["rule"]);
65
+ const instance = asRecord(alert["most_recent_instance"]);
60
66
  const ref = text(instance?.["ref"]);
61
67
  if (!ref)
62
68
  throw new Error("GitHub code-scanning evidence requires the selected instance ref.");
63
- const location = object(instance?.["location"]);
64
- const tool = object(alert["tool"]);
65
- const message = text(object(instance?.["message"])?.["text"]);
69
+ const location = asRecord(instance?.["location"]);
70
+ const tool = asRecord(alert["tool"]);
71
+ const message = text(asRecord(instance?.["message"])?.["text"]);
66
72
  const description = text(rule?.["full_description"]) ?? text(rule?.["description"]);
67
73
  const tags = Array.isArray(rule?.["tags"]) ? rule["tags"] : [];
68
74
  const weaknessIds = [
@@ -74,10 +80,9 @@ function codeScanningFinding(record, target = "cloud") {
74
80
  })),
75
81
  ];
76
82
  const path = text(location?.["path"]);
77
- const sourceId = `${host}/${repository.toLowerCase()}/code-scanning/${number}/${hash("sha256", ref)}`;
78
83
  return {
79
- source_finding_id: sourceId,
80
- evidence: validateExternalEvidence({
84
+ source_finding_id: prefix + hash("sha256", ref),
85
+ evidence: {
81
86
  title: text(rule?.["name"]) ??
82
87
  text(rule?.["description"]) ??
83
88
  `GitHub code-scanning alert #${number}`,
@@ -85,9 +90,7 @@ function codeScanningFinding(record, target = "cloud") {
85
90
  description: [...new Set([message, description].filter(Boolean))].join("\n\n") ||
86
91
  null,
87
92
  url,
88
- locations: path
89
- ? [{ path, line: location?.["start_line"] ?? null }]
90
- : [],
93
+ locations: path ? [{ path, line: location?.["start_line"] ?? null }] : [],
91
94
  branch: ref,
92
95
  code_revision: text(instance?.["commit_sha"]),
93
96
  source_updated_at: sourceTimestamp(alert["updated_at"]),
@@ -95,7 +98,7 @@ function codeScanningFinding(record, target = "cloud") {
95
98
  details: {
96
99
  kind: "sast",
97
100
  repository: {
98
- url: `${origin}/${repository}`,
101
+ url: `${link.origin}/${repository}`,
99
102
  name: repository,
100
103
  },
101
104
  // Dismissal covers every branch; detection state belongs to the selected ref.
@@ -108,12 +111,15 @@ function codeScanningFinding(record, target = "cloud") {
108
111
  remediation_instructions: text(rule?.["help"]),
109
112
  code: path ? { end_line: location?.["end_line"] ?? null } : null,
110
113
  },
111
- }, target),
114
+ },
112
115
  };
113
116
  }
114
- function advisoryFinding(record, target = "cloud") {
117
+ function advisorySourceId(host, selection, repository, id) {
118
+ return `${host}/${selection === "repository" ? repository.toLowerCase() : "global"}/security-advisory/${id.toUpperCase()}`;
119
+ }
120
+ function advisoryFinding(record) {
115
121
  const repository = repositoryName(record["repository"]);
116
- const advisory = object(record["advisory"]);
122
+ const advisory = asRecord(record["advisory"]);
117
123
  const id = text(record["ghsaId"]);
118
124
  const selection = record["selection"];
119
125
  if (!advisory ||
@@ -146,11 +152,11 @@ function advisoryFinding(record, target = "cloud") {
146
152
  const advisoryIds = [
147
153
  id,
148
154
  text(advisory["cve_id"]),
149
- ...identifiers.map((identifier) => text(object(identifier)?.["value"])),
155
+ ...identifiers.map((identifier) => text(asRecord(identifier)?.["value"])),
150
156
  ].filter((value) => value !== null);
151
157
  const packages = vulnerabilities.flatMap((value) => {
152
- const vulnerability = object(value);
153
- const pkg = object(vulnerability?.["package"]);
158
+ const vulnerability = asRecord(value);
159
+ const pkg = asRecord(vulnerability?.["package"]);
154
160
  const name = text(pkg?.["name"]);
155
161
  // GitHub permits incomplete package metadata in advisory disclosures.
156
162
  // Preserve it in source_data without inventing a typed package identity.
@@ -169,8 +175,8 @@ function advisoryFinding(record, target = "cloud") {
169
175
  });
170
176
  const cwes = Array.isArray(advisory["cwes"]) ? advisory["cwes"] : [];
171
177
  return {
172
- source_finding_id: `${host}/${selection === "repository" ? repository.toLowerCase() : "global"}/security-advisory/${id.toUpperCase()}`,
173
- evidence: validateExternalEvidence({
178
+ source_finding_id: advisorySourceId(host, selection, repository, id),
179
+ evidence: {
174
180
  title: text(advisory["summary"]) ?? id,
175
181
  severity: severity(advisory["severity"]),
176
182
  description: text(advisory["description"]),
@@ -196,55 +202,337 @@ function advisoryFinding(record, target = "cloud") {
196
202
  (selection === "global" ? "published" : null)),
197
203
  scanner_origin: "GitHub Security Advisories",
198
204
  weakness_ids: cwes
199
- .map((value) => text(object(value)?.["cwe_id"]))
205
+ .map((value) => text(asRecord(value)?.["cwe_id"]))
200
206
  .filter((value) => value !== null),
201
207
  },
202
- }, target),
208
+ },
209
+ };
210
+ }
211
+ function mapRecord(input) {
212
+ const record = asRecord(input);
213
+ if (!record)
214
+ throw new Error("GitHub finding must be an object.");
215
+ if (record["source"] === "github-code-scanning")
216
+ return codeScanningFinding(record);
217
+ if (record["source"] === "github-security-advisory")
218
+ return advisoryFinding(record);
219
+ throw new Error("Expected saved output from import github or import github-advisories; raw or incomplete API responses need an explicit mapping.");
220
+ }
221
+ function ownData(value, key) {
222
+ if (value && typeof value === "object" && !isProxy(value))
223
+ return Object.getOwnPropertyDescriptor(value, key)?.value;
224
+ }
225
+ function priorAdvisoryId(value) {
226
+ if (ownData(value, "source") !== "github-security-advisory")
227
+ return;
228
+ const id = text(ownData(value, "ghsaId"));
229
+ const host = text(ownData(value, "githubHost"))?.toLowerCase();
230
+ const selection = ownData(value, "selection");
231
+ const repository = text(ownData(value, "repository"));
232
+ if (id &&
233
+ GHSA_ID.test(id) &&
234
+ host &&
235
+ repository &&
236
+ githubRepositoryParts(repository) &&
237
+ (selection === "repository" || selection === "global"))
238
+ return advisorySourceId(host, selection, repository, id);
239
+ }
240
+ // Determine whether JSON can call a serializer without evaluating a getter.
241
+ function maySerialize(value) {
242
+ while (value && typeof value === "object") {
243
+ if (isProxy(value))
244
+ return true;
245
+ const field = Object.getOwnPropertyDescriptor(value, "toJSON");
246
+ if (field)
247
+ return (!Object.hasOwn(field, "value") || typeof field.value === "function");
248
+ value = Object.getPrototypeOf(value);
249
+ }
250
+ return false;
251
+ }
252
+ function codeOccurrencePrefix(value) {
253
+ const repository = ownData(value, "repository"), number = ownData(value, "number"), url = ownData(value, "url");
254
+ if (ownData(value, "source") !== "github-code-scanning" ||
255
+ typeof repository !== "string" ||
256
+ !githubRepositoryParts(repository) ||
257
+ typeof number !== "number" ||
258
+ !Number.isSafeInteger(number) ||
259
+ number <= 0 ||
260
+ typeof url !== "string")
261
+ return;
262
+ try {
263
+ return codeScanningPrefix(sourceUrl(url), repository, number);
264
+ }
265
+ catch {
266
+ /* No validated occurrence anchor. */
267
+ }
268
+ }
269
+ // The released reader measured the caller's source_data JSON before native capture.
270
+ function captureGitHubRecord(input, target) {
271
+ // Only plain records, arrays and standard Buffers have a reconstructable wire size.
272
+ let plainBuffers = [];
273
+ let hiddenFields = false;
274
+ let largeLocalRow = false;
275
+ const record = cloneWithoutGetters(input, (value) => {
276
+ const prototype = Object.getPrototypeOf(value);
277
+ if (target === "local" &&
278
+ ((Array.isArray(value) && value.length > 256 * 1024) ||
279
+ (prototype === Buffer.prototype &&
280
+ Buffer.isBuffer(value) &&
281
+ !Object.hasOwn(value, "byteLength") &&
282
+ value.byteLength > 256 * 1024))) {
283
+ largeLocalRow = true;
284
+ return false;
285
+ }
286
+ // Native capture drops non-enumerable fields the released vendor mapper could read.
287
+ if (!Array.isArray(value) &&
288
+ !ArrayBuffer.isView(value) &&
289
+ !isBoxedPrimitive(value) &&
290
+ !isDate(value) &&
291
+ Object.getOwnPropertyNames(value).some((key) => key !== "toJSON" &&
292
+ !Object.prototype.propertyIsEnumerable.call(value, key)))
293
+ hiddenFields = true;
294
+ if (!plainBuffers)
295
+ return;
296
+ if (Buffer.isBuffer(value)) {
297
+ if (prototype === Buffer.prototype &&
298
+ !Object.hasOwn(value, "toJSON") &&
299
+ !Object.hasOwn(value, "length") &&
300
+ !("_arr" in value))
301
+ plainBuffers.push(value);
302
+ else
303
+ plainBuffers = undefined;
304
+ }
305
+ else if ((prototype !== Object.prototype &&
306
+ prototype !== null &&
307
+ prototype !== Array.prototype) ||
308
+ maySerialize(value))
309
+ plainBuffers = undefined;
310
+ });
311
+ return {
312
+ record: asRecord(record),
313
+ hiddenFields,
314
+ plainBuffers,
315
+ largeLocalRow,
203
316
  };
204
317
  }
205
- function normalizeRecords(records, target = "cloud") {
318
+ function normalizeRecords(records, target = "cloud", snapshot = false) {
206
319
  const result = {
207
320
  read: records.length,
208
321
  findings: [],
209
322
  excluded: [],
210
323
  };
324
+ const previous = snapshot
325
+ ? { read: records.length, findings: [], excluded: [] }
326
+ : undefined;
327
+ const checks = [];
328
+ const uncertainIds = new Set();
329
+ const unidentifiedRows = new Set();
330
+ let independentlyObserved = Infinity;
331
+ let ranRootSerializer = false;
332
+ let largeLocalSelection = false;
333
+ const potentialIds = [];
334
+ const prefixes = new Set();
211
335
  const identities = new Set();
212
- for (const [index, value] of records.entries()) {
213
- const record = object(value);
336
+ for (const [index, input] of records.entries()) {
337
+ const afterRootSerializer = ranRootSerializer;
338
+ const keySensitive = previous !== undefined && maySerialize(input);
339
+ ranRootSerializer ||= keySensitive;
340
+ let exported = input;
341
+ const capture = previous ? captureGitHubRecord(input, target) : undefined;
342
+ const before = capture?.record;
343
+ const priorPrefix = previous ? codeOccurrencePrefix(input) : undefined;
344
+ let priorId = previous ? priorAdvisoryId(input) : undefined;
345
+ let prefix = priorPrefix;
346
+ const rowIds = new Set();
347
+ let rowUncertain = false;
348
+ const priorRowCount = previous?.findings.length ?? 0;
349
+ function possible() {
350
+ rowUncertain = true;
351
+ // A caller getter can mutate a later row before its native evidence is seen.
352
+ independentlyObserved = Math.min(independentlyObserved, priorRowCount);
353
+ for (const id of rowIds)
354
+ uncertainIds.add(id);
355
+ if (prefix)
356
+ prefixes.add(prefix);
357
+ if (priorId)
358
+ uncertainIds.add(priorId);
359
+ else if (!priorPrefix)
360
+ unidentifiedRows.add(index);
361
+ }
362
+ // The old reader called a root serializer with "source_data" rather than its
363
+ // array index. That code could change a later occurrence before it was read.
364
+ if (afterRootSerializer) {
365
+ possible();
366
+ unidentifiedRows.add(index);
367
+ }
368
+ function retainPrevious(selection, id, evidence) {
369
+ selection.findings.push({ source_finding_id: id, evidence });
370
+ potentialIds.push(id);
371
+ checks.push(() => {
372
+ if (!isDeepStrictEqual(before, asRecord(cloneWithoutGetters(input))))
373
+ possible();
374
+ });
375
+ }
376
+ const exclusion = (record, reason) => ({
377
+ position: index + 1,
378
+ source_finding_id: text(asRecord(record)?.["url"]),
379
+ reason,
380
+ });
381
+ let possibleFreshId = false;
214
382
  try {
215
- if (!record)
216
- throw new Error("GitHub finding must be an object.");
217
- let finding;
218
- if (record["source"] === "github-code-scanning")
219
- finding = codeScanningFinding(record, target);
220
- else if (record["source"] === "github-security-advisory")
221
- finding = advisoryFinding(record, target);
222
- else
223
- throw new Error("Expected saved output from import github or import github-advisories; raw or incomplete API responses need an explicit mapping.");
224
- if (identities.has(finding.source_finding_id))
225
- throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each GitHub occurrence once.`);
226
- identities.add(finding.source_finding_id);
227
- result.findings.push(finding);
383
+ if (previous && capture) {
384
+ const source = exportedGitHubRecord(input, index, target, target === "local" && !capture.largeLocalRow);
385
+ exported = source.record;
386
+ prefix ??= codeOccurrencePrefix(exported);
387
+ // A serializer or Buffer can expand a native record that fit the approved request.
388
+ const oversizedLocalRow = target === "local" &&
389
+ (capture.largeLocalRow ||
390
+ (source.bytes > 256 * 1024 &&
391
+ (!before || capture.plainBuffers?.length === 0)));
392
+ if (oversizedLocalRow || !before) {
393
+ if (!oversizedLocalRow &&
394
+ source.previousInvalid &&
395
+ !source.skippedRawValue &&
396
+ canSnapshotWithoutGetters(input)) {
397
+ previous.excluded.push(exclusion(exported, errorMessage(source.previousInvalid)));
398
+ }
399
+ else if (target !== "local" &&
400
+ source.bytes + source.adjustment > 256 * 1024 &&
401
+ canSnapshotWithoutGetters(input) &&
402
+ !keySensitive) {
403
+ previous.excluded.push(exclusion(exported, "Evidence exceeds the Cloud limit of 256 KiB."));
404
+ }
405
+ else {
406
+ largeLocalSelection ||= oversizedLocalRow;
407
+ // An occurrence without independent native evidence can only stop a retry.
408
+ possible();
409
+ possibleFreshId = true;
410
+ }
411
+ }
412
+ else {
413
+ if (capture.hiddenFields || source.skippedRawValue)
414
+ possible();
415
+ try {
416
+ const row = mapRecord(before);
417
+ const knownOldId = row.source_finding_id;
418
+ priorId = knownOldId;
419
+ if (!afterRootSerializer)
420
+ unidentifiedRows.delete(index);
421
+ rowIds.add(knownOldId);
422
+ if (rowUncertain)
423
+ uncertainIds.add(knownOldId);
424
+ const evidence = validateExternalEvidenceFields(row.evidence, target);
425
+ if (source.previousInvalid)
426
+ throw source.previousInvalid;
427
+ if (keySensitive)
428
+ possible();
429
+ const reason = keySensitive || target === "local"
430
+ ? undefined
431
+ : previousGitHubExclusion(evidence, source.bytes, source.adjustment);
432
+ if (reason)
433
+ previous.excluded.push(exclusion(before, reason));
434
+ else
435
+ retainPrevious(previous, knownOldId, evidence);
436
+ }
437
+ catch (error) {
438
+ previous.excluded.push(exclusion(before, errorMessage(error)));
439
+ }
440
+ }
441
+ if (source.invalid)
442
+ throw source.invalid;
443
+ }
444
+ const mapped = mapRecord(exported), id = mapped.source_finding_id;
445
+ rowIds.add(id);
446
+ if (rowUncertain)
447
+ uncertainIds.add(id);
448
+ if (possibleFreshId)
449
+ potentialIds.push(id);
450
+ const evidence = validateExternalEvidence(mapped.evidence, target);
451
+ if (identities.has(id))
452
+ throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(id)}. Select each GitHub occurrence once.`);
453
+ identities.add(id);
454
+ result.findings.push({ source_finding_id: id, evidence });
228
455
  }
229
456
  catch (error) {
230
457
  if (error instanceof CodexSecurityError)
231
458
  throw error;
232
- result.excluded.push({
233
- position: index + 1,
234
- source_finding_id: text(record?.["url"]),
235
- reason: errorMessage(error),
236
- });
459
+ const reason = errorMessage(error);
460
+ result.excluded.push(exclusion(snapshot && exported === input
461
+ ? { url: ownData(input, "url") }
462
+ : exported, reason));
463
+ if (previous && exported === input) {
464
+ if (error instanceof CloudEvidenceDepthError &&
465
+ before &&
466
+ // Extra Buffer fields were inspected by the old row validator, but
467
+ // structuredClone does not retain them as part of the typed array.
468
+ capture?.plainBuffers?.every((buffer) => Object.keys(buffer).length === buffer.length)) {
469
+ // Exported JSON can be deeper than an approved native snapshot.
470
+ // Retain only the independently observed, valid prior selection.
471
+ try {
472
+ const row = mapRecord(before);
473
+ const evidence = validateExternalEvidence(row.evidence, target);
474
+ const savedSource = JSON.stringify(evidence.source_data);
475
+ // structuredClone turns each Buffer into a Uint8Array. Reconstruct its
476
+ // original serialized size on detached data without running caller hooks.
477
+ const oldSource = JSON.stringify(evidence.source_data, (_key, value) => value instanceof Uint8Array
478
+ ? { type: "Buffer", data: [...value] }
479
+ : value);
480
+ validateExternalEvidenceJson(evidence, target, Buffer.byteLength(oldSource) - Buffer.byteLength(savedSource));
481
+ retainPrevious(previous, row.source_finding_id, evidence);
482
+ }
483
+ catch (priorError) {
484
+ previous.excluded.push(exclusion(before, errorMessage(priorError)));
485
+ }
486
+ continue;
487
+ }
488
+ // A serializer may throw at its array key while the old source_data
489
+ // key produced a valid record. Keep only evidence for refusing a match.
490
+ possible();
491
+ if (before)
492
+ try {
493
+ const id = mapRecord(before).source_finding_id;
494
+ priorId = id;
495
+ if (!afterRootSerializer)
496
+ unidentifiedRows.delete(index);
497
+ potentialIds.push(id);
498
+ uncertainIds.add(id);
499
+ }
500
+ catch {
501
+ /* No old identity. */
502
+ }
503
+ }
504
+ }
505
+ }
506
+ if (previous) {
507
+ for (const check of checks)
508
+ check();
509
+ const uncertain = independentlyObserved !== Infinity;
510
+ if (uncertain || !isDeepStrictEqual(previous.findings, result.findings)) {
511
+ const prior = { sourceFindingIds: potentialIds };
512
+ if (uncertain) {
513
+ prior.unprovenIdPrefixes = [...prefixes];
514
+ prior.uncertainFindingIds = [...uncertainIds];
515
+ if (unidentifiedRows.size)
516
+ prior.unprovenOccurrenceCount = unidentifiedRows.size;
517
+ if (!largeLocalSelection)
518
+ prior.knownFindings = previous.findings
519
+ .slice(0, independentlyObserved)
520
+ .filter((finding) => !uncertainIds.has(finding.source_finding_id));
521
+ }
522
+ else
523
+ prior.snapshot = previous;
524
+ rememberPreviousSelection(result, prior);
237
525
  }
238
526
  }
239
527
  return result;
240
528
  }
241
529
  /** Map selected code-scanning instances while retaining complete upstream evidence. */
242
530
  export function normalizeGitHubCodeScanningAlerts(alerts, target = "cloud") {
243
- return normalizeRecords(alerts, target);
531
+ return normalizeRecords(alerts, target, true);
244
532
  }
245
533
  /** Map advisory disclosures without asserting an installed vulnerable dependency. */
246
534
  export function normalizeGitHubAdvisories(advisories, target = "cloud") {
247
- return normalizeRecords(advisories, target);
535
+ return normalizeRecords(advisories, target, true);
248
536
  }
249
537
  /** Read unfiltered JSON/JSONL output saved by the read-only GitHub import commands. */
250
538
  export async function readGitHubFindings(path, target = "cloud") {