@openai/codex-security 0.8.3 → 0.10.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 (658) hide show
  1. package/README.md +36 -746
  2. package/_bundled_plugin/.codex-plugin/plugin.json +2 -0
  3. package/_bundled_plugin/.mcp.json +7 -1
  4. package/_bundled_plugin/examples/completed-scan/findings.json +16 -4
  5. package/_bundled_plugin/examples/completed-scan/report.md +11 -8
  6. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +4 -2
  7. package/_bundled_plugin/mcp/fzstd-LICENSE.txt +21 -0
  8. package/_bundled_plugin/mcp/helpers.mjs +2 -11
  9. package/_bundled_plugin/mcp/helpers.mjs.br +0 -0
  10. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +3 -210
  11. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  13. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  14. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  15. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  16. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  17. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  18. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  19. package/_bundled_plugin/mcp/package.json +1 -0
  20. package/_bundled_plugin/mcp/permission-profile-preflight.mjs +5 -2
  21. package/_bundled_plugin/mcp/server.mjs +2 -11
  22. package/_bundled_plugin/mcp/server.mjs.br +0 -0
  23. package/_bundled_plugin/mcp/session-decompression.mjs +712 -0
  24. package/_bundled_plugin/references/artifact-storage.md +1 -1
  25. package/_bundled_plugin/references/baseline-auditor.md +18 -0
  26. package/_bundled_plugin/references/core-scan.md +5 -42
  27. package/_bundled_plugin/references/default-severity-rubric.md +9 -4
  28. package/_bundled_plugin/references/final-report.md +5 -3
  29. package/_bundled_plugin/references/finding-detail-fields.md +18 -18
  30. package/_bundled_plugin/references/focused-investigator.md +13 -0
  31. package/_bundled_plugin/references/sarif-adapter.md +8 -2
  32. package/_bundled_plugin/references/scan-artifacts.md +21 -12
  33. package/_bundled_plugin/references/scan-contract.md +27 -33
  34. package/_bundled_plugin/references/scan-prologue.md +2 -2
  35. package/_bundled_plugin/references/scan-runtime.md +4 -2
  36. package/_bundled_plugin/references/security-guidance.md +14 -1
  37. package/_bundled_plugin/references/validate-scan-findings.md +3 -0
  38. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +2 -2
  39. package/_bundled_plugin/scripts/check_deep_scan_target.py +97 -0
  40. package/_bundled_plugin/scripts/codex_profile.mjs +7 -1
  41. package/_bundled_plugin/scripts/deep_scan_config.py +20 -1
  42. package/_bundled_plugin/scripts/deep_scan_workbench.py +192 -352
  43. package/_bundled_plugin/scripts/dispatch_inventory_tool +7 -0
  44. package/_bundled_plugin/scripts/filesystem_identity.py +1 -0
  45. package/_bundled_plugin/scripts/finalize_scan_contract.py +182 -230
  46. package/_bundled_plugin/scripts/finding_preview.py +20 -0
  47. package/_bundled_plugin/scripts/launch_codex_security_mcp +55 -16
  48. package/_bundled_plugin/scripts/legacy_findings.py +148 -0
  49. package/_bundled_plugin/scripts/posix_scan_local_files.py +37 -1
  50. package/_bundled_plugin/scripts/read_codex_session.mjs +21 -0
  51. package/_bundled_plugin/scripts/report_projection.py +81 -43
  52. package/_bundled_plugin/scripts/review_state.py +8 -2
  53. package/_bundled_plugin/scripts/servicenow_avit.py +20 -0
  54. package/_bundled_plugin/scripts/snapshot_sqlite.py +9 -2
  55. package/_bundled_plugin/scripts/threat_model_projection.py +22 -26
  56. package/_bundled_plugin/scripts/validate_scan_contract.py +7 -1
  57. package/_bundled_plugin/scripts/windows_scan_local_files.py +582 -20
  58. package/_bundled_plugin/scripts/workbench/__init__.py +1 -1
  59. package/_bundled_plugin/scripts/workbench/handoff.py +100 -23
  60. package/_bundled_plugin/scripts/workbench/retained_coverage.py +30 -51
  61. package/_bundled_plugin/scripts/workbench/retained_records.py +18 -30
  62. package/_bundled_plugin/scripts/workbench/runtime_toml.py +4 -1
  63. package/_bundled_plugin/scripts/workbench/saved_coverage.py +9 -17
  64. package/_bundled_plugin/scripts/workbench/saved_outputs.py +9 -0
  65. package/_bundled_plugin/scripts/workbench/saved_sources.py +47 -40
  66. package/_bundled_plugin/scripts/workbench/storage.py +91 -7
  67. package/_bundled_plugin/scripts/workbench_cli.py +54 -14
  68. package/_bundled_plugin/scripts/workbench_constants.py +12 -0
  69. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +3 -3
  70. package/_bundled_plugin/scripts/workbench_db.py +562 -303
  71. package/_bundled_plugin/scripts/workbench_feedback.py +57 -11
  72. package/_bundled_plugin/scripts/workbench_finding_index.py +1 -0
  73. package/_bundled_plugin/scripts/workbench_finding_workflows.py +4 -0
  74. package/_bundled_plugin/scripts/workbench_native_indexes.py +238 -41
  75. package/_bundled_plugin/scripts/workbench_progress.py +169 -4
  76. package/_bundled_plugin/scripts/workbench_publication.py +16 -13
  77. package/_bundled_plugin/scripts/workbench_remediation.py +155 -2
  78. package/_bundled_plugin/scripts/workbench_saved_results.py +176 -81
  79. package/_bundled_plugin/scripts/workbench_scan_history.py +398 -174
  80. package/_bundled_plugin/scripts/workbench_scan_start.py +224 -31
  81. package/_bundled_plugin/scripts/workbench_scan_usage.py +675 -73
  82. package/_bundled_plugin/scripts/workbench_schema.py +258 -63
  83. package/_bundled_plugin/scripts/workbench_setup.py +14 -2
  84. package/_bundled_plugin/scripts/workbench_source_excerpt.py +13 -0
  85. package/_bundled_plugin/scripts/workbench_source_scopes.py +18 -0
  86. package/_bundled_plugin/scripts/workbench_target.py +594 -136
  87. package/_bundled_plugin/scripts/workbench_target_state.py +1110 -21
  88. package/_bundled_plugin/scripts/workbench_validation.py +43 -3
  89. package/_bundled_plugin/shared/workbench-history-repairs.json +77 -35
  90. package/_bundled_plugin/shared/workbench-migrations.json +100 -0
  91. package/_bundled_plugin/skills/cloud-findings/SKILL.md +5 -5
  92. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +7 -50
  93. package/_bundled_plugin/skills/fix-finding/SKILL.md +2 -1
  94. package/_bundled_plugin/skills/publish-findings/SKILL.md +24 -153
  95. package/_bundled_plugin/skills/publish-findings/agents/openai.yaml +2 -2
  96. package/_bundled_plugin/skills/publish-findings/references/checkmarx-import.md +37 -0
  97. package/_bundled_plugin/skills/publish-findings/references/wiz-import.md +3 -3
  98. package/_bundled_plugin/skills/publish-findings/scripts/collect_checkmarx.py +409 -0
  99. package/_bundled_plugin/skills/publish-findings/scripts/collect_continuum.py +224 -0
  100. package/_bundled_plugin/skills/publish-findings/scripts/collector_paths.py +63 -0
  101. package/_bundled_plugin/skills/security-scan/SKILL.md +9 -46
  102. package/_bundled_plugin/skills/security-scan/agents/openai.yaml +2 -2
  103. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +3 -21
  104. package/_bundled_plugin/skills/security-scan/references/managed-scan.md +11 -0
  105. package/_bundled_plugin/skills/security-scan/references/scan-results.md +15 -0
  106. package/_bundled_plugin/skills/security-scan/references/scoped-paths.md +23 -0
  107. package/_bundled_plugin/skills/security-scan/references/sdk-files.md +24 -0
  108. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +22 -1
  109. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +6 -2
  110. package/bin/codex-security.mjs +2 -2
  111. package/dist/api.d.ts +45 -5
  112. package/dist/api.d.ts.map +1 -1
  113. package/dist/api.js +1192 -427
  114. package/dist/api.js.map +1 -1
  115. package/dist/armorcode-findings.d.ts +9 -0
  116. package/dist/armorcode-findings.d.ts.map +1 -0
  117. package/dist/armorcode-findings.js +145 -0
  118. package/dist/armorcode-findings.js.map +1 -0
  119. package/dist/artifact-export.d.ts +2 -0
  120. package/dist/artifact-export.d.ts.map +1 -1
  121. package/dist/artifact-export.js +29 -13
  122. package/dist/artifact-export.js.map +1 -1
  123. package/dist/auth.d.ts +6 -2
  124. package/dist/auth.d.ts.map +1 -1
  125. package/dist/auth.js +37 -18
  126. package/dist/auth.js.map +1 -1
  127. package/dist/batch-cost.d.ts +18 -0
  128. package/dist/batch-cost.d.ts.map +1 -0
  129. package/dist/batch-cost.js +41 -0
  130. package/dist/batch-cost.js.map +1 -0
  131. package/dist/bedrock-oss-pricing.d.ts +6 -0
  132. package/dist/bedrock-oss-pricing.d.ts.map +1 -0
  133. package/dist/bedrock-oss-pricing.js +58 -0
  134. package/dist/bedrock-oss-pricing.js.map +1 -0
  135. package/dist/bedrock-pricing.d.ts +15 -0
  136. package/dist/bedrock-pricing.d.ts.map +1 -0
  137. package/dist/bedrock-pricing.js +117 -0
  138. package/dist/bedrock-pricing.js.map +1 -0
  139. package/dist/blackduck-findings.d.ts +1 -1
  140. package/dist/blackduck-findings.d.ts.map +1 -1
  141. package/dist/blackduck-findings.js +24 -22
  142. package/dist/blackduck-findings.js.map +1 -1
  143. package/dist/bulk-scan-discovery.d.ts.map +1 -1
  144. package/dist/bulk-scan-discovery.js +4 -4
  145. package/dist/bulk-scan-discovery.js.map +1 -1
  146. package/dist/bundled-plugin.d.ts +4 -0
  147. package/dist/bundled-plugin.d.ts.map +1 -0
  148. package/dist/bundled-plugin.js +23 -0
  149. package/dist/bundled-plugin.js.map +1 -0
  150. package/dist/checkmarx-evidence.d.ts +19 -0
  151. package/dist/checkmarx-evidence.d.ts.map +1 -0
  152. package/dist/checkmarx-evidence.js +36 -0
  153. package/dist/checkmarx-evidence.js.map +1 -0
  154. package/dist/checkmarx-findings.d.ts +4 -0
  155. package/dist/checkmarx-findings.d.ts.map +1 -0
  156. package/dist/checkmarx-findings.js +27 -0
  157. package/dist/checkmarx-findings.js.map +1 -0
  158. package/dist/checkmarx-one.d.ts +4 -0
  159. package/dist/checkmarx-one.d.ts.map +1 -0
  160. package/dist/checkmarx-one.js +53 -0
  161. package/dist/checkmarx-one.js.map +1 -0
  162. package/dist/checkmarx-repository.d.ts +12 -0
  163. package/dist/checkmarx-repository.d.ts.map +1 -0
  164. package/dist/checkmarx-repository.js +181 -0
  165. package/dist/checkmarx-repository.js.map +1 -0
  166. package/dist/checkmarx-xml.d.ts +12 -0
  167. package/dist/checkmarx-xml.d.ts.map +1 -0
  168. package/dist/checkmarx-xml.js +196 -0
  169. package/dist/checkmarx-xml.js.map +1 -0
  170. package/dist/classify-scan-severity.d.ts +1 -1
  171. package/dist/classify-scan-severity.d.ts.map +1 -1
  172. package/dist/classify-scan-severity.js +11 -3
  173. package/dist/classify-scan-severity.js.map +1 -1
  174. package/dist/classify-severity-records.d.ts +1 -9
  175. package/dist/classify-severity-records.d.ts.map +1 -1
  176. package/dist/classify-severity-records.js +3 -13
  177. package/dist/classify-severity-records.js.map +1 -1
  178. package/dist/classify-severity.d.ts.map +1 -1
  179. package/dist/classify-severity.js +11 -10
  180. package/dist/classify-severity.js.map +1 -1
  181. package/dist/cli-argument.d.ts +4 -0
  182. package/dist/cli-argument.d.ts.map +1 -0
  183. package/dist/cli-argument.js +17 -0
  184. package/dist/cli-argument.js.map +1 -0
  185. package/dist/cli-help.d.ts +1 -1
  186. package/dist/cli-help.d.ts.map +1 -1
  187. package/dist/cli-help.js +71 -29
  188. package/dist/cli-help.js.map +1 -1
  189. package/dist/cli-hook.d.ts +3 -0
  190. package/dist/cli-hook.d.ts.map +1 -0
  191. package/dist/cli-hook.js +87 -0
  192. package/dist/cli-hook.js.map +1 -0
  193. package/dist/cli-integrations.d.ts +13 -0
  194. package/dist/cli-integrations.d.ts.map +1 -0
  195. package/dist/cli-integrations.js +333 -0
  196. package/dist/cli-integrations.js.map +1 -0
  197. package/dist/cli-mcp.d.ts +15 -0
  198. package/dist/cli-mcp.d.ts.map +1 -0
  199. package/dist/cli-mcp.js +178 -0
  200. package/dist/cli-mcp.js.map +1 -0
  201. package/dist/cli-token-view.d.ts +10 -0
  202. package/dist/cli-token-view.d.ts.map +1 -0
  203. package/dist/cli-token-view.js +41 -0
  204. package/dist/cli-token-view.js.map +1 -0
  205. package/dist/cli.d.ts +16 -8
  206. package/dist/cli.d.ts.map +1 -1
  207. package/dist/cli.js +3382 -2017
  208. package/dist/cli.js.map +1 -1
  209. package/dist/cloud-publish.d.ts.map +1 -1
  210. package/dist/cloud-publish.js +35 -33
  211. package/dist/cloud-publish.js.map +1 -1
  212. package/dist/codex-sdk-environment.d.ts +6 -0
  213. package/dist/codex-sdk-environment.d.ts.map +1 -1
  214. package/dist/codex-sdk-environment.js +19 -0
  215. package/dist/codex-sdk-environment.js.map +1 -1
  216. package/dist/command-words.d.ts +3 -0
  217. package/dist/command-words.d.ts.map +1 -0
  218. package/dist/command-words.js +46 -0
  219. package/dist/command-words.js.map +1 -0
  220. package/dist/component-scan.d.ts +19 -4
  221. package/dist/component-scan.d.ts.map +1 -1
  222. package/dist/component-scan.js +67 -9
  223. package/dist/component-scan.js.map +1 -1
  224. package/dist/config.d.ts +1 -1
  225. package/dist/config.d.ts.map +1 -1
  226. package/dist/config.js +130 -67
  227. package/dist/config.js.map +1 -1
  228. package/dist/continuum-findings.d.ts +1 -1
  229. package/dist/continuum-findings.d.ts.map +1 -1
  230. package/dist/continuum-findings.js +149 -19
  231. package/dist/continuum-findings.js.map +1 -1
  232. package/dist/contract-values.d.ts +2 -0
  233. package/dist/contract-values.d.ts.map +1 -1
  234. package/dist/contract-values.js +12 -9
  235. package/dist/contract-values.js.map +1 -1
  236. package/dist/cost-model.d.ts +13 -1
  237. package/dist/cost-model.d.ts.map +1 -1
  238. package/dist/cost-model.js +66 -112
  239. package/dist/cost-model.js.map +1 -1
  240. package/dist/cost.d.ts +42 -3
  241. package/dist/cost.d.ts.map +1 -1
  242. package/dist/cost.js +484 -149
  243. package/dist/cost.js.map +1 -1
  244. package/dist/custom-publish.d.ts +4 -0
  245. package/dist/custom-publish.d.ts.map +1 -1
  246. package/dist/custom-publish.js +40 -3
  247. package/dist/custom-publish.js.map +1 -1
  248. package/dist/custom-validation-prompt.d.ts +1 -1
  249. package/dist/custom-validation-prompt.d.ts.map +1 -1
  250. package/dist/custom-validation-prompt.js +29 -19
  251. package/dist/custom-validation-prompt.js.map +1 -1
  252. package/dist/deduplication/local.d.ts +4 -2
  253. package/dist/deduplication/local.d.ts.map +1 -1
  254. package/dist/deduplication/local.js +9 -2
  255. package/dist/deduplication/local.js.map +1 -1
  256. package/dist/deduplication/refusal.d.ts.map +1 -1
  257. package/dist/deduplication/refusal.js +26 -5
  258. package/dist/deduplication/refusal.js.map +1 -1
  259. package/dist/deduplication/scan.d.ts +5 -0
  260. package/dist/deduplication/scan.d.ts.map +1 -1
  261. package/dist/deduplication/scan.js +24 -7
  262. package/dist/deduplication/scan.js.map +1 -1
  263. package/dist/deep-config.d.ts +0 -1
  264. package/dist/deep-config.d.ts.map +1 -1
  265. package/dist/deep-config.js +22 -33
  266. package/dist/deep-config.js.map +1 -1
  267. package/dist/deep-scan-defaults.d.ts +2 -0
  268. package/dist/deep-scan-defaults.d.ts.map +1 -1
  269. package/dist/deep-scan-defaults.js +28 -1
  270. package/dist/deep-scan-defaults.js.map +1 -1
  271. package/dist/deep-scan.d.ts +2 -0
  272. package/dist/deep-scan.d.ts.map +1 -1
  273. package/dist/deep-scan.js +44 -19
  274. package/dist/deep-scan.js.map +1 -1
  275. package/dist/default-severity-rubric.d.ts +1 -1
  276. package/dist/default-severity-rubric.d.ts.map +1 -1
  277. package/dist/default-severity-rubric.js +1 -1
  278. package/dist/default-severity-rubric.js.map +1 -1
  279. package/dist/endor-findings.d.ts +3 -1
  280. package/dist/endor-findings.d.ts.map +1 -1
  281. package/dist/endor-findings.js +86 -45
  282. package/dist/endor-findings.js.map +1 -1
  283. package/dist/errors.d.ts +4 -2
  284. package/dist/errors.d.ts.map +1 -1
  285. package/dist/errors.js +15 -4
  286. package/dist/errors.js.map +1 -1
  287. package/dist/executable-path.d.ts +3 -0
  288. package/dist/executable-path.d.ts.map +1 -1
  289. package/dist/executable-path.js +26 -0
  290. package/dist/executable-path.js.map +1 -1
  291. package/dist/external-findings-import.d.ts +5 -3
  292. package/dist/external-findings-import.d.ts.map +1 -1
  293. package/dist/external-findings-import.js +19 -7
  294. package/dist/external-findings-import.js.map +1 -1
  295. package/dist/external-findings-local.d.ts +69 -5
  296. package/dist/external-findings-local.d.ts.map +1 -1
  297. package/dist/external-findings-local.js +537 -108
  298. package/dist/external-findings-local.js.map +1 -1
  299. package/dist/external-findings-publish.d.ts +13 -6
  300. package/dist/external-findings-publish.d.ts.map +1 -1
  301. package/dist/external-findings-publish.js +895 -1142
  302. package/dist/external-findings-publish.js.map +1 -1
  303. package/dist/external-findings-read.d.ts +21 -2
  304. package/dist/external-findings-read.d.ts.map +1 -1
  305. package/dist/external-findings-read.js +130 -68
  306. package/dist/external-findings-read.js.map +1 -1
  307. package/dist/external-findings.d.ts +15 -3
  308. package/dist/external-findings.d.ts.map +1 -1
  309. package/dist/external-findings.js +54 -2
  310. package/dist/external-findings.js.map +1 -1
  311. package/dist/external-import-contract.d.ts +8 -12
  312. package/dist/external-import-contract.d.ts.map +1 -1
  313. package/dist/external-import-contract.js +51 -184
  314. package/dist/external-import-contract.js.map +1 -1
  315. package/dist/external-import-models.d.ts +1 -1
  316. package/dist/external-import-models.d.ts.map +1 -1
  317. package/dist/external-import-models.js.map +1 -1
  318. package/dist/feedback.d.ts.map +1 -1
  319. package/dist/feedback.js +5 -4
  320. package/dist/feedback.js.map +1 -1
  321. package/dist/finding-prompt.d.ts +5 -0
  322. package/dist/finding-prompt.d.ts.map +1 -0
  323. package/dist/finding-prompt.js +32 -0
  324. package/dist/finding-prompt.js.map +1 -0
  325. package/dist/findings-client.d.ts +1 -0
  326. package/dist/findings-client.d.ts.map +1 -1
  327. package/dist/findings-client.js +27 -3
  328. package/dist/findings-client.js.map +1 -1
  329. package/dist/github-advisories.d.ts.map +1 -1
  330. package/dist/github-advisories.js +0 -2
  331. package/dist/github-advisories.js.map +1 -1
  332. package/dist/github-dependabot-findings.d.ts.map +1 -1
  333. package/dist/github-dependabot-findings.js +18 -8
  334. package/dist/github-dependabot-findings.js.map +1 -1
  335. package/dist/github-findings.d.ts +4 -1
  336. package/dist/github-findings.d.ts.map +1 -1
  337. package/dist/github-findings.js +73 -316
  338. package/dist/github-findings.js.map +1 -1
  339. package/dist/hosted-git-remotes.d.ts +5 -0
  340. package/dist/hosted-git-remotes.d.ts.map +1 -0
  341. package/dist/hosted-git-remotes.js +285 -0
  342. package/dist/hosted-git-remotes.js.map +1 -0
  343. package/dist/hosted-git-repository.d.ts +28 -0
  344. package/dist/hosted-git-repository.d.ts.map +1 -0
  345. package/dist/hosted-git-repository.js +222 -0
  346. package/dist/hosted-git-repository.js.map +1 -0
  347. package/dist/hosted-remediation.d.ts +1 -0
  348. package/dist/hosted-remediation.d.ts.map +1 -1
  349. package/dist/hosted-remediation.js +23 -3
  350. package/dist/hosted-remediation.js.map +1 -1
  351. package/dist/hosted-scan-protocol.js +2 -2
  352. package/dist/hosted-scan-protocol.js.map +1 -1
  353. package/dist/hosted-scan.d.ts.map +1 -1
  354. package/dist/hosted-scan.js +16 -11
  355. package/dist/hosted-scan.js.map +1 -1
  356. package/dist/hosted-scanner-http.d.ts +21 -0
  357. package/dist/hosted-scanner-http.d.ts.map +1 -0
  358. package/dist/hosted-scanner-http.js +204 -0
  359. package/dist/hosted-scanner-http.js.map +1 -0
  360. package/dist/import-scan.d.ts.map +1 -1
  361. package/dist/import-scan.js +3 -0
  362. package/dist/import-scan.js.map +1 -1
  363. package/dist/index.d.ts +21 -9
  364. package/dist/index.d.ts.map +1 -1
  365. package/dist/index.js +12 -3
  366. package/dist/index.js.map +1 -1
  367. package/dist/inspector-findings.d.ts.map +1 -1
  368. package/dist/inspector-findings.js +52 -86
  369. package/dist/inspector-findings.js.map +1 -1
  370. package/dist/knowledge-base.d.ts +1 -1
  371. package/dist/knowledge-base.d.ts.map +1 -1
  372. package/dist/knowledge-base.js +102 -32
  373. package/dist/knowledge-base.js.map +1 -1
  374. package/dist/linear.d.ts +11 -0
  375. package/dist/linear.d.ts.map +1 -1
  376. package/dist/linear.js.map +1 -1
  377. package/dist/local-git-metadata.d.ts +5 -2
  378. package/dist/local-git-metadata.d.ts.map +1 -1
  379. package/dist/local-git-metadata.js +8 -5
  380. package/dist/local-git-metadata.js.map +1 -1
  381. package/dist/multiscan.d.ts +10 -4
  382. package/dist/multiscan.d.ts.map +1 -1
  383. package/dist/multiscan.js +217 -102
  384. package/dist/multiscan.js.map +1 -1
  385. package/dist/native-json-findings.d.ts +2 -1
  386. package/dist/native-json-findings.d.ts.map +1 -1
  387. package/dist/native-json-findings.js +12 -2
  388. package/dist/native-json-findings.js.map +1 -1
  389. package/dist/opengrep-findings.d.ts +5 -2
  390. package/dist/opengrep-findings.d.ts.map +1 -1
  391. package/dist/opengrep-findings.js +54 -33
  392. package/dist/opengrep-findings.js.map +1 -1
  393. package/dist/operation-telemetry.d.ts +104 -0
  394. package/dist/operation-telemetry.d.ts.map +1 -0
  395. package/dist/operation-telemetry.js +293 -0
  396. package/dist/operation-telemetry.js.map +1 -0
  397. package/dist/plugin-python-probe.d.ts +4 -0
  398. package/dist/plugin-python-probe.d.ts.map +1 -0
  399. package/dist/plugin-python-probe.js +10 -0
  400. package/dist/plugin-python-probe.js.map +1 -0
  401. package/dist/private-finding-import.d.ts +99 -9
  402. package/dist/private-finding-import.d.ts.map +1 -1
  403. package/dist/private-finding-import.js +116 -152
  404. package/dist/private-finding-import.js.map +1 -1
  405. package/dist/project-config.d.ts.map +1 -1
  406. package/dist/project-config.js +53 -13
  407. package/dist/project-config.js.map +1 -1
  408. package/dist/prompt-files.d.ts +7 -2
  409. package/dist/prompt-files.d.ts.map +1 -1
  410. package/dist/prompt-files.js +42 -20
  411. package/dist/prompt-files.js.map +1 -1
  412. package/dist/provider-profile.d.ts +1 -1
  413. package/dist/provider-profile.d.ts.map +1 -1
  414. package/dist/provider-profile.js +12 -10
  415. package/dist/provider-profile.js.map +1 -1
  416. package/dist/publication-telemetry.d.ts +45 -0
  417. package/dist/publication-telemetry.d.ts.map +1 -0
  418. package/dist/publication-telemetry.js +50 -0
  419. package/dist/publication-telemetry.js.map +1 -0
  420. package/dist/publication.d.ts +1 -1
  421. package/dist/publication.d.ts.map +1 -1
  422. package/dist/publication.js.map +1 -1
  423. package/dist/publish.d.ts +4 -0
  424. package/dist/publish.d.ts.map +1 -1
  425. package/dist/publish.js +42 -2
  426. package/dist/publish.js.map +1 -1
  427. package/dist/record.d.ts +1 -5
  428. package/dist/record.d.ts.map +1 -1
  429. package/dist/record.js +3 -51
  430. package/dist/record.js.map +1 -1
  431. package/dist/remediation.d.ts +1 -4
  432. package/dist/remediation.d.ts.map +1 -1
  433. package/dist/remediation.js +6 -8
  434. package/dist/remediation.js.map +1 -1
  435. package/dist/request-metadata.d.ts +3 -0
  436. package/dist/request-metadata.d.ts.map +1 -1
  437. package/dist/request-metadata.js +9 -0
  438. package/dist/request-metadata.js.map +1 -1
  439. package/dist/result.d.ts +4 -0
  440. package/dist/result.d.ts.map +1 -1
  441. package/dist/result.js +1 -1
  442. package/dist/result.js.map +1 -1
  443. package/dist/retry-windows-rename.d.ts +8 -0
  444. package/dist/retry-windows-rename.d.ts.map +1 -0
  445. package/dist/retry-windows-rename.js +24 -0
  446. package/dist/retry-windows-rename.js.map +1 -0
  447. package/dist/runtime.d.ts +54 -6
  448. package/dist/runtime.d.ts.map +1 -1
  449. package/dist/runtime.js +1084 -256
  450. package/dist/runtime.js.map +1 -1
  451. package/dist/saved-scan-bootstrap.d.ts +7 -1
  452. package/dist/saved-scan-bootstrap.d.ts.map +1 -1
  453. package/dist/saved-scan-bootstrap.js +269 -114
  454. package/dist/saved-scan-bootstrap.js.map +1 -1
  455. package/dist/scan-activity.d.ts.map +1 -1
  456. package/dist/scan-activity.js +141 -56
  457. package/dist/scan-activity.js.map +1 -1
  458. package/dist/scan-archive-path.d.ts +2 -0
  459. package/dist/scan-archive-path.d.ts.map +1 -0
  460. package/dist/scan-archive-path.js +5 -0
  461. package/dist/scan-archive-path.js.map +1 -0
  462. package/dist/scan-comparison.d.ts +10 -5
  463. package/dist/scan-comparison.d.ts.map +1 -1
  464. package/dist/scan-comparison.js +66 -17
  465. package/dist/scan-comparison.js.map +1 -1
  466. package/dist/scan-dashboard.d.ts +7 -6
  467. package/dist/scan-dashboard.d.ts.map +1 -1
  468. package/dist/scan-dashboard.js +92 -43
  469. package/dist/scan-dashboard.js.map +1 -1
  470. package/dist/scan-executor.d.ts +10 -1
  471. package/dist/scan-executor.d.ts.map +1 -1
  472. package/dist/scan-executor.js +24 -2
  473. package/dist/scan-executor.js.map +1 -1
  474. package/dist/scan-history-renderer.d.ts +1 -0
  475. package/dist/scan-history-renderer.d.ts.map +1 -1
  476. package/dist/scan-history-renderer.js +34 -28
  477. package/dist/scan-history-renderer.js.map +1 -1
  478. package/dist/scan-logs.d.ts +12 -0
  479. package/dist/scan-logs.d.ts.map +1 -1
  480. package/dist/scan-logs.js +131 -78
  481. package/dist/scan-logs.js.map +1 -1
  482. package/dist/scan-measurement.d.ts +26 -0
  483. package/dist/scan-measurement.d.ts.map +1 -0
  484. package/dist/scan-measurement.js +77 -0
  485. package/dist/scan-measurement.js.map +1 -0
  486. package/dist/scan-progress.d.ts +1 -0
  487. package/dist/scan-progress.d.ts.map +1 -1
  488. package/dist/scan-progress.js +3 -0
  489. package/dist/scan-progress.js.map +1 -1
  490. package/dist/scan-sessions.d.ts.map +1 -1
  491. package/dist/scan-sessions.js +4 -1
  492. package/dist/scan-sessions.js.map +1 -1
  493. package/dist/scan-settings.d.ts +1 -1
  494. package/dist/scan-settings.d.ts.map +1 -1
  495. package/dist/scan-settings.js +1 -24
  496. package/dist/scan-settings.js.map +1 -1
  497. package/dist/scanner-import.d.ts +25 -13
  498. package/dist/scanner-import.d.ts.map +1 -1
  499. package/dist/scanner-import.js +216 -97
  500. package/dist/scanner-import.js.map +1 -1
  501. package/dist/scanner-repository-url.d.ts +4 -1
  502. package/dist/scanner-repository-url.d.ts.map +1 -1
  503. package/dist/scanner-repository-url.js +10 -6
  504. package/dist/scanner-repository-url.js.map +1 -1
  505. package/dist/security-policy.d.ts +1 -1
  506. package/dist/security-policy.d.ts.map +1 -1
  507. package/dist/security-policy.js +26 -6
  508. package/dist/security-policy.js.map +1 -1
  509. package/dist/semgrep-findings.d.ts +6 -3
  510. package/dist/semgrep-findings.d.ts.map +1 -1
  511. package/dist/semgrep-findings.js +72 -42
  512. package/dist/semgrep-findings.js.map +1 -1
  513. package/dist/semgrep-guardian-findings.d.ts +38 -0
  514. package/dist/semgrep-guardian-findings.d.ts.map +1 -0
  515. package/dist/semgrep-guardian-findings.js +165 -0
  516. package/dist/semgrep-guardian-findings.js.map +1 -0
  517. package/dist/semgrep-platform-collector.d.ts +26 -0
  518. package/dist/semgrep-platform-collector.d.ts.map +1 -0
  519. package/dist/semgrep-platform-collector.js +108 -0
  520. package/dist/semgrep-platform-collector.js.map +1 -0
  521. package/dist/semgrep-platform-findings.d.ts +157 -6
  522. package/dist/semgrep-platform-findings.d.ts.map +1 -1
  523. package/dist/semgrep-platform-findings.js +766 -103
  524. package/dist/semgrep-platform-findings.js.map +1 -1
  525. package/dist/server/api.d.ts +1 -1
  526. package/dist/server/api.d.ts.map +1 -1
  527. package/dist/server/api.js.map +1 -1
  528. package/dist/server/embedding-tokenizer.cdx.json +33 -0
  529. package/dist/server/embedding-tokenizer.d.ts +2 -0
  530. package/dist/server/embedding-tokenizer.d.ts.map +1 -0
  531. package/dist/server/embedding-tokenizer.js +322 -0
  532. package/dist/server/embedding-tokenizer.js.map +6 -0
  533. package/dist/server/embeddings.d.ts +16 -2
  534. package/dist/server/embeddings.d.ts.map +1 -1
  535. package/dist/server/embeddings.js +35 -5
  536. package/dist/server/embeddings.js.map +1 -1
  537. package/dist/session-lines.d.ts +5 -0
  538. package/dist/session-lines.d.ts.map +1 -0
  539. package/dist/session-lines.js +60 -0
  540. package/dist/session-lines.js.map +1 -0
  541. package/dist/severity-review.d.ts +3 -1
  542. package/dist/severity-review.d.ts.map +1 -1
  543. package/dist/severity-review.js +3 -2
  544. package/dist/severity-review.js.map +1 -1
  545. package/dist/skill-authentication.d.ts +1 -0
  546. package/dist/skill-authentication.d.ts.map +1 -1
  547. package/dist/skill-authentication.js +1 -0
  548. package/dist/skill-authentication.js.map +1 -1
  549. package/dist/snyk-findings.d.ts +9 -2
  550. package/dist/snyk-findings.d.ts.map +1 -1
  551. package/dist/snyk-findings.js +90 -70
  552. package/dist/snyk-findings.js.map +1 -1
  553. package/dist/snyk-rest-findings.d.ts +59 -0
  554. package/dist/snyk-rest-findings.d.ts.map +1 -0
  555. package/dist/snyk-rest-findings.js +879 -0
  556. package/dist/snyk-rest-findings.js.map +1 -0
  557. package/dist/snyk-token-origin.d.ts +4 -0
  558. package/dist/snyk-token-origin.d.ts.map +1 -0
  559. package/dist/snyk-token-origin.js +82 -0
  560. package/dist/snyk-token-origin.js.map +1 -0
  561. package/dist/sonar-collector.d.ts.map +1 -1
  562. package/dist/sonar-collector.js +0 -3
  563. package/dist/sonar-collector.js.map +1 -1
  564. package/dist/sonar-findings.d.ts +1 -1
  565. package/dist/sonar-findings.d.ts.map +1 -1
  566. package/dist/sonar-findings.js +2 -4
  567. package/dist/sonar-findings.js.map +1 -1
  568. package/dist/sonar-import.d.ts +3 -0
  569. package/dist/sonar-import.d.ts.map +1 -1
  570. package/dist/sonar-import.js +30 -34
  571. package/dist/sonar-import.js.map +1 -1
  572. package/dist/stored-finding-projection.d.ts +6 -0
  573. package/dist/stored-finding-projection.d.ts.map +1 -0
  574. package/dist/stored-finding-projection.js +104 -0
  575. package/dist/stored-finding-projection.js.map +1 -0
  576. package/dist/stored-findings-publication.d.ts +23 -0
  577. package/dist/stored-findings-publication.d.ts.map +1 -0
  578. package/dist/stored-findings-publication.js +169 -0
  579. package/dist/stored-findings-publication.js.map +1 -0
  580. package/dist/target-drift.d.ts +9 -0
  581. package/dist/target-drift.d.ts.map +1 -0
  582. package/dist/target-drift.js +27 -0
  583. package/dist/target-drift.js.map +1 -0
  584. package/dist/targets.d.ts +8 -1
  585. package/dist/targets.d.ts.map +1 -1
  586. package/dist/targets.js +131 -42
  587. package/dist/targets.js.map +1 -1
  588. package/dist/tenable-findings.d.ts +6 -0
  589. package/dist/tenable-findings.d.ts.map +1 -0
  590. package/dist/tenable-findings.js +122 -0
  591. package/dist/tenable-findings.js.map +1 -0
  592. package/dist/terminal-stream.d.ts +13 -0
  593. package/dist/terminal-stream.d.ts.map +1 -0
  594. package/dist/terminal-stream.js +35 -0
  595. package/dist/terminal-stream.js.map +1 -0
  596. package/dist/trivy-findings.d.ts +19 -0
  597. package/dist/trivy-findings.d.ts.map +1 -0
  598. package/dist/trivy-findings.js +424 -0
  599. package/dist/trivy-findings.js.map +1 -0
  600. package/dist/trivy-import.d.ts +19 -0
  601. package/dist/trivy-import.d.ts.map +1 -0
  602. package/dist/trivy-import.js +151 -0
  603. package/dist/trivy-import.js.map +1 -0
  604. package/dist/trusted-executable.d.ts +6 -0
  605. package/dist/trusted-executable.d.ts.map +1 -1
  606. package/dist/trusted-executable.js +140 -37
  607. package/dist/trusted-executable.js.map +1 -1
  608. package/dist/validation-records.js +1 -1
  609. package/dist/validation-records.js.map +1 -1
  610. package/dist/veracode-findings.d.ts +1 -1
  611. package/dist/veracode-findings.d.ts.map +1 -1
  612. package/dist/veracode-findings.js +19 -6
  613. package/dist/veracode-findings.js.map +1 -1
  614. package/dist/version.d.ts +3 -1
  615. package/dist/version.d.ts.map +1 -1
  616. package/dist/version.js +184 -32
  617. package/dist/version.js.map +1 -1
  618. package/dist/vertex-pricing.d.ts +8 -0
  619. package/dist/vertex-pricing.d.ts.map +1 -0
  620. package/dist/vertex-pricing.js +20 -0
  621. package/dist/vertex-pricing.js.map +1 -0
  622. package/dist/windows-path.d.ts +1 -0
  623. package/dist/windows-path.d.ts.map +1 -1
  624. package/dist/windows-path.js +26 -1
  625. package/dist/windows-path.js.map +1 -1
  626. package/dist/wiz-findings.d.ts +6 -2
  627. package/dist/wiz-findings.d.ts.map +1 -1
  628. package/dist/wiz-findings.js +65 -89
  629. package/dist/wiz-findings.js.map +1 -1
  630. package/docs/classify-severity-records.md +27 -12
  631. package/docs/cli.md +853 -639
  632. package/docs/dedupe-records.md +44 -24
  633. package/docs/findings-service.md +84 -44
  634. package/docs/hosted-remediation.md +27 -11
  635. package/docs/hosted-scans.md +50 -42
  636. package/docs/sdk.md +903 -0
  637. package/docs/telemetry.md +236 -0
  638. package/docs/validate-records.md +78 -44
  639. package/package.json +23 -16
  640. package/schemas/external-findings.schema.json +4 -1
  641. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  642. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  643. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  644. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  645. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  646. package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +0 -96
  647. package/dist/external-imports-feature.d.ts +0 -6
  648. package/dist/external-imports-feature.d.ts.map +0 -1
  649. package/dist/external-imports-feature.js +0 -51
  650. package/dist/external-imports-feature.js.map +0 -1
  651. package/dist/finding-normalization.d.ts +0 -5
  652. package/dist/finding-normalization.d.ts.map +0 -1
  653. package/dist/finding-normalization.js +0 -155
  654. package/dist/finding-normalization.js.map +0 -1
  655. package/dist/reader-selection.d.ts +0 -13
  656. package/dist/reader-selection.d.ts.map +0 -1
  657. package/dist/reader-selection.js +0 -81
  658. package/dist/reader-selection.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"scan-sessions.js","sourceRoot":"","sources":["../src/scan-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,gBAAgB,CA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from \"node:path\";\nimport { isRecord } from \"./record.js\";\n\nexport function sessionStartedAt(timestamp: unknown): number | null {\n const startedAt =\n typeof timestamp === \"string\" ? Date.parse(timestamp) : Number.NaN;\n return Number.isFinite(startedAt) ? startedAt : null;\n}\n\nexport function sessionOwnsTurn(\n session: { threadId: string | null; startedAt: number | null },\n payload: Readonly<Record<string, unknown>>,\n): boolean {\n // Fresh Codex worker thread/turn IDs share a same-process monotonic UUIDv7 generator.\n const threadOrder = uuid7Order(session.threadId);\n const turnOrder = uuid7Order(payload[\"turn_id\"]);\n return threadOrder === null\n ? typeof payload[\"started_at\"] === \"number\" &&\n session.startedAt !== null &&\n payload[\"started_at\"] >= Math.floor(session.startedAt / 1_000)\n : turnOrder !== null && turnOrder >= threadOrder;\n}\n\nfunction uuid7Order(value: unknown): bigint | null {\n if (\n typeof value !== \"string\" ||\n !/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(\n value,\n )\n ) {\n return null;\n }\n return BigInt(`0x${value.replaceAll(\"-\", \"\")}`);\n}\n\nexport function sessionParentThreadId(\n metadata: Readonly<Record<string, unknown>>,\n): string | null {\n const source = metadata[\"source\"];\n const subagent = isRecord(source) ? source[\"subagent\"] : undefined;\n const spawn = isRecord(subagent) ? subagent[\"thread_spawn\"] : undefined;\n for (const parent of [\n isRecord(spawn) ? spawn[\"parent_thread_id\"] : undefined,\n metadata[\"parent_thread_id\"],\n metadata[\"forked_from_id\"],\n ]) {\n if (typeof parent === \"string\" && parent !== \"\") return parent;\n }\n return null;\n}\n\nexport function isScanArtifactDirectory(\n scanDirectory: string,\n workingDirectory: string,\n): boolean {\n const artifacts = join(scanDirectory, \"artifacts\");\n if (relative(artifacts, workingDirectory) === \"\") return true;\n\n const workers = join(artifacts, \"deep_discovery\", \"workers\");\n const directory = relative(workers, workingDirectory);\n const components = directory.split(sep);\n return (\n !isAbsolute(directory) &&\n components.length === 2 &&\n components[0] !== \"..\" &&\n relative(join(workers, components[0]!, \"output\"), workingDirectory) === \"\"\n );\n}\n"]}
