-
Notifications
You must be signed in to change notification settings - Fork 109
Enable data masking #113
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
Enable data masking #113
Conversation
Thank you very much |
this code changes has integrated into release version of v2.3.9 |
@tpflueger I have written a documentation/wiki page attempting to explain this feature. Wiki: https://github.com/MySqlBackupNET/MySqlBackup.Net/wiki/Adjust-Column-Value As you are the original code contributor of this feature, I would like to invite you to review the wiki page and determine if any meaningful points have been omitted. Thank you again. And my apologies for the "late" response to this pull request :) |
@tpflueger Hi tpflueger, can you share some code snippet of how you use this feature on masking data? I would like to share your idea at the wiki page. thank you very much. |
@adriancs2 The documentation looks great! Our use case was for masking data for privacy in environments other than production. An example below utilizing Faker to generate fake data.
|
@tpflueger Hi Tyler. There is a change of how this feature is handled. below is the new sample code. |
@tpflueger Hi Tyler :D. The new version v2.6 is released. I have updated the wiki guideline specifically for this feature. You may read it at: https://github.com/MySqlBackupNET/MySqlBackup.Net/wiki/Adjust-Column-Value line 285 at the method: void ExportToFile(string dbName, string dumpFile, RowsDataExportMode mode)
{
using (MySqlConnection conn = new MySqlConnection(_connectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = $"USE `{dbName}`";
cmd.ExecuteNonQuery();
using (MySqlBackup mb = new MySqlBackup(cmd))
{
mb.ExportInfo.RowsExportMode = mode;
mb.ExportInfo.RecordDumpTime = false;
mb.ExportInfo.InsertLineBreakBetweenInserts = true;
mb.ExportInfo.AddTableColumnValueAdjustment("member2", "name", MaskName);
mb.ExportInfo.AddTableColumnValueAdjustment("member2", "email", MaskEmail);
mb.ExportInfo.AddTableColumnValueAdjustment("member2", "username", MaskUsername);
mb.ExportToFile(dumpFile);
}
}
}
}
object MaskName(object obInput)
{
return ...
}
object MaskEmail(object obInput)
{
return ...
}
static object MaskUsername(object obInput)
{
return ...
} |
Adds a method that would enable masking row values on export.