34
loading...
This website collects cookies to deliver better user experience
"This sales demo needs updated data to demonstrate a new feature."
"Regression testing wasn't possible because the database is stale."
"Our staging environment doesn't contain the necessary data."
CREATE TABLE `user` (
`id` int NOT NULL DEFAULT '0',
`email` varchar(256),
`full_name` varchar(100),
`birth_date` date,
`gov_id` varchar(20),
PRIMARY KEY (`id`)
);
INSERT INTO `user` VALUES (1,'[email protected]','Florida Gibson','2000-12-10','111-22-3333'),(2,'[email protected]','Godfrey Mosciski','1980-01-01','333-22-1111'),(3,'[email protected]','Tommie Quitzon','1960-06-07','444-55-6666');
{
"columns": [
{
"columnKey": "full_name",
"redactWith": "NAME REMOVED",
"tracked": false
},
{
"columnKey": "email",
"redactWith": "internet.email",
"tracked": false
},
{
"columnKey": "birth_date",
"redactWith": "createBirthday",
"tracked": false
},
{
"columnKey": "gov_id",
"redactWith": "{{datatype.number({\"min\":100,\"max\":999})}}-{{datatype.number({\"min\":10,\"max\":99})}}-{{datatype.number({\"min\":1000,\"max\":9999})}}",
"tracked": false
}
]
}
cat user.sql | de-identify-sql > user-de-identified.sql
INSERT INTO `user` VALUES
(1,'[email protected]','NAME REMOVED','1976-05-17','420-15-1747'),
(2,'[email protected]','NAME REMOVED','1961-10-17','327-49-5054'),
(3,'[email protected]','NAME REMOVED','2002-11-10','106-57-2546');
full_name
is redacted with a constant: NAME_REMOVED
.email
column, we're calling a faker function to generate a new email address.gov_id
, we use a mustache-like template of faker functions.user.js
:
const faker = require('faker')
module.exports = {
createBirthday: () => {
return faker.date.past(80).toISOString().slice(0, 10);
}
}
tracked
parameter in the JSON strategy file from false
to true
this will replace an repeated fields with the same fabricated values. For example, this order SQL:INSERT INTO `order` VALUES
(1000,'[email protected]',12.99),
(1001,'[email protected]',123.45),
(1002,'[email protected]',70.00),
(1003,'[email protected]',542.01),
(1004,'[email protected]',67.52);
{
"columns": [
{
"columnKey": "order_email",
"redactWith": "internet.email",
"tracked": true
}
]
}
INSERT INTO `order` VALUES
(1000,'[email protected]',12.99),
(1001,'[email protected]',123.45),
(1002,'[email protected]',70),
(1003,'[email protected]',542.01),
(1004,'[email protected]',67.52);
mysqldump
should be used to create input SQL.