Skip to content

Commit

Permalink
Fix for issue 20 (#21)
Browse files Browse the repository at this point in the history
* fix: ensure ISensitiveDataFilter are always registered

* chore: minor cleanup
  • Loading branch information
rosrosros authored Mar 26, 2024
1 parent f247f60 commit 4247e7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public BodyLoggerMiddleware(IOptions<BodyLoggerOptions> options, IBodyReader bod
_options = options.Value ?? throw new ArgumentNullException(nameof(options));
_bodyReader = bodyReader ?? throw new ArgumentNullException(nameof(bodyReader));
_telemetryWriter = telemetryWriter ?? throw new ArgumentNullException(nameof(telemetryWriter));
_sensitiveDataFilter = sensitiveDataFilter ?? throw new ArgumentNullException(nameof(telemetryWriter));
_sensitiveDataFilter = sensitiveDataFilter ?? throw new ArgumentNullException(nameof(sensitiveDataFilter));
}

public async Task InvokeAsync(HttpContext context, RequestDelegate next)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ private static void AddBodyLogger(IServiceCollection services, Action<BodyLogger
{
AddBodyLogger(services);
services.Configure(setupAction);
services.AddTransient<ISensitiveDataFilter, SensitiveDataFilter>();
}

private static void AddBodyLogger(IServiceCollection services)
{
services.AddScoped<BodyLoggerMiddleware>();
services.AddScoped<IBodyReader, BodyReader>();
services.AddScoped<ITelemetryWriter, TelemetryWriter>();
services.AddSingleton<ITelemetryInitializer, ClientIpInitializer>();
services.AddTransient<ISensitiveDataFilter, SensitiveDataFilter>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SensitiveDataFilter : ISensitiveDataFilter
{
private const string SensitiveValueMask = "***MASKED***";

public readonly HashSet<string> _sensitiveDataPropertyKeys;
private readonly HashSet<string> _sensitiveDataPropertyKeys;
private readonly IEnumerable<string> _regexesForSensitiveValues;


Expand Down

0 comments on commit 4247e7f

Please sign in to comment.