@repometry/cli 0.0.0-dev.0 → 0.0.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 (415) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -3
  3. package/package.json +65 -2
  4. package/target/main/resources/language-catalog.json +61 -0
  5. package/target/main/resources/report/json/compact-json-v1.schema.json +24 -0
  6. package/target/main/resources/report/json/comparison-v1.schema.json +65 -0
  7. package/target/main/resources/report/json/config-v2.schema.json +224 -0
  8. package/target/main/resources/report/json/diff-coverage-v1.schema.json +55 -0
  9. package/target/main/resources/report/json/file-metrics-v1.schema.json +157 -0
  10. package/target/main/resources/report/json/metabranch-v1.schema.json +9 -0
  11. package/target/main/resources/report/json/metric-catalog-v1.schema.json +31 -0
  12. package/target/main/resources/report/json/pull-review-v1.schema.json +97 -0
  13. package/target/main/resources/report/json/pull-review-v2.schema.json +100 -0
  14. package/target/main/resources/report/json/report-v2.schema.json +530 -0
  15. package/target/main/resources/report/json/repository-summary-v1.schema.json +337 -0
  16. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +534 -0
  17. package/target/main/resources/viewer/files.css +616 -0
  18. package/target/main/resources/viewer/index.html +120 -0
  19. package/target/main/resources/viewer/projects.html +52 -0
  20. package/target/main/resources/viewer/styles.css +579 -0
  21. package/target/main/resources/viewer/viewer-pulls.css +64 -0
  22. package/target/main/ts/api/cache/root.d.ts +2 -0
  23. package/target/main/ts/api/cache/root.js +21 -0
  24. package/target/main/ts/api/gh/github.d.ts +4 -0
  25. package/target/main/ts/api/gh/github.js +47 -0
  26. package/target/main/ts/api/git/blob-batch.d.ts +10 -0
  27. package/target/main/ts/api/git/blob-batch.js +107 -0
  28. package/target/main/ts/api/git/blob-history.d.ts +20 -0
  29. package/target/main/ts/api/git/blob-history.js +54 -0
  30. package/target/main/ts/api/git/changes.d.ts +27 -0
  31. package/target/main/ts/api/git/changes.js +117 -0
  32. package/target/main/ts/api/git/commit-metadata.d.ts +2 -0
  33. package/target/main/ts/api/git/commit-metadata.js +46 -0
  34. package/target/main/ts/api/git/git-churn.d.ts +9 -0
  35. package/target/main/ts/api/git/git-churn.js +72 -0
  36. package/target/main/ts/api/git/git-executable.d.ts +1 -0
  37. package/target/main/ts/api/git/git-executable.js +31 -0
  38. package/target/main/ts/api/git/git-reader.d.ts +24 -0
  39. package/target/main/ts/api/git/git-reader.js +113 -0
  40. package/target/main/ts/api/git/git.d.ts +47 -0
  41. package/target/main/ts/api/git/git.js +289 -0
  42. package/target/main/ts/api/git/inspection-source.d.ts +17 -0
  43. package/target/main/ts/api/git/inspection-source.js +36 -0
  44. package/target/main/ts/api/git/line-changes.d.ts +6 -0
  45. package/target/main/ts/api/git/line-changes.js +57 -0
  46. package/target/main/ts/api/git/local-sources.d.ts +5 -0
  47. package/target/main/ts/api/git/local-sources.js +48 -0
  48. package/target/main/ts/api/git/local.d.ts +7 -0
  49. package/target/main/ts/api/git/local.js +106 -0
  50. package/target/main/ts/api/git/source-cache.d.ts +1 -0
  51. package/target/main/ts/api/git/source-cache.js +42 -0
  52. package/target/main/ts/api/import/cobertura.d.ts +2 -0
  53. package/target/main/ts/api/import/cobertura.js +160 -0
  54. package/target/main/ts/api/import/coverage-xml.d.ts +7 -0
  55. package/target/main/ts/api/import/coverage-xml.js +135 -0
  56. package/target/main/ts/api/import/finding-import.d.ts +9 -0
  57. package/target/main/ts/api/import/finding-import.js +227 -0
  58. package/target/main/ts/api/import/go-cover.d.ts +13 -0
  59. package/target/main/ts/api/import/go-cover.js +150 -0
  60. package/target/main/ts/api/import/lcov-files.d.ts +12 -0
  61. package/target/main/ts/api/import/lcov-files.js +53 -0
  62. package/target/main/ts/api/import/profile-file.d.ts +4 -0
  63. package/target/main/ts/api/import/profile-file.js +17 -0
  64. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  65. package/target/main/ts/api/process/docker-tool-runner.js +92 -0
  66. package/target/main/ts/api/process/failure.d.ts +1 -0
  67. package/target/main/ts/api/process/failure.js +12 -0
  68. package/target/main/ts/api/process/plugin.d.ts +13 -0
  69. package/target/main/ts/api/process/plugin.js +100 -0
  70. package/target/main/ts/api/process/tool-snapshot.d.ts +3 -0
  71. package/target/main/ts/api/process/tool-snapshot.js +26 -0
  72. package/target/main/ts/cli/arguments.d.ts +28 -0
  73. package/target/main/ts/cli/arguments.js +109 -0
  74. package/target/main/ts/cli/config.d.ts +63 -0
  75. package/target/main/ts/cli/config.js +165 -0
  76. package/target/main/ts/cli/imports.d.ts +9 -0
  77. package/target/main/ts/cli/imports.js +37 -0
  78. package/target/main/ts/cli/main.d.ts +2 -0
  79. package/target/main/ts/cli/main.js +4 -0
  80. package/target/main/ts/cli/range-inspection.d.ts +38 -0
  81. package/target/main/ts/cli/range-inspection.js +34 -0
  82. package/target/main/ts/cli/range-jobs.d.ts +23 -0
  83. package/target/main/ts/cli/range-jobs.js +152 -0
  84. package/target/main/ts/cli/range-worker.d.ts +1 -0
  85. package/target/main/ts/cli/range-worker.js +40 -0
  86. package/target/main/ts/cli/reporting.d.ts +42 -0
  87. package/target/main/ts/cli/reporting.js +98 -0
  88. package/target/main/ts/cli/revisions.d.ts +6 -0
  89. package/target/main/ts/cli/revisions.js +16 -0
  90. package/target/main/ts/cli/run.d.ts +2 -0
  91. package/target/main/ts/cli/run.js +306 -0
  92. package/target/main/ts/cli/store.d.ts +13 -0
  93. package/target/main/ts/cli/store.js +39 -0
  94. package/target/main/ts/compose/analysis-report.d.ts +6 -0
  95. package/target/main/ts/compose/analysis-report.js +131 -0
  96. package/target/main/ts/compose/analysis-results.d.ts +42 -0
  97. package/target/main/ts/compose/analysis-results.js +84 -0
  98. package/target/main/ts/compose/analysis-steps.d.ts +23 -0
  99. package/target/main/ts/compose/analysis-steps.js +217 -0
  100. package/target/main/ts/compose/analyze-snapshot.d.ts +7 -0
  101. package/target/main/ts/compose/analyze-snapshot.js +21 -0
  102. package/target/main/ts/compose/attach-churn.d.ts +2 -0
  103. package/target/main/ts/compose/attach-churn.js +50 -0
  104. package/target/main/ts/compose/built-ins.d.ts +6 -0
  105. package/target/main/ts/compose/built-ins.js +12 -0
  106. package/target/main/ts/compose/diff-coverage.d.ts +25 -0
  107. package/target/main/ts/compose/diff-coverage.js +82 -0
  108. package/target/main/ts/compose/distribution.d.ts +17 -0
  109. package/target/main/ts/compose/distribution.js +13 -0
  110. package/target/main/ts/compose/docker-image.d.ts +5 -0
  111. package/target/main/ts/compose/docker-image.js +49 -0
  112. package/target/main/ts/compose/file-selection.d.ts +9 -0
  113. package/target/main/ts/compose/file-selection.js +38 -0
  114. package/target/main/ts/compose/history-cache.d.ts +31 -0
  115. package/target/main/ts/compose/history-cache.js +62 -0
  116. package/target/main/ts/compose/inspect.d.ts +34 -0
  117. package/target/main/ts/compose/inspect.js +51 -0
  118. package/target/main/ts/compose/inspection-coverage.d.ts +9 -0
  119. package/target/main/ts/compose/inspection-coverage.js +9 -0
  120. package/target/main/ts/compose/js-plugin.d.ts +113 -0
  121. package/target/main/ts/compose/js-plugin.js +99 -0
  122. package/target/main/ts/compose/language-discovery.d.ts +12 -0
  123. package/target/main/ts/compose/language-discovery.js +51 -0
  124. package/target/main/ts/compose/languages.d.ts +64 -0
  125. package/target/main/ts/compose/languages.js +98 -0
  126. package/target/main/ts/compose/load-plugins.d.ts +6 -0
  127. package/target/main/ts/compose/load-plugins.js +71 -0
  128. package/target/main/ts/compose/parser-order.d.ts +20 -0
  129. package/target/main/ts/compose/parser-order.js +90 -0
  130. package/target/main/ts/compose/phases.d.ts +140 -0
  131. package/target/main/ts/compose/phases.js +147 -0
  132. package/target/main/ts/compose/plugin-list.d.ts +37 -0
  133. package/target/main/ts/compose/plugin-list.js +30 -0
  134. package/target/main/ts/compose/plugin-manifest.d.ts +14 -0
  135. package/target/main/ts/compose/plugin-manifest.js +50 -0
  136. package/target/main/ts/compose/plugin-options.d.ts +2 -0
  137. package/target/main/ts/compose/plugin-options.js +29 -0
  138. package/target/main/ts/compose/plugin-reference.d.ts +9 -0
  139. package/target/main/ts/compose/plugin-reference.js +40 -0
  140. package/target/main/ts/compose/plugin-requirements.d.ts +5 -0
  141. package/target/main/ts/compose/plugin-requirements.js +83 -0
  142. package/target/main/ts/compose/plugin-scope.d.ts +9 -0
  143. package/target/main/ts/compose/plugin-scope.js +60 -0
  144. package/target/main/ts/compose/process-plugins.d.ts +89 -0
  145. package/target/main/ts/compose/process-plugins.js +74 -0
  146. package/target/main/ts/compose/registered-plugin.d.ts +17 -0
  147. package/target/main/ts/compose/registered-plugin.js +8 -0
  148. package/target/main/ts/compose/review.d.ts +26 -0
  149. package/target/main/ts/compose/review.js +54 -0
  150. package/target/main/ts/compose/schema-error.d.ts +2 -0
  151. package/target/main/ts/compose/schema-error.js +16 -0
  152. package/target/main/ts/compose/sources.d.ts +2 -0
  153. package/target/main/ts/compose/sources.js +32 -0
  154. package/target/main/ts/compose/structure-measures.d.ts +9 -0
  155. package/target/main/ts/compose/structure-measures.js +63 -0
  156. package/target/main/ts/index.d.ts +8 -0
  157. package/target/main/ts/index.js +5 -0
  158. package/target/main/ts/plugin.d.ts +2 -0
  159. package/target/main/ts/plugin.js +2 -0
  160. package/target/main/ts/plugins/built-in.d.ts +3 -0
  161. package/target/main/ts/plugins/built-in.js +19 -0
  162. package/target/main/ts/plugins/coverage/coverage.d.ts +11 -0
  163. package/target/main/ts/plugins/coverage/coverage.js +289 -0
  164. package/target/main/ts/plugins/coverage/diff-coverage.d.ts +3 -0
  165. package/target/main/ts/plugins/coverage/diff-coverage.js +85 -0
  166. package/target/main/ts/plugins/duplication/duplication.d.ts +2 -0
  167. package/target/main/ts/plugins/duplication/duplication.js +95 -0
  168. package/target/main/ts/plugins/language-js/babel-provider.d.ts +10 -0
  169. package/target/main/ts/plugins/language-js/babel-provider.js +54 -0
  170. package/target/main/ts/plugins/language-js/clone-candidates.d.ts +3 -0
  171. package/target/main/ts/plugins/language-js/clone-candidates.js +65 -0
  172. package/target/main/ts/plugins/language-js/code-lines.d.ts +6 -0
  173. package/target/main/ts/plugins/language-js/code-lines.js +36 -0
  174. package/target/main/ts/plugins/language-js/extensions.d.ts +1 -0
  175. package/target/main/ts/plugins/language-js/extensions.js +3 -0
  176. package/target/main/ts/plugins/language-js/function-facts.d.ts +9 -0
  177. package/target/main/ts/plugins/language-js/function-facts.js +74 -0
  178. package/target/main/ts/plugins/language-js/js-security.d.ts +4 -0
  179. package/target/main/ts/plugins/language-js/js-security.js +497 -0
  180. package/target/main/ts/plugins/language-js/qualified-names.d.ts +11 -0
  181. package/target/main/ts/plugins/language-js/qualified-names.js +63 -0
  182. package/target/main/ts/plugins/language-js/structural-observations.d.ts +9 -0
  183. package/target/main/ts/plugins/language-js/structural-observations.js +85 -0
  184. package/target/main/ts/plugins/language-js/syntax.d.ts +2 -0
  185. package/target/main/ts/plugins/language-js/syntax.js +11 -0
  186. package/target/main/ts/plugins/maintainability/maintainability.d.ts +2 -0
  187. package/target/main/ts/plugins/maintainability/maintainability.js +38 -0
  188. package/target/main/ts/plugins/maintainability/structural-smells.d.ts +3 -0
  189. package/target/main/ts/plugins/maintainability/structural-smells.js +17 -0
  190. package/target/main/ts/plugins/security/actions-security.d.ts +2 -0
  191. package/target/main/ts/plugins/security/actions-security.js +581 -0
  192. package/target/main/ts/plugins/security/dockerfile.d.ts +2 -0
  193. package/target/main/ts/plugins/security/dockerfile.js +487 -0
  194. package/target/main/ts/plugins/security/npm-supply-chain.d.ts +4 -0
  195. package/target/main/ts/plugins/security/npm-supply-chain.js +368 -0
  196. package/target/main/ts/plugins/security/secrets.d.ts +12 -0
  197. package/target/main/ts/plugins/security/secrets.js +254 -0
  198. package/target/main/ts/plugins/source/forges.d.ts +4 -0
  199. package/target/main/ts/plugins/source/forges.js +80 -0
  200. package/target/main/ts/plugins/structure/structure.d.ts +2 -0
  201. package/target/main/ts/plugins/structure/structure.js +42 -0
  202. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +13 -0
  203. package/target/main/ts/report/html/app/viewer-chart-bars.js +59 -0
  204. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  205. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  206. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +33 -0
  207. package/target/main/ts/report/html/app/viewer-chart-line.js +88 -0
  208. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +52 -0
  209. package/target/main/ts/report/html/app/viewer-chart-points.js +65 -0
  210. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  211. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  212. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  213. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  214. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  215. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  216. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  217. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  218. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  219. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  220. package/target/main/ts/report/html/app/viewer-chart.d.ts +7 -0
  221. package/target/main/ts/report/html/app/viewer-chart.js +50 -0
  222. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  223. package/target/main/ts/report/html/app/viewer-code-map.js +176 -0
  224. package/target/main/ts/report/html/app/viewer-columns.d.ts +40 -0
  225. package/target/main/ts/report/html/app/viewer-columns.js +97 -0
  226. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  227. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  228. package/target/main/ts/report/html/app/viewer-commits.d.ts +32 -0
  229. package/target/main/ts/report/html/app/viewer-commits.js +81 -0
  230. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  231. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  232. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  233. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  234. package/target/main/ts/report/html/app/viewer-data.d.ts +24 -0
  235. package/target/main/ts/report/html/app/viewer-data.js +78 -0
  236. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  237. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  238. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  239. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  240. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +15 -0
  241. package/target/main/ts/report/html/app/viewer-file-aside.js +134 -0
  242. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +17 -0
  243. package/target/main/ts/report/html/app/viewer-file-figures.js +65 -0
  244. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  245. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  246. package/target/main/ts/report/html/app/viewer-files.d.ts +11 -0
  247. package/target/main/ts/report/html/app/viewer-files.js +40 -0
  248. package/target/main/ts/report/html/app/viewer-filter.d.ts +65 -0
  249. package/target/main/ts/report/html/app/viewer-filter.js +161 -0
  250. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  251. package/target/main/ts/report/html/app/viewer-hotspots.js +133 -0
  252. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  253. package/target/main/ts/report/html/app/viewer-inspection.js +38 -0
  254. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  255. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  256. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  257. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  258. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +11 -0
  259. package/target/main/ts/report/html/app/viewer-language-bar.js +76 -0
  260. package/target/main/ts/report/html/app/viewer-languages.d.ts +35 -0
  261. package/target/main/ts/report/html/app/viewer-languages.js +97 -0
  262. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  263. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  264. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  265. package/target/main/ts/report/html/app/viewer-line-coverage.js +108 -0
  266. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  267. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  268. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  269. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  270. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  271. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  272. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  273. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  274. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +47 -0
  275. package/target/main/ts/report/html/app/viewer-metric-registry.js +138 -0
  276. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  277. package/target/main/ts/report/html/app/viewer-metrics-view.js +159 -0
  278. package/target/main/ts/report/html/app/viewer-metrics.d.ts +51 -0
  279. package/target/main/ts/report/html/app/viewer-metrics.js +195 -0
  280. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  281. package/target/main/ts/report/html/app/viewer-overview-cards.js +121 -0
  282. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  283. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  284. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  285. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  286. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  287. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  288. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  289. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  290. package/target/main/ts/report/html/app/viewer-profile.d.ts +13 -0
  291. package/target/main/ts/report/html/app/viewer-profile.js +180 -0
  292. package/target/main/ts/report/html/app/viewer-projects.d.ts +1 -0
  293. package/target/main/ts/report/html/app/viewer-projects.js +90 -0
  294. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  295. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  296. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  297. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  298. package/target/main/ts/report/html/app/viewer-pulls.d.ts +2 -0
  299. package/target/main/ts/report/html/app/viewer-pulls.js +92 -0
  300. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  301. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  302. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  303. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  304. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  305. package/target/main/ts/report/html/app/viewer-shell.js +113 -0
  306. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  307. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  308. package/target/main/ts/report/html/app/viewer-source.d.ts +27 -0
  309. package/target/main/ts/report/html/app/viewer-source.js +57 -0
  310. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  311. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  312. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  313. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  314. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  315. package/target/main/ts/report/html/app/viewer-table-cells.js +135 -0
  316. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +56 -0
  317. package/target/main/ts/report/html/app/viewer-table-rows.js +97 -0
  318. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +15 -0
  319. package/target/main/ts/report/html/app/viewer-tokenizer.js +241 -0
  320. package/target/main/ts/report/html/app/viewer-totals.d.ts +20 -0
  321. package/target/main/ts/report/html/app/viewer-totals.js +100 -0
  322. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  323. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  324. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
  325. package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
  326. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  327. package/target/main/ts/report/html/app/viewer-trend-nav.js +86 -0
  328. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  329. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  330. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +32 -0
  331. package/target/main/ts/report/html/app/viewer-trend-series.js +128 -0
  332. package/target/main/ts/report/html/app/viewer-trends.d.ts +5 -0
  333. package/target/main/ts/report/html/app/viewer-trends.js +89 -0
  334. package/target/main/ts/report/html/app/viewer.d.ts +1 -0
  335. package/target/main/ts/report/html/app/viewer.js +222 -0
  336. package/target/main/ts/report/html/site/badges.d.ts +11 -0
  337. package/target/main/ts/report/html/site/badges.js +72 -0
  338. package/target/main/ts/report/html/site/export-site.d.ts +16 -0
  339. package/target/main/ts/report/html/site/export-site.js +129 -0
  340. package/target/main/ts/report/html/site/exported-server.d.ts +6 -0
  341. package/target/main/ts/report/html/site/exported-server.js +72 -0
  342. package/target/main/ts/report/html/site/local-server.d.ts +7 -0
  343. package/target/main/ts/report/html/site/local-server.js +59 -0
  344. package/target/main/ts/report/html/site/projects.d.ts +1 -0
  345. package/target/main/ts/report/html/site/projects.js +69 -0
  346. package/target/main/ts/report/html/site/server.d.ts +4 -0
  347. package/target/main/ts/report/html/site/server.js +65 -0
  348. package/target/main/ts/report/html/site/source-route.d.ts +6 -0
  349. package/target/main/ts/report/html/site/source-route.js +23 -0
  350. package/target/main/ts/report/json/projections/commit-summary.d.ts +13 -0
  351. package/target/main/ts/report/json/projections/commit-summary.js +125 -0
  352. package/target/main/ts/report/json/projections/components.d.ts +4 -0
  353. package/target/main/ts/report/json/projections/components.js +30 -0
  354. package/target/main/ts/report/json/projections/file-metrics.d.ts +4 -0
  355. package/target/main/ts/report/json/projections/file-metrics.js +260 -0
  356. package/target/main/ts/report/json/projections/ignore-view.d.ts +2 -0
  357. package/target/main/ts/report/json/projections/ignore-view.js +13 -0
  358. package/target/main/ts/report/json/projections/inspection-context.d.ts +5 -0
  359. package/target/main/ts/report/json/projections/inspection-context.js +104 -0
  360. package/target/main/ts/report/json/projections/inspection-details.d.ts +14 -0
  361. package/target/main/ts/report/json/projections/inspection-details.js +98 -0
  362. package/target/main/ts/report/json/projections/metric-values.d.ts +14 -0
  363. package/target/main/ts/report/json/projections/metric-values.js +104 -0
  364. package/target/main/ts/report/json/projections/profile-selectors.d.ts +8 -0
  365. package/target/main/ts/report/json/projections/profile-selectors.js +34 -0
  366. package/target/main/ts/report/json/projections/security-summary.d.ts +11 -0
  367. package/target/main/ts/report/json/projections/security-summary.js +22 -0
  368. package/target/main/ts/report/json/store/directory.d.ts +3 -0
  369. package/target/main/ts/report/json/store/directory.js +19 -0
  370. package/target/main/ts/report/json/store/local-store.d.ts +25 -0
  371. package/target/main/ts/report/json/store/local-store.js +214 -0
  372. package/target/main/ts/report/json/store/object-store.d.ts +14 -0
  373. package/target/main/ts/report/json/store/object-store.js +73 -0
  374. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  375. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  376. package/target/main/ts/report/json/store/pull-review-store.d.ts +2 -0
  377. package/target/main/ts/report/json/store/pull-review-store.js +33 -0
  378. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  379. package/target/main/ts/report/json/store/replace-file.js +35 -0
  380. package/target/main/ts/report/json/store/report-tree.d.ts +46 -0
  381. package/target/main/ts/report/json/store/report-tree.js +295 -0
  382. package/target/main/ts/report/json/store/store-check.d.ts +32 -0
  383. package/target/main/ts/report/json/store/store-check.js +153 -0
  384. package/target/main/ts/report/json/validation/metabranch.d.ts +4 -0
  385. package/target/main/ts/report/json/validation/metabranch.js +11 -0
  386. package/target/main/ts/report/json/validation/report.d.ts +20 -0
  387. package/target/main/ts/report/json/validation/report.js +77 -0
  388. package/target/main/ts/report/json/validation/summary-validation.d.ts +4 -0
  389. package/target/main/ts/report/json/validation/summary-validation.js +26 -0
  390. package/target/main/ts/report/json/wire/compact-json.d.ts +11 -0
  391. package/target/main/ts/report/json/wire/compact-json.js +76 -0
  392. package/target/main/ts/report/json/wire/component-model.d.ts +9 -0
  393. package/target/main/ts/report/json/wire/component-model.js +1 -0
  394. package/target/main/ts/report/json/wire/domain-types.d.ts +2 -0
  395. package/target/main/ts/report/json/wire/domain-types.js +1 -0
  396. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +81 -0
  397. package/target/main/ts/report/json/wire/file-metrics-model.js +1 -0
  398. package/target/main/ts/report/json/wire/inspection-context-model.d.ts +31 -0
  399. package/target/main/ts/report/json/wire/inspection-context-model.js +1 -0
  400. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +87 -0
  401. package/target/main/ts/report/json/wire/inspection-details-model.js +1 -0
  402. package/target/main/ts/report/json/wire/project-model.d.ts +7 -0
  403. package/target/main/ts/report/json/wire/project-model.js +1 -0
  404. package/target/main/ts/report/json/wire/public-history-model.d.ts +36 -0
  405. package/target/main/ts/report/json/wire/public-history-model.js +5 -0
  406. package/target/main/ts/report/json/wire/pull-review-model.d.ts +54 -0
  407. package/target/main/ts/report/json/wire/pull-review-model.js +3 -0
  408. package/target/main/ts/report/json/wire/summary-model.d.ts +45 -0
  409. package/target/main/ts/report/json/wire/summary-model.js +1 -0
  410. package/target/main/ts/report/markdown/pull-review.d.ts +5 -0
  411. package/target/main/ts/report/markdown/pull-review.js +132 -0
  412. package/target/main/ts/report.d.ts +23 -0
  413. package/target/main/ts/report.js +12 -0
  414. package/target/main/ts/runtime.d.ts +17 -0
  415. package/target/main/ts/runtime.js +30 -0
