diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml index 8ccee406..b791e6f2 100644 --- a/.github/workflows/webpack.yml +++ b/.github/workflows/webpack.yml @@ -32,6 +32,6 @@ jobs: node-version: '16' - run: npm i -g yarn - - run: yarn global add webpack-cli + - run: yarn global add webpack-cli@5.1.4 - run: mkdir -p webpack; cd webpack; yarn add webpack webpack-cli || true - run: $(yarn global bin)/webpack-cli -c .webpack/config.js diff --git a/util/logger.js b/util/logger.js index 47d27d1d..0189d57a 100644 --- a/util/logger.js +++ b/util/logger.js @@ -42,21 +42,24 @@ if (process.env.FWDEBUG) { } const keysToRedact = new Set(["password", "passwd", "psk", "key", "psks"]); -// pass in function arguments object and returns string with whitespaces function redactLog(obj, redactRequired = false) { if (!obj) return obj; // obj should be either object or array + const objCopy = _.isArray(obj) ? [] : Object.create(obj); try { for (const key of Object.keys(obj)) { if (_.isObject(obj[key]) || _.isArray(obj[key])) - redactLog(obj[key], redactRequired || keysToRedact.has(key)); + objCopy[key] = redactLog(obj[key], redactRequired || keysToRedact.has(key)); else { if (redactRequired || keysToRedact.has(key)) - obj[key] = "*** redacted ***"; + objCopy[key] = "*** redacted ***"; + else + objCopy[key] = obj[key]; } } } catch (err) {} + return objCopy; } // pass in function arguments object and returns string with whitespaces @@ -66,8 +69,8 @@ function argumentsToString(v) { for (var k in args) { if (typeof args[k] === "object") { // args[k] = JSON.stringify(args[k]); - args[k] = JSON.parse(JSON.stringify(args[k])); - redactLog(args[k]); + if (_.isArray(args[k]) || _.isObject(args[k])) + args[k] = redactLog(args[k]); args[k] = require('util').inspect(args[k], false, null, true); } }