From fa5ddeefb10afe1a7401d98859ab0c0c56a1615d Mon Sep 17 00:00:00 2001 From: Tapas Thakkar Date: Thu, 12 Dec 2024 14:19:23 +0530 Subject: [PATCH] 383024578 Upgrade supported Node versions to 18,20,22 - Remove support for Node v16 - Fix CVE-2024-45590 vulnerability --- cli/edgemicro | 21 ++++++++++++--------- cli/lib/gateway.js | 2 +- package.json | 17 ++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/cli/edgemicro b/cli/edgemicro index b64044b4..8002d4e4 100755 --- a/cli/edgemicro +++ b/cli/edgemicro @@ -24,32 +24,35 @@ var edgemicroVersion = require('../package.json').version; const writeConsoleLog = require('microgateway-core').Logging.writeConsoleLog; const version = process.version; -const ltsVersion = 16; -const experimental = ["v15","v17","v19"]; -const latest = 20; +const ltsVersion = 18; +const experimental = ["v19", "v21"]; +const latest = 22; const CONSOLE_LOG_TAG_COMP = 'microgateway edgemicro'; +// Add the --no-deprecation flag to NODE_OPTIONS +process.env.NODE_OPTIONS = (process.env.NODE_OPTIONS || '') + ' --no-deprecation'; + //don't print versions when obtaining a token. if (!process.argv.includes("token") && !process.argv.includes("get")) { - writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'current nodejs version is %s', version); - writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},'current edgemicro version is %s', edgemicroVersion); + writeConsoleLog('log', { component: CONSOLE_LOG_TAG_COMP }, 'current nodejs version is %s', version); + writeConsoleLog('log', { component: CONSOLE_LOG_TAG_COMP }, 'current edgemicro version is %s', edgemicroVersion); } for (var ver in experimental) { if (version.includes(experimental[ver])) { - writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},"You are using a version of NodeJS that is not supported"); + writeConsoleLog('log', { component: CONSOLE_LOG_TAG_COMP }, "You are using a version of NodeJS that is not supported"); return; } } var majorVersion = parseInt(version.split(".")[0].replace("v", "")); -if (majorVersion == 16) { - writeConsoleLog('log', {component: CONSOLE_LOG_TAG_COMP},'\x1b[33m%s\x1b[0m',`Current Node.js version is ${version}. Note, v16.x.x will be out of support soon, see https://docs.apigee.com/release/notes/edge-microgateway-release-notes-0`); +if (majorVersion == 18) { + writeConsoleLog('log', { component: CONSOLE_LOG_TAG_COMP }, '\x1b[33m%s\x1b[0m', `Current Node.js version is ${version}. Note, v18.x.x will be out of support soon, see https://docs.apigee.com/release/notes/edge-microgateway-release-notes-0`); } if (majorVersion < ltsVersion || majorVersion > latest) { - writeConsoleLog('log',{component: CONSOLE_LOG_TAG_COMP},"You are using a version of NodeJS that is not supported"); + writeConsoleLog('log', { component: CONSOLE_LOG_TAG_COMP }, "You are using a version of NodeJS that is not supported"); return; } else { require('./cmd')() diff --git a/cli/lib/gateway.js b/cli/lib/gateway.js index 4c3fc689..f04c82c5 100644 --- a/cli/lib/gateway.js +++ b/cli/lib/gateway.js @@ -11,7 +11,7 @@ const isWin = /^win/.test(process.platform); const ipcPath = configLocations.getIPCFilePath(); const pidPath = configLocations.getPIDFilePath(); const defaultPollInterval = 600; -const uuid = require('uuid/v1'); +const { v4: uuid } = require('uuid'); const debug = require('debug')('microgateway'); const jsdiff = require('diff'); const _ = require('lodash'); diff --git a/package.json b/package.json index aaf3c83c..1dcdfd47 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "async": "^2.6.4", - "body-parser": "^1.19.0", + "body-parser": "^1.20.3", "cli-prompt": "^0.5.0", "commander": "^2.9.0", "config": "^3.3.9", @@ -17,7 +17,6 @@ "debug": "^3.1.0", "diff": "^3.4.0", "dotenv": "^8.0.0", - "fs-extra": "^0.20.1", "js-yaml": "^3.5.4", "jsonwebtoken": "^9.0.1", "lodash": "^4.17.19", @@ -28,10 +27,10 @@ "microgateway-plugins": "^3.3.4", "pem": "^1.8.1", "portastic": "^1.0.1", - "postman-request": "^2.88.1-postman.33", + "postman-request": "^2.88.1-postman.40", "rimraf": "^2.4.3", "tmp": "0.0.28", - "uuid": "^3.2.1", + "uuid": "^11.0.3", "volos-cache-memory": "^0.10.1", "volos-spikearrest-common": "^0.10.4", "volos-spikearrest-memory": "^0.10.2", @@ -39,13 +38,13 @@ "xml2js": "^0.5.0" }, "devDependencies": { - "eslint": "^8.44.0", + "eslint": "^8.56.0", "eslint-config-google": "^0.13.0", "jshint-stylish": "^2.2.1", "minimist": "^1.2.6", - "mocha": "^9.2.0", + "mocha": "^11.0.1", "nyc": "^15.1.0", - "restify": "^11.1.0", + "restify": "^9.0.1", "rewire": "^6.0.0", "test-until": "^1.1.1" }, @@ -85,11 +84,11 @@ ], "author": "Kevin Swiber ", "engines": { - "node": "^16 || ^18 || ^20", + "node": "^18 || ^20 || ^22", "npm": ">=8.19.3" }, "cpu": [ "!arm", "!mips" ] -} +} \ No newline at end of file