@openai/codex-security 0.6.0 → 0.8.0

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 (308) hide show
  1. package/README.md +76 -39
  2. package/_bundled_plugin/.mcp.json +1 -0
  3. package/_bundled_plugin/examples/completed-scan/findings.json +34 -34
  4. package/_bundled_plugin/examples/completed-scan/report.md +22 -31
  5. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +27 -29
  6. package/_bundled_plugin/examples/{completed-scan → legacy-completed-scan}/coverage.json +1 -0
  7. package/_bundled_plugin/examples/legacy-completed-scan/findings.json +57 -0
  8. package/_bundled_plugin/examples/legacy-completed-scan/report.md +98 -0
  9. package/_bundled_plugin/examples/legacy-completed-scan/scan-manifest.json +43 -0
  10. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  11. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  12. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +1 -1
  13. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  14. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  15. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  16. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  17. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  18. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  19. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  20. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  21. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  22. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  23. package/_bundled_plugin/references/access-advisory.md +11 -0
  24. package/_bundled_plugin/references/core-scan.md +30 -77
  25. package/_bundled_plugin/references/final-report.md +50 -184
  26. package/_bundled_plugin/references/scan-artifacts.md +5 -5
  27. package/_bundled_plugin/references/scan-contract.md +12 -12
  28. package/_bundled_plugin/references/scan-prologue.md +1 -1
  29. package/_bundled_plugin/references/scan-runtime.md +1 -5
  30. package/_bundled_plugin/references/threat-model.md +33 -41
  31. package/_bundled_plugin/schemas/coverage.schema.json +12 -1
  32. package/_bundled_plugin/schemas/scan-manifest.schema.json +37 -11
  33. package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +38 -1
  34. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +5 -5
  35. package/_bundled_plugin/scripts/deep_scan_config.py +39 -39
  36. package/_bundled_plugin/scripts/deep_scan_workbench.py +146 -86
  37. package/_bundled_plugin/scripts/finalize_scan_contract.py +249 -76
  38. package/_bundled_plugin/scripts/report_projection.py +49 -17
  39. package/_bundled_plugin/scripts/review_state.py +68 -0
  40. package/_bundled_plugin/scripts/threat_model_projection.py +4 -2
  41. package/_bundled_plugin/scripts/validate_scan_contract.py +1 -2
  42. package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -14
  43. package/_bundled_plugin/scripts/workbench/retained_coverage.py +3230 -0
  44. package/_bundled_plugin/scripts/workbench/retained_records.py +627 -0
  45. package/_bundled_plugin/scripts/workbench/saved_coverage.py +651 -8
  46. package/_bundled_plugin/scripts/workbench/saved_outputs.py +72 -0
  47. package/_bundled_plugin/scripts/workbench/saved_sources.py +730 -0
  48. package/_bundled_plugin/scripts/workbench_cli.py +3 -0
  49. package/_bundled_plugin/scripts/workbench_constants.py +0 -1
  50. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +479 -0
  51. package/_bundled_plugin/scripts/workbench_db.py +55 -171
  52. package/_bundled_plugin/scripts/workbench_feedback.py +0 -1
  53. package/_bundled_plugin/scripts/workbench_finding_workflows.py +51 -9
  54. package/_bundled_plugin/scripts/workbench_native_indexes.py +56 -44
  55. package/_bundled_plugin/scripts/workbench_saved_results.py +808 -2389
  56. package/_bundled_plugin/scripts/workbench_scan_history.py +77 -7
  57. package/_bundled_plugin/scripts/workbench_schema.py +1 -1
  58. package/_bundled_plugin/scripts/workbench_source_scopes.py +4 -1
  59. package/_bundled_plugin/scripts/workbench_target.py +142 -17
  60. package/_bundled_plugin/scripts/workbench_validation.py +9 -2
  61. package/_bundled_plugin/shared/workbench-history-repairs.json +21 -0
  62. package/_bundled_plugin/shared/workbench-migrations.json +28 -0
  63. package/_bundled_plugin/skills/assess-patch-risk/SKILL.md +3 -14
  64. package/_bundled_plugin/skills/assess-patch-risk/references/windows-validation.md +14 -0
  65. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +38 -103
  66. package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +11 -73
  67. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +57 -116
  68. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +28 -51
  69. package/_bundled_plugin/skills/define-security-policy/SKILL.md +9 -9
  70. package/_bundled_plugin/skills/finding-discovery/SKILL.md +26 -140
  71. package/_bundled_plugin/skills/fix-finding/SKILL.md +9 -28
  72. package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +28 -218
  73. package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +29 -424
  74. package/_bundled_plugin/skills/publish-findings/SKILL.md +32 -24
  75. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +64 -0
  76. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +12 -12
  77. package/_bundled_plugin/skills/security-scan/SKILL.md +29 -17
  78. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +11 -17
  79. package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +52 -69
  80. package/_bundled_plugin/skills/threat-model/SKILL.md +16 -9
  81. package/_bundled_plugin/skills/track-findings/SKILL.md +1 -1
  82. package/_bundled_plugin/skills/triage-finding/SKILL.md +5 -15
  83. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -6
  84. package/_bundled_plugin/skills/validation/SKILL.md +42 -104
  85. package/_bundled_plugin/skills/validation/references/validation-guidance.md +21 -106
  86. package/_bundled_plugin/skills/verify-fix/SKILL.md +4 -2
  87. package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +21 -159
  88. package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +18 -60
  89. package/dist/api.d.ts +5 -3
  90. package/dist/api.d.ts.map +1 -1
  91. package/dist/api.js +359 -53
  92. package/dist/api.js.map +1 -1
  93. package/dist/auth.d.ts.map +1 -1
  94. package/dist/auth.js +4 -1
  95. package/dist/auth.js.map +1 -1
  96. package/dist/cli.d.ts +2 -2
  97. package/dist/cli.d.ts.map +1 -1
  98. package/dist/cli.js +696 -430
  99. package/dist/cli.js.map +1 -1
  100. package/dist/cloud-publish.d.ts.map +1 -1
  101. package/dist/cloud-publish.js +2 -23
  102. package/dist/cloud-publish.js.map +1 -1
  103. package/dist/component-scan.d.ts +8 -2
  104. package/dist/component-scan.d.ts.map +1 -1
  105. package/dist/component-scan.js +2 -0
  106. package/dist/component-scan.js.map +1 -1
  107. package/dist/contract.d.ts +5 -2
  108. package/dist/contract.d.ts.map +1 -1
  109. package/dist/contract.js +93 -45
  110. package/dist/contract.js.map +1 -1
  111. package/dist/cost.d.ts +18 -0
  112. package/dist/cost.d.ts.map +1 -1
  113. package/dist/cost.js +107 -12
  114. package/dist/cost.js.map +1 -1
  115. package/dist/coverage-presentation.d.ts +6 -0
  116. package/dist/coverage-presentation.d.ts.map +1 -0
  117. package/dist/coverage-presentation.js +34 -0
  118. package/dist/coverage-presentation.js.map +1 -0
  119. package/dist/custom-publish.js +2 -2
  120. package/dist/custom-publish.js.map +1 -1
  121. package/dist/custom-validation-prompt.js +5 -5
  122. package/dist/custom-validation-prompt.js.map +1 -1
  123. package/dist/custom-validation.d.ts.map +1 -1
  124. package/dist/custom-validation.js +47 -19
  125. package/dist/custom-validation.js.map +1 -1
  126. package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
  127. package/dist/deduplication/checkpointed-review.js +3 -1
  128. package/dist/deduplication/checkpointed-review.js.map +1 -1
  129. package/dist/deduplication/codex-review.d.ts.map +1 -1
  130. package/dist/deduplication/codex-review.js +2 -2
  131. package/dist/deduplication/codex-review.js.map +1 -1
  132. package/dist/deduplication/deduplication-prompts.d.ts +1 -0
  133. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  134. package/dist/deduplication/deduplication-prompts.js +3 -0
  135. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  136. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  137. package/dist/deduplication/records-protocol.js +21 -1
  138. package/dist/deduplication/records-protocol.js.map +1 -1
  139. package/dist/deduplication/scan.d.ts.map +1 -1
  140. package/dist/deduplication/scan.js +9 -7
  141. package/dist/deduplication/scan.js.map +1 -1
  142. package/dist/endor-findings.d.ts +4 -3
  143. package/dist/endor-findings.d.ts.map +1 -1
  144. package/dist/endor-findings.js +16 -11
  145. package/dist/endor-findings.js.map +1 -1
  146. package/dist/external-findings-import.d.ts.map +1 -1
  147. package/dist/external-findings-import.js +13 -5
  148. package/dist/external-findings-import.js.map +1 -1
  149. package/dist/external-findings-local.d.ts +1 -0
  150. package/dist/external-findings-local.d.ts.map +1 -1
  151. package/dist/external-findings-local.js +14 -3
  152. package/dist/external-findings-local.js.map +1 -1
  153. package/dist/external-findings-publish.d.ts +2 -1
  154. package/dist/external-findings-publish.d.ts.map +1 -1
  155. package/dist/external-findings-publish.js +64 -28
  156. package/dist/external-findings-publish.js.map +1 -1
  157. package/dist/external-findings-read.d.ts +12 -1
  158. package/dist/external-findings-read.d.ts.map +1 -1
  159. package/dist/external-findings-read.js +25 -6
  160. package/dist/external-findings-read.js.map +1 -1
  161. package/dist/external-findings.d.ts +2 -0
  162. package/dist/external-findings.d.ts.map +1 -1
  163. package/dist/external-findings.js.map +1 -1
  164. package/dist/external-import-contract.d.ts +7 -1
  165. package/dist/external-import-contract.d.ts.map +1 -1
  166. package/dist/external-import-contract.js +63 -31
  167. package/dist/external-import-contract.js.map +1 -1
  168. package/dist/external-imports-feature.d.ts +6 -0
  169. package/dist/external-imports-feature.d.ts.map +1 -0
  170. package/dist/external-imports-feature.js +51 -0
  171. package/dist/external-imports-feature.js.map +1 -0
  172. package/dist/finding-workflow.d.ts +24 -5
  173. package/dist/finding-workflow.d.ts.map +1 -1
  174. package/dist/finding-workflow.js +24 -9
  175. package/dist/finding-workflow.js.map +1 -1
  176. package/dist/github-advisories.d.ts.map +1 -1
  177. package/dist/github-advisories.js +3 -1
  178. package/dist/github-advisories.js.map +1 -1
  179. package/dist/github-findings.d.ts +4 -3
  180. package/dist/github-findings.d.ts.map +1 -1
  181. package/dist/github-findings.js +16 -14
  182. package/dist/github-findings.js.map +1 -1
  183. package/dist/host-protocol.d.ts +1 -1
  184. package/dist/host-protocol.d.ts.map +1 -1
  185. package/dist/host-protocol.js +2 -2
  186. package/dist/host-protocol.js.map +1 -1
  187. package/dist/hosted-remediation.d.ts.map +1 -1
  188. package/dist/hosted-remediation.js +19 -2
  189. package/dist/hosted-remediation.js.map +1 -1
  190. package/dist/hosted-scan.d.ts +1 -1
  191. package/dist/hosted-scan.d.ts.map +1 -1
  192. package/dist/hosted-scan.js +0 -6
  193. package/dist/hosted-scan.js.map +1 -1
  194. package/dist/import-scan.js +17 -17
  195. package/dist/import-scan.js.map +1 -1
  196. package/dist/index.d.ts +4 -3
  197. package/dist/index.d.ts.map +1 -1
  198. package/dist/index.js +2 -1
  199. package/dist/index.js.map +1 -1
  200. package/dist/knowledge-base.d.ts +1 -0
  201. package/dist/knowledge-base.d.ts.map +1 -1
  202. package/dist/knowledge-base.js +20 -8
  203. package/dist/knowledge-base.js.map +1 -1
  204. package/dist/mock-scan.d.ts +1 -2
  205. package/dist/mock-scan.d.ts.map +1 -1
  206. package/dist/mock-scan.js +12 -17
  207. package/dist/mock-scan.js.map +1 -1
  208. package/dist/models.d.ts +10 -1
  209. package/dist/models.d.ts.map +1 -1
  210. package/dist/models.js.map +1 -1
  211. package/dist/multiscan.d.ts.map +1 -1
  212. package/dist/multiscan.js +1 -6
  213. package/dist/multiscan.js.map +1 -1
  214. package/dist/native-json-findings.d.ts +30 -0
  215. package/dist/native-json-findings.d.ts.map +1 -0
  216. package/dist/native-json-findings.js +114 -0
  217. package/dist/native-json-findings.js.map +1 -0
  218. package/dist/opengrep-findings.d.ts +10 -0
  219. package/dist/opengrep-findings.d.ts.map +1 -0
  220. package/dist/opengrep-findings.js +198 -0
  221. package/dist/opengrep-findings.js.map +1 -0
  222. package/dist/owner-evidence.d.ts +2 -0
  223. package/dist/owner-evidence.d.ts.map +1 -1
  224. package/dist/owner-evidence.js +2 -1
  225. package/dist/owner-evidence.js.map +1 -1
  226. package/dist/patch-tui.d.ts.map +1 -1
  227. package/dist/patch-tui.js +2 -0
  228. package/dist/patch-tui.js.map +1 -1
  229. package/dist/publication.js +1 -2
  230. package/dist/publication.js.map +1 -1
  231. package/dist/publish.d.ts +2 -0
  232. package/dist/publish.d.ts.map +1 -1
  233. package/dist/publish.js +1 -1
  234. package/dist/publish.js.map +1 -1
  235. package/dist/record.d.ts +1 -0
  236. package/dist/record.d.ts.map +1 -1
  237. package/dist/record.js +10 -0
  238. package/dist/record.js.map +1 -1
  239. package/dist/remediation.d.ts +1 -25
  240. package/dist/remediation.d.ts.map +1 -1
  241. package/dist/remediation.js +3 -24
  242. package/dist/remediation.js.map +1 -1
  243. package/dist/result.d.ts +5 -3
  244. package/dist/result.d.ts.map +1 -1
  245. package/dist/result.js +9 -6
  246. package/dist/result.js.map +1 -1
  247. package/dist/runtime.d.ts.map +1 -1
  248. package/dist/runtime.js +7 -7
  249. package/dist/runtime.js.map +1 -1
  250. package/dist/scan-dashboard.d.ts +5 -3
  251. package/dist/scan-dashboard.d.ts.map +1 -1
  252. package/dist/scan-dashboard.js +79 -26
  253. package/dist/scan-dashboard.js.map +1 -1
  254. package/dist/scan-history-renderer.d.ts.map +1 -1
  255. package/dist/scan-history-renderer.js +9 -3
  256. package/dist/scan-history-renderer.js.map +1 -1
  257. package/dist/scan-owner-suggestions.d.ts +1 -1
  258. package/dist/scan-owner-suggestions.d.ts.map +1 -1
  259. package/dist/scan-owner-suggestions.js +4 -4
  260. package/dist/scan-owner-suggestions.js.map +1 -1
  261. package/dist/scan-usage-display.d.ts +8 -0
  262. package/dist/scan-usage-display.d.ts.map +1 -0
  263. package/dist/scan-usage-display.js +46 -0
  264. package/dist/scan-usage-display.js.map +1 -0
  265. package/dist/scanner-import.d.ts +1 -1
  266. package/dist/scanner-import.d.ts.map +1 -1
  267. package/dist/scanner-import.js +7 -3
  268. package/dist/scanner-import.js.map +1 -1
  269. package/dist/security-policy.d.ts.map +1 -1
  270. package/dist/security-policy.js +17 -22
  271. package/dist/security-policy.js.map +1 -1
  272. package/dist/semgrep-findings.d.ts +4 -3
  273. package/dist/semgrep-findings.d.ts.map +1 -1
  274. package/dist/semgrep-findings.js +22 -89
  275. package/dist/semgrep-findings.js.map +1 -1
  276. package/dist/skill-authentication.d.ts +18 -0
  277. package/dist/skill-authentication.d.ts.map +1 -0
  278. package/dist/skill-authentication.js +82 -0
  279. package/dist/skill-authentication.js.map +1 -0
  280. package/dist/snyk-findings.d.ts +5 -4
  281. package/dist/snyk-findings.d.ts.map +1 -1
  282. package/dist/snyk-findings.js +18 -17
  283. package/dist/snyk-findings.js.map +1 -1
  284. package/dist/suggest-owners.d.ts +4 -1
  285. package/dist/suggest-owners.d.ts.map +1 -1
  286. package/dist/suggest-owners.js +53 -21
  287. package/dist/suggest-owners.js.map +1 -1
  288. package/dist/targets.d.ts.map +1 -1
  289. package/dist/targets.js +4 -1
  290. package/dist/targets.js.map +1 -1
  291. package/dist/wiz-csv.d.ts +2 -1
  292. package/dist/wiz-csv.d.ts.map +1 -1
  293. package/dist/wiz-csv.js +3 -3
  294. package/dist/wiz-csv.js.map +1 -1
  295. package/dist/wiz-findings.d.ts +2 -1
  296. package/dist/wiz-findings.d.ts.map +1 -1
  297. package/dist/wiz-findings.js +27 -23
  298. package/dist/wiz-findings.js.map +1 -1
  299. package/docs/classify-severity-records.md +3 -4
  300. package/docs/cli.md +171 -41
  301. package/docs/dedupe-records.md +15 -1
  302. package/docs/findings-service.md +119 -118
  303. package/docs/hosted-remediation.md +19 -17
  304. package/docs/hosted-scans.md +37 -11
  305. package/package.json +9 -9
  306. package/_bundled_plugin/scripts/generate_in_scope_files.py +0 -277
  307. package/_bundled_plugin/scripts/generate_rank_input.py +0 -350
  308. package/_bundled_plugin/scripts/rank_preview.py +0 -129
@@ -1,4 +1,5 @@
1
+ import { type ExternalImportTarget } from "./external-import-contract.js";
1
2
  import type { ExternalFindings as VendorFindings } from "./external-findings.js";
2
3
  export type { ExternalFinding as VendorFinding, ExternalFindings as VendorFindings, } from "./external-findings.js";
3
- export declare function readVendorFindings(path: string): Promise<VendorFindings>;
4
+ export declare function readVendorFindings(path: string, target?: ExternalImportTarget): Promise<VendorFindings>;
4
5
  //# sourceMappingURL=wiz-findings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wiz-findings.d.ts","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,gBAAgB,IAAI,cAAc,EAEnC,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,eAAe,IAAI,aAAa,EAChC,gBAAgB,IAAI,cAAc,GACnC,MAAM,wBAAwB,CAAC;AA2ahC,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAEzB"}
1
+ {"version":3,"file":"wiz-findings.d.ts","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,KAAK,EAEV,gBAAgB,IAAI,cAAc,EAEnC,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,eAAe,IAAI,aAAa,EAChC,gBAAgB,IAAI,cAAc,GACnC,MAAM,wBAAwB,CAAC;AA0bhC,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,oBAA8B,GACrC,OAAO,CAAC,cAAc,CAAC,CAEzB"}
@@ -10,21 +10,25 @@ function object(value) {
10
10
  function text(value) {
11
11
  return typeof value === "string" && value.trim() ? value : null;
12
12
  }
13
- function sourceFindingId(value) {
13
+ function sourceFindingId(value, target) {
14
14
  const id = text(value);
15
- if (!id || id.includes("\0") || Buffer.byteLength(id) > 512)
16
- throw new Error("Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.");
15
+ if (!id ||
16
+ id.includes("\0") ||
17
+ (target === "cloud" && Buffer.byteLength(id) > 512))
18
+ throw new Error(target === "cloud"
19
+ ? "Source finding id must contain 1–512 UTF-8 bytes and no NUL characters."
20
+ : "Source finding id must be nonempty and contain no NUL characters.");
17
21
  return id;
18
22
  }
19
23
  /** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */
20
- function wizFinding(record) {
24
+ function wizFinding(record, target) {
21
25
  if (record["detectionMethod"] === "EXTERNAL_NETWORK_SCAN")
22
26
  throw new Error("Wiz external network findings are not supported by the package vulnerability mapping.");
23
- const id = sourceFindingId(record["id"]);
27
+ const id = sourceFindingId(record["id"], target);
24
28
  const name = text(record["name"]);
25
29
  const packageName = text(record["detailedName"]);
26
30
  const version = text(record["version"]);
27
- const severity = text(record["vendorSeverity"]) ?? text(record["severity"]);
31
+ const severity = (text(record["vendorSeverity"]) ?? text(record["severity"]))?.toLowerCase();
28
32
  const asset = object(record["vulnerableAsset"]);
29
33
  const artifact = object(record["artifactType"]);
30
34
  if (!name || !packageName || !text(asset?.["id"])) {
@@ -51,7 +55,7 @@ function wizFinding(record) {
51
55
  title: text(record["title"]) ??
52
56
  [packageName, version, name].filter(Boolean).join(" "),
53
57
  description: text(record["description"]),
54
- severity: severity?.toLowerCase(),
58
+ severity: severity === "none" ? "unknown" : severity,
55
59
  url: text(record["portalUrl"]),
56
60
  advisory_ids: [text(record["vulnerabilityExternalId"]) ?? name],
57
61
  packages: [
@@ -78,7 +82,7 @@ function wizFinding(record) {
78
82
  };
79
83
  return {
80
84
  source_finding_id: id,
81
- evidence: validateExternalEvidence(evidence),
85
+ evidence: validateExternalEvidence(evidence, target),
82
86
  };
83
87
  }
84
88
  // Wiz's documented inventory platform establishes custom GitHub host semantics.
@@ -147,8 +151,8 @@ function content(value) {
147
151
  return typeof value === "string" ? value : null;
148
152
  }
149
153
  /** Map only explicitly identified repository finding collections. */
150
- function repositoryFinding(kind, record, repositories, legacy = false) {
151
- const id = sourceFindingId(record["id"]);
154
+ function repositoryFinding(kind, record, repositories, legacy = false, target = "cloud") {
155
+ const id = sourceFindingId(record["id"], target);
152
156
  const resource = object(record["resource"]);
153
157
  if (kind === "secret" && resource?.["type"] !== "REPOSITORY_BRANCH")
154
158
  throw new Error("Only repository-branch secret findings can be published to a repository. Workload secrets require a resource-scoped import and are not supported.");
@@ -209,7 +213,7 @@ function repositoryFinding(kind, record, repositories, legacy = false) {
209
213
  return {
210
214
  // Existing package occurrence IDs remain unchanged. New families cannot
211
215
  // collide with one another when the same tenant source key is used.
212
- source_finding_id: sourceFindingId(`${kind}:${id}`),
216
+ source_finding_id: sourceFindingId(`${kind}:${id}`, target),
213
217
  evidence: validateExternalEvidence({
214
218
  title: text(record["name"]) ?? text(rule?.["name"]),
215
219
  severity: text(record["severity"])?.toLowerCase(),
@@ -226,7 +230,7 @@ function repositoryFinding(kind, record, repositories, legacy = false) {
226
230
  : null,
227
231
  source_data: record,
228
232
  details,
229
- }),
233
+ }, target),
230
234
  };
231
235
  }
232
236
  function records(payload) {
@@ -325,15 +329,15 @@ function records(payload) {
325
329
  };
326
330
  throw new Error("Unsupported Wiz export. Supply repository vulnerability CSV, vulnerability finding objects, named sastFindings/secretInstances/iacFindings collections, or normalized JSONL. Other CSV reports need an explicit normalized JSONL mapping.");
327
331
  }
328
- export async function readVendorFindings(path) {
329
- return normalizeFindings(await readFindingInput(path));
332
+ export async function readVendorFindings(path, target = "cloud") {
333
+ return normalizeFindings(await readFindingInput(path), target);
330
334
  }
331
335
  /** @internal Preserve older inventory projections only for saved publication replay. */
332
- export async function readVendorFindingsForPublication(path) {
336
+ export async function readVendorFindingsForPublication(path, target = "cloud") {
333
337
  const input = await readFindingInput(path);
334
338
  const normalized = new WeakSet();
335
- const current = normalizeFindings(input, normalized);
336
- const legacy = normalizeFindings({ ...input, repositories: input.legacyRepositories ?? input.repositories }, normalized, true);
339
+ const current = normalizeFindings(input, target, normalized);
340
+ const legacy = normalizeFindings({ ...input, repositories: input.legacyRepositories ?? input.repositories }, target, normalized, true);
337
341
  const identity = (parsed) => parsed.findings.map((finding) => {
338
342
  if (normalized.has(finding))
339
343
  return finding;
@@ -396,7 +400,7 @@ async function readFindingInput(path) {
396
400
  throw new CodexSecurityError(`Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
397
401
  }
398
402
  }
399
- function normalizeFindings(input, normalized, legacy = false) {
403
+ function normalizeFindings(input, target, normalized, legacy = false) {
400
404
  const result = {
401
405
  read: input.records.length,
402
406
  findings: [],
@@ -410,22 +414,22 @@ function normalizeFindings(input, normalized, legacy = false) {
410
414
  throw new Error("Finding must be an object.");
411
415
  let finding;
412
416
  if (item.kind === "sca_csv") {
413
- finding = wizCsvFinding(record, sourceFindingId(record["ID"]));
417
+ finding = wizCsvFinding(record, sourceFindingId(record["ID"], target), target);
414
418
  }
415
419
  else if ("source_finding_id" in record) {
416
420
  if (Object.keys(record).some((key) => !["source_finding_id", "evidence"].includes(key))) {
417
421
  throw new Error("Normalized input permits only source_finding_id and evidence.");
418
422
  }
419
423
  finding = {
420
- source_finding_id: sourceFindingId(record["source_finding_id"]),
421
- evidence: validateExternalEvidence(record["evidence"]),
424
+ source_finding_id: sourceFindingId(record["source_finding_id"], target),
425
+ evidence: validateExternalEvidence(record["evidence"], target),
422
426
  };
423
427
  }
424
428
  else if (item.kind === "cloud_configuration") {
425
429
  throw new Error("Cloud configuration findings require a resource-scoped import and cannot be published to a repository.");
426
430
  }
427
431
  else if (item.kind && item.kind !== "sca") {
428
- finding = repositoryFinding(item.kind, record, input.repositories, legacy);
432
+ finding = repositoryFinding(item.kind, record, input.repositories, legacy, target);
429
433
  }
430
434
  else {
431
435
  if (!item.kind &&
@@ -433,7 +437,7 @@ function normalizeFindings(input, normalized, legacy = false) {
433
437
  object(record["repositoryBranch"]) ||
434
438
  object(record["resource"])))
435
439
  throw new Error("Raw SAST, secret, and IaC records require their named sastFindings, secretInstances, or iacFindings collection. Bare arrays do not identify the finding family; use normalized JSONL for an explicit mapping.");
436
- finding = wizFinding(record);
440
+ finding = wizFinding(record, target);
437
441
  }
438
442
  if (identities.has(finding.source_finding_id)) {
439
443
  throw new CodexSecurityError(`Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each vendor occurrence once.`);
@@ -1 +1 @@
1
- {"version":3,"file":"wiz-findings.js","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAYzD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC;AAED,SAAS,eAAe,C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B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAkB;gBAAE,MAAM,KAAK,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,QAAQ,EAAE,KAAK,GAAG,CAAC;gBACnB,iBAAiB,EACf,IAAI,CAAC,IAAI,KAAK,SAAS;oBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,mBAAmB,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC/D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { CodexSecurityError } from \"./errors.js\";\nimport {\n repositoryUrlKey,\n validateExternalEvidence,\n} from \"./external-import-contract.js\";\nimport { parseJsonOrJsonl, readScannerText } from \"./scanner-import.js\";\nimport { readWizCsv, wizCsvFinding } from \"./wiz-csv.js\";\nimport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\n\nexport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n} from \"./external-findings.js\";\n\nfunction object(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction text(value: unknown): string | null {\n return typeof value === \"string\" && value.trim() ? value : null;\n}\n\nfunction sourceFindingId(value: unknown): string {\n const id = text(value);\n if (!id || id.includes(\"\\0\") || Buffer.byteLength(id) > 512)\n throw new Error(\n \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\",\n );\n return id;\n}\n\n/** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */\nfunction wizFinding(record: Record<string, unknown>): VendorFinding {\n if (record[\"detectionMethod\"] === \"EXTERNAL_NETWORK_SCAN\")\n throw new Error(\n \"Wiz external network findings are not supported by the package vulnerability mapping.\",\n );\n const id = sourceFindingId(record[\"id\"]);\n const name = text(record[\"name\"]);\n const packageName = text(record[\"detailedName\"]);\n const version = text(record[\"version\"]);\n const severity = text(record[\"vendorSeverity\"]) ?? text(record[\"severity\"]);\n const asset = object(record[\"vulnerableAsset\"]);\n const artifact = object(record[\"artifactType\"]);\n if (!name || !packageName || !text(asset?.[\"id\"])) {\n throw new Error(\n \"Expected a Wiz package vulnerability finding with name, detailedName, and vulnerableAsset.id. Other finding classes need a separate mapping.\",\n );\n }\n const assetType = text(asset?.[\"type\"]);\n const repositoryAsset =\n assetType === \"REPOSITORY_BRANCH\" ||\n asset?.[\"nativeType\"] === \"github#repositoryBranch\";\n // Wiz repository reports prefix root-relative paths with '/'. Workload paths\n // are not source locations and must remain only in the original evidence.\n const locationPath = text(record[\"locationPath\"]);\n const repositoryPath =\n repositoryAsset && locationPath ? locationPath.replace(/^\\/+/, \"\") : null;\n const digest =\n text(asset?.[\"imageDigest\"]) ??\n text(record[\"imageDigest\"]) ??\n (assetType === null ||\n assetType === \"CONTAINER_IMAGE\" ||\n assetType === \"CONTAINER\"\n ? (text(asset?.[\"imageId\"]) ??\n text(asset?.[\"containerImageId\"]) ??\n text(asset?.[\"ImageExternalId\"]))\n : null);\n // lastDetectedAt is not proof that the entire vendor record was updated.\n const evidence = {\n title:\n text(record[\"title\"]) ??\n [packageName, version, name].filter(Boolean).join(\" \"),\n description: text(record[\"description\"]),\n severity: severity?.toLowerCase(),\n url: text(record[\"portalUrl\"]),\n advisory_ids: [text(record[\"vulnerabilityExternalId\"]) ?? name],\n packages: [\n {\n name: packageName,\n ecosystem:\n text(record[\"packageManager\"]) ??\n text(artifact?.[\"osPackageManager\"]) ??\n text(artifact?.[\"codeLibraryLanguage\"]) ??\n text(record[\"codeLibraryLanguage\"]),\n installed_version: version,\n manifest_path: repositoryPath,\n fixed_versions: text(record[\"fixedVersion\"])\n ? [record[\"fixedVersion\"]]\n : [],\n },\n ],\n locations: repositoryPath ? [{ path: repositoryPath }] : [],\n branch: null,\n code_revision: null,\n source_scan_id: null,\n image_digests: digest ? [digest] : [],\n source_updated_at: updatedAt(record[\"updatedAt\"], \"updatedAt\"),\n source_data: record,\n };\n return {\n source_finding_id: id,\n evidence: validateExternalEvidence(evidence),\n };\n}\n\ntype RepositoryFindingKind = \"sast\" | \"secret\" | \"iac\";\n\ntype InputRecord = {\n value: unknown;\n kind?: \"sca\" | \"sca_csv\" | RepositoryFindingKind | \"cloud_configuration\";\n};\n\ntype RepositoryMetadata = {\n id: string | null;\n name: string | null;\n url: string;\n};\n\ntype FindingInput = {\n records: InputRecord[];\n repositories: Map<string, RepositoryMetadata & { platform: string | null }>;\n legacyRepositories?: FindingInput[\"repositories\"];\n};\n\n// Wiz's documented inventory platform establishes custom GitHub host semantics.\n// Keep this context separate from the repository metadata published as evidence.\nfunction inventoryRepositoryUrlKey(\n value: string,\n platform: string | null | undefined,\n): string {\n const key = repositoryUrlKey(value);\n return platform === \"GITHUB\" ? key.toLowerCase() : key;\n}\n\nfunction sourceRepository(\n repository: Record<string, unknown> | undefined,\n repositories: FindingInput[\"repositories\"],\n): RepositoryMetadata {\n const id = text(repository?.[\"id\"]);\n const inventory = id ? repositories.get(id) : undefined;\n const suppliedUrl = text(repository?.[\"url\"]);\n if (\n suppliedUrl &&\n inventory &&\n inventoryRepositoryUrlKey(suppliedUrl, inventory.platform) !==\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n )\n throw new Error(\n \"The finding and repository inventory have conflicting repository URLs.\",\n );\n const url = suppliedUrl ?? inventory?.url;\n if (!url)\n throw new Error(\n \"A verified source repository URL is required. Include repository.url or the matching repository.id and repository.url from data.versionControlResources.nodes; names and Wiz IDs are not Cloud repository IDs.\",\n );\n return {\n id,\n name: text(repository?.[\"name\"]) ?? inventory?.name ?? null,\n url,\n };\n}\n\nfunction sourceBranch(\n branch: Record<string, unknown> | undefined,\n repository: RepositoryMetadata,\n legacy = false,\n): string | null {\n const name = text(branch?.[\"name\"]);\n if (!name) return null;\n // Repository names and URL paths can both be literal branch prefixes. Keep\n // the old mapping only for an already approved publication checkpoint.\n if (!legacy) return name;\n const qualifiers = repository.name ? [repository.name] : [];\n\n // Include the URL qualifier before selecting the longest repository prefix.\n // Keep URL normalization and the branch suffix's original case and slashes.\n const repositoryKey = repositoryUrlKey(repository.url).toLowerCase();\n const url = /^(https?:\\/\\/[^/?#]+)\\/([^?#]+)$/iu.exec(repositoryKey);\n if (url) {\n const prefixParts = url[2]!.split(\"/\").length;\n const parts = name.split(\"/\");\n const qualifier = parts.slice(0, prefixParts).join(\"/\");\n if (\n parts.length > prefixParts &&\n repositoryUrlKey(url[1] + \"/\" + qualifier).toLowerCase() === repositoryKey\n )\n qualifiers.push(qualifier);\n }\n for (const qualifier of qualifiers.sort(\n (left, right) => right.length - left.length,\n )) {\n const prefix = qualifier + \"/\";\n if (name.toLowerCase().startsWith(prefix.toLowerCase()))\n return name.slice(prefix.length) || null;\n }\n return url || repository.name ? name : null;\n}\n\nfunction updatedAt(value: unknown, field: string): number | null {\n const timestamp = text(value);\n if (!timestamp) return null;\n const seconds = Date.parse(timestamp) / 1000;\n if (!Number.isFinite(seconds) || seconds < 0)\n throw new Error(`Wiz ${field} is not a valid timestamp.`);\n return Math.floor(seconds);\n}\n\n// Empty code and configuration strings are meaningful vendor evidence.\nfunction content(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\n/** Map only explicitly identified repository finding collections. */\nfunction repositoryFinding(\n kind: RepositoryFindingKind,\n record: Record<string, unknown>,\n repositories: FindingInput[\"repositories\"],\n legacy = false,\n): VendorFinding {\n const id = sourceFindingId(record[\"id\"]);\n const resource = object(record[\"resource\"]);\n if (kind === \"secret\" && resource?.[\"type\"] !== \"REPOSITORY_BRANCH\")\n throw new Error(\n \"Only repository-branch secret findings can be published to a repository. Workload secrets require a resource-scoped import and are not supported.\",\n );\n const suppliedRepository =\n kind === \"secret\"\n ? object(object(resource?.[\"typedProperties\"])?.[\"repository\"])\n : object(record[\"repository\"]);\n const repository = sourceRepository(suppliedRepository, repositories);\n const branch =\n kind === \"secret\"\n ? resource\n : object(record[kind === \"sast\" ? \"repositoryBranch\" : \"branch\"]);\n const rule = object(record[\"rule\"]);\n const path = text(record[kind === \"secret\" ? \"path\" : \"filePath\"]);\n const line = record[kind === \"secret\" ? \"lineNumber\" : \"startLine\"];\n const details = {\n kind,\n repository,\n source_status: text(record[\"status\"]),\n scanner_origin: kind === \"sast\" ? text(record[\"origin\"]) : null,\n scanner_verdict:\n kind === \"sast\" ? text(object(record[\"aiAnalysis\"])?.[\"verdict\"]) : null,\n rule: rule\n ? {\n id: text(rule[\"id\"]),\n short_id: text(rule[\"shortId\"]),\n name: text(rule[\"name\"]),\n }\n : null,\n weakness_ids:\n kind === \"sast\" && Array.isArray(record[\"weaknesses\"])\n ? record[\"weaknesses\"].map((weakness) => object(weakness)?.[\"id\"])\n : [],\n remediation_instructions:\n text(record[\"remediationInstructions\"]) ??\n text(rule?.[\"remediationInstructions\"]),\n code:\n path && kind !== \"secret\"\n ? {\n end_line: record[\"endLine\"] ?? null,\n snippet: content(\n record[kind === \"sast\" ? \"snippet\" : \"matchContent\"],\n ),\n }\n : null,\n secret:\n kind === \"secret\"\n ? {\n type: text(record[\"type\"]),\n confidence: text(record[\"confidence\"]),\n validation_status: text(record[\"validationStatus\"]),\n is_encrypted: record[\"isEncrypted\"] ?? null,\n is_managed: record[\"isManaged\"] ?? null,\n introduced_commit: text(\n object(record[\"vcsDetails\"])?.[\"initialCommitHash\"],\n ),\n }\n : null,\n configuration:\n kind === \"iac\"\n ? {\n platform: text(record[\"platform\"]),\n cloud_platform: text(record[\"cloudPlatform\"]),\n expected: content(record[\"expectedContent\"]),\n actual: content(record[\"foundContent\"]),\n }\n : null,\n file_url: text(record[\"fileURL\"]),\n };\n return {\n // Existing package occurrence IDs remain unchanged. New families cannot\n // collide with one another when the same tenant source key is used.\n source_finding_id: sourceFindingId(`${kind}:${id}`),\n evidence: validateExternalEvidence({\n title: text(record[\"name\"]) ?? text(rule?.[\"name\"]),\n severity: text(record[\"severity\"])?.toLowerCase(),\n description: text(record[\"description\"]) ?? text(rule?.[\"description\"]),\n url: text(record[\"wizUrl\"]) ?? text(record[\"portalUrl\"]),\n locations: path ? [{ path, line: line ?? null }] : [],\n branch: sourceBranch(branch, repository, legacy),\n code_revision: null,\n source_scan_id: null,\n source_updated_at:\n kind === \"secret\"\n ? updatedAt(record[\"lastUpdatedAt\"], \"lastUpdatedAt\")\n : kind === \"iac\"\n ? updatedAt(record[\"updatedAt\"], \"updatedAt\")\n : null,\n source_data: record,\n details,\n }),\n };\n}\n\nfunction records(payload: unknown): FindingInput {\n const repositories: FindingInput[\"repositories\"] = new Map();\n const legacyRepositories: FindingInput[\"repositories\"] = new Map();\n if (Array.isArray(payload))\n return { records: payload.map((value) => ({ value })), repositories };\n const envelope = object(payload);\n if (!envelope)\n throw new Error(\n \"Expected finding objects or a named Wiz finding collection.\",\n );\n if (\n object(envelope[\"scannersRunStatuses\"]) &&\n object(envelope[\"codeAnalyzerDetails\"])\n )\n throw new Error(\n \"This is a Wiz Code & Build Scan event, which contains scan metadata rather than vulnerability records. In Vulnerability Findings, filter the repository and selection, then choose Save as → Report with JSON format and Detailed columns. Download that report instead of Raw Event.\",\n );\n if (Array.isArray(envelope[\"errors\"]) && envelope[\"errors\"].length > 0)\n throw new Error(\n \"Wiz returned GraphQL errors. Resolve them before publishing this response.\",\n );\n if (\n envelope[\"source_finding_id\"] !== undefined ||\n envelope[\"id\"] !== undefined\n )\n return { records: [{ value: envelope }], repositories };\n const data = object(envelope[\"data\"]) ?? envelope;\n const inventory = object(data[\"versionControlResources\"]);\n if (object(inventory?.[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz repository inventory has another page. Finish the selected inventory before publishing.\",\n );\n if (Array.isArray(inventory?.[\"nodes\"])) {\n const entries = inventory[\"nodes\"].flatMap((entry) => {\n const node = object(entry);\n const repository = object(node?.[\"repository\"]);\n const id = text(repository?.[\"id\"]);\n const url = text(repository?.[\"url\"]);\n return id && url\n ? [\n {\n id,\n name: text(repository?.[\"name\"]),\n url,\n platform: text(node?.[\"platform\"]),\n },\n ]\n : [];\n });\n // Resolve provider hints before comparing URLs, so duplicate row order cannot\n // discard a known platform or reject a case variant before its GITHUB hint.\n for (const entry of entries) {\n const previous = repositories.get(entry.id);\n if (\n previous?.platform &&\n entry.platform &&\n previous.platform !== entry.platform\n )\n throw new Error(\n `Repository inventory contains conflicting platforms for ${JSON.stringify(entry.id)}.`,\n );\n repositories.set(entry.id, {\n ...entry,\n // Equivalent inventory aliases must produce the same evidence when the\n // export reorders its rows. Keep a stable supplied URL and nonempty name.\n url: previous && previous.url < entry.url ? previous.url : entry.url,\n name:\n previous?.name && (!entry.name || previous.name < entry.name)\n ? previous.name\n : entry.name,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n legacyRepositories.set(entry.id, {\n ...entry,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n }\n for (const entry of entries) {\n const resolved = repositories.get(entry.id)!;\n if (\n inventoryRepositoryUrlKey(entry.url, resolved.platform) !==\n inventoryRepositoryUrlKey(resolved.url, resolved.platform)\n )\n throw new Error(\n `Repository inventory contains conflicting URLs for ${JSON.stringify(entry.id)}.`,\n );\n }\n }\n const collections = {\n vulnerabilityFindings: \"sca\",\n sastFindings: \"sast\",\n secretInstances: \"secret\",\n iacFindings: \"iac\",\n configurationFindings: \"cloud_configuration\",\n } as const;\n const selected: InputRecord[] = [];\n let found = false;\n for (const [root, kind] of Object.entries(collections)) {\n const collection = object(data[root]);\n if (!collection) continue;\n found = true;\n if (!Array.isArray(collection[\"nodes\"]))\n throw new Error(`Wiz ${root}.nodes must be an array.`);\n if (object(collection[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.\",\n );\n for (const value of collection[\"nodes\"]) selected.push({ value, kind });\n }\n if (found)\n return {\n records: selected,\n repositories,\n legacyRepositories,\n };\n throw new Error(\n \"Unsupported Wiz export. Supply repository vulnerability CSV, vulnerability finding objects, named sastFindings/secretInstances/iacFindings collections, or normalized JSONL. Other CSV reports need an explicit normalized JSONL mapping.\",\n );\n}\n\nexport async function readVendorFindings(\n path: string,\n): Promise<VendorFindings> {\n return normalizeFindings(await readFindingInput(path));\n}\n\n/** @internal Preserve older inventory projections only for saved publication replay. */\nexport async function readVendorFindingsForPublication(path: string): Promise<{\n current: VendorFindings;\n legacy: VendorFindings;\n currentIdentity: unknown[];\n legacyIdentity: unknown[];\n sourceRepositories: ExternalSourceRepository[];\n}> {\n const input = await readFindingInput(path);\n const normalized = new WeakSet<VendorFinding>();\n const current = normalizeFindings(input, normalized);\n const legacy = normalizeFindings(\n { ...input, repositories: input.legacyRepositories ?? input.repositories },\n normalized,\n true,\n );\n const identity = (parsed: VendorFindings) =>\n parsed.findings.map((finding) => {\n if (normalized.has(finding)) return finding;\n const repository = finding.evidence.details?.repository;\n return {\n source_finding_id: finding.source_finding_id,\n evidence: {\n // Raw vendor records retain every original branch/ref and source field.\n // Inventory display aliases must not change an outstanding request's identity.\n source_data: finding.evidence.source_data,\n repository: repository\n ? {\n id: repository.id,\n // Publication targets use Cloud's GitHub URL semantics. Input\n // joins above still require provenance for custom-host folding.\n url: repositoryUrlKey(repository.url).toLowerCase(),\n }\n : null,\n },\n };\n });\n return {\n current,\n legacy,\n currentIdentity: identity(current),\n legacyIdentity: identity(legacy),\n sourceRepositories: current.findings.flatMap(({ evidence }) => {\n const repository = evidence.details?.repository;\n const inventory = input.repositories.get(repository?.id ?? \"\");\n // Forward provenance only for selected findings that match the inventory.\n // Use the emitted spelling so typed evidence and reader hints share it.\n return repository &&\n inventory?.platform === \"GITHUB\" &&\n inventoryRepositoryUrlKey(repository.url, inventory.platform) ===\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n ? [{ url: repository.url, platform: \"github\" as const }]\n : [];\n }),\n };\n}\n\nasync function readFindingInput(path: string): Promise<FindingInput> {\n try {\n const contents = await readScannerText(path);\n let payload: unknown;\n try {\n payload = JSON.parse(contents);\n } catch {\n const csv = readWizCsv(contents);\n if (csv)\n return {\n records: csv.map((value) => ({ value, kind: \"sca_csv\" })),\n repositories: new Map(),\n };\n payload = parseJsonOrJsonl(contents);\n }\n return records(payload);\n } catch (cause) {\n throw new CodexSecurityError(\n `Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n }\n}\n\nfunction normalizeFindings(\n input: FindingInput,\n normalized?: WeakSet<VendorFinding>,\n legacy = false,\n): VendorFindings {\n const result: VendorFindings = {\n read: input.records.length,\n findings: [],\n excluded: [],\n };\n const identities = new Set<string>();\n for (const [index, item] of input.records.entries()) {\n const record = object(item.value);\n try {\n if (!record) throw new Error(\"Finding must be an object.\");\n let finding: VendorFinding;\n if (item.kind === \"sca_csv\") {\n finding = wizCsvFinding(record, sourceFindingId(record[\"ID\"]));\n } else if (\"source_finding_id\" in record) {\n if (\n Object.keys(record).some(\n (key) => ![\"source_finding_id\", \"evidence\"].includes(key),\n )\n ) {\n throw new Error(\n \"Normalized input permits only source_finding_id and evidence.\",\n );\n }\n finding = {\n source_finding_id: sourceFindingId(record[\"source_finding_id\"]),\n evidence: validateExternalEvidence(record[\"evidence\"]),\n };\n } else if (item.kind === \"cloud_configuration\") {\n throw new Error(\n \"Cloud configuration findings require a resource-scoped import and cannot be published to a repository.\",\n );\n } else if (item.kind && item.kind !== \"sca\") {\n finding = repositoryFinding(\n item.kind,\n record,\n input.repositories,\n legacy,\n );\n } else {\n if (\n !item.kind &&\n (object(record[\"repository\"]) ||\n object(record[\"repositoryBranch\"]) ||\n object(record[\"resource\"]))\n )\n throw new Error(\n \"Raw SAST, secret, and IaC records require their named sastFindings, secretInstances, or iacFindings collection. Bare arrays do not identify the finding family; use normalized JSONL for an explicit mapping.\",\n );\n finding = wizFinding(record);\n }\n if (identities.has(finding.source_finding_id)) {\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each vendor occurrence once.`,\n );\n }\n identities.add(finding.source_finding_id);\n result.findings.push(finding);\n if (item.kind !== \"sca_csv\" && \"source_finding_id\" in record)\n normalized?.add(finding);\n } catch (error) {\n if (error instanceof CodexSecurityError) throw error;\n result.excluded.push({\n position: index + 1,\n source_finding_id:\n item.kind === \"sca_csv\"\n ? text(record?.[\"ID\"])\n : (text(record?.[\"source_finding_id\"]) ?? text(record?.[\"id\"])),\n reason: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return result;\n}\n"]}
1
+ {"version":3,"file":"wiz-findings.js","sourceRoot":"","sources":["../src/wiz-findings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAYzD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,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AO,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACvC,CAAC;YACD,IAAI,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC9C,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC,uCAAuC,CAChH,CAAC;YACJ,CAAC;YACD,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAC1C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,mBAAmB,IAAI,MAAM;gBAC1D,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAkB;gBAAE,MAAM,KAAK,CAAC;YACrD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACnB,QAAQ,EAAE,KAAK,GAAG,CAAC;gBACnB,iBAAiB,EACf,IAAI,CAAC,IAAI,KAAK,SAAS;oBACrB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,mBAAmB,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;gBACnE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC/D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { CodexSecurityError } from \"./errors.js\";\nimport {\n repositoryUrlKey,\n validateExternalEvidence,\n type ExternalImportTarget,\n} from \"./external-import-contract.js\";\nimport { parseJsonOrJsonl, readScannerText } from \"./scanner-import.js\";\nimport { readWizCsv, wizCsvFinding } from \"./wiz-csv.js\";\nimport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n ExternalSourceRepository,\n} from \"./external-findings.js\";\n\nexport type {\n ExternalFinding as VendorFinding,\n ExternalFindings as VendorFindings,\n} from \"./external-findings.js\";\n\nfunction object(value: unknown): Record<string, unknown> | undefined {\n return value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\nfunction text(value: unknown): string | null {\n return typeof value === \"string\" && value.trim() ? value : null;\n}\n\nfunction sourceFindingId(value: unknown, target: ExternalImportTarget): string {\n const id = text(value);\n if (\n !id ||\n id.includes(\"\\0\") ||\n (target === \"cloud\" && Buffer.byteLength(id) > 512)\n )\n throw new Error(\n target === \"cloud\"\n ? \"Source finding id must contain 1–512 UTF-8 bytes and no NUL characters.\"\n : \"Source finding id must be nonempty and contain no NUL characters.\",\n );\n return id;\n}\n\n/** Keep a Wiz vulnerability occurrence intact; advisory names are not identities. */\nfunction wizFinding(\n record: Record<string, unknown>,\n target: ExternalImportTarget,\n): VendorFinding {\n if (record[\"detectionMethod\"] === \"EXTERNAL_NETWORK_SCAN\")\n throw new Error(\n \"Wiz external network findings are not supported by the package vulnerability mapping.\",\n );\n const id = sourceFindingId(record[\"id\"], target);\n const name = text(record[\"name\"]);\n const packageName = text(record[\"detailedName\"]);\n const version = text(record[\"version\"]);\n const severity = (\n text(record[\"vendorSeverity\"]) ?? text(record[\"severity\"])\n )?.toLowerCase();\n const asset = object(record[\"vulnerableAsset\"]);\n const artifact = object(record[\"artifactType\"]);\n if (!name || !packageName || !text(asset?.[\"id\"])) {\n throw new Error(\n \"Expected a Wiz package vulnerability finding with name, detailedName, and vulnerableAsset.id. Other finding classes need a separate mapping.\",\n );\n }\n const assetType = text(asset?.[\"type\"]);\n const repositoryAsset =\n assetType === \"REPOSITORY_BRANCH\" ||\n asset?.[\"nativeType\"] === \"github#repositoryBranch\";\n // Wiz repository reports prefix root-relative paths with '/'. Workload paths\n // are not source locations and must remain only in the original evidence.\n const locationPath = text(record[\"locationPath\"]);\n const repositoryPath =\n repositoryAsset && locationPath ? locationPath.replace(/^\\/+/, \"\") : null;\n const digest =\n text(asset?.[\"imageDigest\"]) ??\n text(record[\"imageDigest\"]) ??\n (assetType === null ||\n assetType === \"CONTAINER_IMAGE\" ||\n assetType === \"CONTAINER\"\n ? (text(asset?.[\"imageId\"]) ??\n text(asset?.[\"containerImageId\"]) ??\n text(asset?.[\"ImageExternalId\"]))\n : null);\n // lastDetectedAt is not proof that the entire vendor record was updated.\n const evidence = {\n title:\n text(record[\"title\"]) ??\n [packageName, version, name].filter(Boolean).join(\" \"),\n description: text(record[\"description\"]),\n severity: severity === \"none\" ? \"unknown\" : severity,\n url: text(record[\"portalUrl\"]),\n advisory_ids: [text(record[\"vulnerabilityExternalId\"]) ?? name],\n packages: [\n {\n name: packageName,\n ecosystem:\n text(record[\"packageManager\"]) ??\n text(artifact?.[\"osPackageManager\"]) ??\n text(artifact?.[\"codeLibraryLanguage\"]) ??\n text(record[\"codeLibraryLanguage\"]),\n installed_version: version,\n manifest_path: repositoryPath,\n fixed_versions: text(record[\"fixedVersion\"])\n ? [record[\"fixedVersion\"]]\n : [],\n },\n ],\n locations: repositoryPath ? [{ path: repositoryPath }] : [],\n branch: null,\n code_revision: null,\n source_scan_id: null,\n image_digests: digest ? [digest] : [],\n source_updated_at: updatedAt(record[\"updatedAt\"], \"updatedAt\"),\n source_data: record,\n };\n return {\n source_finding_id: id,\n evidence: validateExternalEvidence(evidence, target),\n };\n}\n\ntype RepositoryFindingKind = \"sast\" | \"secret\" | \"iac\";\n\ntype InputRecord = {\n value: unknown;\n kind?: \"sca\" | \"sca_csv\" | RepositoryFindingKind | \"cloud_configuration\";\n};\n\ntype RepositoryMetadata = {\n id: string | null;\n name: string | null;\n url: string;\n};\n\ntype FindingInput = {\n records: InputRecord[];\n repositories: Map<string, RepositoryMetadata & { platform: string | null }>;\n legacyRepositories?: FindingInput[\"repositories\"];\n};\n\n// Wiz's documented inventory platform establishes custom GitHub host semantics.\n// Keep this context separate from the repository metadata published as evidence.\nfunction inventoryRepositoryUrlKey(\n value: string,\n platform: string | null | undefined,\n): string {\n const key = repositoryUrlKey(value);\n return platform === \"GITHUB\" ? key.toLowerCase() : key;\n}\n\nfunction sourceRepository(\n repository: Record<string, unknown> | undefined,\n repositories: FindingInput[\"repositories\"],\n): RepositoryMetadata {\n const id = text(repository?.[\"id\"]);\n const inventory = id ? repositories.get(id) : undefined;\n const suppliedUrl = text(repository?.[\"url\"]);\n if (\n suppliedUrl &&\n inventory &&\n inventoryRepositoryUrlKey(suppliedUrl, inventory.platform) !==\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n )\n throw new Error(\n \"The finding and repository inventory have conflicting repository URLs.\",\n );\n const url = suppliedUrl ?? inventory?.url;\n if (!url)\n throw new Error(\n \"A verified source repository URL is required. Include repository.url or the matching repository.id and repository.url from data.versionControlResources.nodes; names and Wiz IDs are not Cloud repository IDs.\",\n );\n return {\n id,\n name: text(repository?.[\"name\"]) ?? inventory?.name ?? null,\n url,\n };\n}\n\nfunction sourceBranch(\n branch: Record<string, unknown> | undefined,\n repository: RepositoryMetadata,\n legacy = false,\n): string | null {\n const name = text(branch?.[\"name\"]);\n if (!name) return null;\n // Repository names and URL paths can both be literal branch prefixes. Keep\n // the old mapping only for an already approved publication checkpoint.\n if (!legacy) return name;\n const qualifiers = repository.name ? [repository.name] : [];\n\n // Include the URL qualifier before selecting the longest repository prefix.\n // Keep URL normalization and the branch suffix's original case and slashes.\n const repositoryKey = repositoryUrlKey(repository.url).toLowerCase();\n const url = /^(https?:\\/\\/[^/?#]+)\\/([^?#]+)$/iu.exec(repositoryKey);\n if (url) {\n const prefixParts = url[2]!.split(\"/\").length;\n const parts = name.split(\"/\");\n const qualifier = parts.slice(0, prefixParts).join(\"/\");\n if (\n parts.length > prefixParts &&\n repositoryUrlKey(url[1] + \"/\" + qualifier).toLowerCase() === repositoryKey\n )\n qualifiers.push(qualifier);\n }\n for (const qualifier of qualifiers.sort(\n (left, right) => right.length - left.length,\n )) {\n const prefix = qualifier + \"/\";\n if (name.toLowerCase().startsWith(prefix.toLowerCase()))\n return name.slice(prefix.length) || null;\n }\n return url || repository.name ? name : null;\n}\n\nfunction updatedAt(value: unknown, field: string): number | null {\n const timestamp = text(value);\n if (!timestamp) return null;\n const seconds = Date.parse(timestamp) / 1000;\n if (!Number.isFinite(seconds) || seconds < 0)\n throw new Error(`Wiz ${field} is not a valid timestamp.`);\n return Math.floor(seconds);\n}\n\n// Empty code and configuration strings are meaningful vendor evidence.\nfunction content(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\n/** Map only explicitly identified repository finding collections. */\nfunction repositoryFinding(\n kind: RepositoryFindingKind,\n record: Record<string, unknown>,\n repositories: FindingInput[\"repositories\"],\n legacy = false,\n target: ExternalImportTarget = \"cloud\",\n): VendorFinding {\n const id = sourceFindingId(record[\"id\"], target);\n const resource = object(record[\"resource\"]);\n if (kind === \"secret\" && resource?.[\"type\"] !== \"REPOSITORY_BRANCH\")\n throw new Error(\n \"Only repository-branch secret findings can be published to a repository. Workload secrets require a resource-scoped import and are not supported.\",\n );\n const suppliedRepository =\n kind === \"secret\"\n ? object(object(resource?.[\"typedProperties\"])?.[\"repository\"])\n : object(record[\"repository\"]);\n const repository = sourceRepository(suppliedRepository, repositories);\n const branch =\n kind === \"secret\"\n ? resource\n : object(record[kind === \"sast\" ? \"repositoryBranch\" : \"branch\"]);\n const rule = object(record[\"rule\"]);\n const path = text(record[kind === \"secret\" ? \"path\" : \"filePath\"]);\n const line = record[kind === \"secret\" ? \"lineNumber\" : \"startLine\"];\n const details = {\n kind,\n repository,\n source_status: text(record[\"status\"]),\n scanner_origin: kind === \"sast\" ? text(record[\"origin\"]) : null,\n scanner_verdict:\n kind === \"sast\" ? text(object(record[\"aiAnalysis\"])?.[\"verdict\"]) : null,\n rule: rule\n ? {\n id: text(rule[\"id\"]),\n short_id: text(rule[\"shortId\"]),\n name: text(rule[\"name\"]),\n }\n : null,\n weakness_ids:\n kind === \"sast\" && Array.isArray(record[\"weaknesses\"])\n ? record[\"weaknesses\"].map((weakness) => object(weakness)?.[\"id\"])\n : [],\n remediation_instructions:\n text(record[\"remediationInstructions\"]) ??\n text(rule?.[\"remediationInstructions\"]),\n code:\n path && kind !== \"secret\"\n ? {\n end_line: record[\"endLine\"] ?? null,\n snippet: content(\n record[kind === \"sast\" ? \"snippet\" : \"matchContent\"],\n ),\n }\n : null,\n secret:\n kind === \"secret\"\n ? {\n type: text(record[\"type\"]),\n confidence: text(record[\"confidence\"]),\n validation_status: text(record[\"validationStatus\"]),\n is_encrypted: record[\"isEncrypted\"] ?? null,\n is_managed: record[\"isManaged\"] ?? null,\n introduced_commit: text(\n object(record[\"vcsDetails\"])?.[\"initialCommitHash\"],\n ),\n }\n : null,\n configuration:\n kind === \"iac\"\n ? {\n platform: text(record[\"platform\"]),\n cloud_platform: text(record[\"cloudPlatform\"]),\n expected: content(record[\"expectedContent\"]),\n actual: content(record[\"foundContent\"]),\n }\n : null,\n file_url: text(record[\"fileURL\"]),\n };\n return {\n // Existing package occurrence IDs remain unchanged. New families cannot\n // collide with one another when the same tenant source key is used.\n source_finding_id: sourceFindingId(`${kind}:${id}`, target),\n evidence: validateExternalEvidence(\n {\n title: text(record[\"name\"]) ?? text(rule?.[\"name\"]),\n severity: text(record[\"severity\"])?.toLowerCase(),\n description: text(record[\"description\"]) ?? text(rule?.[\"description\"]),\n url: text(record[\"wizUrl\"]) ?? text(record[\"portalUrl\"]),\n locations: path ? [{ path, line: line ?? null }] : [],\n branch: sourceBranch(branch, repository, legacy),\n code_revision: null,\n source_scan_id: null,\n source_updated_at:\n kind === \"secret\"\n ? updatedAt(record[\"lastUpdatedAt\"], \"lastUpdatedAt\")\n : kind === \"iac\"\n ? updatedAt(record[\"updatedAt\"], \"updatedAt\")\n : null,\n source_data: record,\n details,\n },\n target,\n ),\n };\n}\n\nfunction records(payload: unknown): FindingInput {\n const repositories: FindingInput[\"repositories\"] = new Map();\n const legacyRepositories: FindingInput[\"repositories\"] = new Map();\n if (Array.isArray(payload))\n return { records: payload.map((value) => ({ value })), repositories };\n const envelope = object(payload);\n if (!envelope)\n throw new Error(\n \"Expected finding objects or a named Wiz finding collection.\",\n );\n if (\n object(envelope[\"scannersRunStatuses\"]) &&\n object(envelope[\"codeAnalyzerDetails\"])\n )\n throw new Error(\n \"This is a Wiz Code & Build Scan event, which contains scan metadata rather than vulnerability records. In Vulnerability Findings, filter the repository and selection, then choose Save as → Report with JSON format and Detailed columns. Download that report instead of Raw Event.\",\n );\n if (Array.isArray(envelope[\"errors\"]) && envelope[\"errors\"].length > 0)\n throw new Error(\n \"Wiz returned GraphQL errors. Resolve them before publishing this response.\",\n );\n if (\n envelope[\"source_finding_id\"] !== undefined ||\n envelope[\"id\"] !== undefined\n )\n return { records: [{ value: envelope }], repositories };\n const data = object(envelope[\"data\"]) ?? envelope;\n const inventory = object(data[\"versionControlResources\"]);\n if (object(inventory?.[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz repository inventory has another page. Finish the selected inventory before publishing.\",\n );\n if (Array.isArray(inventory?.[\"nodes\"])) {\n const entries = inventory[\"nodes\"].flatMap((entry) => {\n const node = object(entry);\n const repository = object(node?.[\"repository\"]);\n const id = text(repository?.[\"id\"]);\n const url = text(repository?.[\"url\"]);\n return id && url\n ? [\n {\n id,\n name: text(repository?.[\"name\"]),\n url,\n platform: text(node?.[\"platform\"]),\n },\n ]\n : [];\n });\n // Resolve provider hints before comparing URLs, so duplicate row order cannot\n // discard a known platform or reject a case variant before its GITHUB hint.\n for (const entry of entries) {\n const previous = repositories.get(entry.id);\n if (\n previous?.platform &&\n entry.platform &&\n previous.platform !== entry.platform\n )\n throw new Error(\n `Repository inventory contains conflicting platforms for ${JSON.stringify(entry.id)}.`,\n );\n repositories.set(entry.id, {\n ...entry,\n // Equivalent inventory aliases must produce the same evidence when the\n // export reorders its rows. Keep a stable supplied URL and nonempty name.\n url: previous && previous.url < entry.url ? previous.url : entry.url,\n name:\n previous?.name && (!entry.name || previous.name < entry.name)\n ? previous.name\n : entry.name,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n legacyRepositories.set(entry.id, {\n ...entry,\n platform: entry.platform ?? previous?.platform ?? null,\n });\n }\n for (const entry of entries) {\n const resolved = repositories.get(entry.id)!;\n if (\n inventoryRepositoryUrlKey(entry.url, resolved.platform) !==\n inventoryRepositoryUrlKey(resolved.url, resolved.platform)\n )\n throw new Error(\n `Repository inventory contains conflicting URLs for ${JSON.stringify(entry.id)}.`,\n );\n }\n }\n const collections = {\n vulnerabilityFindings: \"sca\",\n sastFindings: \"sast\",\n secretInstances: \"secret\",\n iacFindings: \"iac\",\n configurationFindings: \"cloud_configuration\",\n } as const;\n const selected: InputRecord[] = [];\n let found = false;\n for (const [root, kind] of Object.entries(collections)) {\n const collection = object(data[root]);\n if (!collection) continue;\n found = true;\n if (!Array.isArray(collection[\"nodes\"]))\n throw new Error(`Wiz ${root}.nodes must be an array.`);\n if (object(collection[\"pageInfo\"])?.[\"hasNextPage\"] === true)\n throw new Error(\n \"Wiz response has another page. Complete the requested pages or save the explicitly selected records in their named collection before publishing.\",\n );\n for (const value of collection[\"nodes\"]) selected.push({ value, kind });\n }\n if (found)\n return {\n records: selected,\n repositories,\n legacyRepositories,\n };\n throw new Error(\n \"Unsupported Wiz export. Supply repository vulnerability CSV, vulnerability finding objects, named sastFindings/secretInstances/iacFindings collections, or normalized JSONL. Other CSV reports need an explicit normalized JSONL mapping.\",\n );\n}\n\nexport async function readVendorFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<VendorFindings> {\n return normalizeFindings(await readFindingInput(path), target);\n}\n\n/** @internal Preserve older inventory projections only for saved publication replay. */\nexport async function readVendorFindingsForPublication(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<{\n current: VendorFindings;\n legacy: VendorFindings;\n currentIdentity: unknown[];\n legacyIdentity: unknown[];\n sourceRepositories: ExternalSourceRepository[];\n}> {\n const input = await readFindingInput(path);\n const normalized = new WeakSet<VendorFinding>();\n const current = normalizeFindings(input, target, normalized);\n const legacy = normalizeFindings(\n { ...input, repositories: input.legacyRepositories ?? input.repositories },\n target,\n normalized,\n true,\n );\n const identity = (parsed: VendorFindings) =>\n parsed.findings.map((finding) => {\n if (normalized.has(finding)) return finding;\n const repository = finding.evidence.details?.repository;\n return {\n source_finding_id: finding.source_finding_id,\n evidence: {\n // Raw vendor records retain every original branch/ref and source field.\n // Inventory display aliases must not change an outstanding request's identity.\n source_data: finding.evidence.source_data,\n repository: repository\n ? {\n id: repository.id,\n // Publication targets use Cloud's GitHub URL semantics. Input\n // joins above still require provenance for custom-host folding.\n url: repositoryUrlKey(repository.url).toLowerCase(),\n }\n : null,\n },\n };\n });\n return {\n current,\n legacy,\n currentIdentity: identity(current),\n legacyIdentity: identity(legacy),\n sourceRepositories: current.findings.flatMap(({ evidence }) => {\n const repository = evidence.details?.repository;\n const inventory = input.repositories.get(repository?.id ?? \"\");\n // Forward provenance only for selected findings that match the inventory.\n // Use the emitted spelling so typed evidence and reader hints share it.\n return repository &&\n inventory?.platform === \"GITHUB\" &&\n inventoryRepositoryUrlKey(repository.url, inventory.platform) ===\n inventoryRepositoryUrlKey(inventory.url, inventory.platform)\n ? [{ url: repository.url, platform: \"github\" as const }]\n : [];\n }),\n };\n}\n\nasync function readFindingInput(path: string): Promise<FindingInput> {\n try {\n const contents = await readScannerText(path);\n let payload: unknown;\n try {\n payload = JSON.parse(contents);\n } catch {\n const csv = readWizCsv(contents);\n if (csv)\n return {\n records: csv.map((value) => ({ value, kind: \"sca_csv\" })),\n repositories: new Map(),\n };\n payload = parseJsonOrJsonl(contents);\n }\n return records(payload);\n } catch (cause) {\n throw new CodexSecurityError(\n `Could not read vendor findings as UTF-8 JSON, JSONL, or Wiz CSV: ${cause instanceof Error ? cause.message : String(cause)}`,\n { cause },\n );\n }\n}\n\nfunction normalizeFindings(\n input: FindingInput,\n target: ExternalImportTarget,\n normalized?: WeakSet<VendorFinding>,\n legacy = false,\n): VendorFindings {\n const result: VendorFindings = {\n read: input.records.length,\n findings: [],\n excluded: [],\n };\n const identities = new Set<string>();\n for (const [index, item] of input.records.entries()) {\n const record = object(item.value);\n try {\n if (!record) throw new Error(\"Finding must be an object.\");\n let finding: VendorFinding;\n if (item.kind === \"sca_csv\") {\n finding = wizCsvFinding(\n record,\n sourceFindingId(record[\"ID\"], target),\n target,\n );\n } else if (\"source_finding_id\" in record) {\n if (\n Object.keys(record).some(\n (key) => ![\"source_finding_id\", \"evidence\"].includes(key),\n )\n ) {\n throw new Error(\n \"Normalized input permits only source_finding_id and evidence.\",\n );\n }\n finding = {\n source_finding_id: sourceFindingId(\n record[\"source_finding_id\"],\n target,\n ),\n evidence: validateExternalEvidence(record[\"evidence\"], target),\n };\n } else if (item.kind === \"cloud_configuration\") {\n throw new Error(\n \"Cloud configuration findings require a resource-scoped import and cannot be published to a repository.\",\n );\n } else if (item.kind && item.kind !== \"sca\") {\n finding = repositoryFinding(\n item.kind,\n record,\n input.repositories,\n legacy,\n target,\n );\n } else {\n if (\n !item.kind &&\n (object(record[\"repository\"]) ||\n object(record[\"repositoryBranch\"]) ||\n object(record[\"resource\"]))\n )\n throw new Error(\n \"Raw SAST, secret, and IaC records require their named sastFindings, secretInstances, or iacFindings collection. Bare arrays do not identify the finding family; use normalized JSONL for an explicit mapping.\",\n );\n finding = wizFinding(record, target);\n }\n if (identities.has(finding.source_finding_id)) {\n throw new CodexSecurityError(\n `Duplicate source finding id ${JSON.stringify(finding.source_finding_id)}. Select each vendor occurrence once.`,\n );\n }\n identities.add(finding.source_finding_id);\n result.findings.push(finding);\n if (item.kind !== \"sca_csv\" && \"source_finding_id\" in record)\n normalized?.add(finding);\n } catch (error) {\n if (error instanceof CodexSecurityError) throw error;\n result.excluded.push({\n position: index + 1,\n source_finding_id:\n item.kind === \"sca_csv\"\n ? text(record?.[\"ID\"])\n : (text(record?.[\"source_finding_id\"]) ?? text(record?.[\"id\"])),\n reason: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return result;\n}\n"]}
@@ -7,9 +7,8 @@ Use `--records` alone or with `--runs N`; model execution remains host-provided.
7
7
 
8
8
  The SDK exports `classifySeverityRecords`, `classifySeverityRecordsInputSchema`,
9
9
  and their input, result, and review-request types. The protocol and input have
10
- version `1`. This is an additive capability: pin an artifact containing this
11
- implementation until it is included in a published release. A prior CLI that does
12
- not advertise `--records` in `classify-severity --help` cannot run this protocol.
10
+ version `1`. Before using the protocol, confirm that your installed CLI lists
11
+ `--records` in `classify-severity --help`.
13
12
 
14
13
  ## Immutable inputs
15
14
 
@@ -26,7 +25,7 @@ Send one newline-delimited JSON-RPC request with `method: "run"` and these param
26
25
  ```
27
26
 
28
27
  The `rubric` field is optional. Omit it to classify with the
29
- [built-in severity rubric](../src/default-severity-rubric.ts), using the same configured
28
+ [built-in severity rubric](https://github.com/openai/codex-security/blob/main/sdk/typescript/src/default-severity-rubric.ts), using the same configured
30
29
  independent host reviews and usage accounting. The result echoes its built-in
31
30
  revision (currently `1`) and exact Markdown SHA-256. Supplying a custom rubric
32
31
  replaces the default completely and preserves the supplied revision/hash binding.