Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedactorProvider returns ErasingRedactor for DataClassification.None type #5265

Closed
cppandcsharp opened this issue Jul 4, 2024 · 0 comments · Fixed by #5424
Closed

RedactorProvider returns ErasingRedactor for DataClassification.None type #5265

cppandcsharp opened this issue Jul 4, 2024 · 0 comments · Fixed by #5424
Assignees
Labels
area-compliance bug This issue describes a behavior which is not expected - a bug. work in progress 🚧

Comments

@cppandcsharp
Copy link

cppandcsharp commented Jul 4, 2024

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-compliance bug This issue describes a behavior which is not expected - a bug. work in progress 🚧
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants