From 043178cf65b4462fbeebd455efba725ea8ee1c7a Mon Sep 17 00:00:00 2001 From: Ghoz Date: Sun, 9 Jun 2024 01:50:17 +0200 Subject: [PATCH 1/5] HIDEs the network key in the logs We do in when calling Zigbee-herdsman from zigbee2mqtt, but not here --- package-lock.json | 16 ++++++++++++++++ package.json | 2 ++ src/controller/controller.ts | 7 ++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 1730dca4d0..c24916990c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "fast-deep-equal": "^3.1.3", "mixin-deep": "^2.0.1", "mz": "^2.7.0", + "object-assign-deep": "^0.4.0", "slip": "^1.0.2" }, "devDependencies": { @@ -32,6 +33,7 @@ "@types/mz": "^2.7.8", "@types/nedb": "*", "@types/node": "*", + "@types/object-assign-deep": "^0.4.3", "@typescript-eslint/eslint-plugin": "*", "@typescript-eslint/parser": "*", "babel-jest": "*", @@ -3119,6 +3121,12 @@ "undici-types": "~5.26.4" } }, + "node_modules/@types/object-assign-deep": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@types/object-assign-deep/-/object-assign-deep-0.4.3.tgz", + "integrity": "sha512-d9Gxaj5j1hzrxJ61EFEg13B4g4FgrT/DYtcDWFXPehR8DF2SUZbVMFtZIs8exkVRiqrqBpdTc/lUUZjncsPpMw==", + "dev": true + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -7197,6 +7205,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-assign-deep": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/object-assign-deep/-/object-assign-deep-0.4.0.tgz", + "integrity": "sha512-54Uvn3s+4A/cMWx9tlRez1qtc7pN7pbQ+Yi7mjLjcBpWLlP+XbSHiHbQW6CElDiV4OvuzqnMrBdkgxI1mT8V/Q==", + "engines": { + "node": ">=6" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", diff --git a/package.json b/package.json index 64ba96f2e5..2e21c25e18 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "fast-deep-equal": "^3.1.3", "mixin-deep": "^2.0.1", "mz": "^2.7.0", + "object-assign-deep": "^0.4.0", "slip": "^1.0.2" }, "deprecated": false, @@ -50,6 +51,7 @@ "@types/mz": "^2.7.8", "@types/nedb": "*", "@types/node": "*", + "@types/object-assign-deep": "^0.4.3", "@typescript-eslint/eslint-plugin": "*", "@typescript-eslint/parser": "*", "babel-jest": "*", diff --git a/src/controller/controller.ts b/src/controller/controller.ts index a4d84966a7..8434f02c5f 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -12,6 +12,7 @@ import Touchlink from './touchlink'; import GreenPower from './greenPower'; import {BackupUtils} from "../utils"; import assert from 'assert'; +import objectAssignDeep from 'object-assign-deep'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -123,7 +124,11 @@ class Controller extends events.EventEmitter { // Adapter (create and inject) this.adapter = await Adapter.create(this.options.network, this.options.serialPort, this.options.backupPath, this.options.adapter); - logger.debug(`Starting with options '${JSON.stringify(this.options)}'`, NS); + + let optionsLog = objectAssignDeep({}, this.options, {network: {networkKey: 'HIDDEN'}}); + logger.debug(`Starting with options '${JSON.stringify(optionsLog)}'`, NS); + optionsLog=null; + const startResult = await this.adapter.start(); logger.debug(`Started with result '${startResult}'`, NS); this.adapterDisconnected = false; From 994d5da8283c1c55662ec447d0645cda402f6821 Mon Sep 17 00:00:00 2001 From: Ghoz Date: Wed, 12 Jun 2024 19:39:02 +0200 Subject: [PATCH 2/5] replace the object replace by a string replace slightly more fragile, please don't use a networkKey "network" or any other option key name... --- src/controller/controller.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/controller/controller.ts b/src/controller/controller.ts index 8434f02c5f..d95d54ead4 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -12,7 +12,6 @@ import Touchlink from './touchlink'; import GreenPower from './greenPower'; import {BackupUtils} from "../utils"; import assert from 'assert'; -import objectAssignDeep from 'object-assign-deep'; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore @@ -125,10 +124,7 @@ class Controller extends events.EventEmitter { // Adapter (create and inject) this.adapter = await Adapter.create(this.options.network, this.options.serialPort, this.options.backupPath, this.options.adapter); - let optionsLog = objectAssignDeep({}, this.options, {network: {networkKey: 'HIDDEN'}}); - logger.debug(`Starting with options '${JSON.stringify(optionsLog)}'`, NS); - optionsLog=null; - + logger.debug(`Starting with options '${JSON.stringify(this.options).replaceAll(JSON.stringify(this.options.network.networkKey), '"HIDDEN"')}'`, NS); const startResult = await this.adapter.start(); logger.debug(`Started with result '${startResult}'`, NS); this.adapterDisconnected = false; From 9caa3a5701fc2ff37ce853589a2412f95eff5785 Mon Sep 17 00:00:00 2001 From: Ghoz Date: Wed, 12 Jun 2024 20:06:39 +0200 Subject: [PATCH 3/5] lint stupid tabs --- src/controller/controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controller/controller.ts b/src/controller/controller.ts index d95d54ead4..b083b563b2 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -124,7 +124,8 @@ class Controller extends events.EventEmitter { // Adapter (create and inject) this.adapter = await Adapter.create(this.options.network, this.options.serialPort, this.options.backupPath, this.options.adapter); - logger.debug(`Starting with options '${JSON.stringify(this.options).replaceAll(JSON.stringify(this.options.network.networkKey), '"HIDDEN"')}'`, NS); + const stringifiedOptions = JSON.stringify(this.options).replaceAll(JSON.stringify(this.options.network.networkKey), '"HIDDEN"') + logger.debug(`Starting with options '${stringifiedOptions}'`, NS); const startResult = await this.adapter.start(); logger.debug(`Started with result '${startResult}'`, NS); this.adapterDisconnected = false; From b8f74a7744732513344db0a242872a3d4bc96be9 Mon Sep 17 00:00:00 2001 From: Ghoz Date: Wed, 12 Jun 2024 20:55:14 +0200 Subject: [PATCH 4/5] no comment; --- src/controller/controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/controller.ts b/src/controller/controller.ts index b083b563b2..e2edb49710 100644 --- a/src/controller/controller.ts +++ b/src/controller/controller.ts @@ -124,7 +124,7 @@ class Controller extends events.EventEmitter { // Adapter (create and inject) this.adapter = await Adapter.create(this.options.network, this.options.serialPort, this.options.backupPath, this.options.adapter); - const stringifiedOptions = JSON.stringify(this.options).replaceAll(JSON.stringify(this.options.network.networkKey), '"HIDDEN"') + const stringifiedOptions = JSON.stringify(this.options).replaceAll(JSON.stringify(this.options.network.networkKey), '"HIDDEN"'); logger.debug(`Starting with options '${stringifiedOptions}'`, NS); const startResult = await this.adapter.start(); logger.debug(`Started with result '${startResult}'`, NS); From ecf808eb75822a5dded953ae0f2babe07eaf4bbf Mon Sep 17 00:00:00 2001 From: Ghoz Date: Wed, 12 Jun 2024 21:29:36 +0200 Subject: [PATCH 5/5] actually removed dependency --- package-lock.json | 16 ---------------- package.json | 2 -- 2 files changed, 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index c24916990c..1730dca4d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,6 @@ "fast-deep-equal": "^3.1.3", "mixin-deep": "^2.0.1", "mz": "^2.7.0", - "object-assign-deep": "^0.4.0", "slip": "^1.0.2" }, "devDependencies": { @@ -33,7 +32,6 @@ "@types/mz": "^2.7.8", "@types/nedb": "*", "@types/node": "*", - "@types/object-assign-deep": "^0.4.3", "@typescript-eslint/eslint-plugin": "*", "@typescript-eslint/parser": "*", "babel-jest": "*", @@ -3121,12 +3119,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/@types/object-assign-deep": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/@types/object-assign-deep/-/object-assign-deep-0.4.3.tgz", - "integrity": "sha512-d9Gxaj5j1hzrxJ61EFEg13B4g4FgrT/DYtcDWFXPehR8DF2SUZbVMFtZIs8exkVRiqrqBpdTc/lUUZjncsPpMw==", - "dev": true - }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -7205,14 +7197,6 @@ "node": ">=0.10.0" } }, - "node_modules/object-assign-deep": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-assign-deep/-/object-assign-deep-0.4.0.tgz", - "integrity": "sha512-54Uvn3s+4A/cMWx9tlRez1qtc7pN7pbQ+Yi7mjLjcBpWLlP+XbSHiHbQW6CElDiV4OvuzqnMrBdkgxI1mT8V/Q==", - "engines": { - "node": ">=6" - } - }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", diff --git a/package.json b/package.json index 2e21c25e18..64ba96f2e5 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "fast-deep-equal": "^3.1.3", "mixin-deep": "^2.0.1", "mz": "^2.7.0", - "object-assign-deep": "^0.4.0", "slip": "^1.0.2" }, "deprecated": false, @@ -51,7 +50,6 @@ "@types/mz": "^2.7.8", "@types/nedb": "*", "@types/node": "*", - "@types/object-assign-deep": "^0.4.3", "@typescript-eslint/eslint-plugin": "*", "@typescript-eslint/parser": "*", "babel-jest": "*",