Byndyusoft.MaskedSerialization.Serilog
3.0.0
dotnet add package Byndyusoft.MaskedSerialization.Serilog --version 3.0.0
NuGet\Install-Package Byndyusoft.MaskedSerialization.Serilog -Version 3.0.0
<PackageReference Include="Byndyusoft.MaskedSerialization.Serilog" Version="3.0.0" />
paket add Byndyusoft.MaskedSerialization.Serilog --version 3.0.0
#r "nuget: Byndyusoft.MaskedSerialization.Serilog, 3.0.0"
// Install Byndyusoft.MaskedSerialization.Serilog as a Cake Addin #addin nuget:?package=Byndyusoft.MaskedSerialization.Serilog&version=3.0.0 // Install Byndyusoft.MaskedSerialization.Serilog as a Cake Tool #tool nuget:?package=Byndyusoft.MaskedSerialization.Serilog&version=3.0.0
Byndyusoft.MaskedSerialization
A tool to mask sensitive data during serialization with the System.Text.Json package
Installing
dotnet add package Byndyusoft.MaskedSerialization
Usage
If you use System.Text.Json to serialize data, use [Masked] attribute to mark properties that should be masked. Example:
public class CompanyDto
{
public string Name { get; set; } = default!;
[Masked]
public string SecretOwner { get; set; } = default!;
public IncomeDto WhiteIncome { get; set; } = default!;
[Masked]
public IncomeDto GreyIncome { get; set; } = default!;
}
public class IncomeDto
{
public string Description { get; set; } = default!;
[Masked]
public long SumInDollars { get; set; }
}
Values of properties SecretOwner and GreyIncome of class CompanyDto will be masked with value "*". Here is an example of simple usage:
var dto = new CompanyDto
{
Name = "Mega Big Company",
SecretOwner = "Navalov",
WhiteIncome = new IncomeDto
{
Description = "White",
SumInDollars = 1000000
},
GreyIncome = new IncomeDto
{
Description = "Black",
SumInDollars = 1000000000
}
};
var serialized = MaskedSerializationHelper.SerializeWithMasking(dto);
The result will be:
{
"Name":"Mega Big Company",
"SecretOwner":"*",
"WhiteIncome":{
"Description":"White",
"SumInDollars":"*"
},
"GreyIncome":"*"
}
You can setup serializer options to enable masking. Another usage example:
var options = new JsonSerializerOptions();
MaskedSerializationHelper.SetupSettingsForMaskedSerialization(options);
var serialized = JsonSerializer.Serialize(dto, options);
Byndyusoft.MaskedSerialization.Newtonsoft
A tool to mask sensitive data during serialization with Newtonsoft.Json
Installing
dotnet add package Byndyusoft.MaskedSerialization.Newtonsoft
Usage
If you use Newtonsoft.Json to serialize data, use [Masked] attribute to mark properties that should be masked. Usage example:
var serialized = MaskedSerializationHelper.SerializeWithMasking(dto);
// Another usage example
var settings = new JsonSerializerSettings();
MaskedSerializationHelper.SetupSettingsForMaskedSerialization(settings);
var serialized = JsonConvert.SerializeObject(dto, settings);
Byndyusoft.MaskedSerialization.Serilog
A tool to mask sensitive destructured data in logging with Serilog
Installing
dotnet add package Byndyusoft.MaskedSerialization.Serilog
Usage
You can setup logger configuration to use destructure masking policy:
var loggerConfiguration = new LoggerConfiguration().WithMaskingPolicy().WriteTo.Console();
Here is an example of simple usage:
public class Service
{
private readonly ILogger<Service> _logger;
public Service(ILogger<Service> logger)
{
_logger = logger;
}
public void LogCompany()
{
var dto = new CompanyDto
{
Name = "Mega Big Company",
SecretOwner = "Navalov",
WhiteIncome = new IncomeDto
{
Description = "White",
SumInDollars = 1000000
},
GreyIncome = new IncomeDto
{
Description = "Black",
SumInDollars = 1000000000
}
};
_logger.LogInformation("Used company {@CompanyDto}", dto);
}
}
The output in the console will be:
[10:47:31 INF] Used company {"Name": "Mega Big Company", "SecretOwner": "*", "WhiteIncome": {"Description": "White", "SumInDollars": "*", "$type": "IncomeDto"}, "GreyIncome": "*", "$type": "CompanyDto"}
Contributing
To contribute, you will need to setup your local environment, see prerequisites. For a contribution and workflow guide, see package development lifecycle.
A detailed overview on how to contribute can be found in the contributing guide.
Prerequisites
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- .NET Core (version 6.0 or higher) - Download & Install .NET Core.
Package development lifecycle
- Implement package logic in
src
- Add or adapt unit-tests in
tests
- Add or change the documentation as needed
- Open pull request for a correct branch. Target the project's
master
branch
Maintainers
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Byndyusoft.MaskedSerialization.Annotations (>= 3.0.0)
- Byndyusoft.MaskedSerialization.Core (>= 3.0.0)
- Serilog (>= 2.10.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.