1
+ {"version":3,"file":"scan-sessions.js","sourceRoot":"","sources":["../src/scan-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,UAAU,gBAAgB,CAAC,SAAkB;IACjD,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACrE,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAA8D,EAC9D,OAA0C;IAE1C,sFAAsF;IACtF,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,OAAO,WAAW,KAAK,IAAI;QACzB,CAAC,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,KAAK,QAAQ;YACvC,OAAO,CAAC,SAAS,KAAK,IAAI;YAC1B,OAAO,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAClE,CAAC,CAAC,SAAS,KAAK,IAAI,IAAI,SAAS,IAAI,WAAW,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,yEAAyE,CAAC,IAAI,CAC7E,KAAK,CACN,EACD,CAAC;QACD,OAAO,IAAI,CA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AAC,CAAC;IAC/C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IACtD,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,CACL,CAAC,UAAU,CAAC,SAAS,CAAC;QACtB,UAAU,CAAC,MAAM,KAAK,CAAC;QACvB,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI;QACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAE,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { isAbsolute, join, relative, sep } from \"node:path\";\nimport { isRecord } from \"./record.js\";\n\nexport function sessionStartedAt(timestamp: unknown): number | null {\n const startedAt =\n typeof timestamp === \"string\" ? Date.parse(timestamp) : Number.NaN;\n return Number.isFinite(startedAt) ? startedAt : null;\n}\n\nexport function sessionOwnsTurn(\n session: { threadId: string | null; startedAt: number | null },\n payload: Readonly<Record<string, unknown>>,\n): boolean {\n // Fresh Codex worker thread/turn IDs share a same-process monotonic UUIDv7 generator.\n const threadOrder = uuid7Order(session.threadId);\n const turnOrder = uuid7Order(payload[\"turn_id\"]);\n return threadOrder === null\n ? typeof payload[\"started_at\"] === \"number\" &&\n session.startedAt !== null &&\n payload[\"started_at\"] >= Math.floor(session.startedAt / 1_000)\n : turnOrder !== null && turnOrder >= threadOrder;\n}\n\nfunction uuid7Order(value: unknown): bigint | null {\n if (\n typeof value !== \"string\" ||\n !/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(\n value,\n )\n ) {\n return null;\n }\n return BigInt(`0x${value.replaceAll(\"-\", \"\")}`);\n}\n\nexport function sessionParentThreadId(\n metadata: Readonly<Record<string, unknown>>,\n): string | null {\n const source = metadata[\"source\"];\n const subagent = isRecord(source) ? source[\"subagent\"] : undefined;\n const spawn = isRecord(subagent) ? subagent[\"thread_spawn\"] : undefined;\n for (const parent of [\n isRecord(spawn) ? spawn[\"parent_thread_id\"] : undefined,\n metadata[\"parent_thread_id\"],\n metadata[\"forked_from_id\"],\n ]) {\n if (typeof parent === \"string\" && parent !== \"\") return parent;\n }\n return null;\n}\n\nexport function isScanArtifactDirectory(\n scanDirectory: string,\n workingDirectory: string,\n): boolean {\n const artifacts = join(scanDirectory, \"artifacts\");\n if (relative(artifacts, workingDirectory) === \"\") return true;\n\n const deepDirectory = join(artifacts, \"deep_discovery\");\n if (relative(deepDirectory, workingDirectory) === \"\") return true;\n\n const workers = join(deepDirectory, \"workers\");\n const directory = relative(workers, workingDirectory);\n const components = directory.split(sep);\n return (\n !isAbsolute(directory) &&\n components.length === 2 &&\n components[0] !== \"..\" &&\n relative(join(workers, components[0]!, \"output\"), workingDirectory) === \"\"\n );\n}\n"]}
@@ -16,7 +16,7 @@ export declare const FailureSeveritySchema: z.ZodEnum<{
16
16
  medium: "medium";
17
17
  }>;
