Added WebPowerSwitch/Raritan DB record encryption.
This commit is contained in:
parent
3ea21b6271
commit
b76b6816cd
21
db.js
21
db.js
|
@ -507,8 +507,9 @@ module.exports.CreateDB = function (parent, func) {
|
|||
} else if (data[i].type == 'node') {
|
||||
data[i] = performPartialRecordDecrypt(data[i]);
|
||||
if (data[i].intelamt) { data[i].intelamt = performPartialRecordDecrypt(data[i].intelamt); }
|
||||
} else if ((data[i].type == 'mesh') && (data[i].amt)) {
|
||||
} else if ((data[i].type == 'mesh') && (data[i].amt || data[i].kvm)) {
|
||||
data[i].amt = performPartialRecordDecrypt(data[i].amt);
|
||||
data[i].kvm = performPartialRecordDecrypt(data[i].kvm);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
|
@ -521,10 +522,15 @@ module.exports.CreateDB = function (parent, func) {
|
|||
else if ((data.type == 'node') && (data.ssh || data.rdp || data.intelamt)) {
|
||||
var xdata = Clone(data);
|
||||
if (data.ssh || data.rdp) { xdata = performPartialRecordEncrypt(xdata, ['ssh', 'rdp']); }
|
||||
if (data.intelamt) { xdata.intelamt = performPartialRecordEncrypt(xdata.intelamt, ['user', 'pass', 'mpspass']); }
|
||||
if (data.intelamt) { xdata.intelamt = performPartialRecordEncrypt(xdata.intelamt, ['pass', 'mpspass']); }
|
||||
return xdata;
|
||||
}
|
||||
else if ((data.type == 'mesh') && (data.amt || data.kvm)) {
|
||||
var xdata = Clone(data);
|
||||
if (data.amt) { xdata.amt = performPartialRecordEncrypt(xdata.amt, ['password']); }
|
||||
if (data.kvm) { xdata.kvm = performPartialRecordEncrypt(xdata.kvm, ['pass']); }
|
||||
return xdata;
|
||||
}
|
||||
else if ((data.type == 'mesh') && (data.amt != null)) { var xdata = Clone(data); xdata.amt = performPartialRecordEncrypt(xdata.amt, ['password']); return xdata; }
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -532,14 +538,7 @@ module.exports.CreateDB = function (parent, func) {
|
|||
function performPartialRecordEncrypt(plainobj, encryptNames) {
|
||||
if (typeof plainobj != 'object') return plainobj;
|
||||
var enc = {}, enclen = 0;
|
||||
for (var i in encryptNames) {
|
||||
if (plainobj[encryptNames[i]] != null) {
|
||||
console.log('ENCRYPT', encryptNames[i]);
|
||||
enclen++;
|
||||
enc[encryptNames[i]] = plainobj[encryptNames[i]];
|
||||
delete plainobj[encryptNames[i]];
|
||||
}
|
||||
}
|
||||
for (var i in encryptNames) { if (plainobj[encryptNames[i]] != null) { enclen++; enc[encryptNames[i]] = plainobj[encryptNames[i]]; delete plainobj[encryptNames[i]]; } }
|
||||
if (enclen > 0) { plainobj._CRYPT = performRecordEncrypt(enc); } else { delete plainobj._CRYPT; }
|
||||
return plainobj;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue