extensions
extensions copied to clipboard
RedactorProvider returns ErasingRedactor for DataClassification.None type
Description
RedactorProvider.GetRedactor(DataClassification.None)
returns ErasingRedactor
instead of NullRedactor
. However a property that is decorated with [NoDataClassification]
attribute is not redacted (which is expected though).
Reproduction Steps
I have enabled and configured redaction in my code. Code:
loggingBuilder.EnableRedaction();
services.AddRedaction();
Set up a dummy API controller with this portion:
var redactor = RedactorProvider.GetRedactor(new DataClassificationSet([DataClassification.None]));
This redactor is of type ErasingRedactor
- validated from unit tests and with breakpoints in the code.
Test:
var services = new ServiceCollection();
var mockLoggingBuilder = new Mock<ILoggingBuilder>();
mockLoggingBuilder.Setup(m => m.Services).Returns(services);
mockLoggingBuilder.Object.EnableRedaction();
services.AddRedaction(mockLoggingBuilder.Object);
var serviceProvider = services.BuildServiceProvider();
var redactorProvider = serviceProvider.GetRequiredService<IRedactorProvider>();
Assert.IsInstanceOfType(redactorProvider.GetRedactor(DataClassification.None), typeof(NullRedactor));
The above assertion failed with ErasingRedactor
received.
Expected behavior
I expect NullRedactor
to be returned for DataClassification.None classification type.
Actual behavior
ErasingRedactor
is returned for DataClassification.None classification type.
Regression?
Not sure.
Known Workarounds
Explicitly set the redactor for DataClassification.None
type using:
serviceCollection.AddRedaction(configure =>
{
configure.SetRedactor<NullRedactor>([new (DataClassification.None)]);
});
Configuration
I use Windows and the latest Compliance.Redaction/Abstraction SDKs.
Other information
No response