18
18
  export type FailureSeverity = z.infer<typeof FailureSeveritySchema>;
19
- export declare const DEEP_SCAN_SETTINGS: readonly [readonly ["workers", "workers", "workers", "--workers"], readonly ["subagents", "subagents", "subagents_per_worker", "--subagents"], readonly ["stopAfterNoNew", "stop_after_no_new", "stop_after_no_new", "--stop-after-no-new"], readonly ["stopAfterConsecutiveErrors", "stop_after_consecutive_errors", "stop_after_consecutive_errors", null], readonly ["maxDiscoveryRuns", "max_discovery_runs", "max_discovery_runs", "--max-discovery-runs"], readonly ["maxTimeHours", "max_time_hours", "max_time_hours", "--max-time-hours"]];
19
+ export { DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
20
20
  export declare const DeepScanSettingsSchema: z.ZodObject<{
21
21
  workers: z.ZodOptional<z.ZodNumber>;
22
22
  subagents: z.ZodOptional<z.ZodNumber>;
@@ -1 +1 @@
1
- {"version":3,"file":"scan-settings.d.ts","sourceRoot":"","sources":["../src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AAoB,CAAC,EAAE,YAAY,CAAC;IACpC,kBAAkB,CAAC,EAAE,YAAY,CAAC;IAClC,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,YAAY,EACV,YAAY,GACZ,gBAAgB,GAChB,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,oBAAoB,CACvB,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG,YAAY,CAUrE;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,EAClC,SAAS,EAAE,aAAa,GACvB,OAAO,CAIT;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,CAQtE"}
@@ -16,30 +16,7 @@ export const SCAN_SEVERITIES = [
16
16
  "informational",
17
17
  ];
18
18
  export const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);
19
- // SDK name, legacy TOML key, project key, and CLI flag (when exposed).
20
- export const DEEP_SCAN_SETTINGS = [
21
- ["workers", "workers", "workers", "--workers"],
22
- ["subagents", "subagents", "subagents_per_worker", "--subagents"],
23
- [
24
- "stopAfterNoNew",
25
- "stop_after_no_new",
26
- "stop_after_no_new",
27
- "--stop-after-no-new",
28
- ],
29
- [
30
- "stopAfterConsecutiveErrors",
31
- "stop_after_consecutive_errors",
32
- "stop_after_consecutive_errors",
33
- null,
34
- ],
35
- [
36
- "maxDiscoveryRuns",
37
- "max_discovery_runs",
38
- "max_discovery_runs",
39
- "--max-discovery-runs",
40
- ],
41
- ["maxTimeHours", "max_time_hours", "max_time_hours", "--max-time-hours"],
42
- ];
19
+ export { DEEP_SCAN_SETTINGS } from "./deep-scan-defaults.js";
43
20
  const positiveIntegerError = "must be a positive integer";
44
21
  const positiveInteger = z
45
22
  .number({ error: positiveIntegerError })
@@ -1 +1 @@
1
- {"version":3,"file":"scan-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a,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,SAAwB;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,MAAM,CAAC,SAAS,CAAC,GAAG,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { ConfigurationError } from \"./errors.js\";\nimport type { Finding, SeverityLevel } from \"./models.js\";\nimport type { AbsolutePath } from \"./config-path.js\";\nimport { SCAN_MODES, type ScanMode } from \"./scan-modes.js\";\nimport type { ScanTarget } from \"./targets.js\";\n\nexport const SCAN_AUTH_MODES = [\"auto\", \"chatgpt\", \"api-key\"] as const;\nexport type ScanAuthMode = (typeof SCAN_AUTH_MODES)[number];\nexport const DEFAULT_SCAN_AUTH = \"auto\";\nexport const DEFAULT_SCAN_MODE = \"standard\";\nexport const REPORTABLE_SEVERITIES = [\n \"critical\",\n \"high\",\n \"medium\",\n \"low\",\n] as const;\nexport const SCAN_SEVERITIES = [\n ...REPORTABLE_SEVERITIES,\n \"informational\",\n] as const;\nexport const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);\nexport type FailureSeverity = z.infer<typeof FailureSeveritySchema>;\n\n// SDK name, legacy TOML key, project key, and CLI flag (when exposed).\nexport const DEEP_SCAN_SETTINGS = [\n [\"workers\", \"workers\", \"workers\", \"--workers\"],\n [\"subagents\", \"subagents\", \"subagents_per_worker\", \"--subagents\"],\n [\n \"stopAfterNoNew\",\n \"stop_after_no_new\",\n \"stop_after_no_new\",\n \"--stop-after-no-new\",\n ],\n [\n \"stopAfterConsecutiveErrors\",\n \"stop_after_consecutive_errors\",\n \"stop_after_consecutive_errors\",\n null,\n ],\n [\n \"maxDiscoveryRuns\",\n \"max_discovery_runs\",\n \"max_discovery_runs\",\n \"--max-discovery-runs\",\n ],\n [\"maxTimeHours\", \"max_time_hours\", \"max_time_hours\", \"--max-time-hours\"],\n] as const;\n\nconst positiveIntegerError = \"must be a positive integer\";\nconst positiveInteger = z\n .number({ error: positiveIntegerError })\n .int({ error: positiveIntegerError })\n .positive({ error: positiveIntegerError });\nconst nonnegativeIntegerError = \"must be a non-negative integer\";\nconst nonnegativeInteger = z\n .number({ error: nonnegativeIntegerError })\n .int({ error: nonnegativeIntegerError })\n .nonnegative({ error: nonnegativeIntegerError });\nconst maximumHours = 96;\nconst hoursError = `must be a positive number no greater than ${maximumHours}`;\n\nexport const DeepScanSettingsSchema = z.strictObject({\n workers: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.workers,\n description: \"Maximum concurrent deep-scan discovery workers.\",\n }),\n subagents: nonnegativeInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.subagents,\n description: \"Subagents available to each deep-scan worker. Zero is valid.\",\n }),\n stopAfterNoNew: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterNoNew,\n description: \"Stop after this many runs find no new issues.\",\n }),\n stopAfterConsecutiveErrors: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterConsecutiveErrors,\n description: \"Stop after this many consecutive discovery errors.\",\n }),\n maxDiscoveryRuns: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxDiscoveryRuns,\n description: \"Maximum deep-scan discovery runs.\",\n }),\n maxTimeHours: z\n .number({ error: hoursError })\n .positive({ error: hoursError })\n .max(maximumHours, { error: hoursError })\n .optional()\n .meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxTimeHours,\n deprecated: true,\n description:\n \"Deprecated Deep-only alias for maxTimeMinutes / --max-time, in hours (default: 96; maximum: 96).\",\n }),\n});\n\nexport type DeepScanOptions = z.infer<typeof DeepScanSettingsSchema>;\n\nconst inputPath = z.string().min(1);\n\nexport const ScanSettingsSchema = DeepScanSettingsSchema.extend({\n auth: z.enum(SCAN_AUTH_MODES).optional().meta({ default: DEFAULT_SCAN_AUTH }),\n cyberAccessProgram: z\n .enum([\"standard\", \"daybreak_blue\", \"daybreak_red\"])\n .optional()\n .describe(\n \"Experimental Cyber access program for scan turns (OpenAI provider only). Omit to preserve Codex defaults.\",\n ),\n mode: z.enum(SCAN_MODES).optional().meta({ default: DEFAULT_SCAN_MODE }),\n maxTimeMinutes: z\n .number()\n .positive()\n .optional()\n .describe(\n \"Investigation minutes: advisory in Standard (default: unset); enforced Deep discovery limit (default and maximum: 5760). Scans may finish early; reporting may run longer.\",\n ),\n knowledgeBasePaths: z.array(inputPath).optional(),\n scanPrompt: z.string().optional(),\n scanPromptFile: inputPath.optional(),\n validationPrompt: z.string().optional(),\n validationPromptFile: inputPath.optional(),\n postScanPrompt: z.string().optional(),\n postScanPromptFile: inputPath.optional(),\n outputDir: inputPath.optional(),\n failureSeverity: z.enum(SCAN_SEVERITIES).optional(),\n maxCostUsd: z.number().positive().optional(),\n ownerSuggestions: z\n .boolean()\n .optional()\n .describe(\n \"Generate optional owner-suggestions.json after a committed scan (default: false).\",\n ),\n});\n\n/** Scan settings shared by SDK calls, CLI flags, and project files. */\nexport interface ScanSettings extends z.infer<typeof ScanSettingsSchema> {\n target?: ScanTarget;\n}\n\nexport interface ResolvedScanSettings extends ScanSettings {\n auth: ScanAuthMode;\n mode: ScanMode;\n target: ScanTarget;\n knowledgeBasePaths: AbsolutePath[];\n scanPromptFile?: AbsolutePath;\n validationPromptFile?: AbsolutePath;\n postScanPromptFile?: AbsolutePath;\n outputDir?: AbsolutePath;\n}\n\nexport type ScanPromptSettings = Pick<\n ScanSettings,\n | \"scanPrompt\"\n | \"scanPromptFile\"\n | \"validationPrompt\"\n | \"validationPromptFile\"\n | \"postScanPrompt\"\n | \"postScanPromptFile\"\n>;\n\n/** Pick defined scan settings without copying callbacks or workflow controls. */\nexport function pickScanSettings(settings: ScanSettings): ScanSettings {\n const keys = [\n \"target\",\n ...Object.keys(ScanSettingsSchema.shape),\n ] as (keyof ScanSettings)[];\n return Object.fromEntries(\n keys\n .filter((key) => settings[key] !== undefined)\n .map((key) => [key, settings[key]]),\n ) as ScanSettings;\n}\n\nexport function meetsSeverity(\n finding: Pick<Finding, \"severity\">,\n threshold: SeverityLevel,\n): boolean {\n const thresholdRank = severityThresholdRank(threshold);\n const severity = SCAN_SEVERITIES.indexOf(finding.severity.level);\n return severity >= 0 && severity <= thresholdRank;\n}\n\nexport function severityThresholdRank(threshold: SeverityLevel): number {\n const rank = SCAN_SEVERITIES.indexOf(threshold);\n if (rank < 0) {\n throw new ConfigurationError(\n `Unknown severity threshold: ${String(threshold)}.`,\n );\n }\n return rank;\n}\n"]}
1
+ {"version":3,"file":"scan-settings.js","sourceRoot":"","sources":["../src/scan-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAC;AAG5D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAU,CAAC;AAEvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,UAAU;IACV,MAAM;IACN,QAAQ;IACR,KAAK;CACG,CAAC;AACX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,qBAAqB;IACxB,eAAe;CACP,CAAC;AACX,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC,q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IACvD,MAAM,QAAQ,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,aAAa,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,SAAwB;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,MAAM,CAAC,SAAS,CAAC,GAAG,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { DEFAULT_DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\nimport { ConfigurationError } from \"./errors.js\";\nimport type { Finding, SeverityLevel } from \"./models.js\";\nimport type { AbsolutePath } from \"./config-path.js\";\nimport { SCAN_MODES, type ScanMode } from \"./scan-modes.js\";\nimport type { ScanTarget } from \"./targets.js\";\n\nexport const SCAN_AUTH_MODES = [\"auto\", \"chatgpt\", \"api-key\"] as const;\nexport type ScanAuthMode = (typeof SCAN_AUTH_MODES)[number];\nexport const DEFAULT_SCAN_AUTH = \"auto\";\nexport const DEFAULT_SCAN_MODE = \"standard\";\nexport const REPORTABLE_SEVERITIES = [\n \"critical\",\n \"high\",\n \"medium\",\n \"low\",\n] as const;\nexport const SCAN_SEVERITIES = [\n ...REPORTABLE_SEVERITIES,\n \"informational\",\n] as const;\nexport const FailureSeveritySchema = z.enum(REPORTABLE_SEVERITIES);\nexport type FailureSeverity = z.infer<typeof FailureSeveritySchema>;\n\nexport { DEEP_SCAN_SETTINGS } from \"./deep-scan-defaults.js\";\n\nconst positiveIntegerError = \"must be a positive integer\";\nconst positiveInteger = z\n .number({ error: positiveIntegerError })\n .int({ error: positiveIntegerError })\n .positive({ error: positiveIntegerError });\nconst nonnegativeIntegerError = \"must be a non-negative integer\";\nconst nonnegativeInteger = z\n .number({ error: nonnegativeIntegerError })\n .int({ error: nonnegativeIntegerError })\n .nonnegative({ error: nonnegativeIntegerError });\nconst maximumHours = 96;\nconst hoursError = `must be a positive number no greater than ${maximumHours}`;\n\nexport const DeepScanSettingsSchema = z.strictObject({\n workers: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.workers,\n description: \"Maximum concurrent deep-scan discovery workers.\",\n }),\n subagents: nonnegativeInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.subagents,\n description: \"Subagents available to each deep-scan worker. Zero is valid.\",\n }),\n stopAfterNoNew: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterNoNew,\n description: \"Stop after this many runs find no new issues.\",\n }),\n stopAfterConsecutiveErrors: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.stopAfterConsecutiveErrors,\n description: \"Stop after this many consecutive discovery errors.\",\n }),\n maxDiscoveryRuns: positiveInteger.optional().meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxDiscoveryRuns,\n description: \"Maximum deep-scan discovery runs.\",\n }),\n maxTimeHours: z\n .number({ error: hoursError })\n .positive({ error: hoursError })\n .max(maximumHours, { error: hoursError })\n .optional()\n .meta({\n default: DEFAULT_DEEP_SCAN_SETTINGS.maxTimeHours,\n deprecated: true,\n description:\n \"Deprecated Deep-only alias for maxTimeMinutes / --max-time, in hours (default: 96; maximum: 96).\",\n }),\n});\n\nexport type DeepScanOptions = z.infer<typeof DeepScanSettingsSchema>;\n\nconst inputPath = z.string().min(1);\n\nexport const ScanSettingsSchema = DeepScanSettingsSchema.extend({\n auth: z.enum(SCAN_AUTH_MODES).optional().meta({ default: DEFAULT_SCAN_AUTH }),\n cyberAccessProgram: z\n .enum([\"standard\", \"daybreak_blue\", \"daybreak_red\"])\n .optional()\n .describe(\n \"Experimental Cyber access program for scan turns (OpenAI provider only). Omit to preserve Codex defaults.\",\n ),\n mode: z.enum(SCAN_MODES).optional().meta({ default: DEFAULT_SCAN_MODE }),\n maxTimeMinutes: z\n .number()\n .positive()\n .optional()\n .describe(\n \"Investigation minutes: advisory in Standard (default: unset); enforced Deep discovery limit (default and maximum: 5760). Scans may finish early; reporting may run longer.\",\n ),\n knowledgeBasePaths: z.array(inputPath).optional(),\n scanPrompt: z.string().optional(),\n scanPromptFile: inputPath.optional(),\n validationPrompt: z.string().optional(),\n validationPromptFile: inputPath.optional(),\n postScanPrompt: z.string().optional(),\n postScanPromptFile: inputPath.optional(),\n outputDir: inputPath.optional(),\n failureSeverity: z.enum(SCAN_SEVERITIES).optional(),\n maxCostUsd: z.number().positive().optional(),\n ownerSuggestions: z\n .boolean()\n .optional()\n .describe(\n \"Generate optional owner-suggestions.json after a committed scan (default: false).\",\n ),\n});\n\n/** Scan settings shared by SDK calls, CLI flags, and project files. */\nexport interface ScanSettings extends z.infer<typeof ScanSettingsSchema> {\n target?: ScanTarget;\n}\n\nexport interface ResolvedScanSettings extends ScanSettings {\n auth: ScanAuthMode;\n mode: ScanMode;\n target: ScanTarget;\n knowledgeBasePaths: AbsolutePath[];\n scanPromptFile?: AbsolutePath;\n validationPromptFile?: AbsolutePath;\n postScanPromptFile?: AbsolutePath;\n outputDir?: AbsolutePath;\n}\n\nexport type ScanPromptSettings = Pick<\n ScanSettings,\n | \"scanPrompt\"\n | \"scanPromptFile\"\n | \"validationPrompt\"\n | \"validationPromptFile\"\n | \"postScanPrompt\"\n | \"postScanPromptFile\"\n>;\n\n/** Pick defined scan settings without copying callbacks or workflow controls. */\nexport function pickScanSettings(settings: ScanSettings): ScanSettings {\n const keys = [\n \"target\",\n ...Object.keys(ScanSettingsSchema.shape),\n ] as (keyof ScanSettings)[];\n return Object.fromEntries(\n keys\n .filter((key) => settings[key] !== undefined)\n .map((key) => [key, settings[key]]),\n ) as ScanSettings;\n}\n\nexport function meetsSeverity(\n finding: Pick<Finding, \"severity\">,\n threshold: SeverityLevel,\n): boolean {\n const thresholdRank = severityThresholdRank(threshold);\n const severity = SCAN_SEVERITIES.indexOf(finding.severity.level);\n return severity >= 0 && severity <= thresholdRank;\n}\n\nexport function severityThresholdRank(threshold: SeverityLevel): number {\n const rank = SCAN_SEVERITIES.indexOf(threshold);\n if (rank < 0) {\n throw new ConfigurationError(\n `Unknown severity threshold: ${String(threshold)}.`,\n );\n }\n return rank;\n}\n"]}
@@ -2,16 +2,33 @@ import { type FileHandle } from "node:fs/promises";
2
2
  import type { ExternalFinding, ExternalFindings } from "./external-findings.js";
3
3
  export declare function record(value: unknown, label: string): Record<string, unknown>;
4
4
  export declare function array(value: unknown, label: string): unknown[];
5
+ export declare function optionalArray(value: unknown, label: string): unknown[];
6
+ export declare function validateSarifRun(run: Record<string, unknown>, producer: string): void;
5
7
  export declare function text(value: unknown): string | null;
8
+ /** AWS APIs use epoch seconds and AWS CLI exports use timezone-qualified ISO dates. */
9
+ export declare function awsTimestampSeconds(value: unknown): number;
10
+ export declare function concreteVersion(value: unknown, ecosystem: string | null, osPackage: boolean): string | null;
6
11
  export declare function requiredText(value: unknown, label: string): string;
12
+ /** SARIF repository claims must be checked even when a run has no results. */
13
+ export declare function sarifRunRepositories(run: unknown, producer: string): {
14
+ url: string;
15
+ branch?: string;
16
+ }[];
17
+ /** Normalize scanners whose reported severities range from low to critical. */
18
+ export declare function reportableScannerSeverity(value: unknown): "critical" | "high" | "low" | "medium" | "unknown";
19
+ export declare function scannerSeverity(value: string | null | undefined): "critical" | "high" | "informational" | "low" | "medium" | "unknown";
7
20
  export declare function strings(value: unknown): string[];
8
21
  /** Paths that cannot be attributed to a repository stay in original evidence. */
9
22
  export declare function relativePath(value: unknown): string | null;
23
+ export declare function hostedRepositoryPath(value: unknown): string | null;
10
24
  export declare function repositoryFilePath(value: unknown): string | null;
11
25
  export declare function stableId(prefix: string, fields: unknown[]): string;
26
+ export declare function readScannerBytes(path: string | FileHandle): Promise<Buffer>;
12
27
  export declare function readScannerText(path: string): Promise<string>;
13
28
  export declare function parseJsonOrJsonl(contents: string): unknown;
14
- export declare function readScannerJson(path: string | FileHandle): Promise<unknown>;
29
+ /** Bind a normalized JSON report reader to the SDK's file entrypoint. */
30
+ export declare function scannerJsonReader<Options extends unknown[]>(normalize: (report: unknown, ...options: Options) => ExternalFindings): (path: string, ...options: Options) => Promise<ExternalFindings>;
31
+ export declare function readScannerJson(path: string | FileHandle, parse?: (json: string) => unknown): Promise<unknown>;
15
32
  /** Empty reference containers and property-bag metadata do not externalize data. */
16
33
  export declare function hasSarifExternalPropertyReferences(value: unknown): boolean;
17
34
  /** Keep original artifact indexes; omit only inventory unrelated to this finding. */
@@ -22,8 +39,11 @@ type IndexedSarifRule = {
22
39
  };
23
40
  /** Duplicate IDs cannot identify a single rule in this run. */
24
41
  export declare function indexSarifRules(entries: Iterable<[number, Record<string, unknown>]>): Map<unknown, IndexedSarifRule | null>;
42
+ type SarifRun = Record<"document" | "run" | "tool" | "driver", Record<string, unknown>>;
43
+ /** Unpack the common SARIF envelope; each reader qualifies its own producer. */
44
+ export declare function readSarifRuns<T>(input: unknown, producer: "Semgrep" | "Snyk" | "Endor", read: (context: SarifRun) => T[]): T[];
25
45
  /** Pair each result with its shared run context and original evidence. */
26
- export declare function sarifRunResults(document: Record<string, unknown>, run: Record<string, unknown>, tool: Record<string, unknown>, driver: Record<string, unknown>, producer: "Endor" | "Semgrep"): {
46
+ export declare function sarifRunResults({ document, run, tool, driver }: SarifRun, producer: "Endor" | "Semgrep"): {
27
47
  result: unknown;
28
48
  context: {
29
49
  rulesById: Map<unknown, IndexedSarifRule | null>;
@@ -48,17 +68,9 @@ export declare function sarifRunResults(document: Record<string, unknown>, run:
48
68
  }[];
49
69
  /** The top-level index and nested descriptor must agree with the selected driver rule. */
50
70
  export declare function validateSarifRuleReference(result: Record<string, unknown>, ruleId: string, selected: IndexedSarifRule | undefined, producer: "Endor" | "Semgrep" | "Snyk"): void;
51
- type SelectionFilter = (selection: ExternalFindings, removedIds?: Set<string>) => void;
52
- /** Track older size decisions while a single reader constructs its result. */
53
- export declare function trackReaderSelection(result: ExternalFindings): {
54
- append: (position: number, id: string, project: () => ExternalFinding["evidence"]) => void;
55
- finish: (filter?: SelectionFilter) => ExternalFindings;
56
- uncertainIds: Set<string>;
57
- };
71
+ /** Append the evidence or its exclusion at the original input position. */
72
+ export declare function appendFinding(result: ExternalFindings, position: number, id: string, project: () => ExternalFinding["evidence"]): void;
58
73
  /** Exclude every colliding record: choosing the first could overwrite another occurrence. */
59
- export declare function normalizeRecords<T>(records: T[], projectEvidence: (record: T, id: string) => ExternalFinding["evidence"], identify: (record: T) => string, target?: "local" | "cloud", options?: {
60
- report?: ExternalFindings["report"];
61
- filter?: SelectionFilter;
62
- }): ExternalFindings;
74
+ export declare function normalizeRecords<T>(records: T[], projectEvidence: (record: T, id: string) => ExternalFinding["evidence"], identify: (record: T) => string, target?: "local" | "cloud", options?: Pick<ExternalFindings, "report">): ExternalFindings;
63
75
  export {};
64
76
  //# sourceMappingURL=scanner-import.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"scanner-import.d.ts","sourceRoot":"","sources":["../src/scanner-import.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK7D,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKhF,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAI7E;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAG9D;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAElD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAA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3C;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,OAAO,EAAE,CAAC,EAAE,EACZ,eAAe,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,eAAe,CAAC,UAAU,CAAC,EACvE,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,MAAM,EAC/B,MAAM,GAAE,OAAO,GAAG,OAAiB,EACnC,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAM,GAC7C,gBAAgB,CA8ClB"}
@@ -3,10 +3,10 @@ import { readFile } from "node:fs/promises";
3
3
  import { posix } from "node:path";
4
4
  import { promisify } from "node:util";
5
5
  import { gunzip } from "node:zlib";
6
+ import validSemver from "semver/functions/valid.js";
6
7
  import { CodexSecurityError, errorMessage } from "./errors.js";
7
- import { isRecord } from "./record.js";
8
- import { previousAdmission } from "./external-import-contract.js";
9
- import { rememberPreviousSelection } from "./reader-selection.js";
8
+ import { REPORTABLE_SEVERITIES, SCAN_SEVERITIES } from "./scan-settings.js";
9
+ import { asRecord, isRecord } from "./record.js";
10
10
  export function record(value, label) {
11
11
  if (!value || typeof value !== "object" || Array.isArray(value))
12
12
  throw new Error(`${label} must be an object.`);
@@ -17,15 +17,172 @@ export function array(value, label) {
17
17
  throw new Error(`${label} must be an array.`);
18
18
  return value;
19
19
  }
20
+ export function optionalArray(value, label) {
21
+ return value === undefined ? [] : array(value, label);
22
+ }
23
+ // SARIF uses the same index/GUID/ID references for components and descriptors.
24
+ function sarifReferences(entries, select, first = 0) {
25
+ const refs = new Map();
26
+ entries.forEach((entry, index) => {
27
+ if (!isRecord(entry))
28
+ return;
29
+ const item = select(entry);
30
+ refs.set(index + first, item);
31
+ if (typeof entry["guid"] === "string")
32
+ refs.set("guid:" + entry["guid"].toLowerCase(), item);
33
+ if (typeof entry["id"] === "string")
34
+ refs.set("id:" + entry["id"], item);
35
+ });
36
+ return (ref) => {
37
+ const { index, guid, id } = asRecord(ref) ?? {};
38
+ if (typeof index === "number" && index >= 0)
39
+ return refs.get(index);
40
+ if (typeof guid === "string")
41
+ return refs.get("guid:" + guid.toLowerCase());
42
+ return typeof id === "string" ? refs.get("id:" + id) : refs.get(-1);
43
+ };
44
+ }
45
+ function notificationDescriptors(value) {
46
+ const tool = asRecord(value);
47
+ // The driver is the default component (-1); extension indexes start at 0.
48
+ const component = sarifReferences([
49
+ tool?.["driver"],
50
+ ...optionalArray(tool?.["extensions"], "SARIF tool extensions"),
51
+ ], (owner) => sarifReferences(optionalArray(owner["notifications"], "SARIF notification descriptors"), (entry) => entry), -1);
52
+ return (ref) => component(asRecord(ref)?.["toolComponent"])?.(ref);
53
+ }
54
+ export function validateSarifRun(run, producer) {
55
+ if (hasSarifExternalPropertyReferences(run["externalPropertyFileReferences"]))
56
+ throw new Error(`Use a self-contained ${producer} SARIF report.`);
57
+ function validate(values, tool, strictExecution) {
58
+ let descriptors;
59
+ const resolve = (ref) => isRecord(ref)
60
+ ? (descriptors ??= notificationDescriptors(tool))(ref)
61
+ : undefined;
62
+ for (const value of values) {
63
+ const invocation = record(value, `${producer} invocation`);
64
+ const successful = invocation["executionSuccessful"];
65
+ if (typeof successful !== "boolean")
66
+ throw new Error(`${producer} SARIF executionSuccessful must be a boolean.`);
67
+ const list = (key) => optionalArray(invocation[key], `${producer} ${key}`);
68
+ const execution = list("toolExecutionNotifications");
69
+ const notices = execution.concat(list("toolConfigurationNotifications"));
70
+ if (!successful) {
71
+ const details = [
72
+ invocation["processStartFailureMessage"],
73
+ invocation["exitCodeDescription"],
74
+ invocation["exitCode"],
75
+ invocation["exitSignalName"],
76
+ ...notices,
77
+ ].filter((value) => value !== undefined);
78
+ throw new Error(`${producer} SARIF contains an unsuccessful invocation.${details.length ? " " + JSON.stringify(details) : ""}`);
79
+ }
80
+ if (strictExecution && execution.length)
81
+ throw new Error(`${producer} SARIF contains scan error notifications: ${JSON.stringify(execution)}`);
82
+ const levels = new Map();
83
+ for (const value of list("notificationConfigurationOverrides")) {
84
+ const override = asRecord(value);
85
+ const descriptor = resolve(override?.["descriptor"]);
86
+ const level = asRecord(override?.["configuration"])?.["level"];
87
+ if (descriptor && level !== undefined)
88
+ levels.set(descriptor, level);
89
+ }
90
+ for (const value of notices) {
91
+ const notice = record(value, `${producer} notification`);
92
+ const descriptor = resolve(notice["descriptor"]);
93
+ const level = notice["level"] ??
94
+ (descriptor && levels.get(descriptor)) ??
95
+ asRecord(descriptor?.["defaultConfiguration"])?.["level"];
96
+ if (level === "error")
97
+ throw new Error(`${producer} SARIF contains scan error notifications: ${JSON.stringify(notice)}`);
98
+ }
99
+ }
100
+ }
101
+ // Semgrep reports scanner errors as execution notices even below error level.
102
+ validate(optionalArray(run["invocations"], `${producer} invocations`), run["tool"], producer === "Semgrep");
103
+ if (run["conversion"] !== undefined) {
104
+ const conversion = record(run["conversion"], `${producer} conversion`);
105
+ if (conversion["invocation"] !== undefined)
106
+ validate([conversion["invocation"]], conversion["tool"], false);
107
+ }
108
+ }
20
109
  export function text(value) {
21
110
  return typeof value === "string" && value.trim() ? value : null;
22
111
  }
112
+ /** AWS APIs use epoch seconds and AWS CLI exports use timezone-qualified ISO dates. */
113
+ export function awsTimestampSeconds(value) {
114
+ if (typeof value === "number")
115
+ return value;
116
+ if (typeof value === "string" &&
117
+ /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)?(?:Z|[+-]\d\d:\d\d)$/u.test(value))
118
+ return Date.parse(value) / 1000;
119
+ return NaN;
120
+ }
121
+ export function concreteVersion(value, ecosystem, osPackage) {
122
+ const version = text(value);
123
+ if (!version)
124
+ return null;
125
+ // Debian versions use internal tildes for prereleases and backports.
126
+ if (osPackage && version.includes("~"))
127
+ return /^(?:\d+:)?\d[a-z\d.+~]*(?:-[a-z\d.+~]+)*$/iu.test(version)
128
+ ? version
129
+ : null;
130
+ if (validSemver(version))
131
+ return version;
132
+ if (ecosystem === "npm" || ecosystem === "cargo")
133
+ return null;
134
+ if (ecosystem === "java" || ecosystem === "maven") {
135
+ if (version === "LATEST" ||
136
+ version === "RELEASE" ||
137
+ version.startsWith("latest."))
138
+ return null;
139
+ return /^[a-z\d][\w.+-]*$/iu.test(version) && !version.endsWith("+")
140
+ ? version
141
+ : null;
142
+ }
143
+ if (!ecosystem && version.endsWith("+"))
144
+ return null;
145
+ const publicVersion = ecosystem === "pypi" ? version.split("+", 1)[0] : version;
146
+ return /\d/u.test(version) &&
147
+ /^(?:\d+:)?[a-z\d][\w.+!-]*$/iu.test(version) &&
148
+ !/(?:^|\.)x(?:\.|$)/iu.test(publicVersion)
149
+ ? version
150
+ : null;
151
+ }
23
152
  export function requiredText(value, label) {
24
153
  const result = text(value);
25
154
  if (!result)
26
155
  throw new Error(`${label} must be nonempty text.`);
27
156
  return result;
28
157
  }
158
+ /** SARIF repository claims must be checked even when a run has no results. */
159
+ export function sarifRunRepositories(run, producer) {
160
+ if (run == null)
161
+ return [];
162
+ return array(record(run, `${producer} run context`)["versionControlProvenance"] ?? [], `${producer} version control provenance`).flatMap((entry) => {
163
+ const ref = record(entry, `${producer} repository provenance`);
164
+ const url = producer === "Semgrep"
165
+ ? text(ref["repositoryUri"])
166
+ : requiredText(ref["repositoryUri"], `${producer} repository URI`);
167
+ if (url === null)
168
+ return [];
169
+ const branch = ref["branch"];
170
+ return [
171
+ {
172
+ url,
173
+ ...(producer === "Semgrep" && typeof branch === "string" && { branch }),
174
+ },
175
+ ];
176
+ });
177
+ }
178
+ /** Normalize scanners whose reported severities range from low to critical. */
179
+ export function reportableScannerSeverity(value) {
180
+ const level = text(value)?.toLowerCase();
181
+ return (REPORTABLE_SEVERITIES.find((severity) => severity === level) ?? "unknown");
182
+ }
183
+ export function scannerSeverity(value) {
184
+ return SCAN_SEVERITIES.find((severity) => severity === value) ?? "unknown";
185
+ }
29
186
  export function strings(value) {
30
187
  return Array.isArray(value)
31
188
  ? value.filter((v) => text(v) !== null)
@@ -42,6 +199,13 @@ export function relativePath(value) {
42
199
  ? path
43
200
  : null;
44
201
  }
202
+ // Hosted findings do not identify the scanner operating system or its path separator.
203
+ export function hostedRepositoryPath(value) {
204
+ const path = text(value);
205
+ return path && !path.includes("\\") && !path.includes("://")
206
+ ? relativePath(path)
207
+ : null;
208
+ }
45
209
  export function repositoryFilePath(value) {
46
210
  const relative = relativePath(value);
47
211
  if (!relative)
@@ -59,12 +223,25 @@ export function stableId(prefix, fields) {
59
223
  }
60
224
  const strictUtf8 = new TextDecoder("utf-8", { fatal: true });
61
225
  const gunzipAsync = promisify(gunzip);
62
- async function readScannerBytes(path) {
226
+ async function readScannerInput(path) {
63
227
  const bytes = await readFile(path);
64
- return bytes[0] === 0x1f && bytes[1] === 0x8b ? gunzipAsync(bytes) : bytes;
228
+ const gzip = bytes[0] === 0x1f && bytes[1] === 0x8b;
229
+ return { gzip, bytes: gzip ? await gunzipAsync(bytes) : bytes };
230
+ }
231
+ export async function readScannerBytes(path) {
232
+ return (await readScannerInput(path)).bytes;
65
233
  }
66
234
  export async function readScannerText(path) {
67
- return strictUtf8.decode(await readScannerBytes(path));
235
+ const { bytes, gzip } = await readScannerInput(path);
236
+ const contents = strictUtf8.decode(bytes);
237
+ // Empty JSONL is a valid stream of zero records; a blank JSON or CSV document isn't.
238
+ if (!contents.trim()) {
239
+ if (!gzip && /\.gz$/iu.test(path))
240
+ throw new Error("The report is blank and contains no gzip stream.");
241
+ if (/\.(?:json|csv)(?:\.gz)?$/iu.test(path))
242
+ throw new Error("The report is blank.");
243
+ }
244
+ return contents;
68
245
  }
69
246
  export function parseJsonOrJsonl(contents) {
70
247
  try {
@@ -77,7 +254,11 @@ export function parseJsonOrJsonl(contents) {
77
254
  .map((line) => JSON.parse(line));
78
255
  }
79
256
  }
80
- export async function readScannerJson(path) {
257
+ /** Bind a normalized JSON report reader to the SDK's file entrypoint. */
258
+ export function scannerJsonReader(normalize) {
259
+ return async (path, ...options) => normalize(await readScannerJson(path), ...options);
260
+ }
261
+ export async function readScannerJson(path, parse = JSON.parse) {
81
262
  const bytes = await readScannerBytes(path);
82
263
  let decoded;
83
264
  try {
@@ -87,7 +268,7 @@ export async function readScannerJson(path) {
87
268
  throw new CodexSecurityError(`Scanner report is not valid UTF-8. ${errorMessage(error)}`, { cause: error });
88
269
  }
89
270
  try {
90
- return JSON.parse(decoded.replace(/^\uFEFF/u, ""));
271
+ return parse(decoded.replace(/^\uFEFF/u, ""));
91
272
  }
92
273
  catch (error) {
93
274
  throw new CodexSecurityError(`Scanner JSON could not be parsed. ${errorMessage(error)}`, { cause: error });
@@ -196,8 +377,21 @@ export function indexSarifRules(entries) {
196
377
  }
197
378
  return byId;
198
379
  }
380
+ /** Unpack the common SARIF envelope; each reader qualifies its own producer. */
381
+ export function readSarifRuns(input, producer, read) {
382
+ const document = record(input, `${producer} SARIF`);
383
+ if (document["version"] !== "2.1.0")
384
+ throw new Error(`Expected ${producer} SARIF 2.1.0.`);
385
+ return array(document["runs"], "SARIF runs").flatMap((value) => {
386
+ const run = record(value, "SARIF run");
387
+ const tool = record(run["tool"], "SARIF tool");
388
+ const driver = record(tool["driver"], "SARIF driver");
389
+ return read({ document, run, tool, driver });
390
+ });
391
+ }
199
392
  /** Pair each result with its shared run context and original evidence. */
200
- export function sarifRunResults(document, run, tool, driver, producer) {
393
+ export function sarifRunResults({ document, run, tool, driver }, producer) {
394
+ validateSarifRun(run, producer);
201
395
  const rules = array(driver["rules"] ?? [], `${producer} rules`).map((rule) => record(rule, `${producer} rule`));
202
396
  const rulesById = indexSarifRules(rules.entries());
203
397
  const { runs: _runs, ...documentContext } = document;
@@ -223,7 +417,7 @@ export function sarifRunResults(document, run, tool, driver, producer) {
223
417
  });
224
418
  },
225
419
  };
226
- return array(run["results"] ?? [], `${producer} results`).map((result) => ({
420
+ return optionalArray(run["results"], `${producer} results`).map((result) => ({
227
421
  result,
228
422
  context,
229
423
  }));
@@ -248,92 +442,18 @@ export function validateSarifRuleReference(result, ruleId, selected, producer) {
248
442
  ? "Result uses an inconsistent or external rule reference."
249
443
  : `Inconsistent or external ${producer} rule reference.`);
250
444
  }
251
- /** Track older size decisions while a single reader constructs its result. */
252
- export function trackReaderSelection(result) {
253
- const changes = [];
254
- const uncertainIds = new Set();
255
- function append(position, id, project) {
256
- const index = result.findings.length;
257
- let outcome;
258
- try {
259
- const evidence = project();
260
- outcome = evidence;
261
- result.findings.push({ source_finding_id: id, evidence });
262
- }
263
- catch (error) {
264
- outcome = error;
265
- result.excluded.push({
266
- position,
267
- source_finding_id: id,
268
- reason: errorMessage(error),
269
- });
270
- }
271
- const previous = outcome && typeof outcome === "object"
272
- ? previousAdmission(outcome)
273
- : undefined;
274
- if (previous === "uncertain")
275
- uncertainIds.add(id);
276
- else if (previous !== undefined)
277
- changes.push({ index, position, id, previous });
445
+ /** Append the evidence or its exclusion at the original input position. */
446
+ export function appendFinding(result, position, id, project) {
447
+ try {
448
+ result.findings.push({ source_finding_id: id, evidence: project() });
278
449
  }
279
- function finish(filter) {
280
- if (!changes.length && !uncertainIds.size) {
281
- filter?.(result);
282
- return result;
283
- }
284
- const findings = [];
285
- const excluded = [];
286
- const restoredPositions = new Set();
287
- let cursor = 0;
288
- for (const { index, position, id, previous } of changes) {
289
- while (cursor < index)
290
- findings.push(result.findings[cursor++]);
291
- if (previous) {
292
- findings.push({ source_finding_id: id, evidence: previous });
293
- restoredPositions.add(position);
294
- }
295
- else {
296
- cursor++;
297
- excluded.push({
298
- position,
299
- source_finding_id: id,
300
- reason: "Evidence exceeds the Cloud limit of 256 KiB.",
301
- });
302
- }
303
- }
304
- while (cursor < result.findings.length)
305
- findings.push(result.findings[cursor++]);
306
- for (const row of result.excluded) {
307
- if (!restoredPositions.has(row.position))
308
- excluded.push(row);
309
- }
310
- excluded.sort((a, b) => a.position - b.position);
311
- const previous = { ...result, findings, excluded };
312
- // A removed sibling could have depended on an unproven row for its scope.
313
- filter?.(previous, uncertainIds.size ? uncertainIds : undefined);
314
- filter?.(result);
315
- const sourceFindingIds = [
316
- ...new Set([
317
- ...previous.findings.map((row) => row.source_finding_id),
318
- ...uncertainIds,
319
- ]),
320
- ];
321
- if (uncertainIds.size) {
322
- rememberPreviousSelection(result, {
323
- sourceFindingIds,
324
- uncertainFindingIds: [...uncertainIds],
325
- knownFindings: structuredClone(previous.findings.filter((row) => !uncertainIds.has(row.source_finding_id))),
326
- });
327
- }
328
- else {
329
- rememberPreviousSelection(result, {
330
- sourceFindingIds,
331
- snapshot: structuredClone(previous),
332
- });
333
- }
334
- return result;
450
+ catch (error) {
451
+ result.excluded.push({
452
+ position,
453
+ source_finding_id: id,
454
+ reason: errorMessage(error),
455
+ });
335
456
  }
336
- return { append, finish, uncertainIds };
337
457
  }
338
458
  /** Exclude every colliding record: choosing the first could overwrite another occurrence. */
339
459
  export function normalizeRecords(records, projectEvidence, identify, target = "cloud", options = {}) {
@@ -343,7 +463,6 @@ export function normalizeRecords(records, projectEvidence, identify, target = "c
343
463
  excluded: [],
344
464
  ...(options.report === undefined ? {} : { report: options.report }),
345
465
  };
346
- const selection = trackReaderSelection(result);
347
466
  const identified = [];
348
467
  const counts = new Map();
349
468
  for (const [index, value] of records.entries()) {
@@ -375,9 +494,9 @@ export function normalizeRecords(records, projectEvidence, identify, target = "c
375
494
  });
376
495
  continue;
377
496
  }
378
- selection.append(position, id, () => projectEvidence(value, id));
497
+ appendFinding(result, position, id, () => projectEvidence(value, id));
379
498
  }
380
499
  result.excluded.sort((a, b) => a.position - b.position);
381
- return selection.finish(options.filter);
500
+ return result;
382
501
  }
383
502
  //# sourceMappingURL=scanner-import.js.map