nx 21.5.2 → 21.5.3
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/package.json +11 -11
- package/schemas/nx-schema.json +14 -0
- package/src/command-line/release/config/config.d.ts.map +1 -1
- package/src/command-line/release/config/config.js +3 -0
- package/src/command-line/release/version/release-group-processor.d.ts +1 -0
- package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
- package/src/command-line/release/version/release-group-processor.js +5 -0
- package/src/config/nx-json.d.ts +9 -0
- package/src/config/nx-json.d.ts.map +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/server/shutdown-utils.d.ts.map +1 -1
- package/src/daemon/server/shutdown-utils.js +6 -2
- package/src/executors/run-script/run-script.impl.d.ts.map +1 -1
- package/src/executors/run-script/run-script.impl.js +33 -8
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/fork.js +31 -5
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +8 -5
- package/src/utils/provenance.d.ts +3 -1
- package/src/utils/provenance.d.ts.map +1 -1
- package/src/utils/provenance.js +52 -30
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shutdown-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/shutdown-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQ5C,eAAO,MAAM,4BAA4B,EAAG,QAAiB,CAAC;AAI9D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,QAErD;AAED,wBAAgB,kBAAkB,YAEjC;AAID,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,QAE3D;AAED,wBAAgB,wBAAwB,YAEvC;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAsB,8BAA8B,CAAC,EACnD,MAAM,EACN,MAAM,EACN,OAAO,GACR,EAAE,oCAAoC,iBAmCtC;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAK3D;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,oBAcpB;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,
|
1
|
+
{"version":3,"file":"shutdown-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/shutdown-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQ5C,eAAO,MAAM,4BAA4B,EAAG,QAAiB,CAAC;AAI9D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,QAErD;AAED,wBAAgB,kBAAkB,YAEjC;AAID,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,QAE3D;AAED,wBAAgB,wBAAwB,YAEvC;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAsB,8BAA8B,CAAC,EACnD,MAAM,EACN,MAAM,EACN,OAAO,GACR,EAAE,oCAAoC,iBAmCtC;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAK3D;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,oBAcpB;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,iBAsBb"}
|
@@ -80,7 +80,8 @@ function respondToClient(socket, response, description) {
|
|
80
80
|
});
|
81
81
|
}
|
82
82
|
async function respondWithErrorAndExit(socket, description, error) {
|
83
|
-
const
|
83
|
+
const isProjectGraphError = error instanceof error_types_1.DaemonProjectGraphError;
|
84
|
+
const normalizedError = isProjectGraphError
|
84
85
|
? error_types_1.ProjectGraphError.fromDaemonProjectGraphError(error)
|
85
86
|
: error;
|
86
87
|
// print some extra stuff in the error message
|
@@ -88,5 +89,8 @@ async function respondWithErrorAndExit(socket, description, error) {
|
|
88
89
|
console.error(normalizedError.stack);
|
89
90
|
// Respond with the original error
|
90
91
|
await respondToClient(socket, (0, socket_utils_1.serializeResult)(error, null, null), null);
|
91
|
-
|
92
|
+
// Project Graph errors are okay. Restarting the daemon won't help with this.
|
93
|
+
if (!isProjectGraphError) {
|
94
|
+
process.exit(1);
|
95
|
+
}
|
92
96
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"run-script.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/executors/run-script/run-script.impl.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"run-script.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/executors/run-script/run-script.impl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AASpE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,yBACE,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,eAAe;;GA6BzB"}
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
4
4
|
const child_process_1 = require("child_process");
|
5
5
|
const path = require("path");
|
6
|
+
const treeKill = require("tree-kill");
|
6
7
|
const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
|
7
8
|
const package_manager_1 = require("../../utils/package-manager");
|
9
|
+
const LARGE_BUFFER = 1024 * 1000000;
|
8
10
|
async function default_1(options, context) {
|
9
11
|
const pm = (0, package_manager_1.getPackageManagerCommand)();
|
10
12
|
try {
|
@@ -22,7 +24,7 @@ async function default_1(options, context) {
|
|
22
24
|
await ptyProcess(command, cwd, env);
|
23
25
|
}
|
24
26
|
else {
|
25
|
-
nodeProcess(command, cwd, env);
|
27
|
+
await nodeProcess(command, cwd, env);
|
26
28
|
}
|
27
29
|
return { success: true };
|
28
30
|
}
|
@@ -31,19 +33,42 @@ async function default_1(options, context) {
|
|
31
33
|
}
|
32
34
|
}
|
33
35
|
function nodeProcess(command, cwd, env) {
|
34
|
-
(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
return new Promise((res, rej) => {
|
37
|
+
let cp = (0, child_process_1.exec)(command, { cwd, env, maxBuffer: LARGE_BUFFER, windowsHide: false }, (error) => {
|
38
|
+
if (error) {
|
39
|
+
rej(error);
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
res();
|
43
|
+
}
|
44
|
+
});
|
45
|
+
// Forward stdout/stderr to parent process
|
46
|
+
cp.stdout.pipe(process.stdout);
|
47
|
+
cp.stderr.pipe(process.stderr);
|
48
|
+
const exitHandler = (signal) => {
|
49
|
+
if (cp && cp.pid && !cp.killed) {
|
50
|
+
treeKill(cp.pid, signal, (error) => {
|
51
|
+
// On Windows, tree-kill (which uses taskkill) may fail when the process or its child process is already terminated.
|
52
|
+
// Ignore the errors, otherwise we will log them unnecessarily.
|
53
|
+
if (error && process.platform !== 'win32') {
|
54
|
+
rej(error);
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
res();
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
61
|
+
};
|
62
|
+
process.on('SIGINT', () => exitHandler('SIGINT'));
|
63
|
+
process.on('SIGTERM', () => exitHandler('SIGTERM'));
|
64
|
+
process.on('SIGHUP', () => exitHandler('SIGHUP'));
|
39
65
|
});
|
40
66
|
}
|
41
|
-
let cp;
|
42
67
|
async function ptyProcess(command, cwd, env) {
|
43
68
|
const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
|
44
69
|
await terminal.init();
|
45
70
|
return new Promise((res, rej) => {
|
46
|
-
cp = terminal.runCommand(command, { cwd, jsEnv: env });
|
71
|
+
let cp = terminal.runCommand(command, { cwd, jsEnv: env });
|
47
72
|
cp.onExit((code) => {
|
48
73
|
if (code === 0) {
|
49
74
|
res();
|
Binary file
|
package/src/tasks-runner/fork.js
CHANGED
@@ -20,26 +20,52 @@ const childProcess = (0, child_process_1.fork)(script, {
|
|
20
20
|
const pseudoIPC = new pseudo_ipc_1.PseudoIPCClient(pseudoIPCPath);
|
21
21
|
pseudoIPC.onMessageFromParent(forkId, (message) => {
|
22
22
|
childProcess.send(message);
|
23
|
+
}, () => {
|
24
|
+
// IPC connection closed
|
25
|
+
cleanup();
|
26
|
+
process.exit(0);
|
27
|
+
}, () => {
|
28
|
+
// IPC connection error
|
29
|
+
cleanup();
|
30
|
+
process.exit(0);
|
23
31
|
});
|
24
32
|
pseudoIPC.notifyChildIsReady(forkId);
|
25
33
|
process.on('message', (message) => {
|
26
34
|
pseudoIPC.sendMessageToParent(message);
|
27
35
|
});
|
28
36
|
childProcess.on('exit', (code) => {
|
29
|
-
|
37
|
+
cleanup();
|
30
38
|
process.exit(code);
|
31
39
|
});
|
40
|
+
let isCleaningUp = false;
|
41
|
+
function cleanup() {
|
42
|
+
if (isCleaningUp) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
isCleaningUp = true;
|
46
|
+
// Kill child process if still running
|
47
|
+
if (childProcess && !childProcess.killed) {
|
48
|
+
childProcess.kill('SIGTERM');
|
49
|
+
}
|
50
|
+
// Close IPC connection
|
51
|
+
try {
|
52
|
+
pseudoIPC.close();
|
53
|
+
}
|
54
|
+
catch {
|
55
|
+
// Ignore errors when closing, connection might already be broken
|
56
|
+
}
|
57
|
+
}
|
32
58
|
// Terminate the child process when exiting
|
33
59
|
process.on('exit', () => {
|
34
|
-
|
60
|
+
cleanup();
|
35
61
|
});
|
36
62
|
process.on('SIGINT', () => {
|
37
|
-
|
63
|
+
cleanup();
|
38
64
|
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
39
65
|
});
|
40
66
|
process.on('SIGTERM', () => {
|
41
|
-
|
67
|
+
cleanup();
|
42
68
|
});
|
43
69
|
process.on('SIGHUP', () => {
|
44
|
-
|
70
|
+
cleanup();
|
45
71
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"task-orchestrator.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/task-orchestrator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAMrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAgB,UAAU,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAiB,MAAM,kBAAkB,CAAC;AAUxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,qBAAa,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S,EACpB,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,GAAG,yBAAyB,EAC3C,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,MAAM,EACnB,mBAAmB,GAAE,SAAqB;IAGvD,IAAI;IAiBJ,GAAG;;;IA4CF,SAAS;YAIF,wCAAwC;IA2CtD,OAAO,CAAC,YAAY;YAUN,WAAW;YAoBX,qBAAqB;IAkB5B,wBAAwB;YAajB,kBAAkB;YAUlB,iBAAiB;IAuClB,wBAAwB,CACnC,cAAc,EAAE,OAAO,EACvB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,EAAE,CAAC;YAmEV,QAAQ;IA6ChB,uBAAuB,CAC3B,cAAc,EAAE,OAAO,EACvB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,CAAC;YAkER,OAAO;YAiKP,sBAAsB;IA2C9B,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM;YAmHvC,WAAW;YAQX,YAAY;YAmFZ,kCAAkC;IAQhD,OAAO,CAAC,QAAQ;YA0CF,iBAAiB;IAiB/B,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,SAAS;YAIH,0BAA0B;YAQ1B,iBAAiB;YAQjB,OAAO;IA4BrB,OAAO,CAAC,8BAA8B;CAwBvC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,GAAG,yBAAyB,EAC3C,SAAS,EAAE,SAAS,UAqBrB"}
|
@@ -505,8 +505,9 @@ class TaskOrchestrator {
|
|
505
505
|
if (this.tuiEnabled) {
|
506
506
|
this.options.lifeCycle.setTaskStatus(task.id, 9 /* NativeTaskStatus.Stopped */);
|
507
507
|
}
|
508
|
-
this.
|
509
|
-
|
508
|
+
if (this.runningContinuousTasks.delete(task.id)) {
|
509
|
+
this.runningTasksService.removeRunningTask(task.id);
|
510
|
+
}
|
510
511
|
});
|
511
512
|
await this.scheduleNextTasksAndReleaseThreads();
|
512
513
|
if (this.initializingTaskIds.has(task.id)) {
|
@@ -667,13 +668,15 @@ class TaskOrchestrator {
|
|
667
668
|
...Array.from(this.runningContinuousTasks).map(async ([taskId, t]) => {
|
668
669
|
try {
|
669
670
|
await t.kill();
|
670
|
-
this.options.lifeCycle.setTaskStatus(taskId, 9 /* NativeTaskStatus.Stopped */);
|
671
|
+
this.options.lifeCycle.setTaskStatus?.(taskId, 9 /* NativeTaskStatus.Stopped */);
|
671
672
|
}
|
672
673
|
catch (e) {
|
673
674
|
console.error(`Unable to terminate ${taskId}\nError:`, e);
|
674
675
|
}
|
675
676
|
finally {
|
676
|
-
this.
|
677
|
+
if (this.runningContinuousTasks.delete(taskId)) {
|
678
|
+
this.runningTasksService.removeRunningTask(taskId);
|
679
|
+
}
|
677
680
|
}
|
678
681
|
}),
|
679
682
|
...Array.from(this.runningRunCommandsTasks).map(async ([taskId, t]) => {
|
@@ -700,7 +703,7 @@ class TaskOrchestrator {
|
|
700
703
|
const runningTask = this.runningContinuousTasks.get(taskId);
|
701
704
|
if (runningTask) {
|
702
705
|
runningTask.kill();
|
703
|
-
this.options.lifeCycle.setTaskStatus(taskId, 9 /* NativeTaskStatus.Stopped */);
|
706
|
+
this.options.lifeCycle.setTaskStatus?.(taskId, 9 /* NativeTaskStatus.Stopped */);
|
704
707
|
}
|
705
708
|
}
|
706
709
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
export declare function ensurePackageHasProvenance(packageName: string, packageVersion: string): Promise<void>;
|
2
|
-
export declare
|
2
|
+
export declare class ProvenanceError extends Error {
|
3
|
+
constructor(packageName: string, packageVersion: string, error?: string);
|
4
|
+
}
|
3
5
|
export declare function getNxPackageGroup(): string[];
|
4
6
|
export type DecodedAttestationPayload = {
|
5
7
|
_type: 'https://in-toto.io/Statement/v1';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/provenance.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/provenance.ts"],"names":[],"mappings":"AAaA,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CA+Gf;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAOxE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAa5C;AAoBD,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,iCAAiC,CAAC;IACzC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,aAAa,EAAE,gCAAgC,CAAC;IAChD,SAAS,EAAE;QACT,eAAe,EAAE;YACf,SAAS,EAAE,MAAM,CAAC;YAClB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YACzC,oBAAoB,CAAC,EAAE,kBAAkB,EAAE,CAAC;SAC7C,CAAC;QACF,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,EAAE,EAAE,MAAM,CAAC;gBACX,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAC;gBAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;aAClC,CAAC;YACF,QAAQ,CAAC,EAAE;gBACT,YAAY,CAAC,EAAE,MAAM,CAAC;gBACtB,SAAS,CAAC,EAAE,MAAM,CAAC;gBACnB,UAAU,CAAC,EAAE,MAAM,CAAC;aACrB,CAAC;YACF,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;SACnC,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE;QACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH"}
|
package/src/utils/provenance.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.ProvenanceError = void 0;
|
4
4
|
exports.ensurePackageHasProvenance = ensurePackageHasProvenance;
|
5
5
|
exports.getNxPackageGroup = getNxPackageGroup;
|
6
6
|
const child_process_1 = require("child_process");
|
7
7
|
const path_1 = require("path");
|
8
8
|
const util_1 = require("util");
|
9
9
|
const fileutils_1 = require("./fileutils");
|
10
|
+
const os_1 = require("os");
|
10
11
|
/*
|
11
12
|
* Verifies that the given npm package has provenance attestations
|
12
13
|
* generated by the GitHub Actions workflow at .github/workflows/publish.yml
|
@@ -21,42 +22,63 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
|
|
21
22
|
return;
|
22
23
|
}
|
23
24
|
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
25
|
+
try {
|
26
|
+
const result = await execFileAsync((0, os_1.platform)() === 'win32' ? 'npm.cmd' : 'npm', ['view', `${packageName}@${packageVersion}`, '--json', '--silent'], {
|
27
|
+
timeout: 20000,
|
28
|
+
});
|
29
|
+
const npmViewResult = JSON.parse(result.stdout.trim());
|
30
|
+
const attURL = npmViewResult.dist?.attestations?.url;
|
31
|
+
if (!attURL)
|
32
|
+
throw new ProvenanceError(packageName, packageVersion, 'No attestation URL found');
|
33
|
+
const response = await fetch(attURL);
|
34
|
+
if (!response.ok) {
|
35
|
+
throw new ProvenanceError(packageName, packageVersion, `HTTP ${response.status}: ${response.statusText}`);
|
36
|
+
}
|
37
|
+
const attestations = (await response.json());
|
38
|
+
const provenanceAttestation = attestations?.attestations?.find((a) => a.predicateType === 'https://slsa.dev/provenance/v1');
|
39
|
+
const dsseEnvelopePayload = JSON.parse(Buffer.from(provenanceAttestation.bundle.dsseEnvelope.payload, 'base64').toString());
|
40
|
+
const workflowParameters = dsseEnvelopePayload?.predicate?.buildDefinition?.externalParameters
|
41
|
+
?.workflow;
|
42
|
+
// verify that provenance was actually generated from the right publishing workflow
|
43
|
+
if (!workflowParameters) {
|
44
|
+
throw new ProvenanceError(packageName, packageVersion, 'Missing workflow parameters in attestation');
|
45
|
+
}
|
46
|
+
if (workflowParameters.repository !== 'https://github.com/nrwl/nx') {
|
47
|
+
throw new ProvenanceError(packageName, packageVersion, 'Repository does not match nrwl/nx');
|
48
|
+
}
|
49
|
+
if (workflowParameters.path !== '.github/workflows/publish.yml') {
|
50
|
+
throw new ProvenanceError(packageName, packageVersion, 'Publishing workflow does not match .github/workflows/publish.yml');
|
51
|
+
}
|
52
|
+
if (workflowParameters.ref !== `refs/tags/${npmViewResult.version}`) {
|
53
|
+
throw new ProvenanceError(packageName, packageVersion, `Version ref does not match refs/tags/${npmViewResult.version}`);
|
54
|
+
}
|
55
|
+
// verify that provenance was generated from the exact same artifact as the one we are installing
|
56
|
+
const distSha = Buffer.from(npmViewResult.dist.integrity.replace('sha512-', ''), 'base64').toString('hex');
|
57
|
+
const attestationSha = dsseEnvelopePayload.subject[0].digest.sha512;
|
58
|
+
if (distSha !== attestationSha) {
|
59
|
+
throw new ProvenanceError(packageName, packageVersion, 'Integrity hash does not match attestation hash');
|
60
|
+
}
|
61
|
+
return;
|
43
62
|
}
|
44
|
-
|
45
|
-
|
63
|
+
catch (error) {
|
64
|
+
if (error instanceof ProvenanceError) {
|
65
|
+
throw error;
|
66
|
+
}
|
67
|
+
throw new ProvenanceError(packageName, packageVersion, error.message || error);
|
46
68
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
throw (0, exports.noProvenanceError)(packageName, packageVersion, 'Integrity hash does not match attestation hash');
|
69
|
+
}
|
70
|
+
class ProvenanceError extends Error {
|
71
|
+
constructor(packageName, packageVersion, error) {
|
72
|
+
super(`An error occurred while checking the provenance of ${packageName}@${packageVersion}. This could indicate a security risk. Please double check https://www.npmjs.com/package/${packageName} to see if the package is published correctly or file an issue at https://github.com/nrwl/nx/issues. To disable this check at your own risk, you can set the NX_SKIP_PROVENANCE_CHECK environment variable to true. \n Error: ${error ?? ''}`);
|
52
73
|
}
|
53
|
-
return;
|
54
74
|
}
|
55
|
-
|
56
|
-
exports.noProvenanceError = noProvenanceError;
|
75
|
+
exports.ProvenanceError = ProvenanceError;
|
57
76
|
function getNxPackageGroup() {
|
58
77
|
const packageJsonPath = (0, path_1.join)(__dirname, '../../package.json');
|
59
78
|
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
79
|
+
if (!packageJson['nx-migrations']?.packageGroup) {
|
80
|
+
return ['nx'];
|
81
|
+
}
|
60
82
|
const packages = packageJson['nx-migrations'].packageGroup.filter((dep) => typeof dep === 'string' && dep.startsWith('@nx/'));
|
61
83
|
packages.push('nx');
|
62
84
|
return packages;
|