Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
global-json-file: global.json

- name: Restore dependencies
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
anonymizer_tables.json

### XbK additions

**/wwwroot/cache.json
Expand Down
39 changes: 11 additions & 28 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "bin/Debug/net8.0/DancingGoat.dll",
"args": [],
"cwd": "${workspaceFolder}/examples/DancingGoat",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/examples/DancingGoat/Views"
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/bin/Debug/net8.0/XperienceCommunity.DatabaseAnonymizer.dll",
"args": [],
"cwd": "${workspaceFolder}",
"console": "externalTerminal",
"stopAtEntry": false,
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
}
93 changes: 12 additions & 81 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,84 +1,15 @@
{
"version": "2.0.0",
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "install",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"group": "build",
"problemMatcher": [],
"label": "npm: install - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"detail": "install dependencies from package"
},
{
"type": "dotnet",
"task": "build",
"problemMatcher": ["$msCompile"],
"group": "build",
"label": "dotnet: build"
},
{
"type": "shell",
"command": "dotnet",
"args": [
"format",
"Kentico.Xperience.RepoTemplate.sln",
"--exclude",
"./examples/**"
],
"problemMatcher": ["$msCompile"],
"group": "none",
"label": "dotnet: format"
},
{
"type": "dotnet",
"task": "clean",
"problemMatcher": ["$msCompile"],
"group": "build",
"label": "dotnet: clean"
},
{
"type": "npm",
"script": "build",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"group": "build",
"problemMatcher": [],
"label": "npm: build - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"detail": "webpack --mode=production"
},
{
"type": "npm",
"script": "build:dev",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"group": "build",
"problemMatcher": [],
"label": "npm: build:dev - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"detail": "webpack --mode=development"
},
{
"type": "npm",
"script": "start",
"path": "src/Kentico.Xperience.RepoTemplate/Admin/Client",
"problemMatcher": [],
"label": "npm: start - src/Kentico.Xperience.RepoTemplate/Admin/Client",
"detail": "webpack serve --mode development"
},
{
"label": "dotnet: watch DancingGoat",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/examples/DancingGoat/DancingGoat.csproj"
],
"options": {
"env": {
"DOTNET_WATCH_RESTART_ON_RUDE_EDIT": "true"
}
},
"problemMatcher": "$msCompile"
}
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/XperienceCommunity.DatabaseAnonymizer.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
}
11 changes: 6 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<Trademark>$(Company)™</Trademark>
<VersionPrefix>0.0.1</VersionPrefix>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<PackageProjectUrl>https://github.com/kentico-ericd/xperience-community-database-anonymizer</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/kentico-ericd/xperience-community-database-anonymizer/releases</PackageReleaseNotes>
<PackageIcon>logo.png</PackageIcon>
Expand All @@ -21,18 +20,20 @@
</ItemGroup>

<PropertyGroup>
<LangVersion>latest</LangVersion>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<PackAsTool>true</PackAsTool>
<ToolCommandName>xperience-anonymizer</ToolCommandName>
<LangVersion>12.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<CopyDocumentationFilesFromPackages>true</CopyDocumentationFilesFromPackages>
<CopyDebugSymbolFilesFromPackages>true</CopyDebugSymbolFilesFromPackages>
<NoWarn>$(NoWarn);1591</NoWarn>
<RootNamespace>XperienceCommunity.DatabaseAnonymizer</RootNamespace>

<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<TimestampServerUrl>http://timestamp.digicert.com</TimestampServerUrl>
</PropertyGroup>
Expand Down
7 changes: 5 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Autofac" Version="7.1.0" />
<PackageVersion Include="Kentico.Xperience.Libraries" Version="13.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Spectre.Console" Version="0.49.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
<PackageVersion Include="Kentico.Xperience.Libraries" Version="13.0.169" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
</Project>
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## Description

This Kentico 13 integration allows developers to encrypt sensitive data within the Kentico database using a salt of their choosing. The data can only be decrypted using this salt, so the database can be shared with members outside of the organization safely. Once a backup of the database with anonymized data is created, the original database can be decrypted to restore the sensitive data.
This dotnet tool allows developers to anonymize sensitive data within a Kentico 13 database. The database remains in a usable state and can be connected to a Kentico 13 instance. This can be useful to protect user and visitor personal data when sending the database to third-parties including Kentico Support.

## Requirements

Expand All @@ -15,28 +15,33 @@ This Kentico 13 integration allows developers to encrypt sensitive data within t
| ----------------- | --------------- |
| >= 13.0.0 | >= 1.0.0 |

## Package Installation
## Installing the tool

Add the package to your CMS application using Visual Studio's [Package Manager](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio) or [NuGet CLI](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell):
Run the following command from a command prompt such as Powershell:

```powershell
Install-Package Xperience.Community.DatabaseAnonymizer
dotnet tool install XperienceCommunity.DatabaseAnonymizer -g
```

