Dandraka.Zoro 4.1.0

dotnet add package Dandraka.Zoro --version 4.1.0
                    
NuGet\Install-Package Dandraka.Zoro -Version 4.1.0
                    
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="Dandraka.Zoro" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dandraka.Zoro" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Dandraka.Zoro" />
                    
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 Dandraka.Zoro --version 4.1.0
                    
#r "nuget: Dandraka.Zoro, 4.1.0"
                    
#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 Dandraka.Zoro@4.1.0
                    
#: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=Dandraka.Zoro&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Dandraka.Zoro&version=4.1.0
                    
Install as a Cake Tool

Zoro - The masked avenger

BIG NEWS FOR VERSION 4.x !!!

Versions 4.x not only support anonymization of Office files (.docx, .xlsx and .pptx) but also now properly support Pseudonymisation: you can have a list of replacements that are applied consistenly. This way, for example, "Jim" is always replaced with "Genius", "George" is always replaced with "Hardworker", "Maria N" is always replaced with "Dancer", "Maria V" is always replaced with "Master of Pastries" and so on.

The list of replacements can be in the config itself, in a CSV or in a database. Read on for details.

Purpose and scope

Zoro is a data masking and anonymization utility. It fetches data from a database, a JSON or a CSV file, and either creates a JSON file, a CSV file or runs SQL statements with the masked data. It can also be used with Office file types (currently .docx, .xlsx and .pptx files are supported) to anonymize their content.

The tool can be used both as a command line program and as a dotnet standard 2.1 library. To run the command line program, simply copy the tools dir from the Nuget package. Windows and Linux versions, both 64-bit, are available.

Usage:

As a command line utility:

[Win] Zoro.exe [mandatory: path to config file] [optional: path to input file] [optional: path to output file]

E.g. Zoro.exe c:\zoro\mask.xml

or Zoro.exe c:\zoro\mask.xml c:\data\original.csv c:\data\anonymized.csv

[Linux] ./zoro [mandatory: path to config file] [optional: path to input file] [optional: path to output file]

E.g. ./zoro /home/jim/zoro/mask.xml

or ./zoro /home/jim/zoro/mask.xml /home/jim/data/original.csv /home/jim/data/anonymized.csv

As a library

// === either read config from file ===
var configFromFile = Zoro.Processor.MaskConfig.ReadConfig("c:\temp\mask.xml");
// === or create in code ===
var config = new Zoro.Processor.MaskConfig()
{
    ConnectionString = "Server=myDbServer;Database=myDb;User Id=myUser;Password=myPassword;",
    ConnectionType = "Microsoft.Data.SqlClient",
    DataSource = DataSource.Database,
    DataDestination = DataDestination.CsvFile,
    SqlSelect = "SELECT * FROM testdata",
    OutputFile = Path.Combine(utility.TestInstanceDir, "maskeddata_db_02.csv")
};
config.FieldMasks.Add(new FieldMask() { FieldName = "name", MaskType = MaskType.Random });
config.FieldMasks.Add(new FieldMask() { FieldName = "iban", MaskType = MaskType.Asterisk });
config.FieldMasks.Add(new FieldMask() { FieldName = "country", MaskType = MaskType.None });
config.FieldMasks.Add(new FieldMask() { FieldName = "address", MaskType = MaskType.List });
config.FieldMasks[3].ListOfPossibleReplacements.Add(new Replacement() 
    { Selector = "country=CH", ReplacementList="Bahnhofstrasse 41,Hauptstrasse 8,Berggasse 4" });
config.FieldMasks[3].ListOfPossibleReplacements.Add(new Replacement() 
    { Selector = "country=GR", ReplacementList="Evangelistrias 22,Thessalias 47,Eparhiaki Odos Lefkogion 6" });
// fallback when nothing matches; MUST be the last one
config.FieldMasks[3].ListOfPossibleReplacements.Add(new Replacement() 
    { Selector = "", ReplacementList="Main Street 9,Fifth Avenue 104,Ranch rd. 1" });         

// === with your config, call the masking method ===
var masker = Zoro.Processor.DataMasking.Create(config);
masker.Mask();

Migrating from 3.x to 4.x

A small change is needed if you use Zoro as a library:

