GenesisMeter: - logging sensitive information from "*****" to SHA256.
This commit is contained in:
@@ -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="checkRegister">check the content of the register by read back</param>
|
||||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||||
/// <returns>true on successful operation</returns>
|
/// <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,
|
public Boolean WriteRegister<T>(String reg, T value, Boolean waitForResult = true,
|
||||||
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
Boolean checkRegister = false, UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
||||||
{
|
{
|
||||||
@@ -2108,9 +2111,11 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
{
|
{
|
||||||
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
|
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
|
||||||
var data = RegisterConverter.ValueToByteArray(value);
|
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})");
|
_logger.Info($"Slot:{Slot} - Write register({regDef.GetIdent()}), record({rawMsg})");
|
||||||
|
|
||||||
PreRegisterWrite(regDef, data);
|
PreRegisterWrite(regDef, data);
|
||||||
@@ -2160,6 +2165,9 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
/// <param name="expectedLength">expected length for response</param>
|
/// <param name="expectedLength">expected length for response</param>
|
||||||
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
/// <param name="skipRetryErrorCode">skip retries on this error code return</param>
|
||||||
/// <returns></returns>
|
/// <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,
|
public Byte[] ReadRegister(String reg, Int32? expectedLength = null,
|
||||||
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
UInt16 skipRetryErrorCode = CommunicationConfig.SkipRetryErrorCode)
|
||||||
{
|
{
|
||||||
@@ -2168,7 +2176,7 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
{
|
{
|
||||||
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
|
var regDef = _configRegister.GetRegisterDefinitionByName(reg);
|
||||||
_configRegister.Set(regDef, null);
|
_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");
|
var hideDataInLog = regDef.RegisterName.Contains("EncryptionKey");
|
||||||
|
|
||||||
@@ -2192,6 +2200,10 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
|
|||||||
|
|
||||||
RequestProtocolProcess();
|
RequestProtocolProcess();
|
||||||
var result = _configRegister.Get(reg);
|
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);
|
PostRegisterRead(regDef, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user