Skip to content

Commit

Permalink
Merge pull request #62 from Grizzelbee/Dev_0.7.3
Browse files Browse the repository at this point in the history
Dev 0.7.3
  • Loading branch information
Grizzelbee authored Feb 10, 2021
2 parents 141eaf7 + 0920323 commit 0cd003a
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 177 deletions.
2 changes: 1 addition & 1 deletion admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<span class="translate">email_desc</span>
</div>
<div class="input-field col s12 m4">
<input class="value" id="Password" maxlength="32" type="text">
<input class="value" id="Password" maxlength="32" type="password">
<label class="translate" for="Password">Lbl_Password</label>
<span class="translate">password_desc</span>
</div>
Expand Down
18 changes: 13 additions & 5 deletions dyson-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ module.exports.zeroFill = function (number, width) {
*/
module.exports.checkAdapterConfig = async function (adapter) {
const config = adapter.config;
// Masking sensitive fields (password) for logging configuration (creating a deep copy of the config)
let logConfig = JSON.parse(JSON.stringify(config));
// logConfig.Password = logConfig.Password.length > 0?'(***YourSecretPwd***)':'';
logConfig = JSON.stringify(logConfig);
// TODO Move to separate function for masking config wherever needed in this module
// Prepare masked Config for debuggging
const logConfig = JSON.stringify(this.maskConfig(config));

return new Promise(
function (resolve, reject) {
Expand Down Expand Up @@ -230,6 +227,17 @@ module.exports.getMqttCredentials = function(adapter) {
});
};

/**
* Returns a masked and cloned copy of provided config
* @param unmaskedConfig The unmasked config
*/
module.exports.maskConfig = function (unmaskedConfig) {
// Masking sensitive fields (password) for logging configuration (creating a deep copy of the config)
const maskedConfig = JSON.parse(JSON.stringify(unmaskedConfig));
maskedConfig.Password = '(***)';
return maskedConfig
}

/**
* Parse an incoming JSON message payload from the Dyson device
*
Expand Down
25 changes: 25 additions & 0 deletions dyson-utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,31 @@ describe('dysonUtils => decryptMqttPasswd', () => {
it.skip('should verify decrypt MQTT password mechanism', () => {});
});


describe('dysonUtils => maskConfig', () => {
it('should mask Password while not modifying the rest', () => {
const expectedTemperaturUnit = 'C';
const expectedPollInterval = 60;
const expectedCountry = 'DE';
const expectedEmail = '[email protected]';

const config = {
temperatureUnit: expectedTemperaturUnit,
pollInterval: expectedPollInterval,
country: expectedCountry,
email: expectedEmail,
Password: 'SecretPassword'
};
const maskedConfig = dysonUtils.maskConfig(config);

expect(maskedConfig.Password).to.equal("(***)", "Password wasn't masked to expected value");
expect(maskedConfig.temperatureUnit).to.equal(expectedTemperaturUnit);
expect(maskedConfig.pollInterval).to.equal(expectedPollInterval);
expect(maskedConfig.country).to.equal(expectedCountry);
expect(maskedConfig.email).to.equal(expectedEmail);
});
});

describe('dysonUtils => parseDysonMsgPayload', () => {
// TODO See adapter.processMsg() for now, considering migration to separate message parser later

Expand Down
25 changes: 20 additions & 5 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "dysonairpurifier",
"version": "0.7.2",
"version": "0.7.3",
"news": {
"0.7.3": {
"en": "Bugfix release for some bug and improvements - Refer to changelog for details.",
"de": "Bugfix-Version für einige Fehler und Verbesserungen - Einzelheiten finden Sie im Änderungsprotokoll.",
"ru": "Выпуск исправлений для некоторых ошибок и улучшений - подробности см. В журнале изменений.",
"pt": "Lançamento de correção de bug para alguns bugs e melhorias - Consulte o changelog para detalhes.",
"nl": "Bugfix-uitgave voor enkele bug en verbeteringen - Raadpleeg de changelog voor details.",
"fr": "Version de correctif pour certains bogues et améliorations - Reportez-vous au journal des modifications pour plus de détails.",
"it": "Rilascio di bugfix per alcuni bug e miglioramenti - Fare riferimento al log delle modifiche per i dettagli.",
"es": "Versión de corrección de errores para algunos errores y mejoras: consulte el registro de cambios para obtener más detalles.",
"pl": "Wydanie poprawek błędów i ulepszeń - szczegółowe informacje znajdują się w dzienniku zmian.",
"zh-cn": "Bugfix版本中的一些错误和改进-有关详细信息,请参考changelog。"
},
"0.7.2": {
"en": "Bugfix for config issue.",
"de": "Bugfix für Konfigurationsproblem.",
Expand Down Expand Up @@ -198,13 +210,16 @@
},
"native": {
"email": "",
"country": "",
"country": "de",
"pollInterval": 30,
"temperatureUnit": "C"
},
"encryptedNative": {
"Password": ""
},
"encryptedNative": [
"Password"
],
"protectedNative": [
"Password"
],
"objects": [],
"instanceObjects": []
}
Loading

0 comments on commit 0cd003a

Please sign in to comment.