ControlR.Libraries.DataRedaction 0.18.22

dotnet add package ControlR.Libraries.DataRedaction --version 0.18.22
                    
NuGet\Install-Package ControlR.Libraries.DataRedaction -Version 0.18.22
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ControlR.Libraries.DataRedaction" Version="0.18.22" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ControlR.Libraries.DataRedaction" Version="0.18.22" />
                    
Directory.Packages.props
<PackageReference Include="ControlR.Libraries.DataRedaction" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ControlR.Libraries.DataRedaction --version 0.18.22
                    
#r "nuget: ControlR.Libraries.DataRedaction, 0.18.22"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ControlR.Libraries.DataRedaction@0.18.22
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ControlR.Libraries.DataRedaction&version=0.18.22
                    
Install as a Cake Addin
#tool nuget:?package=ControlR.Libraries.DataRedaction&version=0.18.22
                    
Install as a Cake Tool

ControlR Data Redaction Library

A lightweight library for redacting sensitive data in logs and outputs using Microsoft's data compliance framework.

Overview

This library provides tools to automatically redact sensitive information during logging operations, helping you maintain security and comply with data protection regulations. It uses Microsoft's Microsoft.Extensions.Compliance.Redaction package to seamlessly integrate with standard .NET logging infrastructure.

Installation

dotnet add package ControlR.Libraries.DataRedaction

Quick Start

1. Register the Redactor

Add the redactor to your service collection:

using ControlR.Libraries.DataRedaction;

var builder = WebApplication.CreateBuilder(args);

// Add redaction services
builder.Services.AddStarRedactor();

var app = builder.Build();

2. Mark Sensitive Properties

Use the ProtectedDataClassification attribute to mark properties that should be redacted:

public class User
{
  public string Name { get; set; }
  
  [ProtectedDataClassification]
  public string Password { get; set; }
  
  [ProtectedDataClassification]
  public string ApiKey { get; set; }
}

3. Log Structured Data

When you log objects with protected properties, they'll automatically be redacted:

var user = new User 
{ 
  Name = "John Doe", 
  Password = "secret123",
  ApiKey = "sk_live_abc123"
};

logger.LogInformation("User details: {@User}", user);
// Output: User details: { Name: "John Doe", Password: "****", ApiKey: "****" }

Features

  • Automatic Redaction: Sensitive data is redacted automatically during logging
  • Attribute-Based: Simple [ProtectedDataClassification] attribute to mark sensitive properties
  • Star Redactor: Replaces sensitive values with ****
  • Standard Integration: Works with Microsoft's logging and compliance infrastructure
  • Zero Configuration: Works out of the box with sensible defaults

API Reference

AddStarRedactor()

Registers the StarRedactor and enables redaction in the logging pipeline.

services.AddStarRedactor();

ProtectedDataClassificationAttribute

Marks a property as containing protected data that should be redacted.

[ProtectedDataClassification]
public string SensitiveData { get; set; }

StarRedactor

The default redactor that replaces sensitive values with ****.

DefaultDataClassifications

Provides standard data classification types:

  • Protected: Data that should be redacted
  • Public: Data that can be logged without redaction

Advanced Usage

Custom Data Classifications

You can use the built-in classifications for more granular control:

using Microsoft.Extensions.Compliance.Classification;

public class CustomModel
{
  [DataClassification(DefaultDataClassifications.Public)]
  public string PublicInfo { get; set; }
  
  [DataClassification(DefaultDataClassifications.Protected)]
  public string PrivateInfo { get; set; }
}

Requirements

  • .NET 10.0 or later
  • Microsoft.Extensions.Compliance.Redaction
  • Microsoft.Extensions.Logging

Learn More

For more information about data redaction in .NET, see the official documentation:

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ControlR.Libraries.DataRedaction:

Package Downloads
ControlR.ApiClient

The API client for ControlR, an open-source remote control and remote access solution.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.18.22 48 1/12/2026
0.17.20 121 12/31/2025
0.17.19-dev 92 12/31/2025
0.17.17 96 12/31/2025