pepr 0.46.2 → 0.46.3-nightly.1

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 (286) hide show
  1. package/dist/cli/banner.d.ts.map +1 -0
  2. package/dist/cli/build.d.ts.map +1 -0
  3. package/dist/cli/build.helpers.d.ts.map +1 -0
  4. package/dist/cli/deploy.d.ts.map +1 -0
  5. package/dist/cli/dev.d.ts.map +1 -0
  6. package/dist/cli/format.d.ts.map +1 -0
  7. package/dist/cli/format.helpers.d.ts.map +1 -0
  8. package/dist/cli/init/enums.d.ts.map +1 -0
  9. package/dist/cli/init/index.d.ts.map +1 -0
  10. package/dist/{src/cli → cli}/init/templates.d.ts +2 -6
  11. package/dist/cli/init/templates.d.ts.map +1 -0
  12. package/dist/cli/init/utils.d.ts.map +1 -0
  13. package/dist/cli/init/walkthrough.d.ts.map +1 -0
  14. package/dist/cli/kfc.d.ts.map +1 -0
  15. package/dist/cli/monitor.d.ts.map +1 -0
  16. package/dist/cli/root.d.ts.map +1 -0
  17. package/dist/cli/types.d.ts.map +1 -0
  18. package/dist/cli/update.d.ts.map +1 -0
  19. package/dist/cli/uuid.d.ts.map +1 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +79 -23
  22. package/dist/controller.js +1 -1
  23. package/dist/fixtures/loader.d.ts.map +1 -0
  24. package/dist/lib/assets/assets.d.ts.map +1 -0
  25. package/dist/lib/assets/defaultTestObjects.d.ts.map +1 -0
  26. package/dist/lib/assets/deploy.d.ts.map +1 -0
  27. package/dist/lib/assets/destroy.d.ts.map +1 -0
  28. package/dist/lib/assets/helm.d.ts.map +1 -0
  29. package/dist/lib/assets/index.d.ts.map +1 -0
  30. package/dist/lib/assets/loader.d.ts.map +1 -0
  31. package/dist/lib/assets/networking.d.ts.map +1 -0
  32. package/dist/lib/assets/pods.d.ts.map +1 -0
  33. package/dist/lib/assets/rbac.d.ts.map +1 -0
  34. package/dist/lib/assets/store.d.ts.map +1 -0
  35. package/dist/lib/assets/webhooks.d.ts.map +1 -0
  36. package/dist/lib/assets/yaml/generateAllYaml.d.ts.map +1 -0
  37. package/dist/lib/assets/yaml/generateZarfYaml.d.ts.map +1 -0
  38. package/dist/lib/assets/yaml/overridesFile.d.ts.map +1 -0
  39. package/dist/lib/common-types.d.ts.map +1 -0
  40. package/dist/lib/controller/index.d.ts.map +1 -0
  41. package/dist/lib/controller/index.util.d.ts.map +1 -0
  42. package/dist/lib/controller/store.d.ts.map +1 -0
  43. package/dist/lib/controller/storeCache.d.ts.map +1 -0
  44. package/dist/lib/core/capability.d.ts.map +1 -0
  45. package/dist/lib/core/envChecks.d.ts.map +1 -0
  46. package/dist/lib/core/module.d.ts.map +1 -0
  47. package/dist/lib/core/queue.d.ts.map +1 -0
  48. package/dist/lib/core/schedule.d.ts.map +1 -0
  49. package/dist/lib/core/storage.d.ts.map +1 -0
  50. package/dist/lib/deploymentChecks.d.ts.map +1 -0
  51. package/dist/lib/enums.d.ts.map +1 -0
  52. package/dist/lib/errors.d.ts.map +1 -0
  53. package/dist/lib/filesystemService.d.ts.map +1 -0
  54. package/dist/lib/filter/adjudicators/admissionRequest.d.ts.map +1 -0
  55. package/dist/lib/filter/adjudicators/binding.d.ts.map +1 -0
  56. package/dist/lib/filter/adjudicators/defaultTestObjects.d.ts.map +1 -0
  57. package/dist/lib/filter/adjudicators/kubernetesObject.d.ts.map +1 -0
  58. package/dist/lib/filter/adjudicators/mismatch.d.ts.map +1 -0
  59. package/dist/lib/filter/adjudicators/postCollection.d.ts.map +1 -0
  60. package/dist/lib/filter/filter.d.ts.map +1 -0
  61. package/dist/lib/finalizer.d.ts.map +1 -0
  62. package/dist/lib/helpers.d.ts.map +1 -0
  63. package/dist/lib/included-files.d.ts.map +1 -0
  64. package/dist/lib/k8s.d.ts.map +1 -0
  65. package/dist/lib/mutate-request.d.ts.map +1 -0
  66. package/dist/lib/processors/decode-utils.d.ts.map +1 -0
  67. package/dist/lib/processors/mutate-processor.d.ts.map +1 -0
  68. package/dist/lib/processors/validate-processor.d.ts.map +1 -0
  69. package/dist/lib/processors/watch-processor.d.ts.map +1 -0
  70. package/dist/lib/telemetry/logger.d.ts.map +1 -0
  71. package/dist/lib/telemetry/metrics.d.ts.map +1 -0
  72. package/dist/lib/telemetry/timeUtils.d.ts.map +1 -0
  73. package/dist/lib/telemetry/webhookTimeouts.d.ts.map +1 -0
  74. package/dist/lib/tls.d.ts.map +1 -0
  75. package/dist/lib/types.d.ts.map +1 -0
  76. package/dist/lib/utils.d.ts.map +1 -0
  77. package/dist/lib/validate-request.d.ts.map +1 -0
  78. package/dist/lib.d.ts.map +1 -0
  79. package/dist/lib.js +124 -38
  80. package/dist/lib.js.map +2 -2
  81. package/dist/{src/runtime → runtime}/controller.d.ts.map +1 -1
  82. package/dist/sdk/heredoc.d.ts.map +1 -0
  83. package/dist/sdk/sdk.d.ts.map +1 -0
  84. package/package.json +8 -13
  85. package/src/lib/assets/assets.ts +46 -11
  86. package/src/lib/assets/defaultTestObjects.ts +13 -2
  87. package/src/lib/assets/deploy.ts +25 -5
  88. package/src/lib/assets/index.ts +8 -2
  89. package/src/lib/assets/pods.ts +5 -1
  90. package/src/lib/assets/webhooks.ts +12 -3
  91. package/src/lib/assets/yaml/generateAllYaml.ts +12 -2
  92. package/src/lib/controller/index.ts +9 -3
  93. package/src/lib/core/capability.ts +32 -8
  94. package/src/lib/core/module.ts +5 -1
  95. package/src/lib/core/storage.ts +3 -1
  96. package/src/lib/deploymentChecks.ts +3 -1
  97. package/src/lib/filter/adjudicators/admissionRequest.ts +4 -1
  98. package/src/lib/filter/adjudicators/binding.ts +17 -4
  99. package/src/lib/filter/adjudicators/kubernetesObject.ts +4 -2
  100. package/src/lib/filter/adjudicators/mismatch.ts +25 -6
  101. package/src/lib/filter/adjudicators/postCollection.ts +15 -3
  102. package/src/lib/filter/filter.ts +63 -15
  103. package/src/lib/helpers.ts +36 -10
  104. package/src/lib/included-files.ts +5 -1
  105. package/src/lib/processors/decode-utils.ts +4 -1
  106. package/src/lib/processors/mutate-processor.ts +4 -1
  107. package/src/lib/processors/validate-processor.ts +4 -1
  108. package/src/lib/processors/watch-processor.ts +49 -19
  109. package/src/lib/telemetry/metrics.ts +6 -2
  110. package/src/lib/telemetry/webhookTimeouts.ts +4 -1
  111. package/src/templates/.prettierrc.json +3 -2
  112. package/src/templates/capabilities/hello-pepr.ts +2 -8
  113. package/dist/.github/workflows/pepr-excellent-examples-matrix.d.ts +0 -2
  114. package/dist/.github/workflows/pepr-excellent-examples-matrix.d.ts.map +0 -1
  115. package/dist/commitlint.config.d.ts +0 -4
  116. package/dist/commitlint.config.d.ts.map +0 -1
  117. package/dist/integration/helpers/cmd.d.ts +0 -22
  118. package/dist/integration/helpers/cmd.d.ts.map +0 -1
  119. package/dist/integration/helpers/pepr.d.ts +0 -5
  120. package/dist/integration/helpers/pepr.d.ts.map +0 -1
  121. package/dist/integration/helpers/resource.d.ts +0 -18
  122. package/dist/integration/helpers/resource.d.ts.map +0 -1
  123. package/dist/integration/helpers/time.d.ts +0 -4
  124. package/dist/integration/helpers/time.d.ts.map +0 -1
  125. package/dist/integration/helpers/workdir.d.ts +0 -12
  126. package/dist/integration/helpers/workdir.d.ts.map +0 -1
  127. package/dist/scripts/set-version.d.ts +0 -2
  128. package/dist/scripts/set-version.d.ts.map +0 -1
  129. package/dist/src/cli/banner.d.ts.map +0 -1
  130. package/dist/src/cli/build.d.ts.map +0 -1
  131. package/dist/src/cli/build.helpers.d.ts.map +0 -1
  132. package/dist/src/cli/deploy.d.ts.map +0 -1
  133. package/dist/src/cli/dev.d.ts.map +0 -1
  134. package/dist/src/cli/format.d.ts.map +0 -1
  135. package/dist/src/cli/format.helpers.d.ts.map +0 -1
  136. package/dist/src/cli/init/enums.d.ts.map +0 -1
  137. package/dist/src/cli/init/index.d.ts.map +0 -1
  138. package/dist/src/cli/init/templates.d.ts.map +0 -1
  139. package/dist/src/cli/init/utils.d.ts.map +0 -1
  140. package/dist/src/cli/init/walkthrough.d.ts.map +0 -1
  141. package/dist/src/cli/kfc.d.ts.map +0 -1
  142. package/dist/src/cli/monitor.d.ts.map +0 -1
  143. package/dist/src/cli/root.d.ts.map +0 -1
  144. package/dist/src/cli/types.d.ts.map +0 -1
  145. package/dist/src/cli/update.d.ts.map +0 -1
  146. package/dist/src/cli/uuid.d.ts.map +0 -1
  147. package/dist/src/cli.d.ts.map +0 -1
  148. package/dist/src/fixtures/loader.d.ts.map +0 -1
  149. package/dist/src/lib/assets/assets.d.ts.map +0 -1
  150. package/dist/src/lib/assets/defaultTestObjects.d.ts.map +0 -1
  151. package/dist/src/lib/assets/deploy.d.ts.map +0 -1
  152. package/dist/src/lib/assets/destroy.d.ts.map +0 -1
  153. package/dist/src/lib/assets/helm.d.ts.map +0 -1
  154. package/dist/src/lib/assets/index.d.ts.map +0 -1
  155. package/dist/src/lib/assets/loader.d.ts.map +0 -1
  156. package/dist/src/lib/assets/networking.d.ts.map +0 -1
  157. package/dist/src/lib/assets/pods.d.ts.map +0 -1
  158. package/dist/src/lib/assets/rbac.d.ts.map +0 -1
  159. package/dist/src/lib/assets/store.d.ts.map +0 -1
  160. package/dist/src/lib/assets/webhooks.d.ts.map +0 -1
  161. package/dist/src/lib/assets/yaml/generateAllYaml.d.ts.map +0 -1
  162. package/dist/src/lib/assets/yaml/generateZarfYaml.d.ts.map +0 -1
  163. package/dist/src/lib/assets/yaml/overridesFile.d.ts.map +0 -1
  164. package/dist/src/lib/common-types.d.ts.map +0 -1
  165. package/dist/src/lib/controller/index.d.ts.map +0 -1
  166. package/dist/src/lib/controller/index.util.d.ts.map +0 -1
  167. package/dist/src/lib/controller/store.d.ts.map +0 -1
  168. package/dist/src/lib/controller/storeCache.d.ts.map +0 -1
  169. package/dist/src/lib/core/capability.d.ts.map +0 -1
  170. package/dist/src/lib/core/envChecks.d.ts.map +0 -1
  171. package/dist/src/lib/core/module.d.ts.map +0 -1
  172. package/dist/src/lib/core/queue.d.ts.map +0 -1
  173. package/dist/src/lib/core/schedule.d.ts.map +0 -1
  174. package/dist/src/lib/core/storage.d.ts.map +0 -1
  175. package/dist/src/lib/deploymentChecks.d.ts.map +0 -1
  176. package/dist/src/lib/enums.d.ts.map +0 -1
  177. package/dist/src/lib/errors.d.ts.map +0 -1
  178. package/dist/src/lib/filesystemService.d.ts.map +0 -1
  179. package/dist/src/lib/filter/adjudicators/admissionRequest.d.ts.map +0 -1
  180. package/dist/src/lib/filter/adjudicators/binding.d.ts.map +0 -1
  181. package/dist/src/lib/filter/adjudicators/defaultTestObjects.d.ts.map +0 -1
  182. package/dist/src/lib/filter/adjudicators/kubernetesObject.d.ts.map +0 -1
  183. package/dist/src/lib/filter/adjudicators/mismatch.d.ts.map +0 -1
  184. package/dist/src/lib/filter/adjudicators/postCollection.d.ts.map +0 -1
  185. package/dist/src/lib/filter/filter.d.ts.map +0 -1
  186. package/dist/src/lib/finalizer.d.ts.map +0 -1
  187. package/dist/src/lib/helpers.d.ts.map +0 -1
  188. package/dist/src/lib/included-files.d.ts.map +0 -1
  189. package/dist/src/lib/k8s.d.ts.map +0 -1
  190. package/dist/src/lib/mutate-request.d.ts.map +0 -1
  191. package/dist/src/lib/processors/decode-utils.d.ts.map +0 -1
  192. package/dist/src/lib/processors/mutate-processor.d.ts.map +0 -1
  193. package/dist/src/lib/processors/validate-processor.d.ts.map +0 -1
  194. package/dist/src/lib/processors/watch-processor.d.ts.map +0 -1
  195. package/dist/src/lib/telemetry/logger.d.ts.map +0 -1
  196. package/dist/src/lib/telemetry/metrics.d.ts.map +0 -1
  197. package/dist/src/lib/telemetry/timeUtils.d.ts.map +0 -1
  198. package/dist/src/lib/telemetry/webhookTimeouts.d.ts.map +0 -1
  199. package/dist/src/lib/tls.d.ts.map +0 -1
  200. package/dist/src/lib/types.d.ts.map +0 -1
  201. package/dist/src/lib/utils.d.ts.map +0 -1
  202. package/dist/src/lib/validate-request.d.ts.map +0 -1
  203. package/dist/src/lib.d.ts.map +0 -1
  204. package/dist/src/sdk/cosign.d.ts +0 -18
  205. package/dist/src/sdk/cosign.d.ts.map +0 -1
  206. package/dist/src/sdk/heredoc.d.ts.map +0 -1
  207. package/dist/src/sdk/sdk.d.ts.map +0 -1
  208. package/src/lib/.prettierrc +0 -14
  209. package/src/sdk/cosign.ts +0 -327
  210. /package/dist/{src/cli → cli}/banner.d.ts +0 -0
  211. /package/dist/{src/cli → cli}/build.d.ts +0 -0
  212. /package/dist/{src/cli → cli}/build.helpers.d.ts +0 -0
  213. /package/dist/{src/cli → cli}/deploy.d.ts +0 -0
  214. /package/dist/{src/cli → cli}/dev.d.ts +0 -0
  215. /package/dist/{src/cli → cli}/format.d.ts +0 -0
  216. /package/dist/{src/cli → cli}/format.helpers.d.ts +0 -0
  217. /package/dist/{src/cli → cli}/init/enums.d.ts +0 -0
  218. /package/dist/{src/cli → cli}/init/index.d.ts +0 -0
  219. /package/dist/{src/cli → cli}/init/utils.d.ts +0 -0
  220. /package/dist/{src/cli → cli}/init/walkthrough.d.ts +0 -0
  221. /package/dist/{src/cli → cli}/kfc.d.ts +0 -0
  222. /package/dist/{src/cli → cli}/monitor.d.ts +0 -0
  223. /package/dist/{src/cli → cli}/root.d.ts +0 -0
  224. /package/dist/{src/cli → cli}/types.d.ts +0 -0
  225. /package/dist/{src/cli → cli}/update.d.ts +0 -0
  226. /package/dist/{src/cli → cli}/uuid.d.ts +0 -0
  227. /package/dist/{src/cli.d.ts → cli.d.ts} +0 -0
  228. /package/dist/{src/fixtures → fixtures}/loader.d.ts +0 -0
  229. /package/dist/{src/lib → lib}/assets/assets.d.ts +0 -0
  230. /package/dist/{src/lib → lib}/assets/defaultTestObjects.d.ts +0 -0
  231. /package/dist/{src/lib → lib}/assets/deploy.d.ts +0 -0
  232. /package/dist/{src/lib → lib}/assets/destroy.d.ts +0 -0
  233. /package/dist/{src/lib → lib}/assets/helm.d.ts +0 -0
  234. /package/dist/{src/lib → lib}/assets/index.d.ts +0 -0
  235. /package/dist/{src/lib → lib}/assets/loader.d.ts +0 -0
  236. /package/dist/{src/lib → lib}/assets/networking.d.ts +0 -0
  237. /package/dist/{src/lib → lib}/assets/pods.d.ts +0 -0
  238. /package/dist/{src/lib → lib}/assets/rbac.d.ts +0 -0
  239. /package/dist/{src/lib → lib}/assets/store.d.ts +0 -0
  240. /package/dist/{src/lib → lib}/assets/webhooks.d.ts +0 -0
  241. /package/dist/{src/lib → lib}/assets/yaml/generateAllYaml.d.ts +0 -0
  242. /package/dist/{src/lib → lib}/assets/yaml/generateZarfYaml.d.ts +0 -0
  243. /package/dist/{src/lib → lib}/assets/yaml/overridesFile.d.ts +0 -0
  244. /package/dist/{src/lib → lib}/common-types.d.ts +0 -0
  245. /package/dist/{src/lib → lib}/controller/index.d.ts +0 -0
  246. /package/dist/{src/lib → lib}/controller/index.util.d.ts +0 -0
  247. /package/dist/{src/lib → lib}/controller/store.d.ts +0 -0
  248. /package/dist/{src/lib → lib}/controller/storeCache.d.ts +0 -0
  249. /package/dist/{src/lib → lib}/core/capability.d.ts +0 -0
  250. /package/dist/{src/lib → lib}/core/envChecks.d.ts +0 -0
  251. /package/dist/{src/lib → lib}/core/module.d.ts +0 -0
  252. /package/dist/{src/lib → lib}/core/queue.d.ts +0 -0
  253. /package/dist/{src/lib → lib}/core/schedule.d.ts +0 -0
  254. /package/dist/{src/lib → lib}/core/storage.d.ts +0 -0
  255. /package/dist/{src/lib → lib}/deploymentChecks.d.ts +0 -0
  256. /package/dist/{src/lib → lib}/enums.d.ts +0 -0
  257. /package/dist/{src/lib → lib}/errors.d.ts +0 -0
  258. /package/dist/{src/lib → lib}/filesystemService.d.ts +0 -0
  259. /package/dist/{src/lib → lib}/filter/adjudicators/admissionRequest.d.ts +0 -0
  260. /package/dist/{src/lib → lib}/filter/adjudicators/binding.d.ts +0 -0
  261. /package/dist/{src/lib → lib}/filter/adjudicators/defaultTestObjects.d.ts +0 -0
  262. /package/dist/{src/lib → lib}/filter/adjudicators/kubernetesObject.d.ts +0 -0
  263. /package/dist/{src/lib → lib}/filter/adjudicators/mismatch.d.ts +0 -0
  264. /package/dist/{src/lib → lib}/filter/adjudicators/postCollection.d.ts +0 -0
  265. /package/dist/{src/lib → lib}/filter/filter.d.ts +0 -0
  266. /package/dist/{src/lib → lib}/finalizer.d.ts +0 -0
  267. /package/dist/{src/lib → lib}/helpers.d.ts +0 -0
  268. /package/dist/{src/lib → lib}/included-files.d.ts +0 -0
  269. /package/dist/{src/lib → lib}/k8s.d.ts +0 -0
  270. /package/dist/{src/lib → lib}/mutate-request.d.ts +0 -0
  271. /package/dist/{src/lib → lib}/processors/decode-utils.d.ts +0 -0
  272. /package/dist/{src/lib → lib}/processors/mutate-processor.d.ts +0 -0
  273. /package/dist/{src/lib → lib}/processors/validate-processor.d.ts +0 -0
  274. /package/dist/{src/lib → lib}/processors/watch-processor.d.ts +0 -0
  275. /package/dist/{src/lib → lib}/telemetry/logger.d.ts +0 -0
  276. /package/dist/{src/lib → lib}/telemetry/metrics.d.ts +0 -0
  277. /package/dist/{src/lib → lib}/telemetry/timeUtils.d.ts +0 -0
  278. /package/dist/{src/lib → lib}/telemetry/webhookTimeouts.d.ts +0 -0
  279. /package/dist/{src/lib → lib}/tls.d.ts +0 -0
  280. /package/dist/{src/lib → lib}/types.d.ts +0 -0
  281. /package/dist/{src/lib → lib}/utils.d.ts +0 -0
  282. /package/dist/{src/lib → lib}/validate-request.d.ts +0 -0
  283. /package/dist/{src/lib.d.ts → lib.d.ts} +0 -0
  284. /package/dist/{src/runtime → runtime}/controller.d.ts +0 -0
  285. /package/dist/{src/sdk → sdk}/heredoc.d.ts +0 -0
  286. /package/dist/{src/sdk → sdk}/sdk.d.ts +0 -0
