masking 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +26 -12
- data/.codeclimate.yml +4 -0
- data/.rubocop.yml +8 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +25 -1
- data/Dockerfile +5 -3
- data/Gemfile.lock +54 -72
- data/README.md +25 -30
- data/benchmark/masking.yml +12 -0
- data/{bin/benchmark.rb → benchmark/run.rb} +4 -4
- data/benchmark/users.sql +400 -0
- data/lib/masking/cli.rb +3 -2
- data/lib/masking/config/target_columns/column.rb +1 -9
- data/lib/masking/config/target_columns/method.rb +2 -2
- data/lib/masking/config/target_columns.rb +1 -1
- data/lib/masking/data_mask_processor/cache.rb +22 -0
- data/lib/masking/data_mask_processor.rb +35 -27
- data/lib/masking/insert_statement/sql_builder.rb +5 -10
- data/lib/masking/insert_statement.rb +14 -5
- data/lib/masking/sql_dump_line.rb +21 -6
- data/lib/masking/version.rb +1 -1
- data/lib/masking.rb +4 -4
- data/masking.gemspec +5 -5
- metadata +24 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4d34aeecc48c47e5ad4f96b35f3f8c6afb36a870402e44839a9a4d13af065f1
|
4
|
+
data.tar.gz: 1089fad50f9aaab3afcf32a553c0cba62754ddf05a630f35f6e928e5a205d090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37b50a385f56ab9e7359d245dada16a3f619341e41089bbaafd97a42d2f73d471ea12c014cec410adc1575fdc764c1b88065850decaa992fa0bbd95926919fa
|
7
|
+
data.tar.gz: d071b2b682a2f20a5cb9e5a04ce91901ba4066520ea740058730d19205376e90f23f5e26721bd17fe75657332551bd145a09870fcfb077a5cecfadc06bb5b76b
|
data/.circleci/config.yml
CHANGED
@@ -1,30 +1,44 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
3
|
test_attributes: &test_attributes
|
4
|
-
|
4
|
+
docker:
|
5
|
+
- image: cimg/base:current
|
6
|
+
resource_class: small
|
5
7
|
steps:
|
6
8
|
- checkout
|
7
|
-
-
|
8
|
-
- run:
|
9
|
-
|
9
|
+
- setup_remote_docker
|
10
|
+
- run:
|
11
|
+
name: build docker image
|
12
|
+
command: docker build -t masking-$RUBY_VERSION-$CIRCLE_SHA1 --build-arg ruby_version=$RUBY_VERSION .
|
13
|
+
- run:
|
14
|
+
name: output Ruby version (debug)
|
15
|
+
command: docker run --entrypoint sh masking-$RUBY_VERSION-$CIRCLE_SHA1 -c "ruby -v" # debug
|
16
|
+
- run:
|
17
|
+
name: run test
|
18
|
+
command: docker run --entrypoint sh -e CI -e CODECOV_TOKEN masking-$RUBY_VERSION-$CIRCLE_SHA1 -c "bundle exec rspec"
|
10
19
|
|
11
20
|
jobs:
|
12
|
-
test-
|
21
|
+
test-ruby31:
|
13
22
|
<<: *test_attributes
|
14
23
|
environment:
|
15
|
-
RUBY_VERSION:
|
16
|
-
test-
|
24
|
+
RUBY_VERSION: '3.1'
|
25
|
+
test-ruby30:
|
17
26
|
<<: *test_attributes
|
18
27
|
environment:
|
19
|
-
RUBY_VERSION: '
|
20
|
-
test-
|
28
|
+
RUBY_VERSION: '3.0'
|
29
|
+
test-ruby27:
|
30
|
+
<<: *test_attributes
|
31
|
+
environment:
|
32
|
+
RUBY_VERSION: '2.7'
|
33
|
+
test-ruby26:
|
21
34
|
<<: *test_attributes
|
22
35
|
environment:
|
23
|
-
RUBY_VERSION: '2.
|
36
|
+
RUBY_VERSION: '2.6'
|
24
37
|
|
25
38
|
workflows:
|
26
39
|
'CircleCI: build':
|
27
40
|
jobs:
|
28
41
|
- test-ruby26
|
29
|
-
- test-
|
30
|
-
- test-
|
42
|
+
- test-ruby27
|
43
|
+
- test-ruby30
|
44
|
+
- test-ruby31
|
data/.codeclimate.yml
CHANGED
@@ -9,6 +9,10 @@ plugins:
|
|
9
9
|
enabled: false
|
10
10
|
MD033: # MD033/no-inline-html
|
11
11
|
enabled: false
|
12
|
+
MD024: # Multiple headers with the same content, it is okay for CHANGELOG,md
|
13
|
+
enabled: false
|
14
|
+
MD046: # Code block style, not possible to work with number list
|
15
|
+
enabled: false
|
12
16
|
# below 3 checks are disabled because Codeclimate's Markdownlint is not latest version (0.5.0)
|
13
17
|
MD023:
|
14
18
|
enabled: false
|
data/.rubocop.yml
CHANGED
@@ -3,16 +3,23 @@ AllCops:
|
|
3
3
|
- 'vendor/**/*'
|
4
4
|
- 'spec/fixtures/**/*'
|
5
5
|
- 'tmp/**/*'
|
6
|
-
TargetRubyVersion: 2.
|
6
|
+
TargetRubyVersion: 2.6
|
7
7
|
|
8
8
|
Metrics/LineLength:
|
9
9
|
Max: 120
|
10
10
|
|
11
11
|
Metrics/BlockLength:
|
12
12
|
Max: 75
|
13
|
+
Exclude:
|
14
|
+
- spec/**/*
|
13
15
|
|
14
16
|
Style/Documentation:
|
15
17
|
Enabled: false
|
16
18
|
|
17
19
|
Style/CharacterLiteral:
|
18
20
|
Enabled: false
|
21
|
+
|
22
|
+
Style/BlockDelimiters:
|
23
|
+
Enabled: true
|
24
|
+
Exclude:
|
25
|
+
- spec/**/*
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.3
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [v1.1.0] - 2023-02-25 Happy #ruby30th Birthday🎉
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
- add Ruby 3.0 support [#55](https://github.com/kibitan/masking/pull/55)
|
15
|
+
- add Ruby 3.1 support [#60](https://github.com/kibitan/masking/pull/60)
|
16
|
+
|
17
|
+
### Security
|
18
|
+
|
19
|
+
- chore(deps): bump kramdown from 2.1.0 to 2.3.0 [#54](https://github.com/kibitan/masking/pull/54)
|
20
|
+
|
21
|
+
## [v1.0.1] - 2019-12-31
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- add Ruby 2.7 support [#53](https://github.com/kibitan/masking/pull/53)
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
|
29
|
+
- refactoring [#48](https://github.com/kibitan/masking/pull/48) [#49](https://github.com/kibitan/masking/pull/49) [#50](https://github.com/kibitan/masking/pull/50)
|
30
|
+
|
10
31
|
## [v1.0.0] - 2019-11-10
|
11
32
|
|
12
33
|
### Added
|
@@ -46,7 +67,10 @@ $ bin/benchmark.rb
|
|
46
67
|
|
47
68
|
Initial release version. 🎉
|
48
69
|
|
49
|
-
[Unreleased]: https://github.com/kibitan/masking/compare/
|
70
|
+
[Unreleased]: https://github.com/kibitan/masking/compare/v1.1.0...HEAD
|
71
|
+
[v1.1.0]: https://github.com/kibitan/masking/compare/v1.0.1...v1.1.0
|
72
|
+
[v1.0.1]: https://github.com/kibitan/masking/compare/v1.0.0...v1.0.1
|
73
|
+
[v1.0.0]: https://github.com/kibitan/masking/compare/v0.0.3...v1.0.0
|
50
74
|
[v0.0.3]: https://github.com/kibitan/masking/compare/v0.0.2...v0.0.3
|
51
75
|
[v0.0.2]: https://github.com/kibitan/masking/compare/v0.0.1...v0.0.2
|
52
76
|
[v0.0.1]: https://github.com/kibitan/masking/tree/v0.0.1
|
data/Dockerfile
CHANGED
@@ -2,11 +2,11 @@ ARG ruby_version=2.6
|
|
2
2
|
|
3
3
|
FROM ruby:$ruby_version-alpine AS builder
|
4
4
|
RUN apk add --no-cache build-base git
|
5
|
-
WORKDIR /app
|
6
5
|
RUN addgroup -S app && adduser -S -G app app
|
7
6
|
USER app
|
7
|
+
WORKDIR /app
|
8
8
|
COPY --chown=app . ./
|
9
|
-
RUN gem install bundler:2.
|
9
|
+
RUN gem install bundler:2.4.7 && bundle install -j "$(nproc)"
|
10
10
|
|
11
11
|
FROM builder AS with-mysql-client
|
12
12
|
USER root
|
@@ -14,10 +14,12 @@ RUN apk add --no-cache mysql-client
|
|
14
14
|
USER app
|
15
15
|
|
16
16
|
FROM ruby:$ruby_version-alpine
|
17
|
-
WORKDIR /app
|
18
17
|
# TODO: remove dependecy of `git` from masking.gemspec:L19
|
19
18
|
RUN apk add --no-cache git
|
20
19
|
RUN addgroup -S app && adduser -S -G app app
|
20
|
+
ENV PATH $PATH:/app/exe
|
21
|
+
WORKDIR /app
|
22
|
+
RUN chown app /app
|
21
23
|
USER app
|
22
24
|
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
|
23
25
|
COPY --chown=app . ./
|
data/Gemfile.lock
CHANGED
@@ -1,119 +1,101 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
masking (1.
|
4
|
+
masking (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.0)
|
10
|
-
byebug (
|
10
|
+
byebug (11.0.1)
|
11
|
+
codecov (0.2.12)
|
12
|
+
json
|
13
|
+
simplecov
|
11
14
|
coderay (1.1.2)
|
12
15
|
colored (1.2)
|
13
|
-
coveralls (0.7.1)
|
14
|
-
multi_json (~> 1.3)
|
15
|
-
rest-client
|
16
|
-
simplecov (>= 0.7)
|
17
|
-
term-ansicolor
|
18
|
-
thor
|
19
16
|
diff-lcs (1.3)
|
20
|
-
docile (1.3.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
kramdown (~> 1.
|
30
|
-
mixlib-cli (~> 1
|
31
|
-
mixlib-config (
|
17
|
+
docile (1.3.2)
|
18
|
+
jaro_winkler (1.5.4)
|
19
|
+
json (2.3.1)
|
20
|
+
kramdown (2.3.0)
|
21
|
+
rexml
|
22
|
+
kramdown-parser-gfm (1.1.0)
|
23
|
+
kramdown (~> 2.0)
|
24
|
+
mdl (0.8.0)
|
25
|
+
kramdown (~> 2.0)
|
26
|
+
kramdown-parser-gfm (~> 1.0)
|
27
|
+
mixlib-cli (~> 2.1, >= 2.1.1)
|
28
|
+
mixlib-config (>= 2.2.1, < 4)
|
32
29
|
method_source (0.9.2)
|
33
|
-
|
34
|
-
|
35
|
-
mime-types-data (3.2018.0812)
|
36
|
-
mixlib-cli (1.7.0)
|
37
|
-
mixlib-config (2.2.18)
|
30
|
+
mixlib-cli (2.1.5)
|
31
|
+
mixlib-config (3.0.5)
|
38
32
|
tomlrb
|
39
|
-
|
40
|
-
|
41
|
-
parallel (1.12.1)
|
42
|
-
parser (2.5.3.0)
|
33
|
+
parallel (1.19.1)
|
34
|
+
parser (2.6.5.0)
|
43
35
|
ast (~> 2.4.0)
|
44
|
-
powerpack (0.1.2)
|
45
36
|
pry (0.12.2)
|
46
37
|
coderay (~> 1.1.0)
|
47
38
|
method_source (~> 0.9.0)
|
48
|
-
pry-byebug (3.
|
49
|
-
byebug (~>
|
39
|
+
pry-byebug (3.7.0)
|
40
|
+
byebug (~> 11.0)
|
50
41
|
pry (~> 0.10)
|
51
42
|
rainbow (3.0.0)
|
52
|
-
rake (
|
43
|
+
rake (13.0.1)
|
53
44
|
rake-notes (0.2.2)
|
54
45
|
colored
|
55
46
|
rake
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
rspec-
|
63
|
-
|
64
|
-
rspec-core (3.8.0)
|
65
|
-
rspec-support (~> 3.8.0)
|
66
|
-
rspec-expectations (3.8.2)
|
47
|
+
rexml (3.2.4)
|
48
|
+
rspec (3.9.0)
|
49
|
+
rspec-core (~> 3.9.0)
|
50
|
+
rspec-expectations (~> 3.9.0)
|
51
|
+
rspec-mocks (~> 3.9.0)
|
52
|
+
rspec-core (3.9.0)
|
53
|
+
rspec-support (~> 3.9.0)
|
54
|
+
rspec-expectations (3.9.0)
|
67
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
-
rspec-support (~> 3.
|
69
|
-
rspec-mocks (3.
|
56
|
+
rspec-support (~> 3.9.0)
|
57
|
+
rspec-mocks (3.9.0)
|
70
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
-
rspec-support (~> 3.
|
72
|
-
rspec-support (3.
|
73
|
-
rubocop (0.
|
59
|
+
rspec-support (~> 3.9.0)
|
60
|
+
rspec-support (3.9.0)
|
61
|
+
rubocop (0.78.0)
|
74
62
|
jaro_winkler (~> 1.5.1)
|
75
63
|
parallel (~> 1.10)
|
76
|
-
parser (>= 2.
|
77
|
-
powerpack (~> 0.1)
|
64
|
+
parser (>= 2.6)
|
78
65
|
rainbow (>= 2.2.2, < 4.0)
|
79
66
|
ruby-progressbar (~> 1.7)
|
80
|
-
unicode-display_width (
|
81
|
-
ruby-prof (
|
82
|
-
ruby-progressbar (1.10.
|
83
|
-
simplecov (0.
|
67
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
68
|
+
ruby-prof (1.1.0)
|
69
|
+
ruby-progressbar (1.10.1)
|
70
|
+
simplecov (0.20.0)
|
84
71
|
docile (~> 1.1)
|
85
|
-
|
86
|
-
|
87
|
-
simplecov-html (0.
|
72
|
+
simplecov-html (~> 0.11)
|
73
|
+
simplecov_json_formatter (~> 0.1)
|
74
|
+
simplecov-html (0.12.3)
|
75
|
+
simplecov_json_formatter (0.1.2)
|
88
76
|
tapp (1.5.1)
|
89
77
|
thor
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
tins (1.20.2)
|
94
|
-
tomlrb (1.2.8)
|
95
|
-
unf (0.1.4)
|
96
|
-
unf_ext
|
97
|
-
unf_ext (0.0.7.5)
|
98
|
-
unicode-display_width (1.4.1)
|
78
|
+
thor (1.0.1)
|
79
|
+
tomlrb (1.2.9)
|
80
|
+
unicode-display_width (1.6.0)
|
99
81
|
|
100
82
|
PLATFORMS
|
101
83
|
ruby
|
102
84
|
|
103
85
|
DEPENDENCIES
|
104
|
-
bundler
|
105
|
-
|
86
|
+
bundler
|
87
|
+
codecov
|
106
88
|
masking!
|
107
89
|
mdl
|
108
90
|
pry
|
109
91
|
pry-byebug
|
110
|
-
rake
|
92
|
+
rake
|
111
93
|
rake-notes
|
112
|
-
rspec
|
94
|
+
rspec
|
113
95
|
rubocop
|
114
96
|
ruby-prof
|
115
97
|
simplecov
|
116
98
|
tapp
|
117
99
|
|
118
100
|
BUNDLED WITH
|
119
|
-
2.
|
101
|
+
2.4.7
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
[![Acceptance Test MySQL Status](https://github.com/kibitan/masking/workflows/Acceptance%20Test%20MySQL/badge.svg?branch=master)](https://github.com/kibitan/masking/actions?query=workflow%3A%22Acceptance+Test+MySQL%22+branch%3Amaster)
|
5
5
|
[![Acceptance Test MariaDB Status](https://github.com/kibitan/masking/workflows/Acceptance%20Test%20MariaDB/badge.svg?branch=master)](https://github.com/kibitan/masking/actions?query=workflow%3A%22Acceptance+Test+MariaDB%22+branch%3Amaster)
|
6
6
|
|
7
|
-
[![
|
7
|
+
[![codecov](https://codecov.io/gh/kibitan/masking/branch/master/graph/badge.svg)](https://codecov.io/gh/kibitan/masking)
|
8
8
|
[![Maintainability](https://api.codeclimate.com/v1/badges/290b3005ecc193a3d138/maintainability)](https://codeclimate.com/github/kibitan/masking/maintainability)
|
9
9
|
[![Gem Version](https://badge.fury.io/rb/masking.svg)](https://badge.fury.io/rb/masking)
|
10
10
|
|
11
|
-
The command line tool for anonymizing database records by parsing a SQL dump file and build new SQL dump file with masking sensitive/credential data.
|
11
|
+
The command line tool for anonymizing database records by parsing a SQL dump file and build a new SQL dump file with masking sensitive/credential data.
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -18,7 +18,7 @@ gem install masking
|
|
18
18
|
|
19
19
|
## Requirement
|
20
20
|
|
21
|
-
* Ruby 2.
|
21
|
+
* Ruby 2.6/2.7/3.0/3.1
|
22
22
|
|
23
23
|
## Supported RDBMS
|
24
24
|
|
@@ -49,7 +49,7 @@ gem install masking
|
|
49
49
|
AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
|
50
50
|
```
|
51
51
|
|
52
|
-
A value will be implicitly converted to compatible type. If you prefer to explicitly convert, you could use a tag as defined in [YAML Version 1.1](http://yaml.org/spec/current.html#id2503753)
|
52
|
+
A value will be implicitly converted to a compatible type. If you prefer to explicitly convert, you could use a tag as defined in [YAML Version 1.1](http://yaml.org/spec/current.html#id2503753)
|
53
53
|
|
54
54
|
```yaml
|
55
55
|
not-date: !!str 2002-04-28
|
@@ -57,7 +57,7 @@ gem install masking
|
|
57
57
|
|
58
58
|
String should be matched with [MySQL String Type]( https://dev.mysql.com/doc/refman/8.0/en/string-type-overview.html). Integer/Float should be matched with [MySQL Numeric Type](https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html). Date/Time should be matched with [MySQL Date and Time Type](https://dev.mysql.com/doc/refman/8.0/en/date-and-time-type-overview.html).
|
59
59
|
|
60
|
-
*NOTE: MasKING doesn't check actual schema's type from dump. If you put
|
60
|
+
*NOTE: MasKING doesn't check actual schema's type from the dump. If you put incompatible value it will cause an error during restoring to the database.*
|
61
61
|
|
62
62
|
1. Dump database with anonymizing
|
63
63
|
|
@@ -67,13 +67,13 @@ gem install masking
|
|
67
67
|
mysqldump --complete-insert -u USERNAME DATABASE_NAME | masking > anonymized_dump.sql
|
68
68
|
```
|
69
69
|
|
70
|
-
1. Restore from anonymized dump file
|
70
|
+
1. Restore from the anonymized dump file
|
71
71
|
|
72
72
|
```bash
|
73
73
|
mysql -u USERNAME ANONYMIZED_DATABASE_NAME < anonymized_dump.sql
|
74
74
|
```
|
75
75
|
|
76
|
-
Tip: If you don't need to have anonymized dump file, you can directly insert from stream. It can be faster because it has less IO interaction.
|
76
|
+
Tip: If you don't need to have an anonymized dump file, you can directly insert it from the stream. It can be faster because it has less IO interaction.
|
77
77
|
|
78
78
|
```bash
|
79
79
|
mysqldump --complete-insert -u USERNAME DATABASE_NAME | masking | mysql -u USERNAME ANONYMIZED_DATABASE_NAME
|
@@ -88,27 +88,21 @@ Usage: masking [options]
|
|
88
88
|
-v, --version version
|
89
89
|
```
|
90
90
|
|
91
|
-
## Use case of
|
91
|
+
## Use case of anonymized (production) database
|
92
92
|
|
93
|
-
*
|
93
|
+
* Analyzing production databases for BI, Machine Learning, troubleshooting with respecting GDPR
|
94
|
+
* Stress test / Integration test
|
95
|
+
* Performance optimization for slow query
|
94
96
|
|
95
|
-
|
97
|
+
The analyzing slow query often needs a similar amount of records/cardinality with production, the anonymized database help to analyze and tune the slow query.
|
96
98
|
|
97
|
-
*
|
99
|
+
* Simulating database migration
|
98
100
|
|
99
|
-
Some
|
101
|
+
Some schema migration locks table and it causes trouble during the execution. With a smaller amount of database, the migration will finish in a short time and easy to overlook the problem. With the anonymized production database, it is easy to simulate the migration as the real release and makes it easy to find the problem.
|
100
102
|
|
101
|
-
*
|
103
|
+
* Better feature development flow
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
-
* Better development/demo of a feature
|
106
|
-
|
107
|
-
Using similar data with real one will be good to make a good view of how feature looks like. It makes easy to find out the things to be changed/fixed before release/check the feature in production.
|
108
|
-
|
109
|
-
* Analyze metrics on our production data with respecting GDPR
|
110
|
-
|
111
|
-
We can use this database for BI and some trouble shooting.
|
105
|
+
Using similar data with the production database makes better development experience. It makes easy to find out the things which should be changed/fixed. Also, some bugs are related to unexpected data in production, it makes easy to find them too.
|
112
106
|
|
113
107
|
* And… your idea here!
|
114
108
|
|
@@ -148,7 +142,7 @@ available option via environment variable:
|
|
148
142
|
* `MYSQL_PASSWORD`: password for user(default: `password`)
|
149
143
|
* `MYSQL_DBNAME`: database name(default: `mydb`)
|
150
144
|
|
151
|
-
##### with docker
|
145
|
+
##### with docker-compose
|
152
146
|
|
153
147
|
```bash
|
154
148
|
docker-compose -f docker-compose.yml -f docker-compose/mysql80.yml run -e MYSQL_HOST=mysql80 app acceptance/run_test.sh
|
@@ -185,6 +179,7 @@ bundle exec mdl *.md
|
|
185
179
|
docker build . -t masking
|
186
180
|
echo "sample stdout" | docker run -i masking
|
187
181
|
docker run masking -v
|
182
|
+
docker run --entrypoint sh -it masking # inside of docker container
|
188
183
|
```
|
189
184
|
|
190
185
|
## Profiling
|
@@ -204,31 +199,31 @@ see also: [ruby-prof/ruby-prof: ruby-prof: a code profiler for MRI rubies](https
|
|
204
199
|
|
205
200
|
### Benchmark
|
206
201
|
|
207
|
-
use `
|
202
|
+
use `benchmark/run.rb`
|
208
203
|
|
209
204
|
```bash
|
210
|
-
$
|
205
|
+
$ benchmark/run.rb
|
211
206
|
user system total real
|
212
|
-
1.
|
207
|
+
1.103012 0.009460 1.112472 ( 1.123093)
|
213
208
|
```
|
214
209
|
|
215
210
|
## Design Concept
|
216
211
|
|
217
212
|
### KISS ~ keep it simple, stupid ~
|
218
213
|
|
219
|
-
No connection to database, No handling
|
214
|
+
No connection to the database, No handling files, Only dealing with stdin/stdout. ~ Do One Thing and Do It Well ~
|
220
215
|
|
221
216
|
### No External Dependency
|
222
217
|
|
223
|
-
Depend on only pure language standard libraries, no external libraries
|
218
|
+
Depend on only pure language standard libraries, no external libraries
|
224
219
|
|
225
220
|
## Future Todo
|
226
221
|
|
227
|
-
*
|
222
|
+
* Pluggable/customizable for a mask way e.g. integrate with [Faker](https://github.com/stympy/faker)
|
228
223
|
* Compatible with other RDBMS e.g. PostgreSQL, Oracle, SQL Server
|
229
224
|
* Parse the schema type information and validate target columns value
|
230
225
|
* Performance optimization
|
231
|
-
* Write in streaming process
|
226
|
+
* Write in the streaming process
|
232
227
|
* rewrite by another language?
|
233
228
|
* Well-documentation
|
234
229
|
|
@@ -5,13 +5,13 @@ $LOAD_PATH.unshift('./lib')
|
|
5
5
|
require 'benchmark'
|
6
6
|
require 'masking'
|
7
7
|
|
8
|
-
n = 10_000
|
9
|
-
|
10
8
|
Masking.configure do |config|
|
11
|
-
config.target_columns_file_path = '
|
9
|
+
config.target_columns_file_path = 'benchmark/masking.yml'
|
12
10
|
end
|
13
11
|
|
14
|
-
|
12
|
+
n = 30
|
13
|
+
|
14
|
+
fixture = File.open('benchmark/users.sql')
|
15
15
|
|
16
16
|
Benchmark.bm do |x|
|
17
17
|
x.report do
|