## Quick Start

> :warning: Always make a backup of your database _before_ running anonymization!
## Updating the tool

The anonymization/deanonymization process will _only_ run if there are two application settings present in the CMS project's `web.config`:
Run the following command from a command prompt such as Powershell:

```xml
<add key="XperienceCommunityEnableAnonymization" value="true" />
<add key="XperienceCommunityAnonymizationSalt" value="<your salt>" />
```bash
dotnet tool update XperienceCommunity.DatabaseAnonymizer -g
```

Add these keys to your `web.config` with the desired salt, and upon the next application start, the database will be anonymized. A new settings key (installed automatically) named "XperienceCommunityDatabaseAnonymized" tracks the current state of the database, so it is safe to leave these keys in the `web.config`- the process will only run once.
Updates to the tool may include changes to the `anonymizer_tables.json` file used to define the tables and columns anonymized by the tool (see the [Usage Guide](/docs/Usage-Guide.md#adding-your-tables)). In these cases, we recommend regenerating the default configuration file and merging your customizations into the generated file.

## Quick Start

Run the following command from a command prompt such as Powershell:

```powershell
xperience-anonymizer
```

The anonymization process runs in the background on application start. To monitor its progress, check the __Event log__ for "ANONYMIZE_START" and "ANONYMIZE_END" events (or, the equivalent "DEANONYMIZE" events). The "END" event will contain a detailed description of the process and modified records. To restore the database to its original state, set the "XperienceCommunityEnableAnonymization" key to false. If you are shipping the entire project (not just the sanitized database), be sure to remove the salt from the `web.config`!
The tool will prompt you to provide connection details for the Kentico 13 database, then run the anonymization process.

## Full Instructions

Expand Down
64 changes: 39 additions & 25 deletions docs/Usage-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## Supported tables

See the default implementation [`AnonymizationTableProvider`](/src/Services/AnonymizationTableProvider.cs) for a full list of supported tables and columns. This integration currently anonymizes the data contained in the following tables:
See [`TablesConfiguration`](/src/Models/TablesConfiguration.cs) for a full list of supported tables and columns. This integration currently anonymizes the data contained in the following tables:

- CMS_Country
- CMS_Email
- CMS_State
- CMS_User
- CMS_UserSettings
- COM_Address
Expand All @@ -15,32 +17,44 @@ See the default implementation [`AnonymizationTableProvider`](/src/Services/Anon

## Adding your tables

If the list of [supported tables](#supported-tables) doesn't meet your needs, you can use a custom `IAnonymizationTableProvider` to generate a list of your own. You can copy tables from [`AnonymizationTableProvider`](/src/Services/AnonymizationTableProvider.cs), add your tables and columns, and use the `RegisterImplementation` to register it. For example, you may want to anonymize data entered in your forms:
If the list of [supported tables](#supported-tables) doesn't meet your needs, you can modify the `anonymizer_tables.json` file to add your own tables. This file is automatically generated when running the tool for the first time, and can be found in the directory the tool is executed from. If the directory doesn't contain this file, you can run the tool and cancel (CTRL+C) before answering the prompts.

```cs
[assembly: RegisterImplementation(typeof(IAnonymizationTableProvider), typeof(MyTableProvider))]
//...
public class MyTableProvider : IAnonymizationTableProvider
Each record in this JSON file contains the table name, the `AnonymizeColumns` property indicating which columns to anonymize, and the `NullColumns` property indicating which columns to set to `null`:

```json
{
"TableName": "CMS_UserSettings",
"AnonymizeColumns": [
"UserNickName",
"UserSignature",
"UserRegistrationInfo",
"UserDescription",
"UserSkype",
"UserIM",
"UserPhone",
"UserPosition"
],
"NullColumns": [
"UserGender",
"UserDateOfBirth",
"UserTimeZoneID"
]
},
```

For example, you may want to anonymize data entered in your forms:

```json
{
private readonly Dictionary<string, string[]> myTables = new Dictionary<string, string[]>
"Tables": [
{
{ "OM_Contact", new string[]
{
nameof(ContactInfo.ContactFirstName),
// Other columns from default implementation...
}
},
{ "DancingGoat_ContactForm", new string[]
{
"Name",
"Email"
}
}
};

public IEnumerable<string> GetTables() => myTables.Keys;

public IEnumerable<string> GetColumns(string tableName) =>
myTables.FirstOrDefault(x => x.Key.Equals(tableName, StringComparison.OrdinalIgnoreCase)).Value;
"TableName": "DancingGoat_ContactUs",
"AnonymizeColumns": [
"Name",
"Email",
]
},
// Other tables...
]
}
```
47 changes: 0 additions & 47 deletions src/AnonymizerModule.cs

This file was deleted.

Loading
Loading