Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace Particular.LicensingComponent.Report
public class QueueThroughput : System.IEquatable<Particular.LicensingComponent.Report.QueueThroughput>
{
public QueueThroughput() { }
public string NameHash { get; set; }
public string QueueName { get; set; }
public long? Throughput { get; set; }
public Particular.LicensingComponent.Report.DailyThroughput[] DailyThroughputFromAudit { get; init; }
Expand Down Expand Up @@ -77,4 +78,16 @@ namespace Particular.LicensingComponent.Report
public Particular.LicensingComponent.Report.Report ReportData { get; init; }
public string Signature { get; init; }
}
}
namespace Particular.LicensingComponent.Report.Utility
{
public class Masker
{
public Masker(string[] wordsToMask) { }
public string Mask(string stringToMask) { }
}
public static class OneWayHasher
{
public static string CalculateOneWayHash(string input) { }
}
}
8 changes: 8 additions & 0 deletions src/Particular.LicensingComponent.Report/Report.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public record QueueThroughput
/// </summary>
public string QueueName { get; set; }

/// <summary>
/// A hash of the queue name to support unique identification of queues across reports without exposing potentially sensitive information.
/// </summary>
/// <remarks>
/// This should be a one-way hash of the unmasked queue name.
/// </remarks>
public string NameHash { get; set; }

/// <summary>
/// Queue max daily throughput
/// </summary>
Expand Down
36 changes: 36 additions & 0 deletions src/Particular.LicensingComponent.Report/Utility/Masker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Particular.LicensingComponent.Report.Utility;
/// <summary>
/// Provides functionality to mask specified words in a given string with unique replacement values.
/// </summary>
public class Masker
{
readonly (string Mask, string Replacement)[] masks;

/// <summary>
/// Initializes a new instance of the Masker class with the specified words to be masked.
/// </summary>
public Masker(string[] wordsToMask)
{
var number = 0;
masks = [.. wordsToMask
.Select(mask =>
{
number++;
return (mask, $"REDACTED{number}");
})];
}

/// <summary>
/// Replaces all occurrences of specified substrings in the input string with their corresponding masked values
/// using a predefined set of masks.
/// </summary>
public string Mask(string stringToMask)
{
var result = stringToMask;
foreach (var (mask, replacement) in masks)
{
result = result.Replace(mask, replacement, StringComparison.OrdinalIgnoreCase);
}
return result;
}
}
16 changes: 16 additions & 0 deletions src/Particular.LicensingComponent.Report/Utility/OneWayHasher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Particular.LicensingComponent.Report.Utility;

using System.Security.Cryptography;
using System.Text;

/// <summary>
/// Provides static methods for computing one-way hashes using the SHA3-256 algorithm.
/// </summary>
public static class OneWayHasher
{
/// <summary>
/// Calculates the SHA3-256 hash of the specified input string and returns the result as a hexadecimal string.
/// </summary>
public static string CalculateOneWayHash(string input)
=> BitConverter.ToString(SHA3_256.HashData(Encoding.UTF8.GetBytes(input))).Replace("-", "");
}