DataMasking is now an abstract class, so new DataMasking(config) no longer compiles. Replace it with DataMasking.Create(config), which picks the right implementation for config.DataSource.

Nothing else is affected.

Documentation:

Masking types reference

Please see the anonymization and masking types reference doc.

Developer documentation

Please see the generated docs.

Notes on usage

  • Input & Output files are optional, but if specified they take precedence over (i.e. are used instead of) the config file.
  • Field names are case-insensitive for CSV files & DB queries, but case-sensitive for JSON files.
  • If using a database to write data (DataDestination=Database), all names of parameters in SqlCommand (@field for SqlServer or $field elsewhere) must have a corresponding FieldMask, even if the MaskType is None. Also, currently connection types of Microsoft.Data.SqlClient and System.Data.OleDb are supported, but if anything else (e.g. MySql, Oracle) is needed please open an issue; adding more is trivial.
  • If input is a JSON of an Office file type (Docx, Xlsx, Pptx) and one or more FieldMasks are type List (FieldMask.MaskType=List), one 1 Replacement entry is allowed, which has to have an empty Selector (Selector="").
  • If input is a JSON file type, FieldMasks that perform a database query (FieldMask.MaskType=Query) are not allowed. This is planned to be supported in a later version.
  • If the input is an Office file type (Docx, Xlsx, Pptx), the output must be of the same type.
  • The masking types ReplacementList and ReplacementQuery work like List and Query, but the masking is consistent (pseudonymisation): the same original value always gets the same replacement. If a value has no replacement left, it is masked with asterisks by default and the console program prints a warning; see OnListExhausted in the masking types reference.

Examples:

Sample configurations for CSV, database, JSON, Word, Excel and PowerPoint files are in the configuration samples.

Note:

Although not required by the license, the author kindly asks that you share any improvements you made.

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0 50 11/13/2026
4.0.0 48 11/12/2026
3.1.0 214 7/18/2026
3.0.0 149 7/10/2026
2.4.0 150 7/7/2026
2.3.4 864 6/3/2024
2.3.3 476 5/31/2024
2.3.2 521 5/31/2024
2.3.1 537 5/30/2024
2.3.0 549 5/29/2024
2.2.1 591 4/29/2024
2.1.4 486 4/25/2024
2.1.3 485 4/23/2024
2.1.2 469 4/23/2024
2.0.3 478 2/28/2024
2.0.1 942 1/4/2023
2.0.0 1,111 12/9/2021
1.0.7 769 11/28/2021
Loading failed

[2.x] Added new masking type 'Expression'. Added full JSON support. Added masking types reference documentation. Added developer docs. Addressed SQL Data Provider Security Feature Bypass Vulnerability CVE-2024-0056 on Microsoft.Data.SqlClient and Microsoft.Data.SqlClient. Fixed case-sensitivity and regex bugs, updated to latest package versions.
   [2.3.5] Updated to dotnet 8 and latest package versions.
   [2.4.0] Updated to dotnet 10, replaced obsolete System.Data.SqlClient with Microsoft.Data.SqlClient and updated to latest package versions.
   [3.0.0] Added Office documents (.docx) support.
   [3.1.0] Added Office spreadsheets (.xlsx) support. Renamed mask type Similar to Random (more intuitive) but kept Similar for backwards compatibility.
   [4.0.0] BREAKING: DataMasking is now abstract, create instances with DataMasking.Create(config) instead of new DataMasking(config). Added new masking types ReplacementList and ReplacementQuery for consistent masking (pseudonymisation), where the same original value always gets the same replacement. The mappings of ReplacementList can be read from a csv file using ReplacementCSV. Fixed List masks never picking the last item, Random masks never generating the digit 9, and rich-text cells in .xlsx files not being masked.
   [4.1.0] Added PowerPoint (.pptx) support (DataSource and DataDestination PptXFile): the text of all slides (hidden ones too), of the layouts and masters they use and of the speaker notes is masked; charts and SmartArt are not. Added configuration samples (ZoroConfigSamples.md) with new Excel and PowerPoint examples. The package now lists all its dependencies (DocumentFormat.OpenXml, Newtonsoft.Json and others were missing) with the versions the library is built with.