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
4 changes: 3 additions & 1 deletion src/AppCommon/Commands/BaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Particular.EndpointThroughputCounter.Infra;
using Particular.EndpointThroughputCounter.ServiceControl;
using Particular.LicensingComponent.Report;
using Particular.LicensingComponent.Report.Utility;

abstract class BaseCommand
{
Expand Down Expand Up @@ -206,6 +207,7 @@ async Task RunInternal(CancellationToken cancellationToken)

foreach (var q in data.Queues)
{
q.NameHash = OneWayHasher.CalculateOneWayHash(q.QueueName);
q.QueueName = shared.Mask(q.QueueName);
if (q.Throughput.HasValue)
{
Expand Down Expand Up @@ -247,7 +249,7 @@ async Task RunInternal(CancellationToken cancellationToken)
StartTime = new DateTimeOffset(DateTime.UtcNow.Date, TimeSpan.Zero),
EndTime = new DateTimeOffset(DateTime.UtcNow.Date.AddDays(1), TimeSpan.Zero),
ReportDuration = TimeSpan.FromDays(1),
Queues = mappedQueueNames.Select(map => new QueueThroughput { QueueName = map.Masked, Throughput = 0 }).ToArray(),
Queues = mappedQueueNames.Select(map => new QueueThroughput { QueueName = map.Masked, NameHash = OneWayHasher.CalculateOneWayHash(map.Name), Throughput = 0 }).ToArray(),
TotalThroughput = 0,
TotalQueues = mappedQueueNames.Length,
IgnoredQueues = metadata.IgnoredQueues?.Select(q => shared.Mask(q)).ToArray()
Expand Down
21 changes: 4 additions & 17 deletions src/AppCommon/Infra/SharedOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using Particular.LicensingComponent.Report.Utility;

class SharedOptions
{
Expand Down Expand Up @@ -43,7 +44,7 @@ class SharedOptions
public bool SkipThroughputCollection { get; private set; }
public int RuntimeInHours { get; private set; }

(string Mask, string Replacement)[] masks;
Masker masker;

public static void Register(Command command)
{
Expand Down Expand Up @@ -73,14 +74,7 @@ public static void Register(Command command)
SkipThroughputCollection = parse.GetValueForOption(skipThroughputCollection);
RuntimeInHours = parse.GetValueForOption(runtimeInHours);

int number = 0;
masks = parse.GetValueForOption(maskNames)
.Select(mask =>
{
number++;
return (mask, $"REDACTED{number}");
})
.ToArray();
masker = new(parse.GetValueForOption(maskNames) ?? []);
}

public static SharedOptions Parse(InvocationContext context)
Expand All @@ -89,12 +83,5 @@ public static SharedOptions Parse(InvocationContext context)
}

public string Mask(string stringToMask)
{
foreach (var (mask, replacement) in masks)
{
stringToMask = stringToMask.Replace(mask, replacement, StringComparison.OrdinalIgnoreCase);
}

return stringToMask;
}
=> masker.Mask(stringToMask);
}
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<PackageVersion Include="NUnit.Analyzers" Version="4.11.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.1.0" />
<PackageVersion Include="Particular.Approvals" Version="2.0.1" />
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.0.0" />
<PackageVersion Include="Particular.LicensingComponent.Report" Version="1.1.0" />
<PackageVersion Include="Particular.Packaging" Version="4.5.0" />
<PackageVersion Include="PublicApiGenerator" Version="11.5.4" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
Expand Down