@@ -0,0 +1,227 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { isAbsolute, relative, resolve, sep } from 'node:path';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
+ import { isRecord } from '@repometry/core/internal/engine/plugin.js';
5
+ import { digest } from '@repometry/core/internal/model/snapshot.js';
6
+ import { uniqueScanners, scannerText as text } from '@repometry/core/internal/model/scanner-import.js';
7
+ export { findingImportMethods } from '@repometry/core/internal/model/scanner-import.js';
8
+ export async function importFindings(input, root, excludes, knownPaths) {
9
+ const bytes = await readFile(input.file);
10
+ let parsed;
11
+ try {
12
+ const value = JSON.parse(bytes.toString('utf8'));
13
+ const map = (path) => repositoryPath(root, path);
14
+ parsed = input.format === 'sarif' ? parseSarif(value, input.category, root)
15
+ : input.format === 'eslint' ? parseESLint(value, map) : parseOSV(value, map);
16
+ }
17
+ catch {
18
+ throw new Error(`Invalid ${input.format.toUpperCase()} finding input (${input.category})`);
19
+ }
20
+ const { toolVersion, settingsDigest = null, scope = null } = input;
21
+ if (toolVersion !== undefined && (parsed.tools.length !== 1 || !text(toolVersion)))
22
+ throw new Error('A scanner version override requires one scanner');
23
+ if (settingsDigest !== null && !/^[a-f0-9]{64}$/.test(settingsDigest))
24
+ throw new Error('Invalid scanner configuration digest');
25
+ const tools = toolVersion === undefined ? parsed.tools : [{ name: parsed.tools[0].name, version: toolVersion }];
26
+ const findings = [];
27
+ let unmapped = 0;
28
+ for (const item of parsed.items) {
29
+ if (item?.path && excludes(item.path))
30
+ continue;
31
+ if (item === null || (item.path && knownPaths && !knownPaths.has(item.path))) {
32
+ unmapped++;
33
+ continue;
34
+ }
35
+ const related = item.related?.filter(location => !excludes(location.path) && (!knownPaths || knownPaths.has(location.path)));
36
+ findings.push({ ...item, related: related?.length ? related : undefined });
37
+ }
38
+ return { findings, metadata: { format: input.format, category: input.category, inputDigest: digest(bytes), tools, settingsDigest, scope,
39
+ imported: findings.length, reported: parsed.items.length, unmapped, units: parsed.units } };
40
+ }
41
+ function parseSarif(value, category, root) {
42
+ const report = object(value);
43
+ if (report.version !== '2.1.0')
44
+ throw new Error('Unknown SARIF version');
45
+ const runs = array(report.runs);
46
+ const tools = [];
47
+ const items = [];
48
+ for (const value of runs) {
49
+ const run = object(value);
50
+ const driver = object(object(run.tool).driver);
51
+ const tool = requiredText(driver.name);
52
+ tools.push({ name: tool, version: text(driver.semanticVersion) ?? text(driver.version) ?? null });
53
+ const rules = optionalArray(driver.rules);
54
+ const rulesById = new Map(rules.filter(isRecord).map(rule => [text(rule.id), rule]));
55
+ const artifacts = optionalArray(run.artifacts);
56
+ const bases = isRecord(run.originalUriBaseIds) ? run.originalUriBaseIds : {};
57
+ if (optionalArray(run.invocations).some(invocation => object(invocation).executionSuccessful === false)) {
58
+ throw new Error('SARIF run reports an execution failure');
59
+ }
60
+ for (const candidate of optionalArray(run.results)) {
61
+ const result = object(candidate);
62
+ if (result.kind !== undefined && result.kind !== 'fail' || optionalArray(result.suppressions).some(suppression => object(suppression).status === undefined || object(suppression).status === 'accepted'))
63
+ continue;
64
+ const id = text(result.ruleId);
65
+ const descriptor = safeIndex(result.ruleIndex) ? rules[result.ruleIndex] : id ? rulesById.get(id) : undefined;
66
+ const rule = isRecord(descriptor) ? descriptor : {};
67
+ const defaultConfiguration = isRecord(rule.defaultConfiguration) ? rule.defaultConfiguration : {};
68
+ const level = lookupLevel(result.level ?? defaultConfiguration.level);
69
+ const ruleId = id ?? text(rule.id) ?? '(unclassified)';
70
+ const message = category === 'secret' ? 'Potential secret reported by a scanner' : sarifMessage(result.message);
71
+ const locations = optionalArray(result.locations).map(location => sarifLocation(location, artifacts, bases, root));
72
+ const primary = locations.find(location => location && location.path !== null);
73
+ const related = locations.filter((location) => location !== primary && location !== undefined && location.path !== null && location.line !== undefined && location.endLine !== undefined);
74
+ items.push(locations.some(location => location?.path === null) && !primary ? null : {
75
+ tool, rule: ruleId, category, level, message, ...(primary?.path && { ...primary, path: primary.path }), related,
76
+ });
77
+ }
78
+ }
79
+ return { tools: uniqueScanners(tools), items, units: runs.length };
80
+ }
81
+ function sarifMessage(value) {
82
+ const message = object(value);
83
+ return text(message.text) ?? text(message.markdown) ?? text(message.id) ?? '(missing message)';
84
+ }
85
+ function sarifLocation(value, artifacts, bases, root) {
86
+ const location = object(value);
87
+ const physical = location.physicalLocation;
88
+ if (!isRecord(physical) || !isRecord(physical.artifactLocation))
89
+ return;
90
+ const artifact = physical.artifactLocation;
91
+ const stored = safeIndex(artifact.index) ? artifacts[artifact.index] : undefined;
92
+ const fallback = isRecord(stored) && isRecord(stored.location) ? stored.location : {};
93
+ const uri = text(artifact.uri) ?? text(fallback.uri);
94
+ if (!uri)
95
+ return { path: null };
96
+ const baseId = text(artifact.uriBaseId) ?? text(fallback.uriBaseId);
97
+ const base = pathToFileURL(`${root}${sep}`);
98
+ const resolvedBase = baseId ? sarifBase(baseId, bases, base, new Set()) : base;
99
+ const file = fileLocation(uri, resolvedBase);
100
+ const path = file === null ? null : repositoryPath(root, file);
101
+ const source = isRecord(physical.region) ? physical.region : {};
102
+ return { path, ...range(source.startLine, source.endLine) };
103
+ }
104
+ function sarifBase(id, bases, fallback, visited) {
105
+ if (visited.has(id))
106
+ return null;
107
+ if (!Object.hasOwn(bases, id))
108
+ return id === '%SRCROOT%' ? fallback : null;
109
+ visited.add(id);
110
+ const item = object(bases[id]);
111
+ const uri = text(item.uri);
112
+ const parent = text(item.uriBaseId);
113
+ const base = parent ? sarifBase(parent, bases, fallback, visited) : fallback;
114
+ const file = uri && fileLocation(uri, base);
115
+ return file ? pathToFileURL(file) : null;
116
+ }
117
+ function fileLocation(uri, base) {
118
+ try {
119
+ const url = base === null ? new URL(uri) : new URL(uri, base);
120
+ if (url.protocol !== 'file:' || url.search !== '' || url.hash !== '')
121
+ return null;
122
+ return fileURLToPath(url);
123
+ }
124
+ catch {
125
+ return null;
126
+ }
127
+ }
128
+ function parseESLint(value, map) {
129
+ const files = array(isRecord(value) ? value.results : value);
130
+ const items = [];
131
+ for (const candidate of files) {
132
+ const file = object(candidate);
133
+ const path = map(requiredText(file.filePath));
134
+ for (const value of array(file.messages)) {
135
+ const message = object(value);
136
+ items.push(path === null ? null : { tool: 'eslint', rule: text(message.ruleId) ?? (message.fatal === true ? 'parse-error' : '(unclassified)'),
137
+ category: 'lint', level: message.severity === 2 ? 'high' : message.severity === 1 ? 'medium' : 'unknown',
138
+ message: requiredText(message.message), path, ...range(message.line, message.endLine) });
139
+ }
140
+ }
141
+ return { tools: [{ name: 'eslint', version: null }], items, units: files.length };
142
+ }
143
+ function parseOSV(value, map) {
144
+ const report = object(value);
145
+ const sources = report.results === null ? [] : array(report.results);
146
+ const items = [];
147
+ let units = 0;
148
+ for (const value of sources) {
149
+ const source = object(value);
150
+ const pathValue = isRecord(source.source) ? text(source.source.path) : undefined;
151
+ const path = pathValue === undefined ? undefined : map(pathValue);
152
+ for (const candidate of array(source.packages)) {
153
+ units++;
154
+ const listed = object(candidate);
155
+ const pkg = object(listed.package);
156
+ const name = requiredText(pkg.name);
157
+ const version = text(pkg.version) ?? text(pkg.commit);
158
+ const advisories = new Set(optionalArray(listed.vulnerabilities).map(value => requiredText(object(value).id)));
159
+ for (const entry of optionalArray(listed.groups)) {
160
+ const group = object(entry);
161
+ const identifiers = array(group.ids).map(requiredText);
162
+ if (advisories.size > 0 && identifiers.some(id => advisories.has(id))) {
163
+ const canonical = advisoryId([...identifiers, ...optionalArray(group.aliases).map(requiredText)]);
164
+ add(canonical, scoreLevel(group.max_severity));
165
+ for (const id of identifiers)
166
+ advisories.delete(id);
167
+ }
168
+ }
169
+ for (const advisory of advisories)
170
+ add(advisory, 'unknown');
171
+ function add(rule, level) {
172
+ items.push(path === null ? null : { tool: 'osv-scanner', rule, category: 'dependency', level, path,
173
+ message: `Advisory for ${name}${version ? `@${version}` : ''}` });
174
+ }
175
+ }
176
+ }
177
+ return { tools: [{ name: 'osv-scanner', version: null }], items, units };
178
+ }
179
+ function advisoryId(ids) {
180
+ const sorted = [...ids].sort();
181
+ return sorted.find(id => id.startsWith('CVE-')) ?? sorted.find(id => id.startsWith('GHSA-')) ?? sorted[0];
182
+ }
183
+ function scoreLevel(value) {
184
+ const numeric = typeof value === 'string' && /^(?:\d+|\d+\.\d+)$/.test(value) ? Number(value) : value;
185
+ if (typeof numeric !== 'number' || !Number.isFinite(numeric) || numeric <= 0 || numeric > 10)
186
+ return 'unknown';
187
+ return numeric >= 7 ? 'high' : numeric >= 4 ? 'medium' : 'low';
188
+ }
189
+ function lookupLevel(value) {
190
+ return value === 'error' ? 'high' : value === 'warning' ? 'medium' : value === 'note' ? 'low' : 'unknown';
191
+ }
192
+ function range(first, last) {
193
+ if (!safeIndex(first) || first === 0)
194
+ return {};
195
+ return { line: first, endLine: safeIndex(last) && last >= first ? last : first };
196
+ }
197
+ function repositoryPath(root, path) {
198
+ if (/[\0\r\n]/.test(path))
199
+ return null;
200
+ const result = relative(root, resolve(root, path));
201
+ if (result === '' || isAbsolute(result) || result === '..' || result.startsWith(`..${sep}`))
202
+ return null;
203
+ return result.split(sep).join('/');
204
+ }
205
+ function requiredText(value) {
206
+ const result = text(value);
207
+ if (result === undefined)
208
+ throw new Error('Invalid scanner field');
209
+ return result;
210
+ }
211
+ function object(value) {
212
+ if (!isRecord(value))
213
+ throw new Error('Expected scanner object');
214
+ return value;
215
+ }
216
+ function array(value) {
217
+ if (!Array.isArray(value))
218
+ throw new Error('Expected scanner array');
219
+ return value;
220
+ }
221
+ function optionalArray(value) {
222
+ return value === undefined ? [] : array(value);
223
+ }
224
+ function safeIndex(value) {
225
+ return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
226
+ }
227
+ //# sourceMappingURL=finding-import.js.map
@@ -0,0 +1,13 @@
1
+ import type { SourceSnapshot } from '@repometry/core/internal/model/source.js';
2
+ export interface CoverageSource {
3
+ readonly root: string;
4
+ readonly snapshot: SourceSnapshot;
5
+ readonly readCommittedManifest?: (path: string) => Promise<string>;
6
+ }
7
+ interface GoSource {
8
+ readonly lines: ReadonlyMap<string, number>;
9
+ path(input: string): string;
10
+ }
11
+ export declare function goCoverSource(source: CoverageSource): Promise<GoSource>;
12
+ export declare function goCoverToLcov(text: string, input: string, source: GoSource): string;
13
+ export {};
@@ -0,0 +1,150 @@
1
+ import { lstat, readFile } from 'node:fs/promises';
2
+ import { join, posix, win32 } from 'node:path';
3
+ import { comparePaths, sourceLineCounts } from '@repometry/core/internal/model/snapshot.js';
4
+ export async function goCoverSource(source) {
5
+ const { root, snapshot } = source;
6
+ const lines = sourceLineCounts(snapshot.files.filter(({ path }) => path.endsWith('.go')));
7
+ const known = new Set([...lines.keys(), ...(snapshot.generatedExcluded ?? []),
8
+ ...(snapshot.inventory?.map(({ path }) => path) ?? [])]);
9
+ const modules = await goModules(source, known);
10
+ const platform = win32.isAbsolute(root) && !posix.isAbsolute(root) ? win32 : posix;
11
+ return {
12
+ lines,
13
+ path(input) {
14
+ const path = platform === win32 ? input.replaceAll('\\', '/') : input;
15
+ if (platform.isAbsolute(path)) {
16
+ const relative = platform.relative(root, path) || '.';
17
+ return platform === win32 ? relative.replaceAll('\\', '/') : relative;
18
+ }
19
+ const relative = posix.normalize(path);
20
+ if (path.startsWith('./') || relative.startsWith('../') || win32.isAbsolute(path))
21
+ return relative;
22
+ const candidates = new Set(modules.flatMap(({ directory, module }) => relative.startsWith(`${module}/`)
23
+ ? [posix.join(directory, relative.slice(module.length + 1))] : []));
24
+ const matches = [...new Set([relative, ...candidates])].filter(candidate => known.has(candidate));
25
+ if (matches.length > 1)
26
+ throw new Error(`Ambiguous Go coverprofile source ${JSON.stringify(input)}: ${matches.sort(comparePaths).join(', ')}`);
27
+ // Keep an unresolved import path so the normal coverage pipeline can report the missing source.
28
+ return matches[0] ?? (candidates.size === 1 ? [...candidates][0] : relative);
29
+ },
30
+ };
31
+ }
32
+ async function goModules({ root, snapshot, readCommittedManifest }, known) {
33
+ const { subject } = snapshot;
34
+ const manifests = new Set();
35
+ if (subject.kind === 'commit') {
36
+ for (const path of known)
37
+ if (posix.basename(path) === 'go.mod')
38
+ manifests.add(path);
39
+ }
40
+ else {
41
+ manifests.add('go.mod');
42
+ for (const path of known) {
43
+ if (!path.endsWith('.go'))
44
+ continue;
45
+ for (let directory = posix.dirname(path); directory !== '.'; directory = posix.dirname(directory)) {
46
+ const manifest = posix.join(directory, 'go.mod');
47
+ if (manifests.has(manifest))
48
+ break;
49
+ manifests.add(manifest);
50
+ }
51
+ }
52
+ }
53
+ const modules = await Promise.all([...manifests].map(async (path) => {
54
+ const text = subject.kind === 'commit'
55
+ ? await readCommittedManifest?.(path) ?? '' : await workingManifest(join(root, path));
56
+ return { directory: posix.dirname(path), module: modulePath(text) };
57
+ }));
58
+ return modules.flatMap(({ directory, module }) => module === undefined ? [] : [{ directory, module }]);
59
+ }
60
+ async function workingManifest(path) {
61
+ try {
62
+ return (await lstat(path)).isFile() ? await readFile(path, 'utf8') : '';
63
+ }
64
+ catch (error) {
65
+ if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR'))
66
+ return '';
67
+ throw error;
68
+ }
69
+ }
70
+ function modulePath(text) {
71
+ let grouped = false;
72
+ for (const raw of text.split(/\r?\n/)) {
73
+ const line = raw.replace(/\/\/.*$/, '').trim();
74
+ if (line === '')
75
+ continue;
76
+ const value = grouped ? line : /^module[ \t]+(.+)$/.exec(line)?.[1];
77
+ if (value === undefined)
78
+ continue;
79
+ if (value === '(') {
80
+ grouped = true;
81
+ continue;
82
+ }
83
+ const path = value.replace(/^"([^"]*)"$|^`([^`]*)`$/, '$1$2');
84
+ if (/^[A-Za-z0-9_.~-]+(?:\/[A-Za-z0-9_.~-]+)*$/.test(path) && !path.split('/').some(part => part === '.' || part === '..')) {
85
+ return path;
86
+ }
87
+ return undefined;
88
+ }
89
+ }
90
+ export function goCoverToLcov(text, input, source) {
91
+ const [header, ...records] = text.split(/\r?\n/);
92
+ const mode = /^mode: (set|count|atomic)$/.exec(header ?? '')?.[1];
93
+ if (!mode)
94
+ throw new Error(`Invalid Go coverprofile ${input} at line 1: expected mode: set, count, or atomic`);
95
+ const files = new Map();
96
+ const paths = new Map();
97
+ for (const [index, record] of records.entries()) {
98
+ if (record === '' && index === records.length - 1)
99
+ break;
100
+ const invalid = (reason) => new Error(`Invalid Go coverprofile ${input} at line ${index + 2}: ${reason}`);
101
+ const match = /^([^\0]+):(\d+)\.(\d+),(\d+)\.(\d+) (\d+) (\d+)$/.exec(record);
102
+ if (!match)
103
+ throw invalid('expected file:startLine.startColumn,endLine.endColumn statements hits');
104
+ const [first, startColumn, end, endColumn, statements, count] = match.slice(2).map(Number);
105
+ if (![first, startColumn, end, endColumn, statements, count].every(Number.isSafeInteger)
106
+ || first < 1 || startColumn < 1 || endColumn < 1 || end < first || (end === first && endColumn < startColumn)) {
107
+ throw invalid('invalid block coordinates or counts');
108
+ }
109
+ const raw = match[1];
110
+ const path = paths.get(raw) ?? source.path(raw);
111
+ paths.set(raw, path);
112
+ const blocks = files.get(path) ?? new Map();
113
+ files.set(path, blocks);
114
+ const key = `${first}.${startColumn},${end}.${endColumn}`;
115
+ const previous = blocks.get(key);
116
+ if (previous && previous.statements !== statements)
117
+ throw invalid('conflicting statement counts for the same block');
118
+ const hits = mode === 'set' ? Number((previous?.hits ?? 0) > 0 || count > 0) : (previous?.hits ?? 0) + count;
119
+ if (!Number.isSafeInteger(hits))
120
+ throw invalid('hit count exceeds the supported integer range');
121
+ // Go's end column is exclusive. A block ending at column 1 never touches that source line.
122
+ const last = end - Number(endColumn === 1);
123
+ blocks.set(key, { first, last: end === first && endColumn === startColumn ? first - 1 : last, statements, hits });
124
+ }
125
+ return renderLcov(files, source.lines);
126
+ }
127
+ function renderLcov(files, sourceLines) {
128
+ const output = [];
129
+ for (const [path, blocks] of [...files].sort(([left], [right]) => comparePaths(left, right))) {
130
+ output.push(`SF:${path}`);
131
+ const lines = new Map();
132
+ const length = sourceLines.get(path);
133
+ if (length !== undefined) {
134
+ for (const { first, last, statements, hits } of blocks.values()) {
135
+ if (statements === 0 || first > last)
136
+ continue;
137
+ // Include a single out-of-range line to let LCOV flag stale coverage without expanding arbitrary coordinates.
138
+ for (let line = Math.min(first, length + 1); line <= Math.min(last, length + 1); line++) {
139
+ // Separate blocks on one line can observe the same execution.
140
+ lines.set(line, Math.max(lines.get(line) ?? 0, hits));
141
+ }
142
+ }
143
+ }
144
+ for (const [line, hits] of [...lines].sort(([left], [right]) => left - right))
145
+ output.push(`DA:${line},${hits}`);
146
+ output.push('end_of_record');
147
+ }
148
+ return output.join('\n');
149
+ }
150
+ //# sourceMappingURL=go-cover.js.map
@@ -0,0 +1,12 @@
1
+ import type { CoverageSource } from './go-cover.js';
2
+ export type LcovFiles = string | readonly string[];
3
+ export interface CoverageInputs {
4
+ readonly lcov?: LcovFiles;
5
+ readonly goCover?: LcovFiles;
6
+ readonly cobertura?: LcovFiles;
7
+ }
8
+ export declare function hasCoverageInputs({ lcov, goCover, cobertura }: CoverageInputs): boolean;
9
+ export declare function readCoverageFiles({ lcov, goCover, cobertura }: CoverageInputs, source: CoverageSource): Promise<{
10
+ text: string;
11
+ inputDigests: string[];
12
+ }>;
@@ -0,0 +1,53 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { comparePaths, digest, utf8 } from '@repometry/core/internal/model/snapshot.js';
3
+ import { coberturaToLcov } from './cobertura.js';
4
+ import { goCoverSource, goCoverToLcov } from './go-cover.js';
5
+ export function hasCoverageInputs({ lcov, goCover, cobertura }) {
6
+ return lcov !== undefined || goCover !== undefined || cobertura !== undefined;
7
+ }
8
+ export async function readCoverageFiles({ lcov, goCover, cobertura }, source) {
9
+ const lcovPaths = paths(lcov);
10
+ const goPaths = paths(goCover);
11
+ const coberturaPaths = paths(cobertura);
12
+ if (lcov !== undefined && lcovPaths.length === 0)
13
+ throw new Error('Provide at least one LCOV file');
14
+ if (goCover !== undefined && goPaths.length === 0)
15
+ throw new Error('Provide at least one Go coverprofile');
16
+ if (cobertura !== undefined && coberturaPaths.length === 0)
17
+ throw new Error('Provide at least one Cobertura file');
18
+ if (lcovPaths.length === 0 && goPaths.length === 0 && coberturaPaths.length === 0)
19
+ throw new Error('Provide at least one coverage input');
20
+ const [lcovSources, goSources, coberturaSources] = await Promise.all([
21
+ Promise.all(lcovPaths.map(readInput)),
22
+ readGoCoverFiles(goPaths, source),
23
+ Promise.all(coberturaPaths.map(file => readCobertura(file, source))),
24
+ ]);
25
+ const sources = [...lcovSources, ...goSources, ...coberturaSources];
26
+ sources.sort((a, b) => comparePaths(a.digest, b.digest));
27
+ return { text: sources.map(source => source.text).join('\n'), inputDigests: sources.map(source => source.digest) };
28
+ }
29
+ function paths(input) {
30
+ return typeof input === 'string' ? [input] : input ?? [];
31
+ }
32
+ async function readGoCoverFiles(files, source) {
33
+ if (files.length === 0)
34
+ return [];
35
+ const [goSource, inputs] = await Promise.all([goCoverSource(source), Promise.all(files.map(readInput))]);
36
+ return inputs.map((input, index) => ({ ...input, text: goCoverToLcov(input.text, files[index], goSource) }));
37
+ }
38
+ async function readCobertura(path, source) {
39
+ const bytes = await readFile(path);
40
+ let text;
41
+ try {
42
+ text = utf8(bytes);
43
+ }
44
+ catch (error) {
45
+ throw new Error('Invalid Cobertura report ' + path + ' at line 1: invalid UTF-8', { cause: error });
46
+ }
47
+ return { text: coberturaToLcov(text, path, source), digest: digest(text) };
48
+ }
49
+ async function readInput(path) {
50
+ const text = utf8(await readFile(path));
51
+ return { text, digest: digest(text) };
52
+ }
53
+ //# sourceMappingURL=lcov-files.js.map
@@ -0,0 +1,4 @@
1
+ export declare function readProfile(file: string | undefined, optional?: boolean): Promise<{
2
+ exclude: readonly string[];
3
+ ignore: readonly import("@repometry/core/internal/model/ignore-rule.js").FindingIgnoreRule[];
4
+ }>;
@@ -0,0 +1,17 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { normalizeProfile } from '@repometry/core/internal/profile/profile.js';
3
+ export async function readProfile(file, optional = false) {
4
+ if (file === undefined)
5
+ return { exclude: [], ignore: [] };
6
+ let text;
7
+ try {
8
+ text = await readFile(file, 'utf8');
9
+ }
10
+ catch (error) {
11
+ if (optional && error instanceof Error && 'code' in error && error.code === 'ENOENT')
12
+ return { exclude: [], ignore: [] };
13
+ throw error;
14
+ }
15
+ return normalizeProfile(JSON.parse(text));
16
+ }
17
+ //# sourceMappingURL=profile-file.js.map
@@ -0,0 +1,13 @@
1
+ import type { ToolInvocation, ToolResult, ToolRunner } from '@repometry/core/internal/ports/tool-runner.js';
2
+ export interface DockerToolLimits {
3
+ readonly memoryBytes?: number;
4
+ readonly pidsLimit?: number;
5
+ }
6
+ export declare class DockerToolRunner implements ToolRunner {
7
+ private readonly image;
8
+ readonly network = "none";
9
+ readonly implementation: string;
10
+ private readonly limits;
11
+ constructor(image: string, { memoryBytes, pidsLimit }?: DockerToolLimits);
12
+ run(invocation: ToolInvocation): Promise<ToolResult>;
13
+ }
@@ -0,0 +1,92 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { mkdtemp, rm } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { join } from 'node:path';
6
+ import { promisify } from 'node:util';
7
+ import { toolFailure } from './failure.js';
8
+ import { validateToolInvocation, writeToolSnapshot } from './tool-snapshot.js';
9
+ const docker = promisify(execFile);
10
+ const proxyOverrides = ['HTTP_PROXY', 'HTTPS_PROXY', 'FTP_PROXY', 'ALL_PROXY', 'NO_PROXY']
11
+ .flatMap(name => ['--env', `${name}=`, '--env', `${name.toLowerCase()}=`]);
12
+ export class DockerToolRunner {
13
+ image;
14
+ network = 'none';
15
+ implementation;
16
+ limits;
17
+ constructor(image, { memoryBytes, pidsLimit } = {}) {
18
+ this.image = image;
19
+ if (!image || /[\s\0]/.test(image))
20
+ throw new Error('A locally available Docker image is required');
21
+ if ([memoryBytes, pidsLimit].some(value => value !== undefined && (!Number.isSafeInteger(value) || value < 1))) {
22
+ throw new Error('Docker memory and process limits must be positive integers');
23
+ }
24
+ this.limits = [...(memoryBytes === undefined ? [] : ['--memory', String(memoryBytes)]),
25
+ ...(pidsLimit === undefined ? [] : ['--pids-limit', String(pidsLimit)])];
26
+ this.implementation = JSON.stringify(['docker-tool-runner/v2', image, this.limits]);
27
+ }
28
+ async run(invocation) {
29
+ validateToolInvocation(invocation);
30
+ const [command, ...args] = invocation.argv;
31
+ const directory = await mkdtemp(join(tmpdir(), 'repometry-tool-'));
32
+ const container = `repometry-tool-${randomUUID()}`;
33
+ try {
34
+ await writeToolSnapshot(directory, invocation.files);
35
+ const mount = `type=bind,"source=${directory.replaceAll('"', '""')}",target=/snapshot,readonly`;
36
+ const uid = process.getuid?.();
37
+ const gid = process.getgid?.();
38
+ const user = uid === undefined || gid === undefined ? [] : ['--user', `${uid}:${gid}`];
39
+ let result;
40
+ try {
41
+ result = await runTool([
42
+ 'run', '--rm', '--name', container, '--interactive', '--pull', 'never', '--network', 'none', '--read-only',
43
+ '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--tmpfs', '/tmp:rw,nosuid,nodev', '--env', 'HOME=/tmp',
44
+ ...this.limits, ...user, ...proxyOverrides,
45
+ '--mount', mount, '--workdir', '/snapshot', '--entrypoint', command, '--', this.image, ...args,
46
+ ], invocation);
47
+ }
48
+ catch (error) {
49
+ await removeContainer(container);
50
+ throw error;
51
+ }
52
+ if ([125, 126, 127].includes(result.exitCode)) {
53
+ throw new Error(toolFailure(`Docker could not start the tool (exit code ${result.exitCode})`, result.stderr));
54
+ }
55
+ return result;
56
+ }
57
+ finally {
58
+ await rm(directory, { recursive: true, force: true });
59
+ }
60
+ }
61
+ }
62
+ function runTool(args, { stdin, timeoutMs, maxOutputBytes }) {
63
+ return new Promise((resolve, reject) => {
64
+ const child = execFile('docker', args, { encoding: 'buffer', timeout: timeoutMs, maxBuffer: maxOutputBytes, killSignal: 'SIGKILL' }, (error, stdout, stderr) => {
65
+ if (error?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' || stdout.length + stderr.length > maxOutputBytes) {
66
+ reject(new Error('Tool exceeded the output limit'));
67
+ }
68
+ else if (error?.killed) {
69
+ reject(new Error('Tool timed out'));
70
+ }
71
+ else if (error && typeof error.code !== 'number') {
72
+ reject(new Error('Could not run the Docker tool', { cause: error }));
73
+ }
74
+ else {
75
+ resolve({ exitCode: typeof error?.code === 'number' ? error.code : 0, stdout, stderr });
76
+ }
77
+ });
78
+ child.stdin?.on('error', () => { });
79
+ child.stdin?.end(stdin);
80
+ });
81
+ }
82
+ async function removeContainer(container) {
83
+ try {
84
+ await docker('docker', ['rm', '-f', '-v', container], { timeout: 5_000, maxBuffer: 16_384 });
85
+ }
86
+ catch (error) {
87
+ if (error instanceof Error && 'stderr' in error && String(error.stderr).includes('No such container'))
88
+ return;
89
+ throw new Error('Could not confirm Docker tool cleanup', { cause: error });
90
+ }
91
+ }
92
+ //# sourceMappingURL=docker-tool-runner.js.map
@@ -0,0 +1 @@
1
+ export declare function toolFailure(message: string, stderr: Uint8Array): string;
@@ -0,0 +1,12 @@
1
+ const credentialAssignment = /\b[\w.-]*(?:password|passwd|secret|token|credential|authorization|api[_-]?key|private[_-]?key)[\w.-]*["']?\s*[:=]/i;
2
+ export function toolFailure(message, stderr) {
3
+ const lines = new TextDecoder().decode(stderr).split(/\r?\n/).map(line => line.trim()).filter(Boolean).slice(-3);
4
+ const tail = lines.map(line => {
5
+ if (credentialAssignment.test(line))
6
+ return '[redacted tool output]';
7
+ return line.replace(/[\p{Cc}\p{Cf}]/gu, '').replace(/:\/\/[^/\s]+@/g, '://[redacted]@')
8
+ .replace(/[A-Za-z0-9_+=-]{32,}/g, '[redacted]').slice(0, 240);
9
+ });
10
+ return tail.length ? `${message}\n${tail.join('\n')}` : message;
11
+ }
12
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1,13 @@
1
+ import type { Operation, Plugin } from '@repometry/core/internal/engine/plugin.js';
2
+ import type { ToolInvocation, ToolRunner } from '@repometry/core/internal/ports/tool-runner.js';
3
+ export declare const pluginRequestSchema = "urn:repometry:schema:plugin-request:1";
4
+ export interface ProcessOperation extends Omit<Operation, 'execute'>, Pick<ToolInvocation, 'argv' | 'timeoutMs' | 'maxOutputBytes'> {
5
+ }
6
+ export interface ProcessPluginManifest extends Omit<Plugin, 'operations' | 'tools'> {
7
+ readonly operations: readonly ProcessOperation[];
8
+ readonly tools: Readonly<Record<string, string>>;
9
+ }
10
+ type ProcessRunner = Pick<ToolRunner, 'run' | 'implementation'>;
11
+ export declare function processPlugin(manifest: ProcessPluginManifest, runner: ToolRunner): Plugin;
12
+ export declare function bindProcessPlugin({ operations, ...manifest }: ProcessPluginManifest, runner: ProcessRunner): Plugin;
13
+ export {};