Vanir is a database masking tool.
$ cat example.sql
INSERT INTO `users` (name, email) VALUES ("Fumiaki MATSUSHIMA", "[email protected]");
$ cat example.yml
users: # Table name
name: "AAA" # Simply replace all name with "AAA"
email: "{{.First 6}}.{{.Hashed}}.{{.Last 3}}@example.com" # You can use go template here
$ cat example.sql | vanir --config example.yml > masked.sql
Masking `users`...
$ cat masked.sql
insert into users(name, email) values ('AAA', '[email protected]');
```
go get github.com/xwb1989/sqlparser@a9cdf22bd561e715bba34ee228cb1c06bfa2719c
```
- Write config file:
users: # Table name
name: "AAA" # Simply replace all name with "AAA"
email: "{{.Raw}}+{{.Hashed}}@example.com" # You can use go template here
- Pipe the dumped SQL:
At this time, vanir can mask SQL dumped with --complete-insert
option only.
mysqldump --complete-insert | vanir -c path/to/config.yml
You can use Go templates to format output.
Function | Configuration | Input | Output |
---|---|---|---|
Hashed | {{.Hashed}}@example.com |
[email protected] | [email protected] |
First(n) | {{.First 3}}@example.com |
[email protected] | [email protected] |
Last(n) | {{.Last 3}}@example.com |
[email protected] | [email protected] |
Raw | {{.Raw}}@example.com |
[email protected] | mtsmfm@[email protected] |
Salt | {{.Salt}}@example.com |
[email protected] | [email protected] |
RandInt(n) | {{.RandInt 3}}@example.com |
[email protected] | [email protected] |
RandString(n) | {{.RandString 3}}@example.com |
[email protected] | [email protected] |
Donwload an executable binary for your platform:
https://github.com/mtsmfm/vanir/releases
- docker
- docker-compose
git clone https://github.com/mtsmfm/vanir
cd vanir
docker-compose run app go-wrapper download
docker-compose run app go-wrapper install
docker-compose run app go-wrapper run