@ship.zone/runner 2.1.0 → 4.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 (200) hide show
  1. package/.smartconfig.json +118 -3
  2. package/changelog.md +101 -0
  3. package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
  4. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.json +679 -0
  5. package/dist_rust/runnerworkspace_linux_amd64_musl.third-party-notices.txt +15719 -0
  6. package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +5 -5
  7. package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
  8. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.json +679 -0
  9. package/dist_rust/runnerworkspace_linux_arm64_musl.third-party-notices.txt +15719 -0
  10. package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +5 -5
  11. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  12. package/dist_ts/00_commitinfo_data.js +9 -0
  13. package/dist_ts/api-client.d.ts +47 -0
  14. package/dist_ts/api-client.js +600 -0
  15. package/dist_ts/artifact-manager.d.ts +11 -0
  16. package/dist_ts/artifact-manager.js +140 -0
  17. package/dist_ts/attempt-state.d.ts +18 -0
  18. package/dist_ts/attempt-state.js +151 -0
  19. package/dist_ts/cache-manager.d.ts +13 -0
  20. package/dist_ts/cache-manager.js +300 -0
  21. package/dist_ts/cli-entry.d.ts +2 -0
  22. package/dist_ts/cli-entry.js +18 -0
  23. package/dist_ts/cli.d.ts +14 -0
  24. package/dist_ts/cli.js +243 -0
  25. package/dist_ts/config.d.ts +8 -0
  26. package/dist_ts/config.js +495 -0
  27. package/dist_ts/egress-proxy.d.ts +99 -0
  28. package/dist_ts/egress-proxy.js +607 -0
  29. package/dist_ts/errors.d.ts +41 -0
  30. package/dist_ts/errors.js +90 -0
  31. package/dist_ts/filesystem.d.ts +73 -0
  32. package/dist_ts/filesystem.js +207 -0
  33. package/dist_ts/index.d.ts +20 -0
  34. package/dist_ts/index.js +21 -0
  35. package/dist_ts/interfaces.d.ts +685 -0
  36. package/dist_ts/interfaces.js +3 -0
  37. package/dist_ts/log-sender.d.ts +26 -0
  38. package/dist_ts/log-sender.js +124 -0
  39. package/dist_ts/microvm-executor.d.ts +90 -0
  40. package/dist_ts/microvm-executor.js +1045 -0
  41. package/dist_ts/node-version.d.ts +11 -0
  42. package/dist_ts/node-version.js +43 -0
  43. package/dist_ts/npm-grants.d.ts +9 -0
  44. package/dist_ts/npm-grants.js +44 -0
  45. package/dist_ts/oci-registry.d.ts +73 -0
  46. package/dist_ts/oci-registry.js +508 -0
  47. package/dist_ts/plugins.d.ts +23 -0
  48. package/dist_ts/plugins.js +27 -0
  49. package/dist_ts/protocol-validator.d.ts +39 -0
  50. package/dist_ts/protocol-validator.js +488 -0
  51. package/dist_ts/redactor.d.ts +78 -0
  52. package/dist_ts/redactor.js +235 -0
  53. package/dist_ts/registration-state.d.ts +16 -0
  54. package/dist_ts/registration-state.js +171 -0
  55. package/dist_ts/runner.d.ts +65 -0
  56. package/dist_ts/runner.js +912 -0
  57. package/dist_ts/source-workspace.d.ts +10 -0
  58. package/dist_ts/source-workspace.js +125 -0
  59. package/dist_ts/spec-version.d.ts +11 -0
  60. package/dist_ts/spec-version.js +41 -0
  61. package/dist_ts/staging-scavenger.d.ts +7 -0
  62. package/dist_ts/staging-scavenger.js +63 -0
  63. package/dist_ts/state-owner.d.ts +74 -0
  64. package/dist_ts/state-owner.js +291 -0
  65. package/dist_ts/transfer-archive.d.ts +78 -0
  66. package/dist_ts/transfer-archive.js +1619 -0
  67. package/dist_ts/validation.d.ts +11 -0
  68. package/dist_ts/validation.js +79 -0
  69. package/dist_ts/vsock-protocol.d.ts +130 -0
  70. package/dist_ts/vsock-protocol.js +336 -0
  71. package/dist_ts/wire-schema.d.ts +10 -0
  72. package/dist_ts/wire-schema.js +114 -0
  73. package/native-notices/crates/bitflags-2.13.1/license-apache +201 -0
  74. package/native-notices/crates/bitflags-2.13.1/license-mit +25 -0
  75. package/native-notices/crates/cc-1.8.0/license-apache +201 -0
  76. package/native-notices/crates/cc-1.8.0/license-mit +25 -0
  77. package/native-notices/crates/cfg-if-1.0.4/license-apache +201 -0
  78. package/native-notices/crates/cfg-if-1.0.4/license-mit +25 -0
  79. package/native-notices/crates/cfg_aliases-0.2.2/license +9 -0
  80. package/native-notices/crates/cfg_aliases-0.2.2/notices.md +26 -0
  81. package/native-notices/crates/find-msvc-tools-0.1.14/license-apache +201 -0
  82. package/native-notices/crates/find-msvc-tools-0.1.14/license-mit +25 -0
  83. package/native-notices/crates/itoa-1.0.18/license-apache +176 -0
  84. package/native-notices/crates/itoa-1.0.18/license-mit +23 -0
  85. package/native-notices/crates/libc-0.2.189/license-apache +176 -0
  86. package/native-notices/crates/libc-0.2.189/license-mit +25 -0
  87. package/native-notices/crates/memchr-2.8.3/copying +3 -0
  88. package/native-notices/crates/memchr-2.8.3/license-mit +21 -0
  89. package/native-notices/crates/memchr-2.8.3/unlicense +24 -0
  90. package/native-notices/crates/nix-0.30.1/license +21 -0
  91. package/native-notices/crates/proc-macro2-1.0.107/license-apache +176 -0
  92. package/native-notices/crates/proc-macro2-1.0.107/license-mit +23 -0
  93. package/native-notices/crates/quote-1.0.47/license-apache +176 -0
  94. package/native-notices/crates/quote-1.0.47/license-mit +23 -0
  95. package/native-notices/crates/serde-1.0.229/license-apache +176 -0
  96. package/native-notices/crates/serde-1.0.229/license-mit +23 -0
  97. package/native-notices/crates/serde_core-1.0.229/license-apache +176 -0
  98. package/native-notices/crates/serde_core-1.0.229/license-mit +23 -0
  99. package/native-notices/crates/serde_derive-1.0.229/license-apache +176 -0
  100. package/native-notices/crates/serde_derive-1.0.229/license-mit +23 -0
  101. package/native-notices/crates/serde_json-1.0.151/license-apache +176 -0
  102. package/native-notices/crates/serde_json-1.0.151/license-mit +23 -0
  103. package/native-notices/crates/shlex-2.0.1/license-apache +13 -0
  104. package/native-notices/crates/shlex-2.0.1/license-mit +21 -0
  105. package/native-notices/crates/syn-3.0.3/license-apache +176 -0
  106. package/native-notices/crates/syn-3.0.3/license-mit +23 -0
  107. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-apache +201 -0
  108. package/native-notices/crates/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/license-mit +25 -0
  109. package/native-notices/crates/tikv-jemallocator-0.7.0/license-apache +201 -0
  110. package/native-notices/crates/tikv-jemallocator-0.7.0/license-mit +25 -0
  111. package/native-notices/crates/unicode-ident-1.0.24/license-apache +176 -0
  112. package/native-notices/crates/unicode-ident-1.0.24/license-mit +23 -0
  113. package/native-notices/crates/unicode-ident-1.0.24/license-unicode +39 -0
  114. package/native-notices/crates/zmij-1.0.23/license-mit +23 -0
  115. package/native-notices/manifest.json +763 -0
  116. package/native-notices/native/tikv-jemalloc-sys-0.7.1+5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8/jemalloc-5.3.1/jemalloc-copying +27 -0
  117. package/native-notices/readme.md +46 -0
  118. package/native-notices/runtime/gcc/gpl-3.0.txt +674 -0
  119. package/native-notices/runtime/gcc/runtime-library-exception-3.1.txt +73 -0
  120. package/native-notices/runtime/libunwind-22.1.2/license.txt +311 -0
  121. package/native-notices/runtime/musl-1.2.5/copyright +193 -0
  122. package/native-notices/rust/compiler-builtins-license.txt +275 -0
  123. package/native-notices/rust/copyright-library.html +8266 -0
  124. package/native-notices/rust/crates/addr2line-0.25.1/license-apache +201 -0
  125. package/native-notices/rust/crates/addr2line-0.25.1/license-mit +25 -0
  126. package/native-notices/rust/crates/adler2-2.0.1/license-0bsd +12 -0
  127. package/native-notices/rust/crates/adler2-2.0.1/license-apache +201 -0
  128. package/native-notices/rust/crates/adler2-2.0.1/license-mit +23 -0
  129. package/native-notices/rust/crates/memchr-2.7.6/copying +3 -0
  130. package/native-notices/rust/crates/memchr-2.7.6/license-mit +21 -0
  131. package/native-notices/rust/crates/memchr-2.7.6/unlicense +24 -0
  132. package/native-notices/rust/crates/miniz_oxide-0.8.9/license +25 -0
  133. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-apache.md +177 -0
  134. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-mit.md +24 -0
  135. package/native-notices/rust/crates/miniz_oxide-0.8.9/license-zlib.md +14 -0
  136. package/native-notices/rust/crates/object-0.37.3/license-apache +201 -0
  137. package/native-notices/rust/crates/object-0.37.3/license-mit +25 -0
  138. package/native-notices/rust/licenses/apache-2.0.txt +73 -0
  139. package/native-notices/rust/licenses/bsd-2-clause.txt +9 -0
  140. package/native-notices/rust/licenses/cc-by-sa-4.0.txt +427 -0
  141. package/native-notices/rust/licenses/gcc-exception-3.1.txt +30 -0
  142. package/native-notices/rust/licenses/gpl-2.0-only.txt +133 -0
  143. package/native-notices/rust/licenses/gpl-3.0-or-later.txt +202 -0
  144. package/native-notices/rust/licenses/isc.txt +7 -0
  145. package/native-notices/rust/licenses/llvm-exception.txt +15 -0
  146. package/native-notices/rust/licenses/mit.txt +9 -0
  147. package/native-notices/rust/licenses/ncsa.txt +29 -0
  148. package/native-notices/rust/licenses/ofl-1.1.txt +43 -0
  149. package/native-notices/rust/licenses/unicode-3.0.txt +39 -0
  150. package/package.json +31 -26
  151. package/readme.md +157 -95
  152. package/rust/.cargo/config.toml +1 -1
  153. package/rust/Cargo.lock +1 -0
  154. package/rust/Cargo.toml +3 -2
  155. package/rust/src/cpio.rs +147 -0
  156. package/rust/src/extfs.rs +747 -0
  157. package/rust/src/guest.rs +2411 -0
  158. package/rust/src/lib.rs +197 -1
  159. package/rust/src/main.rs +7 -2
  160. package/rust/src/oci_tar.rs +842 -0
  161. package/rust-toolchain.toml +4 -0
  162. package/ts/00_commitinfo_data.ts +2 -2
  163. package/ts/api-client.ts +29 -8
  164. package/ts/artifact-manager.ts +9 -7
  165. package/ts/attempt-state.ts +75 -84
  166. package/ts/cache-manager.ts +22 -28
  167. package/ts/cli-entry.ts +17 -0
  168. package/ts/cli.ts +86 -53
  169. package/ts/config.ts +146 -62
  170. package/ts/egress-proxy.ts +649 -0
  171. package/ts/errors.ts +19 -0
  172. package/ts/filesystem.ts +316 -0
  173. package/ts/index.ts +20 -15
  174. package/ts/interfaces.ts +105 -23
  175. package/ts/log-sender.ts +4 -4
  176. package/ts/microvm-executor.ts +1265 -0
  177. package/ts/node-version.ts +49 -0
  178. package/ts/npm-grants.ts +49 -0
  179. package/ts/oci-registry.ts +649 -0
  180. package/ts/plugins.ts +25 -3
  181. package/ts/protocol-validator.ts +34 -30
  182. package/ts/redactor.ts +2 -2
  183. package/ts/registration-state.ts +82 -90
  184. package/ts/runner.ts +81 -34
  185. package/ts/source-workspace.ts +11 -8
  186. package/ts/spec-version.ts +2 -2
  187. package/ts/staging-scavenger.ts +37 -26
  188. package/ts/state-owner.ts +353 -0
  189. package/ts/transfer-archive.ts +214 -243
  190. package/ts/validation.ts +1 -1
  191. package/ts/vsock-protocol.ts +437 -0
  192. package/ts/wire-schema.ts +3 -3
  193. package/deno.json +0 -56
  194. package/deno.lock +0 -1495
  195. package/dist_npm/mod.d.ts +0 -967
  196. package/dist_npm/mod.js +0 -10058
  197. package/mod.ts +0 -8
  198. package/musl-copyright.md +0 -81
  199. package/third-party-licenses.md +0 -187
  200. package/ts/oci-executor.ts +0 -3137
@@ -0,0 +1,99 @@
1
+ import * as plugins from './plugins.js';
2
+ import type { IEgressRule, IImageGrant } from './interfaces.js';
3
+ export declare const EGRESS_VSOCK_PORT = 1025;
4
+ export interface IResolvedAddress {
5
+ readonly address: string;
6
+ readonly family: 4 | 6;
7
+ readonly ttlSeconds: number;
8
+ }
9
+ export type TDnsResolveFn = (hostname: string, family: 4 | 6) => Promise<IResolvedAddress[]>;
10
+ export interface ICidrBlock {
11
+ readonly family: 4 | 6;
12
+ readonly network: bigint;
13
+ readonly prefixLength: number;
14
+ }
15
+ export interface IEgressProxyOptions {
16
+ readonly allow: readonly IEgressRule[];
17
+ /** Extra registry origins authorized by lease grants for `oci-image` builds (runner-plane). */
18
+ readonly grantOrigins?: readonly {
19
+ host: string;
20
+ port: number;
21
+ }[];
22
+ /** Additional deployment-declared internal CIDRs to block (e.g. coordinator networks). */
23
+ readonly blockedCidrs?: readonly string[];
24
+ /** Optional custom DNS resolver (defaults to Node `dns.promises.resolve4/resolve6`). */
25
+ readonly resolveDns?: TDnsResolveFn;
26
+ /** Optional clock for TTL verification in tests. */
27
+ readonly now?: () => number;
28
+ /** Optional loopback override ONLY for local unit tests. */
29
+ readonly allowLoopbackForTest?: boolean;
30
+ }
31
+ /** Parses an IPv4 dotted quad to a 32-bit unsigned BigInt, or returns undefined if invalid. */
32
+ export declare const parseIpv4: (ip: string) => bigint | undefined;
33
+ /** Parses an IPv6 address (including compressed `::` and IPv4-mapped `::ffff:a.b.c.d`) to 128-bit BigInt. */
34
+ export declare const parseIpv6: (ip: string) => bigint | undefined;
35
+ export declare const parseCidr: (cidr: string) => ICidrBlock;
36
+ /**
37
+ * Returns true if `ip` is globally reachable (not loopback, private, link-local, CGNAT, ULA,
38
+ * multicast, unspecified, IPv4-mapped non-global, or inside `extraBlocked`).
39
+ */
40
+ export declare const isGloballyReachableIp: (ip: string, extraBlocked?: readonly ICidrBlock[]) => boolean;
41
+ /** Validates a DNS host allowlist pattern (`exact.host` or `*.suffix.tld`). */
42
+ export declare const validateAllowHostPattern: (pattern: string) => void;
43
+ /** Matches a lowercase hostname against an allowlist pattern (`exact` or `*.suffix` at any depth). */
44
+ export declare const hostnameMatchesPattern: (hostname: string, pattern: string) => boolean;
45
+ /**
46
+ * Extracts the Server Name Indication (SNI) hostname from a TLS ClientHello record,
47
+ * or returns `undefined` if the bytes are not a valid TLS ClientHello with a `host_name` SNI.
48
+ */
49
+ export declare const extractTlsSni: (data: Uint8Array) => string | undefined;
50
+ /**
51
+ * Extracts the HTTP/1.x `Host` header hostname (without optional `:port`) from initial request bytes.
52
+ */
53
+ export declare const extractHttpHost: (data: Uint8Array) => string | undefined;
54
+ /** Converts lease grants into allowed `{ host, port }` registry origins for `oci-image` builders. */
55
+ export declare const grantOriginsFromLease: (grants: readonly IImageGrant[]) => Array<{
56
+ host: string;
57
+ port: number;
58
+ }>;
59
+ /**
60
+ * Host-side egress allowlist policy & proxy enforcing `@ship.zone/ci-spec` Network rules:
61
+ * - Resolves only `A` and `AAAA` queries for allowlisted hosts (plus optional `oci-image` grant origins).
62
+ * - Withholds and blocks all non-globally-reachable IPs and deployment-declared internal CIDRs.
63
+ * - Permits TCP dials only to IPs returned by this attempt's resolver within TTL and on an allowed port.
64
+ * - Enforces TLS SNI on port 443 and HTTP `Host` on port 80 matching the resolved allowlisted host.
65
+ */
66
+ export declare class EgressAllowlistController {
67
+ private readonly allowRules;
68
+ private readonly grantOrigins;
69
+ private readonly blockedCidrs;
70
+ private readonly resolveDnsImpl;
71
+ private readonly now;
72
+ private readonly allowLoopbackForTest;
73
+ private readonly ipBindings;
74
+ constructor(options: IEgressProxyOptions);
75
+ /** Returns the set of allowed TCP ports for `hostname`, or `undefined` if the host is not allowed. */
76
+ allowedPortsForHost(hostname: string): Set<number> | undefined;
77
+ /** Resolves `A` or `AAAA` for an allowlisted host, filtering out non-global/blocked IPs and recording TTL bindings. */
78
+ resolveQuery(hostname: string, queryType: number, queryClass?: number): Promise<{
79
+ allowed: boolean;
80
+ records: IResolvedAddress[];
81
+ }>;
82
+ private isPermittedIp;
83
+ /**
84
+ * Authorizes a TCP connection to `(ip, port)` and validates initial payload (`SNI` on 443,
85
+ * `Host` on 80) against the allowlisted hostname(s) bound to `ip` within TTL.
86
+ */
87
+ authorizeConnection(ip: string, port: number, initialPayload?: Uint8Array): {
88
+ allowed: true;
89
+ hostname: string;
90
+ } | {
91
+ allowed: false;
92
+ reason: string;
93
+ };
94
+ /**
95
+ * Proxies an outbound TCP connection from an incoming guest tunnel socket after verifying
96
+ * IP/port TTL binding and (on ports 80/443) initial SNI/Host header bytes before dialing.
97
+ */
98
+ proxyTcpStream(clientSocket: plugins.net.Socket, destinationIp: string, destinationPort: number): Promise<void>;
99
+ }