@ship.zone/runner 0.2.3 → 1.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.
- package/changelog.md +65 -0
- package/deno.json +18 -4
- package/deno.lock +143 -224
- package/dist_npm/mod.d.ts +287 -39
- package/dist_npm/mod.js +897 -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 +58 -17
- 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 +190 -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 +229 -224
- package/ts/redactor.ts +229 -20
- package/ts/registration-state.ts +13 -46
- package/ts/runner.ts +104 -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,20 @@
|
|
|
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 TNetworkMode = 'none' | 'egress';
|
|
12
9
|
export type TSourceFormat = 'tar.gz';
|
|
13
10
|
export type TOciRuntime = 'docker' | 'podman';
|
|
14
11
|
export type TArtifactPermission = 'none' | 'write';
|
|
15
12
|
export type TCachePermission = 'none' | 'read' | 'read-write';
|
|
13
|
+
export type TImagePermission = 'none' | 'push';
|
|
16
14
|
export type TCacheAccess = 'read' | 'read-write';
|
|
17
15
|
export type TArtifactWhen = 'always' | 'success' | 'failure';
|
|
18
16
|
export type TLogStream = 'stdout' | 'stderr' | 'runner';
|
|
17
|
+
export type TImageGrantAccess = 'pull' | 'push';
|
|
19
18
|
export type TJobCompletionStatus =
|
|
20
19
|
| 'succeeded'
|
|
21
20
|
| 'failed'
|
|
@@ -41,8 +40,8 @@ export interface IProtocolLimits {
|
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export interface IDiscoveryResponse {
|
|
44
|
-
|
|
45
|
-
basePath: '/api/runner
|
|
43
|
+
spec: string;
|
|
44
|
+
basePath: '/api/runner';
|
|
46
45
|
status: 'draft';
|
|
47
46
|
serverTime: string;
|
|
48
47
|
limits: IProtocolLimits;
|
|
@@ -74,25 +73,35 @@ export interface ITransferLimits {
|
|
|
74
73
|
maximumWorkspaceEntries: number;
|
|
75
74
|
}
|
|
76
75
|
|
|
76
|
+
export interface IResourceLimits {
|
|
77
|
+
maximumMemoryBytes: number;
|
|
78
|
+
maximumCpus: number;
|
|
79
|
+
maximumPids: number;
|
|
80
|
+
maximumSharedMemoryBytes: number;
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
export interface IRunnerCapabilities {
|
|
78
84
|
executionProfiles: TExecutionProfile[];
|
|
85
|
+
isolation: TIsolation[];
|
|
86
|
+
platforms: string[];
|
|
79
87
|
labels: string[];
|
|
80
88
|
features: TRunnerFeature[];
|
|
81
|
-
networks:
|
|
89
|
+
networks: TNetworkMode[];
|
|
82
90
|
sourceFormats: TSourceFormat[];
|
|
83
91
|
limits: ITransferLimits;
|
|
92
|
+
resources?: IResourceLimits;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
export interface IRegisterRunnerRequest {
|
|
87
96
|
registrationRequestId: string;
|
|
88
|
-
|
|
97
|
+
spec: string;
|
|
89
98
|
runnerVersion: string;
|
|
90
99
|
name: string;
|
|
91
100
|
capabilities: IRunnerCapabilities;
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
export interface IRegisterRunnerResponse {
|
|
95
|
-
|
|
104
|
+
spec: string;
|
|
96
105
|
serverTime: string;
|
|
97
106
|
registrationReplayUntil: string;
|
|
98
107
|
credential: IRunnerCredential;
|
|
@@ -101,14 +110,14 @@ export interface IRegisterRunnerResponse {
|
|
|
101
110
|
export interface IStartSessionRequest {
|
|
102
111
|
sessionRequestId: string;
|
|
103
112
|
runnerId: string;
|
|
104
|
-
|
|
113
|
+
spec: string;
|
|
105
114
|
runnerVersion: string;
|
|
106
115
|
capabilities: IRunnerCapabilities;
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
export interface IStartSessionResponse {
|
|
110
119
|
sessionId: string;
|
|
111
|
-
|
|
120
|
+
spec: string;
|
|
112
121
|
serverTime: string;
|
|
113
122
|
credential?: IRunnerCredential;
|
|
114
123
|
}
|
|
@@ -137,13 +146,53 @@ export interface IClaimJobResponse {
|
|
|
137
146
|
lease: unknown | null;
|
|
138
147
|
}
|
|
139
148
|
|
|
149
|
+
/** Attempt-scoped registry credential for one registry, repository, and access mode. */
|
|
150
|
+
export interface IImageGrant {
|
|
151
|
+
grantId: string;
|
|
152
|
+
access: TImageGrantAccess;
|
|
153
|
+
registry: string;
|
|
154
|
+
repository: string;
|
|
155
|
+
username: string;
|
|
156
|
+
secret: string;
|
|
157
|
+
expiresAt: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Resolution of one candidate reference of the job to a digest-pinned image. */
|
|
161
|
+
export interface IImageBinding {
|
|
162
|
+
candidate: string;
|
|
163
|
+
image: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Attempt-scoped read-only npm registry token for one `npmRead` entry of the job. */
|
|
167
|
+
export interface INpmGrant {
|
|
168
|
+
grantId: string;
|
|
169
|
+
registry: string;
|
|
170
|
+
scopes: string[];
|
|
171
|
+
secret: string;
|
|
172
|
+
expiresAt: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** A lease exactly as the protocol defines it, for every execution profile. */
|
|
140
176
|
export interface IJobLease {
|
|
141
177
|
jobId: string;
|
|
142
178
|
attemptId: string;
|
|
143
179
|
leaseId: string;
|
|
144
180
|
fencingToken: string;
|
|
145
181
|
leaseExpiresAt: string;
|
|
146
|
-
job:
|
|
182
|
+
job: TCompiledRunnerJob;
|
|
183
|
+
grants: IImageGrant[];
|
|
184
|
+
bindings: IImageBinding[];
|
|
185
|
+
npmGrants?: INpmGrant[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* A lease this runner executes: an `oci` job in `container` isolation with a digest-pinned image,
|
|
190
|
+
* no image grants or bindings, and no npm grants.
|
|
191
|
+
*/
|
|
192
|
+
export interface IOciJobLease extends Omit<IJobLease, 'job' | 'grants' | 'bindings' | 'npmGrants'> {
|
|
193
|
+
job: IOciRunnerJob;
|
|
194
|
+
grants: [];
|
|
195
|
+
bindings: [];
|
|
147
196
|
}
|
|
148
197
|
|
|
149
198
|
export interface IJobIdentity {
|
|
@@ -242,6 +291,8 @@ export interface IErrorResponse {
|
|
|
242
291
|
|
|
243
292
|
export interface IJobRequirements {
|
|
244
293
|
executionProfile: TExecutionProfile;
|
|
294
|
+
isolation: TIsolation;
|
|
295
|
+
platform?: string;
|
|
245
296
|
labels: string[];
|
|
246
297
|
features: TRunnerFeature[];
|
|
247
298
|
limits: ITransferLimits;
|
|
@@ -251,16 +302,63 @@ export interface IJobPermissions {
|
|
|
251
302
|
source: 'read';
|
|
252
303
|
artifacts: TArtifactPermission;
|
|
253
304
|
caches: TCachePermission;
|
|
254
|
-
|
|
305
|
+
images: TImagePermission;
|
|
255
306
|
}
|
|
256
307
|
|
|
308
|
+
export interface IEgressRule {
|
|
309
|
+
host: string;
|
|
310
|
+
ports: number[];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface INoNetwork {
|
|
314
|
+
mode: 'none';
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface IEgressNetwork {
|
|
318
|
+
mode: 'egress';
|
|
319
|
+
allow: IEgressRule[];
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export type TJobNetwork = INoNetwork | IEgressNetwork;
|
|
323
|
+
|
|
324
|
+
export interface ICandidateReference {
|
|
325
|
+
candidate: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export type TImageReference = string | ICandidateReference;
|
|
329
|
+
|
|
257
330
|
export interface IOciExecution {
|
|
258
|
-
profile: 'oci
|
|
259
|
-
image:
|
|
260
|
-
|
|
331
|
+
profile: 'oci';
|
|
332
|
+
image: TImageReference;
|
|
333
|
+
workingDirectory?: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface IVmExecution {
|
|
337
|
+
profile: 'vm';
|
|
338
|
+
image: TImageReference;
|
|
261
339
|
workingDirectory?: string;
|
|
262
340
|
}
|
|
263
341
|
|
|
342
|
+
export interface IBuildSecret {
|
|
343
|
+
id: string;
|
|
344
|
+
environment: string;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export interface IBaseImage {
|
|
348
|
+
name: string;
|
|
349
|
+
image: TImageReference;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export interface IImageBuild {
|
|
353
|
+
context: string;
|
|
354
|
+
dockerfile: string;
|
|
355
|
+
target?: string;
|
|
356
|
+
buildArgs: Record<string, string>;
|
|
357
|
+
secrets: IBuildSecret[];
|
|
358
|
+
labels: Record<string, string>;
|
|
359
|
+
baseImages: IBaseImage[];
|
|
360
|
+
}
|
|
361
|
+
|
|
264
362
|
export interface ICompiledStep {
|
|
265
363
|
name?: string;
|
|
266
364
|
command: string[];
|
|
@@ -279,6 +377,12 @@ export interface IJobResources {
|
|
|
279
377
|
memoryBytes?: number;
|
|
280
378
|
cpus?: number;
|
|
281
379
|
pids?: number;
|
|
380
|
+
sharedMemoryBytes?: number;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export interface INpmReadEntry {
|
|
384
|
+
registry: string;
|
|
385
|
+
scopes: string[];
|
|
282
386
|
}
|
|
283
387
|
|
|
284
388
|
export interface IArtifactDeclaration {
|
|
@@ -293,10 +397,9 @@ export interface IArtifactDeclaration {
|
|
|
293
397
|
retentionDays?: number;
|
|
294
398
|
}
|
|
295
399
|
|
|
296
|
-
export interface
|
|
400
|
+
export interface IBuildCacheDeclaration {
|
|
297
401
|
name: string;
|
|
298
402
|
key: string;
|
|
299
|
-
paths: string[];
|
|
300
403
|
access: TCacheAccess;
|
|
301
404
|
maximumBytes: number;
|
|
302
405
|
maximumExtractedBytes: number;
|
|
@@ -304,23 +407,56 @@ export interface ICacheDeclaration {
|
|
|
304
407
|
retentionDays?: number;
|
|
305
408
|
}
|
|
306
409
|
|
|
307
|
-
export interface
|
|
308
|
-
|
|
410
|
+
export interface ICacheDeclaration extends IBuildCacheDeclaration {
|
|
411
|
+
paths: string[];
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
interface ICompiledRunnerJobBase {
|
|
415
|
+
spec: string;
|
|
309
416
|
sourceObjectId: string;
|
|
310
417
|
workflowDigest: string;
|
|
311
418
|
compiledPlanDigest: string;
|
|
312
419
|
requirements: IJobRequirements;
|
|
313
420
|
permissions: IJobPermissions;
|
|
314
|
-
|
|
315
|
-
steps: ICompiledStep[];
|
|
421
|
+
network: TJobNetwork;
|
|
316
422
|
source: IJobSource;
|
|
317
423
|
secrets: Record<string, string>;
|
|
318
424
|
timeoutMs: number;
|
|
319
425
|
resources?: IJobResources;
|
|
426
|
+
npmRead?: INpmReadEntry[];
|
|
320
427
|
artifacts: IArtifactDeclaration[];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** A compiled `oci` job: ordered argument-array steps in fresh containers. */
|
|
431
|
+
export interface IContainerRunnerJob extends ICompiledRunnerJobBase {
|
|
432
|
+
execution: IOciExecution;
|
|
433
|
+
steps: ICompiledStep[];
|
|
434
|
+
caches: ICacheDeclaration[];
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** A compiled `vm` job: ordered steps as root in one microVM guest per attempt. */
|
|
438
|
+
export interface IVmRunnerJob extends ICompiledRunnerJobBase {
|
|
439
|
+
execution: IVmExecution;
|
|
440
|
+
steps: ICompiledStep[];
|
|
321
441
|
caches: ICacheDeclaration[];
|
|
322
442
|
}
|
|
323
443
|
|
|
444
|
+
/** A compiled `oci-image` job: one single-platform image build in a microVM guest. */
|
|
445
|
+
export interface IImageBuildRunnerJob extends ICompiledRunnerJobBase {
|
|
446
|
+
build: IImageBuild;
|
|
447
|
+
caches: IBuildCacheDeclaration[];
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/** Every compiled job shape the published runner job schema admits. */
|
|
451
|
+
export type TCompiledRunnerJob = IContainerRunnerJob | IVmRunnerJob | IImageBuildRunnerJob;
|
|
452
|
+
|
|
453
|
+
/** An `oci` job this runner executes: container isolation, no network, a digest-pinned image. */
|
|
454
|
+
export interface IOciRunnerJob extends IContainerRunnerJob {
|
|
455
|
+
requirements: IJobRequirements & { executionProfile: 'oci'; isolation: 'container' };
|
|
456
|
+
network: INoNetwork;
|
|
457
|
+
execution: IOciExecution & { image: string };
|
|
458
|
+
}
|
|
459
|
+
|
|
324
460
|
export interface ITransferMetadata {
|
|
325
461
|
sha256: string;
|
|
326
462
|
sizeBytes: number;
|
|
@@ -381,7 +517,7 @@ export interface IOciExecutorConfig {
|
|
|
381
517
|
runtimePath: string;
|
|
382
518
|
workspaceHelperPath?: string;
|
|
383
519
|
requireRootless: boolean;
|
|
384
|
-
allowedNetworks:
|
|
520
|
+
allowedNetworks: TNetworkMode[];
|
|
385
521
|
containerUser: string;
|
|
386
522
|
defaultTimeoutMs: number;
|
|
387
523
|
maximumTimeoutMs: number;
|
|
@@ -391,6 +527,8 @@ export interface IOciExecutorConfig {
|
|
|
391
527
|
maximumCpus: number;
|
|
392
528
|
defaultPids: number;
|
|
393
529
|
maximumPids: number;
|
|
530
|
+
defaultSharedMemoryBytes: number;
|
|
531
|
+
maximumSharedMemoryBytes: number;
|
|
394
532
|
workspaceSizeBytes: number;
|
|
395
533
|
temporarySizeBytes: number;
|
|
396
534
|
stopTimeoutSeconds: number;
|
|
@@ -426,9 +564,14 @@ export interface IRunnerConfig extends ITransferManagerConfig {
|
|
|
426
564
|
export interface IExecutionContext {
|
|
427
565
|
runnerId: string;
|
|
428
566
|
sessionId: string;
|
|
429
|
-
lease:
|
|
567
|
+
lease: IOciJobLease;
|
|
430
568
|
preparedLease: IPreparedOciLease;
|
|
431
569
|
workspacePath: string;
|
|
570
|
+
/**
|
|
571
|
+
* Milliseconds left until the attempt deadline when execution starts: the job `timeoutMs`
|
|
572
|
+
* counted from the acceptance 204, less the time source extraction and cache restoration took.
|
|
573
|
+
*/
|
|
574
|
+
timeoutMs: number;
|
|
432
575
|
signal: AbortSignal;
|
|
433
576
|
terminationDeadline?: () => number | undefined;
|
|
434
577
|
onLog: (stream: 'stdout' | 'stderr', data: string) => Promise<void>;
|
|
@@ -449,7 +592,7 @@ export interface IOciRuntimeFacts {
|
|
|
449
592
|
export interface IPrepareOciLeaseContext {
|
|
450
593
|
runnerId: string;
|
|
451
594
|
sessionId: string;
|
|
452
|
-
lease:
|
|
595
|
+
lease: IOciJobLease;
|
|
453
596
|
signal: AbortSignal;
|
|
454
597
|
}
|
|
455
598
|
|
|
@@ -506,7 +649,7 @@ export interface IPreparedWorkspace {
|
|
|
506
649
|
|
|
507
650
|
export interface ISourcePrepareContext {
|
|
508
651
|
identity: IJobIdentity;
|
|
509
|
-
job: Pick<
|
|
652
|
+
job: Pick<IOciRunnerJob, 'source' | 'permissions' | 'requirements'>;
|
|
510
653
|
signal: AbortSignal;
|
|
511
654
|
}
|
|
512
655
|
|
|
@@ -515,10 +658,24 @@ export interface IRunnerRunResult {
|
|
|
515
658
|
status?: TJobCompletionStatus;
|
|
516
659
|
}
|
|
517
660
|
|
|
661
|
+
/** A streaming check of bytes against the attempt's redaction set. */
|
|
662
|
+
export interface ISecretContentMatcher {
|
|
663
|
+
/** Feeds bytes and returns whether a member has occurred anywhere in the stream so far. */
|
|
664
|
+
push(bytes: Uint8Array): boolean;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** The attempt's redaction set as the archive publication check consumes it. */
|
|
668
|
+
export interface ISecretRedactionSet {
|
|
669
|
+
readonly empty: boolean;
|
|
670
|
+
occursIn(text: string): boolean;
|
|
671
|
+
createContentMatcher(): ISecretContentMatcher;
|
|
672
|
+
}
|
|
673
|
+
|
|
518
674
|
export interface IArtifactUploadContext {
|
|
519
675
|
workspace: IRuntimeWorkspaceExporter;
|
|
520
|
-
job: Pick<
|
|
676
|
+
job: Pick<IOciRunnerJob, 'artifacts' | 'permissions' | 'requirements'>;
|
|
521
677
|
status: TJobCompletionStatus;
|
|
678
|
+
redactionSet: ISecretRedactionSet;
|
|
522
679
|
identity: IJobIdentity;
|
|
523
680
|
signal: AbortSignal;
|
|
524
681
|
}
|
|
@@ -530,15 +687,16 @@ export interface IArtifactManager {
|
|
|
530
687
|
export interface ICacheRestoreContext {
|
|
531
688
|
workspacePath: string;
|
|
532
689
|
workspaceEntryCount: number;
|
|
533
|
-
job: Pick<
|
|
690
|
+
job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements' | 'source'>;
|
|
534
691
|
identity: IJobIdentity;
|
|
535
692
|
signal: AbortSignal;
|
|
536
693
|
}
|
|
537
694
|
|
|
538
695
|
export interface ICacheSaveContext {
|
|
539
696
|
workspace: IRuntimeWorkspaceExporter;
|
|
540
|
-
job: Pick<
|
|
697
|
+
job: Pick<IOciRunnerJob, 'caches' | 'permissions' | 'requirements'>;
|
|
541
698
|
status: TJobCompletionStatus;
|
|
699
|
+
redactionSet: ISecretRedactionSet;
|
|
542
700
|
identity: IJobIdentity;
|
|
543
701
|
signal: AbortSignal;
|
|
544
702
|
}
|
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
|
|