GenesisMeter: - logging sensitive information from "*****" to SHA256.

This commit is contained in:
Thomas Wiedebusch
2024-05-17 10:23:40 +02:00
parent 0da0c23689
commit 8a0064aaec
@@ -2101,6 +2101,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <param name="checkRegister">check the content of the register by read back</param>
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
/// <returns>true on successful operation</returns>
/// <remarks date="2024-May-17" author="Thomas Wiedebusch">
/// - Changed sensitive information from "*****" to SHA256.
/// </remarks>
public Boolean WriteRegister<T>(String reg, T value, Boolean waitForResult = true,
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
{
@@ -2108,9 +2111,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
{
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
var data = RegisterConverter.ValueToByteArray(value);
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey") || regDef.RegisterName.Contains("Password");
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey") ||
regDef.RegisterName.Contains("Password");
var rawMsg = hideDataInLog ? "(*****)" : $"({BitConverter.ToString(data.ToArray())})";
//var rawMsg = hideDataInLog ? "(*****)" : $"({BitConverter.ToString(data.ToArray())})";
var rawMsg = RegisterConverter.GetRegisterRawText(regDef, data, hideDataInLog);
_logger.Info($"Slot:{Slot} - Write register({regDef.GetIdent()}), record({rawMsg})");
PreRegisterWrite(regDef, data);
@@ -2160,6 +2165,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
/// <param name="expectedLength">expected length for response</param>
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
/// <returns></returns>
/// <remarks date="2024-May-17" author="Thomas Wiedebusch">
/// - Changed sensitive information from "*****" to SHA256.
/// </remarks>
public Byte[] ReadRegister(String reg, Int32? expectedLength = null,
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
{
@@ -2168,7 +2176,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
{
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
_configRegister.Set(regDef, null);
_logger.Info($"Slot:{Slot} - Read register({regDef.GetIdent()})");
//_logger.Info($"Slot:{Slot} - Read register({regDef.GetIdent()})");
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey");
@@ -2192,6 +2200,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
RequestProtocolProcess();
var result = _configRegister.Get(reg);
var rawMsg = RegisterConverter.GetRegisterRawText(regDef, result, hideDataInLog);
_logger.Info($"Slot:{Slot} - Read register({regDef.GetIdent()}), record({rawMsg})");
PostRegisterRead(regDef, result);
return result;
}