From 42e8a573fbd01d68d9e2678070036ed411b9128f Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 4 Oct 2024 15:57:51 -0400 Subject: [PATCH 1/5] Explicitly import `crypto` --- packages/cache/src/internal/cacheUtils.ts | 1 + packages/core/package-lock.json | 14 +++++++------- packages/core/package.json | 2 +- packages/core/src/file-command.ts | 1 + packages/tool-cache/src/tool-cache.ts | 1 + 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/cache/src/internal/cacheUtils.ts b/packages/cache/src/internal/cacheUtils.ts index d8b7f3e090..4c2a16f35a 100644 --- a/packages/cache/src/internal/cacheUtils.ts +++ b/packages/cache/src/internal/cacheUtils.ts @@ -2,6 +2,7 @@ import * as core from '@actions/core' import * as exec from '@actions/exec' import * as glob from '@actions/glob' import * as io from '@actions/io' +import * as crypto from 'crypto' import * as fs from 'fs' import * as path from 'path' import * as semver from 'semver' diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json index fb11ec9eab..6da88d7b83 100644 --- a/packages/core/package-lock.json +++ b/packages/core/package-lock.json @@ -13,7 +13,7 @@ "@actions/http-client": "^2.0.1" }, "devDependencies": { - "@types/node": "^12.0.2" + "@types/node": "^16.18.112" } }, "node_modules/@actions/exec": { @@ -38,9 +38,9 @@ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" }, "node_modules/@types/node": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", - "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==", + "version": "16.18.112", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.112.tgz", + "integrity": "sha512-EKrbKUGJROm17+dY/gMi31aJlGLJ75e1IkTojt9n6u+hnaTBDs+M1bIdOawpk2m6YUAXq/R2W0SxCng1tndHCg==", "dev": true }, "node_modules/tunnel": { @@ -75,9 +75,9 @@ "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" }, "@types/node": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", - "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==", + "version": "16.18.112", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.112.tgz", + "integrity": "sha512-EKrbKUGJROm17+dY/gMi31aJlGLJ75e1IkTojt9n6u+hnaTBDs+M1bIdOawpk2m6YUAXq/R2W0SxCng1tndHCg==", "dev": true }, "tunnel": { diff --git a/packages/core/package.json b/packages/core/package.json index 6bc7f70b60..20de3b9b16 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -40,6 +40,6 @@ "@actions/http-client": "^2.0.1" }, "devDependencies": { - "@types/node": "^12.0.2" + "@types/node": "^16.18.112" } } \ No newline at end of file diff --git a/packages/core/src/file-command.ts b/packages/core/src/file-command.ts index 6750e85775..30c9519eed 100644 --- a/packages/core/src/file-command.ts +++ b/packages/core/src/file-command.ts @@ -3,6 +3,7 @@ // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ +import * as crypto from 'crypto' import * as fs from 'fs' import * as os from 'os' import {toCommandValue} from './utils' diff --git a/packages/tool-cache/src/tool-cache.ts b/packages/tool-cache/src/tool-cache.ts index f7a7545bbd..961c26b8d7 100644 --- a/packages/tool-cache/src/tool-cache.ts +++ b/packages/tool-cache/src/tool-cache.ts @@ -1,5 +1,6 @@ import * as core from '@actions/core' import * as io from '@actions/io' +import * as crypto from 'crypto' import * as fs from 'fs' import * as mm from './manifest' import * as os from 'os' From 67ed54fe9d25dac774947eae5b021934fdba89b4 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 4 Oct 2024 16:02:36 -0400 Subject: [PATCH 2/5] Add release notes for 1.11.1 --- packages/core/RELEASES.md | 3 +++ packages/core/package-lock.json | 4 ++-- packages/core/package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core/RELEASES.md b/packages/core/RELEASES.md index 5bc0e31ea2..697016601f 100644 --- a/packages/core/RELEASES.md +++ b/packages/core/RELEASES.md @@ -1,5 +1,8 @@ # @actions/core Releases +### 1.11.1 +- Fix uses of `crypto.randomUUID` on Node 18 and earlier [#1842](https://github.com/actions/toolkit/pull/1842) + ### 1.11.0 - Add platform info utilities [#1551](https://github.com/actions/toolkit/pull/1551) - Remove dependency on `uuid` package [#1824](https://github.com/actions/toolkit/pull/1824) diff --git a/packages/core/package-lock.json b/packages/core/package-lock.json index 6da88d7b83..95cf58d255 100644 --- a/packages/core/package-lock.json +++ b/packages/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@actions/core", - "version": "1.11.0", + "version": "1.11.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/core", - "version": "1.11.0", + "version": "1.11.1", "license": "MIT", "dependencies": { "@actions/exec": "^1.1.1", diff --git a/packages/core/package.json b/packages/core/package.json index 20de3b9b16..6d60010e37 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@actions/core", - "version": "1.11.0", + "version": "1.11.1", "description": "Actions core lib", "keywords": [ "github", From 0b4cb720e7885eea1deab690543c8b6e6263831a Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 4 Oct 2024 16:31:36 -0400 Subject: [PATCH 3/5] Fix crypto mock in test --- packages/core/__tests__/core.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/__tests__/core.test.ts b/packages/core/__tests__/core.test.ts index 7fcb37592d..3774b794a4 100644 --- a/packages/core/__tests__/core.test.ts +++ b/packages/core/__tests__/core.test.ts @@ -1,3 +1,4 @@ +import * as crypto from 'crypto' import * as fs from 'fs' import * as os from 'os' import * as path from 'path' From 1810f8776b8690d4e70413385ea08037197cc34a Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 4 Oct 2024 16:56:33 -0400 Subject: [PATCH 4/5] Fix `crypto` mock --- packages/core/__tests__/core.test.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/__tests__/core.test.ts b/packages/core/__tests__/core.test.ts index 3774b794a4..628da3dbd6 100644 --- a/packages/core/__tests__/core.test.ts +++ b/packages/core/__tests__/core.test.ts @@ -47,6 +47,11 @@ const testEnvVars = { const UUID = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d' const DELIMITER = `ghadelimiter_${UUID}` +jest.mock('crypto', () => ({ + ...jest.requireActual('crypto'), + randomUUID: jest.fn(() => UUID), +})); + const TEMP_DIR = path.join(__dirname, '_temp') describe('@actions/core', () => { @@ -67,10 +72,6 @@ describe('@actions/core', () => { process.env[key] = testEnvVars[key as keyof typeof testEnvVars] } process.stdout.write = jest.fn() - - jest.spyOn(crypto, 'randomUUID').mockImplementation(() => { - return UUID - }) }) afterEach(() => { From 190c2939493541daaef51436f55e490676b05eca Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 4 Oct 2024 17:06:46 -0400 Subject: [PATCH 5/5] Lint --- packages/core/__tests__/core.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/core/__tests__/core.test.ts b/packages/core/__tests__/core.test.ts index 628da3dbd6..2928788d7f 100644 --- a/packages/core/__tests__/core.test.ts +++ b/packages/core/__tests__/core.test.ts @@ -1,4 +1,3 @@ -import * as crypto from 'crypto' import * as fs from 'fs' import * as os from 'os' import * as path from 'path' @@ -49,8 +48,8 @@ const DELIMITER = `ghadelimiter_${UUID}` jest.mock('crypto', () => ({ ...jest.requireActual('crypto'), - randomUUID: jest.fn(() => UUID), -})); + randomUUID: jest.fn(() => UUID) +})) const TEMP_DIR = path.join(__dirname, '_temp')