package/src/sdk/cosign.ts DELETED
@@ -1,327 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- // SPDX-FileCopyrightText: 2023-Present The Pepr Authors
3
-
4
- import { https } from "follow-redirects";
5
- import { readFile, unlink } from "node:fs/promises";
6
- import { createWriteStream } from "node:fs";
7
- import * as crypto from "node:crypto";
8
- import { PublicKeyDetails, TrustedRoot } from "@sigstore/protobuf-specs";
9
- import { bundleFromJSON } from "@sigstore/bundle";
10
- import { toSignedEntity, toTrustMaterial, Verifier } from "@sigstore/verify";
11
-
12
- export enum MediaTypeDockerV2 {
13
- Manifest = "application/vnd.docker.distribution.manifest.v2+json",
14
- }
15
-
16
- export enum MediaTypeOciV1 {
17
- Manifest = "application/vnd.oci.image.manifest.v1+json",
18
- Index = "application/vnd.oci.image.index.v1+json",
19
- }
20
-
21
- /* eslint-disable @typescript-eslint/no-explicit-any */
22
- export async function head(
23
- rawUrl: string,
24
- mediaType: string,
25
- optsParam: Record<string, any> = {},
26
- ): Promise<any> {
27
- const url = new URL(rawUrl);
28
-
29
- return new Promise((resolve, reject) => {
30
- const opts = {
31
- protocol: url.protocol,
32
- hostname: url.hostname,
33
- port: url.port,
34
- path: url.pathname,
35
- method: "HEAD",
36
- headers: { Accept: mediaType },
37
- ...optsParam,
38
- };
39
-
40
- https
41
- .request(opts, resp => {
42
- const { statusCode } = resp;
43
-
44
- let error;
45
- if (!statusCode?.toString().startsWith("2") && !statusCode?.toString().startsWith("3")) {
46
- reject(new Error(`err: status code: ${statusCode}: expected 2xx|3xx`));
47
- error = true;
48
- }
49
-
50
- if (error) {
51
- resp.resume();
52
- return;
53
- }
54
-
55
- resp.setEncoding("utf8");
56
-
57
- resp.on("data", () => {});
58
-
59
- resp.on("end", () => {
60
- resolve(resp.headers);
61
- });
62
- })
63
- .on("error", e => reject(e))
64
- .end();
65
- });
66
- }
67
-
68
- /* eslint-disable @typescript-eslint/no-explicit-any */
69
- export async function get(
70
- rawUrl: string,
71
- mediaType: string,
72
- optsParam: Record<string, any> = {},
73
- ): Promise<any> {
74
- const url = new URL(rawUrl);
75
-
76
- return new Promise((resolve, reject) => {
77
- const opts = {
78
- protocol: url.protocol,
79
- hostname: url.hostname,
80
- port: url.port,
81
- path: url.pathname,
82
- method: "GET",
83
- headers: {
84
- "User-Agent": "node",
85
- Accept: mediaType,
86
- },
87
- ...optsParam,
88
- };
89
-
90
- https
91
- .request(opts, resp => {
92
- const { statusCode } = resp;
93
-
94
- let error;
95
-
96
- if (!statusCode?.toString().startsWith("2") && !statusCode?.toString().startsWith("3")) {
97
- console.log(resp.headers);
98
- reject(new Error(`err: status code: ${statusCode}: expected 2xx`));
99
- error = true;
100
- }
101
-
102
- if (error) {
103
- resp.resume();
104
- return;
105
- }
106
-
107
- resp.setEncoding("utf8");
108
-
109
- let raw = "";
110
- resp.on("data", chunk => {
111
- raw += chunk;
112
- });
113
- resp.on("end", () => {
114
- try {
115
- resolve({ head: resp.headers, body: raw });
116
- } catch (e) {
117
- reject(e);
118
- }
119
- });
120
- })
121
- .on("error", e => reject(e))
122
- .end();
123
- });
124
- }
125
-
126
- /* eslint-disable @typescript-eslint/no-explicit-any */
127
- export async function download(
128
- rawUrl: string,
129
- localPath: string,
130
- optsParam: Record<string, any> = {},
131
- ): Promise<void> {
132
- const url = new URL(rawUrl);
133
-
134
- return new Promise((resolve, reject) => {
135
- const opts = {
136
- protocol: url.protocol,
137
- hostname: url.hostname,
138
- port: url.port,
139
- path: url.pathname,
140
- method: "GET",
141
- headers: {
142
- "User-Agent": "node",
143
- Accept: "application/octet-stream",
144
- },
145
- ...optsParam,
146
- };
147
-
148
- https
149
- .request(opts, resp => {
150
- const { statusCode } = resp;
151
-
152
- let error;
153
-
154
- if (!statusCode?.toString().startsWith("2") && !statusCode?.toString().startsWith("3")) {
155
- console.log(resp.headers);
156
- reject(new Error(`err: status code: ${statusCode}: expected 2xx`));
157
- error = true;
158
- }
159
-
160
- if (error) {
161
- resp.resume();
162
- return;
163
- }
164
-
165
- const ws = createWriteStream(localPath).on("finish", () => {
166
- ws.close(() => resolve());
167
- });
168
-
169
- resp.pipe(ws);
170
- })
171
- .on("error", async err => {
172
- await unlink(localPath);
173
- reject(err);
174
- })
175
- .end();
176
- });
177
- }
178
-
179
- //
180
- // TODO: should support using certs too
181
- //
182
-
183
- /**
184
- * Returns all containers in a pod
185
- * @param {string} iref image reference
186
- * @param {array} pubkeys list of paths to node crypto code signing pubkeys
187
- * @returns {boolean} whether the iref was signed by a key in the pubkeys
188
- */
189
- export async function verifyImage(
190
- iref: string,
191
- pubkeys: string[],
192
- tlsCrts?: string[],
193
- ): Promise<boolean> {
194
- const X: Record<string, any> = {};
195
-
196
- // <host---> / <image----------------------->
197
- // / <name---------------> : <tag->
198
- // docker.io / library / hello-world : latest
199
- //
200
- // <host> / <image------------------------------------->
201
- // / <name------------------------------> : <tag>
202
- // ttl.sh / 5dad3c9b-7ccc-4115-be27-c9244e7c0e06 : 2000m
203
-
204
- X.iref = {};
205
- X.iref.raw = iref;
206
- X.iref.host = iref.split("/")[0];
207
- X.iref.image = iref.replace(`${X.iref.host}/`, "");
208
- X.iref.tag = X.iref.image.split(":").at(-1);
209
- X.iref.name = X.iref.image.replace(`:${X.iref.tag}`, "");
210
-
211
- X.manifest = {
212
- url: `https://${X.iref.host}/v2/${X.iref.name}/manifests/${X.iref.tag}`,
213
- };
214
-
215
- const supportsMediaType = async (url: string, mediaType: string): Promise<boolean> => {
216
- return (await head(url, mediaType, { ca: tlsCrts }))["content-type"] === mediaType;
217
- };
218
-
219
- const canOciV1Manifest = async (manifestUrl: string): Promise<boolean> => {
220
- return supportsMediaType(manifestUrl, MediaTypeOciV1.Manifest);
221
- };
222
-
223
- const canDockerV2Manifest = async (manifestUrl: string): Promise<boolean> => {
224
- return supportsMediaType(manifestUrl, MediaTypeDockerV2.Manifest);
225
- };
226
-
227
- // prettier-ignore
228
- const manifestResp =
229
- await canOciV1Manifest(X.manifest.url) ? await get(X.manifest.url, MediaTypeOciV1.Manifest, {ca: tlsCrts}) :
230
- await canDockerV2Manifest(X.manifest.url) ? await get(X.manifest.url, MediaTypeDockerV2.Manifest, {ca: tlsCrts}) :
231
- (():never => { throw "Can't pull image manifest with supported MediaType." })();
232
- X.manifest.content = manifestResp.body;
233
-
234
- X.manifest.digest = `sha256:${crypto
235
- .createHash("sha256")
236
- .update(X.manifest.content)
237
- .digest("hex")
238
- .toString()}`;
239
-
240
- X.sig = {};
241
- X.sig.tag = `${X.manifest.digest.replace(":", "-")}.sig`;
242
- X.sig.triangulated = `${X.iref.host}/${X.iref.name}:${X.sig.tag}`;
243
- X.sig.url = `https://${X.iref.host}/v2/${X.iref.name}/manifests/${X.sig.tag}`;
244
-
245
- const sigManifestResp = await get(X.sig.url, MediaTypeOciV1.Manifest, { ca: tlsCrts });
246
- X.sig.manifest = sigManifestResp.body;
247
-
248
- const cosignSigLayer = JSON.parse(X.sig.manifest).layers.filter((f: any) =>
249
- Object.hasOwn(f?.annotations, "dev.cosignproject.cosign/signature"),
250
- )[0];
251
-
252
- X.sig.blob = {};
253
- X.sig.blob.digest = cosignSigLayer.digest;
254
- X.sig.blob.signature = cosignSigLayer.annotations["dev.cosignproject.cosign/signature"];
255
- X.sig.blob.url = `https://${X.iref.host}/v2/${X.iref.name}/blobs/${X.sig.blob.digest}`;
256
-
257
- const sigBlobResp = await get(X.sig.blob.url, "application/octet-stream", { ca: tlsCrts });
258
- X.sig.blob.content = sigBlobResp.body;
259
-
260
- let verified = false;
261
-
262
- for (const pubkey of pubkeys) {
263
- // https://github.com/sigstore/sigstore-js/blob/main/packages/verify/src/__tests__/verifier.test.ts
264
- const pubKeyRaw = await readFile(`${pubkey}`, { encoding: "utf8" });
265
- const pubKey = crypto.createPublicKey({
266
- key: pubKeyRaw,
267
- format: "pem",
268
- encoding: "utf-8",
269
- });
270
-
271
- const trustedRoot = {
272
- tlogs: [],
273
- ctlogs: [],
274
- timestampAuthorities: [],
275
- certificateAuthorities: [],
276
- } as unknown as TrustedRoot;
277
-
278
- const keys = {
279
- hint: {
280
- rawBytes: pubKey.export({ type: "spki", format: "der" }),
281
- keyDetails: PublicKeyDetails.PKIX_ECDSA_P256_SHA_256,
282
- },
283
- };
284
- const trustMaterial = toTrustMaterial(trustedRoot, keys);
285
-
286
- const subject = new Verifier(trustMaterial, {
287
- ctlogThreshold: 0,
288
- tlogThreshold: 0,
289
- tsaThreshold: 0,
290
- });
291
-
292
- const bundle = bundleFromJSON({
293
- mediaType: "application/vnd.dev.sigstore.bundle+json;version=0.1",
294
- verificationMaterial: {
295
- publicKey: {
296
- hint: "hint",
297
- },
298
- tlogEntries: [],
299
- timestampVerificationData: {
300
- rfc3161Timestamps: [],
301
- },
302
- },
303
- messageSignature: {
304
- messageDigest: {
305
- algorithm: "SHA2_256",
306
- digest: crypto.createHash("sha256").update(X.sig.blob.content).digest().toString(),
307
- },
308
- signature: X.sig.blob.signature,
309
- },
310
- });
311
-
312
- const signedEntity = toSignedEntity(bundle, Buffer.from(X.sig.blob.content));
313
-
314
- try {
315
- subject.verify(signedEntity);
316
- verified = true;
317
- break;
318
- } catch (e) {
319
- if (e.message.includes("signature verification failed")) {
320
- continue;
321
- }
322
- throw e;
323
- }
324
- }
325
-
326
- return verified;
327
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes