@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
@@ -7,12 +7,12 @@ import json
7
7
  import re
8
8
  import sys
9
9
  from bisect import bisect_right
10
- from itertools import chain, islice
10
+ from itertools import islice
11
11
  from pathlib import Path
12
12
  from typing import Any
13
13
 
14
14
  sys.path.insert(0, str(Path(__file__).resolve().parent))
15
- from report_projection import merged_root_cause
15
+ from report_projection import code_evidence_rows, merged_root_cause
16
16
  from workbench_constants import (
17
17
  FINDING_ATTACK_PATH_PREVIEW_BYTES,
18
18
  FINDING_CODE_EVIDENCE_LIMIT,
@@ -35,14 +35,12 @@ def bounded_finding_details(value: Any) -> dict[str, Any]:
35
35
  ("rootCause", "root_cause"),
36
36
  FINDING_ROOT_CAUSE_PREVIEW_BYTES,
37
37
  (
38
- "summary",
39
38
  "description",
40
39
  "detail",
41
40
  "cause",
42
41
  "rationale",
43
42
  "why",
44
43
  "explanation",
45
- "evidenceRefs",
46
44
  "evidence_refs",
47
45
  ),
48
46
  (
@@ -54,21 +52,13 @@ def bounded_finding_details(value: Any) -> dict[str, Any]:
54
52
  ("validation",),
55
53
  FINDING_VALIDATION_PREVIEW_BYTES,
56
54
  (
57
- "summary",
58
55
  "conclusion",
59
- "method",
60
- "status",
61
56
  "disposition",
62
57
  "result",
63
58
  "rationale",
64
59
  "evidenceRef",
65
60
  "evidence_ref",
66
- "evidenceRefs",
67
61
  "evidence_refs",
68
- "assertions",
69
- "evidence",
70
- "counterEvidence",
71
- "limitations",
72
62
  ),
73
63
  (
74
64
  (("summary", "conclusion", "rationale", "detail", "disposition"), 800),
@@ -85,23 +75,14 @@ def bounded_finding_details(value: Any) -> dict[str, Any]:
85
75
  ("attackPath",),
86
76
  FINDING_ATTACK_PATH_PREVIEW_BYTES,
87
77
  (
88
- "narrative",
89
78
  "summary",
90
79
  "description",
91
- "dataFlow",
92
80
  "data_flow",
93
81
  "dataflow",
94
82
  "path",
95
- "reachability",
96
- "steps",
97
- "authScope",
98
83
  "auth_scope",
99
- "vector",
100
- "preconditions",
101
- "assumptions",
102
84
  "impact",
103
85
  "likelihood",
104
- "evidenceRefs",
105
86
  "evidence_refs",
106
87
  ),
107
88
  (
@@ -277,6 +258,7 @@ def bounded_finding_section(
277
258
  key = next((alias for alias in aliases if alias in value), None)
278
259
  if key is not None:
279
260
  ordered[key] = bounded_json_value(value[key], [field_bytes])
261
+ # Reserved fields already come first. Order the remaining aliases and fields next.
280
262
  for key in (*priority_keys, *value):
281
263
  if key in value and key not in ordered:
282
264
  ordered[key] = value[key]
@@ -295,14 +277,8 @@ def merged_bounded_code_evidence(value: dict[str, Any]) -> tuple[str | None, Any
295
277
  if not catalogs:
296
278
  return evidence_keys[0], value[evidence_keys[0]]
297
279
  bounded = {}
298
- for item in chain.from_iterable(catalogs):
299
- if not (
300
- isinstance(item, dict)
301
- and isinstance(item.get("id"), str)
302
- and bool(item["id"].strip())
303
- and isinstance(item.get("code"), str)
304
- and bool(item["code"].strip())
305
- ):
280
+ for item in code_evidence_rows(*catalogs):
281
+ if not isinstance(item.get("id"), str) or not item["id"].strip():
306
282
  continue
307
283
  if item["id"] in bounded:
308
284
  continue
@@ -0,0 +1,187 @@
1
+ """Stage and publish POSIX scan-local files through verified directory descriptors."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import errno
7
+ import os
8
+ import secrets
9
+ import stat
10
+ import sys
11
+ from collections.abc import Callable, Iterator
12
+ from contextlib import contextmanager
13
+ from pathlib import Path, PurePosixPath
14
+
15
+
16
+ def descriptor_relative_writes_available() -> bool:
17
+ # os.replace accepts src_dir_fd/dst_dir_fd wherever descriptor-relative
18
+ # os.rename is supported, but Python lists only os.rename in supports_dir_fd.
19
+ required_operations = (os.mkdir, os.open, os.rename, os.stat, os.unlink)
20
+ return hasattr(os, "O_NOFOLLOW") and all(
21
+ operation in os.supports_dir_fd for operation in required_operations
22
+ )
23
+
24
+
25
+ @contextmanager
26
+ def managed_fd(descriptor: int) -> Iterator[int]:
27
+ try:
28
+ yield descriptor
29
+ finally:
30
+ os.close(descriptor)
31
+
32
+
33
+ @contextmanager
34
+ def stage_file(
35
+ parent_fd: int, filename: str, payload: bytes, owner_read_write: bool
36
+ ) -> Iterator[int]:
37
+ descriptor = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600, dir_fd=parent_fd)
38
+ try:
39
+ with os.fdopen(descriptor, "wb", closefd=False) as handle:
40
+ if owner_read_write:
41
+ os.fchmod(descriptor, 0o600)
42
+ handle.write(payload)
43
+ handle.flush()
44
+ os.fsync(descriptor)
45
+ yield descriptor
46
+ finally:
47
+ try:
48
+ entry = os.stat(filename, dir_fd=parent_fd, follow_symlinks=False)
49
+ if os.path.samestat(os.fstat(descriptor), entry):
50
+ os.unlink(filename, dir_fd=parent_fd)
51
+ except FileNotFoundError:
52
+ # Successful publication has already removed the temporary name.
53
+ pass
54
+ finally:
55
+ os.close(descriptor)
56
+
57
+
58
+ def _rename_exclusive(parent_fd: int, source: str, destination: str) -> None:
59
+ import ctypes
60
+
61
+ libc = ctypes.CDLL(None, use_errno=True)
62
+ if sys.platform == "linux":
63
+ rename = getattr(libc, "renameat2", None)
64
+ flag = 1 # RENAME_NOREPLACE
65
+ elif sys.platform == "darwin":
66
+ rename = getattr(libc, "renameatx_np", None)
67
+ flag = 4 # RENAME_EXCL
68
+ else:
69
+ rename = None
70
+ code = errno.ENOSYS
71
+ if rename is not None:
72
+ rename.argtypes = [
73
+ ctypes.c_int,
74
+ ctypes.c_char_p,
75
+ ctypes.c_int,
76
+ ctypes.c_char_p,
77
+ ctypes.c_uint,
78
+ ]
79
+ rename.restype = ctypes.c_int
80
+ if rename(parent_fd, os.fsencode(source), parent_fd, os.fsencode(destination), flag) == 0:
81
+ return
82
+ code = ctypes.get_errno()
83
+ detail = os.strerror(code)
84
+ if code in {errno.ENOSYS, errno.ENOTSUP, errno.EOPNOTSUPP, errno.EINVAL}:
85
+ detail = f"cannot publish a new file atomically without hard links or exclusive rename ({detail})"
86
+ raise OSError(code, detail, destination)
87
+
88
+
89
+ def publish_new_file(parent_fd: int, source: str, destination: str) -> None:
90
+ try:
91
+ os.link(
92
+ source, destination, src_dir_fd=parent_fd, dst_dir_fd=parent_fd, follow_symlinks=False
93
+ )
94
+ except OSError as exc:
95
+ if exc.errno not in {
96
+ errno.EPERM,
97
+ errno.ENOTSUP,
98
+ errno.EOPNOTSUPP,
99
+ errno.ENOSYS,
100
+ errno.EXDEV,
101
+ errno.EMLINK,
102
+ }:
103
+ raise
104
+ _rename_exclusive(parent_fd, source, destination)
105
+ else:
106
+ os.unlink(source, dir_fd=parent_fd)
107
+
108
+
109
+ @contextmanager
110
+ def stage_write(
111
+ parent_fd: int,
112
+ relative_path: str,
113
+ payload: bytes,
114
+ *,
115
+ owner_read_write: bool,
116
+ replace_existing: bool,
117
+ compare_existing: bool,
118
+ check_parent: Callable[[Path], None],
119
+ contract_error: type[ValueError],
120
+ ) -> Iterator[Callable[..., tuple[os.stat_result, int]]]:
121
+ name = PurePosixPath(relative_path).name
122
+ # Stage through the held parent so a replacement path cannot redirect the write.
123
+ try:
124
+ metadata = os.stat(name, dir_fd=parent_fd, follow_symlinks=False)
125
+ except FileNotFoundError:
126
+ pass
127
+ else:
128
+ if not replace_existing:
129
+ raise FileExistsError(errno.EEXIST, os.strerror(errno.EEXIST), relative_path)
130
+ if not stat.S_ISREG(metadata.st_mode):
131
+ raise contract_error(f"{relative_path}: expected a regular non-symlink file")
132
+ try:
133
+ existing_fd = os.open(
134
+ name,
135
+ os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0) | getattr(os, "O_NONBLOCK", 0),
136
+ dir_fd=parent_fd,
137
+ )
138
+ except OSError as exc:
139
+ if exc.errno not in {errno.ENOENT, errno.EACCES, errno.EPERM}:
140
+ raise
141
+ else:
142
+ with managed_fd(existing_fd):
143
+ opened = os.fstat(existing_fd)
144
+ if not stat.S_ISREG(opened.st_mode):
145
+ raise contract_error(f"{relative_path}: expected a regular non-symlink file")
146
+ if not os.path.samestat(opened, metadata):
147
+ raise contract_error(f"{relative_path}: changed while it was being opened")
148
+ if compare_existing and opened.st_size == len(payload):
149
+ from windows_scan_local_files import stream_matches_payload
150
+
151
+ try:
152
+ with os.fdopen(existing_fd, "rb", closefd=False) as handle:
153
+ matches = stream_matches_payload(handle, payload)
154
+ except OSError:
155
+ # A failed content comparison still allows an atomic replacement.
156
+ matches = False
157
+ if matches:
158
+ yield lambda _directory=None: (opened, opened.st_ctime_ns)
159
+ return
160
+ candidate = f".{name}.{secrets.token_hex(8)}.tmp"
161
+
162
+ with stage_file(parent_fd, candidate, payload, owner_read_write) as staged_fd:
163
+ staged = os.fstat(staged_fd)
164
+
165
+ def publish(directory: Path | None = None) -> tuple[os.stat_result, int]:
166
+ if directory is not None:
167
+ check_parent(directory)
168
+ if replace_existing:
169
+ os.replace(candidate, name, src_dir_fd=parent_fd, dst_dir_fd=parent_fd)
170
+ return staged, staged.st_ctime_ns
171
+ named = os.stat(candidate, dir_fd=parent_fd, follow_symlinks=False)
172
+ if not os.path.samestat(staged, named) or staged.st_ctime_ns != named.st_ctime_ns:
173
+ raise contract_error(f"{relative_path}: staged file changed before publication")
174
+ publish_new_file(parent_fd, candidate, name)
175
+ published = os.fstat(staged_fd)
176
+ if (staged.st_size, staged.st_mtime_ns) != (
177
+ published.st_size,
178
+ published.st_mtime_ns,
179
+ ):
180
+ raise contract_error(f"{relative_path}: staged contents changed during publication")
181
+ return published, published.st_ctime_ns
182
+
183
+ yield publish
184
+
185
+
186
+ if __name__ == "__main__":
187
+ argparse.ArgumentParser(description=__doc__).parse_args()
@@ -7,6 +7,8 @@ import argparse
7
7
  import json
8
8
  import re
9
9
  from collections import Counter
10
+ from collections.abc import Iterator
11
+ from itertools import chain
10
12
  from typing import Any
11
13
 
12
14
  SEVERITY_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3, "informational": 4}
@@ -60,12 +62,15 @@ def _text(value: Any, fallback: str) -> str:
60
62
  return _escape_markdown(normalized)
61
63
 
62
64
 
63
- def _strings(value: Any) -> list[str]:
65
+ def _string_values(value: Any) -> Iterator[str]:
64
66
  if isinstance(value, str):
65
- value = [value]
66
- if not isinstance(value, list):
67
- return []
68
- return [text for item in value if (text := _text(item, ""))]
67
+ yield value
68
+ elif isinstance(value, list):
69
+ yield from (item for item in value if isinstance(item, str))
70
+
71
+
72
+ def _strings(value: Any) -> list[str]:
73
+ return [text for item in _string_values(value) if (text := _text(item, ""))]
69
74
 
70
75
 
71
76
  def _path_label(value: str, *, ensure_ascii: bool = False) -> str:
@@ -139,7 +144,7 @@ def uses_deep_presentation(coverage: dict[str, Any], findings: list[dict[str, An
139
144
  return any(_has_deep_child_metadata(finding) for finding in findings)
140
145
 
141
146
 
142
- def _deep_title_parts(finding: dict[str, Any]) -> tuple[str, str | None]:
147
+ def _deep_title_parts(finding: dict[str, Any], report_id: str) -> tuple[str, str | None]:
143
148
  title = finding.get("title")
144
149
  if not isinstance(title, str):
145
150
  return "Untitled finding", None
@@ -149,7 +154,7 @@ def _deep_title_parts(finding: dict[str, Any]) -> tuple[str, str | None]:
149
154
  return normalized, None
150
155
  annotation = match.group(2)
151
156
  extensions = finding.get("extensions")
152
- recognized_ids = [_deep_report_id(finding)]
157
+ recognized_ids = [report_id]
153
158
  if isinstance(extensions, dict):
154
159
  ledger_row_id = extensions.get("ledgerRowId")
155
160
  if isinstance(ledger_row_id, str) and ledger_row_id.strip():
@@ -171,12 +176,6 @@ def _deep_finding_groups(
171
176
  return list(groups.values())
172
177
 
173
178
 
174
- def _deep_group_titles(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
175
- return "<br>".join(
176
- dict.fromkeys(_cell(_deep_title_parts(finding)[0]) for _, finding, _ in group)
177
- )
178
-
179
-
180
179
  def _deep_group_levels(
181
180
  group: list[tuple[int, dict[str, Any], str | None]],
182
181
  field: str,
@@ -186,47 +185,34 @@ def _deep_group_levels(
186
185
  return "<br>".join(sorted(levels, key=lambda level: order.get(level, len(order))))
187
186
 
188
187
 
189
- def _deep_group_report_labels(
190
- group: list[tuple[int, dict[str, Any], str | None]],
191
- ) -> list[str]:
188
+ def _deep_group_row(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
192
189
  report_ids = [_deep_report_id(finding) for _, finding, _ in group]
193
- report_id_counts = Counter(report_ids)
194
- labels = [
195
- (_deep_title_parts(finding)[1] if report_id_counts[report_id] > 1 else report_id)
196
- or report_id
197
- for report_id, (_, finding, _) in zip(report_ids, group, strict=True)
198
- ]
199
- label_counts = Counter(labels)
200
- return [
201
- (
202
- finding.get("identity", {}).get("instance")
203
- if label_counts[label] > 1 and isinstance(finding.get("identity"), dict)
204
- else label
205
- )
206
- or _deep_report_id(finding)
207
- for label, (_, finding, _) in zip(labels, group, strict=True)
208
- ]
209
-
190
+ report_counts = Counter(report_ids)
191
+ titles = []
192
+ labels = []
193
+ for report_id, (_, finding, _) in zip(report_ids, group, strict=True):
194
+ title, annotation = _deep_title_parts(finding, report_id)
195
+ titles.append(_cell(title))
196
+ labels.append(annotation if report_counts[report_id] > 1 and annotation else report_id)
210
197
 
211
- def _deep_group_report_links(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
212
- labels = _deep_group_report_labels(group)
213
- return "<br>".join(
214
- f"[{_cell(label)}](#finding-{number})"
215
- for label, (number, _, _) in zip(labels, group, strict=True)
198
+ label_counts = Counter(labels)
199
+ report_links = []
200
+ writeup_links = []
201
+ for report_id, label, (number, finding, path) in zip(report_ids, labels, group, strict=True):
202
+ identity = finding.get("identity")
203
+ if label_counts[label] > 1 and isinstance(identity, dict):
204
+ label = identity.get("instance") or report_id
205
+ label = _cell(label)
206
+ report_links.append(f"[{label}](#finding-{number})")
207
+ writeup_links.append(f"[Open {label}]({path})" if path else f"{label}: inline below")
208
+ return (
209
+ f"| {'<br>'.join(dict.fromkeys(titles))} | {'<br>'.join(report_links)} "
210
+ f"| {_deep_group_levels(group, 'severity', SEVERITY_ORDER)} "
211
+ f"| {_deep_group_levels(group, 'confidence', CONFIDENCE_ORDER)} "
212
+ f"| {'<br>'.join(writeup_links)} |"
216
213
  )
217
214
 
218
215
 
219
- def _deep_group_writeup_links(group: list[tuple[int, dict[str, Any], str | None]]) -> str:
220
- labels = _deep_group_report_labels(group)
221
- links: list[str] = []
222
- for label, (_, _, report_path) in zip(labels, group, strict=True):
223
- report_id = _cell(label)
224
- links.append(
225
- f"[Open {report_id}]({report_path})" if report_path else f"{report_id}: inline below"
226
- )
227
- return "<br>".join(links)
228
-
229
-
230
216
  def _writeup_report_path(finding: dict[str, Any]) -> str | None:
231
217
  writeup = finding.get("writeup")
232
218
  if writeup is None:
@@ -255,51 +241,43 @@ def _bullet_section(heading: str, items: list[str]) -> list[str]:
255
241
  return ["", heading, *(f"- {item}" for item in items)] if items else []
256
242
 
257
243
 
258
- def _code_evidence_catalog(finding: dict[str, Any]) -> dict[str, dict[str, Any]]:
259
- catalog: dict[str, dict[str, Any]] = {}
260
- for key in ("codeEvidence", "code_evidence"):
261
- raw = finding.get(key, [])
262
- if not isinstance(raw, list):
263
- continue
264
- for item in raw:
265
- if (
266
- isinstance(item, dict)
267
- and isinstance(item.get("id"), str)
244
+ def code_evidence_rows(*catalogs: Any) -> Iterator[dict[str, Any]]:
245
+ for items in catalogs:
246
+ if isinstance(items, list):
247
+ yield from (
248
+ item
249
+ for item in items
250
+ if isinstance(item, dict)
268
251
  and isinstance(item.get("code"), str)
269
252
  and item["code"].strip()
270
- ):
271
- catalog.setdefault(item["id"], item)
253
+ )
254
+
255
+
256
+ def embedded_code_evidence(section: dict[str, Any]) -> Iterator[dict[str, Any]]:
257
+ return code_evidence_rows(section.get("codeEvidence"), section.get("code_evidence"))
258
+
259
+
260
+ def _code_evidence_catalog(finding: dict[str, Any]) -> dict[str, dict[str, Any]]:
261
+ catalog = {}
262
+ for item in embedded_code_evidence(finding):
263
+ if isinstance(item.get("id"), str):
264
+ catalog.setdefault(item["id"], item)
272
265
  return catalog
273
266
 
274
267
 
275
268
  def _section_code_evidence(
276
- finding: dict[str, Any], *sections: dict[str, Any]
269
+ catalog: dict[str, dict[str, Any]], *sections: dict[str, Any]
277
270
  ) -> list[dict[str, Any]]:
278
- catalog = _code_evidence_catalog(finding)
279
- resolved: list[dict[str, Any]] = []
280
- for section in sections:
281
- for key in ("evidenceRefs", "evidence_refs"):
282
- refs = section.get(key, [])
283
- if isinstance(refs, str):
284
- refs = [refs]
285
- if isinstance(refs, list):
286
- resolved.extend(
287
- catalog[ref] for ref in refs if isinstance(ref, str) and ref in catalog
288
- )
289
- for key in ("codeEvidence", "code_evidence"):
290
- embedded = section.get(key, [])
291
- if isinstance(embedded, list):
292
- resolved.extend(
293
- item
294
- for item in embedded
295
- if isinstance(item, dict)
296
- and isinstance(item.get("code"), str)
297
- and item["code"].strip()
298
- )
299
271
  unique: dict[tuple[str, str], dict[str, Any]] = {}
300
- for item in resolved:
301
- key = (str(item.get("id", "")), item["code"])
302
- unique.setdefault(key, item)
272
+ for section in sections:
273
+ referenced = (
274
+ catalog[ref]
275
+ for key in ("evidenceRefs", "evidence_refs")
276
+ for ref in _string_values(section.get(key))
277
+ if ref in catalog
278
+ )
279
+ for item in chain(referenced, embedded_code_evidence(section)):
280
+ unique.setdefault((str(item.get("id", "")), item["code"]), item)
303
281
  return list(unique.values())
304
282
 
305
283
 
@@ -359,12 +337,7 @@ def merged_root_cause(value: dict[str, Any]) -> tuple[str | None, Any]:
359
337
  ]
360
338
  if evidence_values:
361
339
  merged["evidenceRefs"] = list(
362
- dict.fromkeys(
363
- item
364
- for evidence in evidence_values
365
- for item in (evidence if isinstance(evidence, list) else [evidence])
366
- if isinstance(item, str)
367
- )
340
+ dict.fromkeys(item for evidence in evidence_values for item in _string_values(evidence))
368
341
  )
369
342
 
370
343
  embedded_evidence = [
@@ -396,9 +369,9 @@ def merged_root_cause(value: dict[str, Any]) -> tuple[str | None, Any]:
396
369
 
397
370
 
398
371
  def _root_cause_code_evidence(
399
- finding: dict[str, Any], root_cause: dict[str, Any]
372
+ finding: dict[str, Any], root_cause: dict[str, Any], catalog: dict[str, dict[str, Any]]
400
373
  ) -> list[dict[str, Any]]:
401
- evidence = _section_code_evidence(finding, root_cause)
374
+ evidence = _section_code_evidence(catalog, root_cause)
402
375
  legacy_code = root_cause.get("code")
403
376
  if not isinstance(legacy_code, str) or not legacy_code.strip():
404
377
  return evidence
@@ -599,33 +572,17 @@ def _finding_section(number: int, finding: dict[str, Any]) -> list[str]:
599
572
  if isinstance((value := attack_path.get(key)), (str, dict))
600
573
  ]
601
574
  dataflow: dict[str, Any] = {}
602
- for key in ("summary", "source", "sink", "outcome"):
603
- value = next(
604
- (
605
- section[key]
606
- for section in dataflow_sections
607
- if key in section and isinstance(section[key], str) and section[key].strip()
608
- ),
609
- None,
610
- )
611
- if value is not None:
612
- dataflow[key] = value
613
- transformations = list(
614
- dict.fromkeys(
615
- transformation
616
- for section in dataflow_sections
617
- for transformation in (
618
- [section.get("transformations")]
619
- if isinstance(section.get("transformations"), str)
620
- else section.get("transformations")
621
- if isinstance(section.get("transformations"), list)
622
- else []
623
- )
624
- if isinstance(transformation, str) and transformation.strip()
625
- )
575
+ for section in dataflow_sections:
576
+ for key in ("summary", "source", "sink", "outcome"):
577
+ value = section.get(key)
578
+ if isinstance(value, str) and value.strip():
579
+ dataflow.setdefault(key, value)
580
+ transformations = dict.fromkeys(
581
+ value
582
+ for section in dataflow_sections
583
+ for value in _string_values(section.get("transformations"))
584
+ if value.strip()
626
585
  )
627
- if transformations:
628
- dataflow["transformations"] = transformations
629
586
  raw_reachability = attack_path.get("reachability")
630
587
  reachability = (
631
588
  {"summary": raw_reachability}
@@ -654,10 +611,11 @@ def _finding_section(number: int, finding: dict[str, Any]) -> list[str]:
654
611
  raw_root_cause if isinstance(raw_root_cause, str) else root_cause.get("summary"),
655
612
  "",
656
613
  )
657
- root_cause_code_evidence = _root_cause_code_evidence(finding, root_cause)
658
- validation_code_evidence = _section_code_evidence(finding, validation)
659
- dataflow_code_evidence = _section_code_evidence(finding, attack_path, *dataflow_sections)
660
- reachability_code_evidence = _section_code_evidence(finding, reachability)
614
+ catalog = _code_evidence_catalog(finding)
615
+ root_cause_code_evidence = _root_cause_code_evidence(finding, root_cause, catalog)
616
+ validation_code_evidence = _section_code_evidence(catalog, validation)
617
+ dataflow_code_evidence = _section_code_evidence(catalog, attack_path, *dataflow_sections)
618
+ reachability_code_evidence = _section_code_evidence(catalog, reachability)
661
619
  dataflow_summary = _text(dataflow.get("summary"), "") or (
662
620
  f"The canonical finding records the affected path at {_locations(finding)}, "
663
621
  "but no expanded source-to-sink narrative was recorded."
@@ -704,7 +662,9 @@ def _finding_section(number: int, finding: dict[str, Any]) -> list[str]:
704
662
  for label, key in (("Source", "source"), ("Sink", "sink"), ("Outcome", "outcome")):
705
663
  if dataflow.get(key):
706
664
  lines.extend(["", f"- **{label}:** {_text(dataflow[key], 'not recorded')}"])
707
- lines.extend(_bullet_section("Transformations:", _strings(dataflow.get("transformations"))))
665
+ lines.extend(
666
+ _bullet_section("Transformations:", [_text(value, "") for value in transformations])
667
+ )
708
668
  lines.extend(_code_evidence_lines(dataflow_code_evidence))
709
669
  lines.extend(["", "#### Reachability", "", reachability_summary])
710
670
  for label, key in (
@@ -718,10 +678,7 @@ def _finding_section(number: int, finding: dict[str, Any]) -> list[str]:
718
678
  lines.extend(["", f"- **{label}:** {_text(reachability[key], 'not recorded')}"])
719
679
  preconditions = list(
720
680
  dict.fromkeys(
721
- [
722
- *_strings(attack_path.get("preconditions")),
723
- *_strings(reachability.get("preconditions")),
724
- ]
681
+ _strings(attack_path.get("preconditions")) + _strings(reachability.get("preconditions"))
725
682
  )
726
683
  )
727
684
  lines.extend(_bullet_section("Preconditions:", preconditions))
@@ -912,13 +869,7 @@ def build_report_markdown(
912
869
  "| --- | --- | --- | --- | --- |",
913
870
  ]
914
871
  )
915
- for group in deep_finding_groups:
916
- lines.append(
917
- f"| {_deep_group_titles(group)} | {_deep_group_report_links(group)} "
918
- f"| {_deep_group_levels(group, 'severity', SEVERITY_ORDER)} "
919
- f"| {_deep_group_levels(group, 'confidence', CONFIDENCE_ORDER)} "
920
- f"| {_deep_group_writeup_links(group)} |"
921
- )
872
+ lines.extend(_deep_group_row(group) for group in deep_finding_groups)
922
873
  else:
923
874
  lines.extend(
924
875
  [
@@ -57,14 +57,10 @@ def receipt(validated: dict[str, Any]) -> dict[str, Any]:
57
57
  }
58
58
 
59
59
 
60
- def _parse_args(argv: list[str]) -> argparse.Namespace:
60
+ def main(argv: list[str] | None = None) -> int:
61
61
  parser = argparse.ArgumentParser(description=__doc__)
62
62
  parser.add_argument("--scan-dir", required=True, type=Path)
63
- return parser.parse_args(argv)
64
-
65
-
66
- def main(argv: list[str] | None = None) -> int:
67
- args = _parse_args(sys.argv[1:] if argv is None else argv)
63
+ args = parser.parse_args(argv)
68
64
  try:
69
65
  validated = validate_contract(args.scan_dir)
70
66
  except (OSError, ValueError, RecursionError) as exc: