@ship.zone/runner 0.2.4 → 1.1.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.
- package/changelog.md +74 -0
- package/deno.json +18 -4
- package/deno.lock +143 -224
- package/dist_npm/mod.d.ts +297 -39
- package/dist_npm/mod.js +941 -628
- package/dist_rust/runnerworkspace_linux_amd64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_amd64_musl.tsrust-build.json +14 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl +0 -0
- package/dist_rust/runnerworkspace_linux_arm64_musl.tsrust-build.json +14 -0
- package/package.json +3 -3
- package/readme.md +65 -18
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/api-client.ts +85 -304
- package/ts/artifact-manager.ts +9 -3
- package/ts/cache-manager.ts +3 -2
- package/ts/cli.ts +16 -6
- package/ts/config.ts +50 -16
- package/ts/errors.ts +11 -0
- package/ts/index.ts +2 -0
- package/ts/interfaces.ts +196 -32
- package/ts/log-sender.ts +18 -9
- package/ts/oci-executor.ts +48 -22
- package/ts/plugins.ts +5 -1
- package/ts/protocol-validator.ts +261 -224
- package/ts/redactor.ts +229 -20
- package/ts/registration-state.ts +12 -45
- package/ts/runner.ts +116 -22
- package/ts/spec-version.ts +66 -0
- package/ts/transfer-archive.ts +25 -3
- package/ts/validation.ts +20 -0
- package/ts/wire-schema.ts +137 -0
package/ts/config.ts
CHANGED
|
@@ -21,6 +21,8 @@ const defaultOciConfig: IOciExecutorConfig = {
|
|
|
21
21
|
maximumCpus: 8,
|
|
22
22
|
defaultPids: 256,
|
|
23
23
|
maximumPids: 1024,
|
|
24
|
+
defaultSharedMemoryBytes: 64 * 1024 * 1024,
|
|
25
|
+
maximumSharedMemoryBytes: 1024 * 1024 * 1024,
|
|
24
26
|
workspaceSizeBytes: 4 * 1024 * 1024 * 1024,
|
|
25
27
|
temporarySizeBytes: 256 * 1024 * 1024,
|
|
26
28
|
stopTimeoutSeconds: 10,
|
|
@@ -157,11 +159,25 @@ const validTimestamp = (value: string): boolean => {
|
|
|
157
159
|
second <= 59 && offsetHour <= 23 && offsetMinute <= 59;
|
|
158
160
|
};
|
|
159
161
|
|
|
162
|
+
/**
|
|
163
|
+
* The OCI executor enforces only the `none` network mode: every step container gets a new network
|
|
164
|
+
* namespace with loopback only. `egress` needs a runner-provided resolver and per-attempt
|
|
165
|
+
* connection filtering that this executor does not implement, so it can be neither configured nor
|
|
166
|
+
* advertised.
|
|
167
|
+
*/
|
|
168
|
+
const requireEnforceableNetworks = (networks: readonly string[]): void => {
|
|
169
|
+
if (networks.length !== 1 || networks[0] !== 'none') {
|
|
170
|
+
throw new ConfigurationError(
|
|
171
|
+
'oci.allowedNetworks must be ["none"]: this runner does not enforce egress allowlists',
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
160
176
|
const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecutorConfig => {
|
|
161
177
|
const value = input === undefined ? {} : input;
|
|
162
178
|
if (!isRecord(value)) throw new ConfigurationError('oci must be an object');
|
|
163
179
|
if (Object.hasOwn(value, 'allowMutableImages')) {
|
|
164
|
-
throw new ConfigurationError('oci.allowMutableImages is not supported by runner protocol
|
|
180
|
+
throw new ConfigurationError('oci.allowMutableImages is not supported by the runner protocol');
|
|
165
181
|
}
|
|
166
182
|
const runtime = value.runtime ?? fallback.runtime;
|
|
167
183
|
if (runtime !== 'docker' && runtime !== 'podman') {
|
|
@@ -173,12 +189,7 @@ const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecu
|
|
|
173
189
|
'oci.allowedNetworks',
|
|
174
190
|
2,
|
|
175
191
|
);
|
|
176
|
-
|
|
177
|
-
allowedNetworks.length === 0 ||
|
|
178
|
-
allowedNetworks.some((network) => network !== 'none' && network !== 'bridge')
|
|
179
|
-
) {
|
|
180
|
-
throw new ConfigurationError('oci.allowedNetworks may only contain none or bridge');
|
|
181
|
-
}
|
|
192
|
+
requireEnforceableNetworks(allowedNetworks);
|
|
182
193
|
return {
|
|
183
194
|
runtime,
|
|
184
195
|
runtimePath: stringValue(value.runtimePath, fallback.runtimePath, 'oci.runtimePath'),
|
|
@@ -234,6 +245,20 @@ const parseOciConfig = (input: unknown, fallback: IOciExecutorConfig): IOciExecu
|
|
|
234
245
|
1,
|
|
235
246
|
1_048_576,
|
|
236
247
|
),
|
|
248
|
+
defaultSharedMemoryBytes: integerValue(
|
|
249
|
+
value.defaultSharedMemoryBytes,
|
|
250
|
+
fallback.defaultSharedMemoryBytes,
|
|
251
|
+
'oci.defaultSharedMemoryBytes',
|
|
252
|
+
1_048_576,
|
|
253
|
+
1_099_511_627_776,
|
|
254
|
+
),
|
|
255
|
+
maximumSharedMemoryBytes: integerValue(
|
|
256
|
+
value.maximumSharedMemoryBytes,
|
|
257
|
+
fallback.maximumSharedMemoryBytes,
|
|
258
|
+
'oci.maximumSharedMemoryBytes',
|
|
259
|
+
1_048_576,
|
|
260
|
+
1_099_511_627_776,
|
|
261
|
+
),
|
|
237
262
|
workspaceSizeBytes: integerValue(
|
|
238
263
|
value.workspaceSizeBytes,
|
|
239
264
|
fallback.workspaceSizeBytes,
|
|
@@ -559,6 +584,18 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
|
|
|
559
584
|
[config.oci.maximumMemoryBytes, 'oci.maximumMemoryBytes', 16_777_216, 1_099_511_627_776],
|
|
560
585
|
[config.oci.defaultPids, 'oci.defaultPids', 1, 1_048_576],
|
|
561
586
|
[config.oci.maximumPids, 'oci.maximumPids', 1, 1_048_576],
|
|
587
|
+
[
|
|
588
|
+
config.oci.defaultSharedMemoryBytes,
|
|
589
|
+
'oci.defaultSharedMemoryBytes',
|
|
590
|
+
1_048_576,
|
|
591
|
+
1_099_511_627_776,
|
|
592
|
+
],
|
|
593
|
+
[
|
|
594
|
+
config.oci.maximumSharedMemoryBytes,
|
|
595
|
+
'oci.maximumSharedMemoryBytes',
|
|
596
|
+
1_048_576,
|
|
597
|
+
1_099_511_627_776,
|
|
598
|
+
],
|
|
562
599
|
[config.oci.workspaceSizeBytes, 'oci.workspaceSizeBytes', 16_777_216, 1_099_511_627_776],
|
|
563
600
|
[config.oci.temporarySizeBytes, 'oci.temporarySizeBytes', 1, 1_099_511_627_776],
|
|
564
601
|
[config.oci.stopTimeoutSeconds, 'oci.stopTimeoutSeconds', 1, 30],
|
|
@@ -571,15 +608,7 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
|
|
|
571
608
|
if (config.oci.runtime !== 'docker' && config.oci.runtime !== 'podman') {
|
|
572
609
|
throw new ConfigurationError('oci.runtime must be docker or podman');
|
|
573
610
|
}
|
|
574
|
-
|
|
575
|
-
config.oci.allowedNetworks.length === 0 || config.oci.allowedNetworks.length > 2 ||
|
|
576
|
-
new Set(config.oci.allowedNetworks).size !== config.oci.allowedNetworks.length ||
|
|
577
|
-
config.oci.allowedNetworks.some((network) => network !== 'none' && network !== 'bridge')
|
|
578
|
-
) {
|
|
579
|
-
throw new ConfigurationError(
|
|
580
|
-
'oci.allowedNetworks may only contain unique none or bridge values',
|
|
581
|
-
);
|
|
582
|
-
}
|
|
611
|
+
requireEnforceableNetworks(config.oci.allowedNetworks);
|
|
583
612
|
if (!isAbsolute(config.oci.runtimePath)) {
|
|
584
613
|
throw new ConfigurationError('oci.runtimePath must be absolute');
|
|
585
614
|
}
|
|
@@ -602,6 +631,11 @@ export const validateRunnerConfig = (config: IRunnerConfig): void => {
|
|
|
602
631
|
if (config.oci.defaultPids > config.oci.maximumPids) {
|
|
603
632
|
throw new ConfigurationError('oci.defaultPids exceeds oci.maximumPids');
|
|
604
633
|
}
|
|
634
|
+
if (config.oci.defaultSharedMemoryBytes > config.oci.maximumSharedMemoryBytes) {
|
|
635
|
+
throw new ConfigurationError(
|
|
636
|
+
'oci.defaultSharedMemoryBytes exceeds oci.maximumSharedMemoryBytes',
|
|
637
|
+
);
|
|
638
|
+
}
|
|
605
639
|
if (
|
|
606
640
|
config.maximumSourceExtractedBytes > config.oci.workspaceSizeBytes ||
|
|
607
641
|
config.maximumArtifactExtractedBytes > config.oci.workspaceSizeBytes ||
|
package/ts/errors.ts
CHANGED
|
@@ -66,3 +66,14 @@ export class ProtocolError extends CoordinatorError {
|
|
|
66
66
|
this.name = 'ProtocolError';
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* An archive prepared for publication contains a member of the attempt's redaction set in an entry
|
|
72
|
+
* path, a link target, or file content. The archive is never published.
|
|
73
|
+
*/
|
|
74
|
+
export class SecretDisclosureError extends RunnerError {
|
|
75
|
+
constructor(message = 'Archive contains a redacted secret value and was not published') {
|
|
76
|
+
super(message);
|
|
77
|
+
this.name = 'SecretDisclosureError';
|
|
78
|
+
}
|
|
79
|
+
}
|
package/ts/index.ts
CHANGED
|
@@ -10,4 +10,6 @@ export * from './protocol-validator.ts';
|
|
|
10
10
|
export * from './redactor.ts';
|
|
11
11
|
export * from './runner.ts';
|
|
12
12
|
export * from './source-workspace.ts';
|
|
13
|
+
export * from './spec-version.ts';
|
|
13
14
|
export * from './staging-scavenger.ts';
|
|
15
|
+
export * from './wire-schema.ts';
|
package/ts/interfaces.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import * as plugins from './plugins.ts';
|
|
2
1
|
import denoConfig from '../deno.json' with { type: 'json' };
|
|
3
2
|
|
|
4
3
|
export const runnerVersion: string = denoConfig.version;
|
|
5
|
-
export const runnerProtocolIdentifier: 'foss-ci-runner/2.0-draft.2' =
|
|
6
|
-
plugins.runnerProtocolIdentifier;
|
|
7
4
|
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
10
|
-
export type TRunnerFeature = 'source.tar-gz' | 'artifacts
|
|
11
|
-
export type
|
|
5
|
+
export type TExecutionProfile = 'oci' | 'oci-image' | 'vm';
|
|
6
|
+
export type TIsolation = 'container' | 'microvm';
|
|
7
|
+
export type TRunnerFeature = 'source.tar-gz' | 'artifacts' | 'caches';
|
|
8
|
+
export type TLeaseFeature = 'image-pull-grants' | 'candidate-bindings' | 'npm-read-grants';
|
|
9
|
+
export type TNetworkMode = 'none' | 'egress';
|
|
12
10
|
export type TSourceFormat = 'tar.gz';
|
|
13
11
|
export type TOciRuntime = 'docker' | 'podman';
|
|
14
12
|
export type TArtifactPermission = 'none' | 'write';
|
|
15
13
|
export type TCachePermission = 'none' | 'read' | 'read-write';
|
|
14
|
+
export type TImagePermission = 'none' | 'push';
|
|
16
15
|
export type TCacheAccess = 'read' | 'read-write';
|
|
17
16
|
export type TArtifactWhen = 'always' | 'success' | 'failure';
|
|
18
17
|
export type TLogStream = 'stdout' | 'stderr' | 'runner';
|
|
18
|
+
export type TImageGrantAccess = 'pull' | 'push';
|
|
19
19
|
export type TJobCompletionStatus =
|
|
20
20
|
| 'succeeded'
|
|
21
21
|
| 'failed'
|
|
@@ -41,8 +41,8 @@ export interface IProtocolLimits {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface IDiscoveryResponse {
|
|
44
|
-
|
|
45
|
-
basePath: '/api/runner
|
|
44
|
+
spec: string;
|
|
45
|
+
basePath: '/api/runner';
|
|
46
46
|
status: 'draft';
|
|
47
47
|
serverTime: string;
|
|
48
48
|
limits: IProtocolLimits;
|
|
@@ -74,25 +74,40 @@ export interface ITransferLimits {
|
|
|
74
74
|
maximumWorkspaceEntries: number;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export interface IResourceLimits {
|
|
78
|
+
maximumMemoryBytes: number;
|
|
79
|
+
maximumCpus: number;
|
|
80
|
+
maximumPids: number;
|
|
81
|
+
maximumSharedMemoryBytes: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
export interface IRunnerCapabilities {
|
|
78
85
|
executionProfiles: TExecutionProfile[];
|
|
86
|
+
isolation: TIsolation[];
|
|
87
|
+
platforms: string[];
|
|
79
88
|
labels: string[];
|
|
80
89
|
features: TRunnerFeature[];
|
|
81
|
-
networks:
|
|
90
|
+
networks: TNetworkMode[];
|
|
82
91
|
sourceFormats: TSourceFormat[];
|
|
83
92
|
limits: ITransferLimits;
|
|
93
|
+
/** Defined from specification 1.1.0 on. */
|
|
94
|
+
resources?: IResourceLimits;
|
|
95
|
+
/** Defined from specification 1.2.0 on: the lease contents the runner uses. */
|
|
96
|
+
leaseFeatures?: TLeaseFeature[];
|
|
97
|
+
/** Defined from specification 1.2.0 on: the largest job `timeoutMs` the runner executes. */
|
|
98
|
+
maximumTimeoutMs?: number;
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
export interface IRegisterRunnerRequest {
|
|
87
102
|
registrationRequestId: string;
|
|
88
|
-
|
|
103
|
+
spec: string;
|
|
89
104
|
runnerVersion: string;
|
|
90
105
|
name: string;
|
|
91
106
|
capabilities: IRunnerCapabilities;
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
export interface IRegisterRunnerResponse {
|
|
95
|
-
|
|
110
|
+
spec: string;
|
|
96
111
|
serverTime: string;
|
|
97
112
|
registrationReplayUntil: string;
|
|
98
113
|
credential: IRunnerCredential;
|
|
@@ -101,14 +116,14 @@ export interface IRegisterRunnerResponse {
|
|
|
101
116
|
export interface IStartSessionRequest {
|
|
102
117
|
sessionRequestId: string;
|
|
103
118
|
runnerId: string;
|
|
104
|
-
|
|
119
|
+
spec: string;
|
|
105
120
|
runnerVersion: string;
|
|
106
121
|
capabilities: IRunnerCapabilities;
|
|
107
122
|
}
|
|
108
123
|
|
|
109
124
|
export interface IStartSessionResponse {
|
|
110
125
|
sessionId: string;
|
|
111
|
-
|
|
126
|
+
spec: string;
|
|
112
127
|
serverTime: string;
|
|
113
128
|
credential?: IRunnerCredential;
|
|
114
129
|
}
|
|
@@ -137,13 +152,53 @@ export interface IClaimJobResponse {
|
|
|
137
152
|
lease: unknown | null;
|
|
138
153
|
}
|
|
139
154
|
|
|
155
|
+
/** Attempt-scoped registry credential for one registry, repository, and access mode. */
|
|
156
|
+
export interface IImageGrant {
|
|
157
|
+
grantId: string;
|
|
158
|
+
access: TImageGrantAccess;
|
|
159
|
+
registry: string;
|
|
160
|
+
repository: string;
|
|
161
|
+
username: string;
|
|
162
|
+
secret: string;
|
|
163
|
+
expiresAt: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Resolution of one candidate reference of the job to a digest-pinned image. */
|
|
167
|
+
export interface IImageBinding {
|
|
168
|
+
candidate: string;
|
|
169
|
+
image: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Attempt-scoped read-only npm registry token for one `npmRead` entry of the job. */
|
|
173
|
+
export interface INpmGrant {
|
|
174
|
+
grantId: string;
|
|
175
|
+
registry: string;
|
|
176
|
+
scopes: string[];
|
|
177
|
+
secret: string;
|
|
178
|
+
expiresAt: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** A lease exactly as the protocol defines it, for every execution profile. */
|
|
140
182
|
export interface IJobLease {
|
|
141
183
|
jobId: string;
|
|
142
184
|
attemptId: string;
|
|
143
185
|
leaseId: string;
|
|
144
186
|
fencingToken: string;
|
|
145
187
|
leaseExpiresAt: string;
|
|
146
|
-
job:
|
|
188
|
+
job: TCompiledRunnerJob;
|
|
189
|
+
grants: IImageGrant[];
|
|
190
|
+
bindings: IImageBinding[];
|
|
191
|
+
npmGrants?: INpmGrant[];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
|
|
196
|
+
* no image grants or bindings, and no npm grants.
|
|
197
|
+
*/
|
|
198
|
+
export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> {
|
|
199
|
+
job: IOciRunnerJob;
|
|
200
|
+
grants: [];
|
|
201
|
+
bindings: [];
|
|
147
202
|
}
|
|
148
203
|
|
|
149
204
|
export interface IJobIdentity {
|
|
@@ -242,6 +297,8 @@ export interface IErrorResponse {
|
|
|
242
297
|
|
|
243
298
|
export interface IJobRequirements {
|
|
244
299
|
executionProfile: TExecutionProfile;
|
|
300
|
+
isolation: TIsolation;
|
|
301
|
+
platform?: string;
|
|
245
302
|
labels: string[];
|
|
246
303
|
features: TRunnerFeature[];
|
|
247
304
|
limits: ITransferLimits;
|
|
@@ -251,16 +308,63 @@ export interface IJobPermissions {
|
|
|
251
308
|
source: 'read';
|
|
252
309
|
artifacts: TArtifactPermission;
|
|
253
310
|
caches: TCachePermission;
|
|
254
|
-
|
|
311
|
+
images: TImagePermission;
|
|
255
312
|
}
|
|
256
313
|
|
|
314
|
+
export interface IEgressRule {
|
|
315
|
+
host: string;
|
|
316
|
+
ports: number[];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export interface INoNetwork {
|
|
320
|
+
mode: 'none';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export interface IEgressNetwork {
|
|
324
|
+
mode: 'egress';
|
|
325
|
+
allow: IEgressRule[];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type TJobNetwork = INoNetwork | IEgressNetwork;
|
|
329
|
+
|
|
330
|
+
export interface ICandidateReference {
|
|
331
|
+
candidate: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export type TImageReference = string | ICandidateReference;
|
|
335
|
+
|
|
257
336
|
export interface IOciExecution {
|
|
258
|
-
profile: 'oci
|
|
259
|
-
image:
|
|
260
|
-
|
|
337
|
+
profile: 'oci';
|
|
338
|
+
image: TImageReference;
|
|
339
|
+
workingDirectory?: string;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface IVmExecution {
|
|
343
|
+
profile: 'vm';
|
|
344
|
+
image: TImageReference;
|
|
261
345
|
workingDirectory?: string;
|
|
262
346
|
}
|
|
263
347
|
|
|
348
|
+
export interface IBuildSecret {
|
|
349
|
+
id: string;
|
|
350
|
+
environment: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface IBaseImage {
|
|
354
|
+
name: string;
|
|
355
|
+
image: TImageReference;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export interface IImageBuild {
|
|
359
|
+
context: string;
|
|
360
|
+
dockerfile: string;
|
|
361
|
+
target?: string;
|
|
362
|
+
buildArgs: Record<string, string>;
|
|
363
|
+
secrets: IBuildSecret[];
|
|
364
|
+
labels: Record<string, string>;
|
|
365
|
+
baseImages: IBaseImage[];
|
|
366
|
+
}
|
|
367
|
+
|
|
264
368
|
export interface ICompiledStep {
|
|
265
369
|
name?: string;
|
|
266
370
|
command: string[];
|
|
@@ -279,6 +383,12 @@ export interface IJobResources {
|
|
|
279
383
|
memoryBytes?: number;
|
|
280
384
|
cpus?: number;
|
|
281
385
|
pids?: number;
|
|
386
|
+
sharedMemoryBytes?: number;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export interface INpmReadEntry {
|
|
390
|
+
registry: string;
|
|
391
|
+
scopes: string[];
|
|
282
392
|
}
|
|
283
393
|
|
|
284
394
|
export interface IArtifactDeclaration {
|
|
@@ -293,10 +403,9 @@ export interface IArtifactDeclaration {
|
|
|
293
403
|
retentionDays?: number;
|
|
294
404
|
}
|
|
295
405
|
|
|
296
|
-
export interface
|
|
406
|
+
export interface IBuildCacheDeclaration {
|
|
297
407
|
name: string;
|
|
298
408
|
key: string;
|
|
299
|
-
paths: string[];
|
|
300
409
|
access: TCacheAccess;
|
|
301
410
|
maximumBytes: number;
|
|
302
411
|
maximumExtractedBytes: number;
|
|
@@ -304,23 +413,56 @@ export interface ICacheDeclaration {
|
|
|
304
413
|
retentionDays?: number;
|
|
305
414
|
}
|
|
306
415
|
|
|
307
|
-
export interface
|
|
308
|
-
|
|
416
|
+
export interface ICacheDeclaration extends IBuildCacheDeclaration {
|
|
417
|
+
paths: string[];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
interface ICompiledRunnerJobBase {
|
|
421
|
+
spec: string;
|
|
309
422
|
sourceObjectId: string;
|
|
310
423
|
workflowDigest: string;
|
|
311
424
|
compiledPlanDigest: string;
|
|
312
425
|
requirements: IJobRequirements;
|
|
313
426
|
permissions: IJobPermissions;
|
|
314
|
-
|
|
315
|
-
steps: ICompiledStep[];
|
|
427
|
+
network: TJobNetwork;
|
|
316
428
|
source: IJobSource;
|
|
317
429
|
secrets: Record<string, string>;
|
|
318
430
|
timeoutMs: number;
|
|
319
431
|
resources?: IJobResources;
|
|
432
|
+
npmRead?: INpmReadEntry[];
|
|
320
433
|
artifacts: IArtifactDeclaration[];
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** A compiled `oci` job: ordered argument-array steps in fresh containers. */
|
|
437
|
+
export interface IContainerRunnerJob extends ICompiledRunnerJobBase {
|
|
438
|
+
execution: IOciExecution;
|
|
439
|
+
steps: ICompiledStep[];
|
|
440
|
+
caches: ICacheDeclaration[];
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/** A compiled `vm` job: ordered steps as root in one microVM guest per attempt. */
|
|
444
|
+
export interface IVmRunnerJob extends ICompiledRunnerJobBase {
|
|
445
|
+
execution: IVmExecution;
|
|
446
|
+
steps: ICompiledStep[];
|
|
321
447
|
caches: ICacheDeclaration[];
|
|
322
448
|
}
|
|
323
449
|
|
|
450
|
+
/** A compiled `oci-image` job: one single-platform image build in a microVM guest. */
|
|
451
|
+
export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase {
|
|
452
|
+
build: IImageBuild;
|
|
453
|
+
caches: IBuildCacheDeclaration[];
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/** Every compiled job shape the published runner job schema admits. */
|
|
457
|
+
export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
|
|
458
|
+
|
|
459
|
+
/** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
|
|
460
|
+
export interface IOciRunnerJob extends IContainerRunnerJob {
|
|
461
|
+
requirements: IJobRequirements & { executionProfile: 'oci'; isolation: 'container' };
|
|
462
|
+
network: INoNetwork;
|
|
463
|
+
execution: IOciExecution & { image: string };
|
|
464
|
+
}
|
|
465
|
+
|
|
324
466
|
export interface ITransferMetadata {
|
|
325
467
|
sha256: string;
|
|
326
468
|
sizeBytes: number;
|
|
@@ -381,7 +523,7 @@ export interface IOciExecutorConfig {
|
|
|
381
523
|
runtimePath: string;
|
|
382
524
|
workspaceHelperPath?: string;
|
|
383
525
|
requireRootless: boolean;
|
|
384
|
-
allowedNetworks:
|
|
526
|
+
allowedNetworks: TNetworkMode[];
|
|
385
527
|
containerUser: string;
|
|
386
528
|
defaultTimeoutMs: number;
|
|
387
529
|
maximumTimeoutMs: number;
|
|
@@ -391,6 +533,8 @@ export interface IOciExecutorConfig {
|
|
|
391
533
|
maximumCpus: number;
|
|
392
534
|
defaultPids: number;
|
|
393
535
|
maximumPids: number;
|
|
536
|
+
defaultSharedMemoryBytes: number;
|
|
537
|
+
maximumSharedMemoryBytes: number;
|
|
394
538
|
workspaceSizeBytes: number;
|
|
395
539
|
temporarySizeBytes: number;
|
|
396
540
|
stopTimeoutSeconds: number;
|
|
@@ -426,9 +570,14 @@ export interface IRunnerConfig extends ITransferManagerConfig {
|
|
|
426
570
|
export interface IExecutionContext {
|
|
427
571
|
runnerId: string;
|
|
428
572
|
sessionId: string;
|
|
429
|
-
lease:
|
|
573
|
+
lease: IOciJobLease;
|
|
430
574
|
preparedLease: IPreparedOciLease;
|
|
431
575
|
workspacePath: string;
|
|
576
|
+
/**
|
|
577
|
+
* Milliseconds left until the attempt deadline when execution starts: the job `timeoutMs`
|
|
578
|
+
* counted from the acceptance 204, less the time source extraction and cache restoration took.
|
|
579
|
+
*/
|
|
580
|
+
timeoutMs: number;
|
|
432
581
|
signal: AbortSignal;
|
|
433
582
|
terminationDeadline?: () => number | undefined;
|
|
434
583
|
onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
|
|
@@ -449,7 +598,7 @@ export interface IOciRuntimeFacts {
|
|
|
449
598
|
export interface IPrepareOciLeaseContext {
|
|
450
599
|
runnerId: string;
|
|
451
600
|
sessionId: string;
|
|
452
|
-
lease:
|
|
601
|
+
lease: IOciJobLease;
|
|
453
602
|
signal: AbortSignal;
|
|
454
603
|
}
|
|
455
604
|
|
|
@@ -506,7 +655,7 @@ export interface IPreparedWorkspace {
|
|
|
506
655
|
|
|
507
656
|
export interface ISourcePrepareContext {
|
|
508
657
|
identity: IJobIdentity;
|
|
509
|
-
job: Pick<
|
|
658
|
+
job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
|
|
510
659
|
signal: AbortSignal;
|
|
511
660
|
}
|
|
512
661
|
|
|
@@ -515,10 +664,24 @@ export interface IRunnerRunResult {
|
|
|
515
664
|
status?: TJobCompletionStatus;
|
|
516
665
|
}
|
|
517
666
|
|
|
667
|
+
/** A streaming check of bytes against the attempt's redaction set. */
|
|
668
|
+
export interface ISecretContentMatcher {
|
|
669
|
+
/** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */
|
|
670
|
+
push(bytes: Uint8Array): boolean;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** The attempt's redaction set as the archive publication check consumes it. */
|
|
674
|
+
export interface ISecretRedactionSet {
|
|
675
|
+
readonly empty: boolean;
|
|
676
|
+
occursIn(text: string): boolean;
|
|
677
|
+
createContentMatcher(): ISecretContentMatcher;
|
|
678
|
+
}
|
|
679
|
+
|
|
518
680
|
export interface IArtifactUploadContext {
|
|
519
681
|
workspace: IRuntimeWorkspaceExporter;
|
|
520
|
-
job: Pick<
|
|
682
|
+
job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
|
|
521
683
|
status: TJobCompletionStatus;
|
|
684
|
+
redactionSet: ISecretRedactionSet;
|
|
522
685
|
identity: IJobIdentity;
|
|
523
686
|
signal: AbortSignal;
|
|
524
687
|
}
|
|
@@ -530,15 +693,16 @@ export interface IArtifactManager {
|
|
|
530
693
|
export interface ICacheRestoreContext {
|
|
531
694
|
workspacePath: string;
|
|
532
695
|
workspaceEntryCount: number;
|
|
533
|
-
job: Pick<
|
|
696
|
+
job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
|
|
534
697
|
identity: IJobIdentity;
|
|
535
698
|
signal: AbortSignal;
|
|
536
699
|
}
|
|
537
700
|
|
|
538
701
|
export interface ICacheSaveContext {
|
|
539
702
|
workspace: IRuntimeWorkspaceExporter;
|
|
540
|
-
job: Pick<
|
|
703
|
+
job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
|
|
541
704
|
status: TJobCompletionStatus;
|
|
705
|
+
redactionSet: ISecretRedactionSet;
|
|
542
706
|
identity: IJobIdentity;
|
|
543
707
|
signal: AbortSignal;
|
|
544
708
|
}
|
package/ts/log-sender.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ProtocolError } from './errors.ts';
|
|
2
2
|
import type { IJobIdentity, ILogAcknowledgement, ILogChunk, TLogStream } from './interfaces.ts';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
LogSequenceRedactor,
|
|
5
|
+
type SecretRedactionSet,
|
|
6
|
+
StreamingSecretRedactor,
|
|
7
|
+
} from './redactor.ts';
|
|
4
8
|
import { utf8Length } from './validation.ts';
|
|
5
9
|
|
|
6
10
|
export interface ILogApi {
|
|
@@ -35,6 +39,7 @@ const splitByUtf8Bytes = (value: string, maximumBytes: number): string[] => {
|
|
|
35
39
|
|
|
36
40
|
export class LogSender {
|
|
37
41
|
private readonly redactors: Record<'stdout' | 'stderr', StreamingSecretRedactor>;
|
|
42
|
+
private readonly sequenceRedactor: LogSequenceRedactor;
|
|
38
43
|
private sequence = 0;
|
|
39
44
|
private sentBytes = 0;
|
|
40
45
|
private operationQueue: Promise<void> = Promise.resolve();
|
|
@@ -45,7 +50,7 @@ export class LogSender {
|
|
|
45
50
|
constructor(
|
|
46
51
|
private readonly api: ILogApi,
|
|
47
52
|
private readonly identity: IJobIdentity,
|
|
48
|
-
|
|
53
|
+
redactionSet: SecretRedactionSet,
|
|
49
54
|
private readonly maximumBytes: number,
|
|
50
55
|
private readonly maximumChunkBytes: number,
|
|
51
56
|
private readonly signal?: AbortSignal,
|
|
@@ -56,30 +61,34 @@ export class LogSender {
|
|
|
56
61
|
if (!Number.isSafeInteger(maximumChunkBytes) || maximumChunkBytes <= 0) {
|
|
57
62
|
throw new ProtocolError('Maximum log chunk bytes must be a positive integer');
|
|
58
63
|
}
|
|
59
|
-
const secretValues = [...secrets];
|
|
60
64
|
this.redactors = {
|
|
61
|
-
stdout: new StreamingSecretRedactor(
|
|
62
|
-
stderr: new StreamingSecretRedactor(
|
|
65
|
+
stdout: new StreamingSecretRedactor(redactionSet),
|
|
66
|
+
stderr: new StreamingSecretRedactor(redactionSet),
|
|
63
67
|
};
|
|
68
|
+
this.sequenceRedactor = new LogSequenceRedactor(redactionSet);
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
write(stream: 'stdout' | 'stderr', rawData: string): Promise<void> {
|
|
67
72
|
return this.schedule(async () => {
|
|
68
73
|
this.lastObservation[stream] = ++this.observationSequence;
|
|
69
|
-
await this.sendBatch(
|
|
74
|
+
await this.sendBatch(
|
|
75
|
+
this.sequenceRedactor.push(stream, this.redactors[stream].push(rawData)),
|
|
76
|
+
);
|
|
70
77
|
});
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
writeRunnerMessage(data: string): Promise<void> {
|
|
74
|
-
return this.schedule(() => this.sendBatch(
|
|
81
|
+
return this.schedule(() => this.sendBatch(this.sequenceRedactor.push('runner', data)));
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
flush(): Promise<void> {
|
|
78
85
|
return this.schedule(async () => {
|
|
79
86
|
const streams: Array<'stdout' | 'stderr'> = ['stdout', 'stderr'];
|
|
80
87
|
streams.sort((left, right) => this.lastObservation[left] - this.lastObservation[right]);
|
|
81
|
-
const writes = streams.
|
|
82
|
-
|
|
88
|
+
const writes = streams.flatMap((stream) =>
|
|
89
|
+
this.sequenceRedactor.push(stream, this.redactors[stream].flush())
|
|
90
|
+
);
|
|
91
|
+
await this.sendBatch([...writes, ...this.sequenceRedactor.flush()]);
|
|
83
92
|
});
|
|
84
93
|
}
|
|
85
94
|
|