data-anonymization 0.8.0 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/.ruby-version +1 -1
- data/.travis.yml +4 -3
- data/README.md +24 -8
- data/commands.txt +4 -0
- data/data-anonymization.gemspec +7 -7
- data/examples/blacklist_dsl.rb +3 -3
- data/examples/mongodb_blacklist_dsl.rb +5 -5
- data/examples/mongodb_whitelist_dsl.rb +7 -7
- data/examples/whitelist_dsl.rb +4 -4
- data/examples/whitelist_dsl_threads.rb +66 -0
- data/lib/core/field.rb +1 -1
- data/lib/core/table_errors.rb +1 -1
- data/lib/data-anonymization.rb +22 -22
- data/lib/strategy/base.rb +41 -1
- data/lib/strategy/blacklist.rb +3 -2
- data/lib/strategy/field/datetime/anonymize_time.rb +3 -3
- data/lib/strategy/field/default_anon.rb +1 -0
- data/lib/strategy/field/number/random_big_decimal_delta.rb +1 -1
- data/lib/strategy/field/string/random_url.rb +1 -1
- data/lib/strategy/field/string/select_from_database.rb +14 -7
- data/lib/strategy/strategies.rb +1 -1
- data/lib/thor/helpers/mongodb_dsl_generator.rb +2 -3
- data/lib/utils/database.rb +1 -1
- data/lib/utils/random_int.rb +2 -2
- data/lib/utils/template_helper.rb +4 -2
- data/lib/version.rb +1 -1
- data/spec/acceptance/mongodb_blacklist_spec.rb +39 -39
- data/spec/acceptance/mongodb_whitelist_spec.rb +45 -45
- data/spec/acceptance/rdbms_whitelist_spec.rb +1 -1
- data/spec/acceptance/rdbms_whitelist_with_primary_key_spec.rb +8 -8
- data/spec/core/fields_missing_strategy_spec.rb +15 -15
- data/spec/strategy/field/contact/random_address_spec.rb +2 -2
- data/spec/strategy/field/default_anon_spec.rb +3 -3
- data/spec/strategy/field/number/random_big_decimal_delta_spec.rb +1 -1
- data/spec/strategy/field/random_boolean_spec.rb +1 -1
- data/spec/strategy/field/whitelist_spec.rb +1 -1
- data/spec/strategy/mongodb/anonymize_field_spec.rb +11 -11
- data/spec/utils/database_spec.rb +4 -4
- data/spec/utils/template_helper_spec.rb +6 -6
- metadata +19 -18
@@ -1,26 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DataAnon::Core::FieldsMissingStrategy do
|
4
4
|
|
5
5
|
FMS = DataAnon::Core::FieldsMissingStrategy
|
6
6
|
|
7
|
-
it
|
8
|
-
users = FMS.new(
|
9
|
-
users.missing(
|
10
|
-
users.fields_missing_strategy.should == [
|
7
|
+
it 'should be able to add field for new table that doesnot exist' do
|
8
|
+
users = FMS.new('users')
|
9
|
+
users.missing('confirm_email')
|
10
|
+
users.fields_missing_strategy.should == ['confirm_email']
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
14
|
-
users = FMS.new(
|
15
|
-
users.missing(
|
16
|
-
users.missing(
|
17
|
-
users.fields_missing_strategy.should == [
|
13
|
+
it 'should be able to take care for same field appearing multiple time' do
|
14
|
+
users = FMS.new('users')
|
15
|
+
users.missing('confirm_email')
|
16
|
+
users.missing('confirm_email')
|
17
|
+
users.fields_missing_strategy.should == ['confirm_email']
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
users = FMS.new(
|
22
|
-
users.missing(
|
23
|
-
users.missing(
|
24
|
-
users.fields_missing_strategy.should ==
|
20
|
+
it 'should be able to add multiple fields for table' do
|
21
|
+
users = FMS.new('users')
|
22
|
+
users.missing('confirm_email')
|
23
|
+
users.missing('password_reset')
|
24
|
+
users.fields_missing_strategy.should == %w(confirm_email password_reset)
|
25
25
|
end
|
26
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DataAnon::Strategy::Field::RandomAddress do
|
4
4
|
|
@@ -7,6 +7,6 @@ describe DataAnon::Strategy::Field::RandomAddress do
|
|
7
7
|
|
8
8
|
describe 'anonymized address should be different from original address' do
|
9
9
|
let(:anonymized_address) {RandomAddress.region_US.anonymize(field)}
|
10
|
-
it {anonymized_address.should_not eq(
|
10
|
+
it {anonymized_address.should_not eq('1 Infinite Loop')}
|
11
11
|
end
|
12
12
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FieldStrategy::DefaultAnon do
|
4
4
|
|
@@ -29,14 +29,14 @@ describe FieldStrategy::DefaultAnon do
|
|
29
29
|
let(:field) {DataAnon::Core::Field.new('int_field',2,1,nil)}
|
30
30
|
let(:anonymized_value) {DefaultAnon.new.anonymize(field)}
|
31
31
|
|
32
|
-
it { anonymized_value.should be_kind_of
|
32
|
+
it { anonymized_value.should be_kind_of Integer }
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'anonymized bignum value' do
|
36
36
|
let(:field) {DataAnon::Core::Field.new('int_field',2348723489723847382947,1,nil)}
|
37
37
|
let(:anonymized_value) {DefaultAnon.new.anonymize(field)}
|
38
38
|
|
39
|
-
it { anonymized_value.should be_kind_of
|
39
|
+
it { anonymized_value.should be_kind_of Integer }
|
40
40
|
end
|
41
41
|
|
42
42
|
describe 'anonymized string value' do
|
@@ -4,7 +4,7 @@ require 'bigdecimal'
|
|
4
4
|
describe FieldStrategy::RandomBigDecimalDelta do
|
5
5
|
|
6
6
|
RandomBigDecimalDelta = FieldStrategy::RandomBigDecimalDelta
|
7
|
-
let(:field) {DataAnon::Core::Field.new('decimal_field',BigDecimal
|
7
|
+
let(:field) {DataAnon::Core::Field.new('decimal_field',BigDecimal("53422342378687687342893.23324"),1,nil)}
|
8
8
|
|
9
9
|
describe 'anonymized big decimal should not be the same as original value' do
|
10
10
|
let(:anonymized_value) {RandomBigDecimalDelta.new.anonymize(field)}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe DataAnon::Strategy::MongoDB::AnonymizeField do
|
4
4
|
|
@@ -6,30 +6,30 @@ describe DataAnon::Strategy::MongoDB::AnonymizeField do
|
|
6
6
|
it 'should do callback recursive in case of sub document' do
|
7
7
|
sub_document = {'key' => 'value'}
|
8
8
|
field_strategy = {'key' => FieldStrategy::LoremIpsum.new}
|
9
|
-
anonymization_strategy = double(
|
10
|
-
anonymization_strategy.should_receive(:anonymize_document).with(sub_document,1,field_strategy).and_return({'key' =>
|
9
|
+
anonymization_strategy = double('AnonymizationStrategy')
|
10
|
+
anonymization_strategy.should_receive(:anonymize_document).with(sub_document,1,field_strategy).and_return({'key' => 'anonymized_value'})
|
11
11
|
field = DataAnon::Core::Field.new('sub_document_field', sub_document,1,nil)
|
12
12
|
anonymize_field = DataAnon::Strategy::MongoDB::AnonymizeField.new(field, field_strategy,anonymization_strategy)
|
13
13
|
anonymized_value = anonymize_field.anonymize
|
14
|
-
anonymized_value['key'].should ==
|
14
|
+
anonymized_value['key'].should == 'anonymized_value'
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should do callback recursive multiple time in case of array of sub document' do
|
18
18
|
sub_documents = [{'key' => 'value1'},{'key' => 'value2'}]
|
19
19
|
field_strategy = {'key' => FieldStrategy::LoremIpsum.new}
|
20
|
-
anonymization_strategy = double(
|
21
|
-
anonymization_strategy.should_receive(:anonymize_document).with({'key' => 'value1'},1,field_strategy).and_return({'key' =>
|
22
|
-
anonymization_strategy.should_receive(:anonymize_document).with({'key' => 'value2'},1,field_strategy).and_return({'key' =>
|
20
|
+
anonymization_strategy = double('AnonymizationStrategy')
|
21
|
+
anonymization_strategy.should_receive(:anonymize_document).with({'key' => 'value1'},1,field_strategy).and_return({'key' => 'anonymized_value1'})
|
22
|
+
anonymization_strategy.should_receive(:anonymize_document).with({'key' => 'value2'},1,field_strategy).and_return({'key' => 'anonymized_value2'})
|
23
23
|
field = DataAnon::Core::Field.new('sub_document_field', sub_documents,1,nil)
|
24
24
|
anonymize_field = DataAnon::Strategy::MongoDB::AnonymizeField.new(field, field_strategy,anonymization_strategy)
|
25
25
|
anonymized_value = anonymize_field.anonymize
|
26
26
|
anonymized_value.length.should == 2
|
27
|
-
anonymized_value[0]['key'].should ==
|
28
|
-
anonymized_value[1]['key'].should ==
|
27
|
+
anonymized_value[0]['key'].should == 'anonymized_value1'
|
28
|
+
anonymized_value[1]['key'].should == 'anonymized_value2'
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should anonymize array field data type' do
|
32
|
-
anonymization_strategy = double(
|
32
|
+
anonymization_strategy = double('AnonymizationStrategy')
|
33
33
|
anonymization_strategy.should_not_receive(:anonymize_document)
|
34
34
|
field = DataAnon::Core::Field.new('tags',['tag1','tag2'],1,nil)
|
35
35
|
anonymize_field = DataAnon::Strategy::MongoDB::AnonymizeField.new(field,FieldStrategy::SelectFromList.new(['tag4','tag5','tag6','tag7','tag8']),anonymization_strategy)
|
@@ -40,7 +40,7 @@ describe DataAnon::Strategy::MongoDB::AnonymizeField do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should anonymize field and return anonymized value using passed strategy' do
|
43
|
-
anonymization_strategy = double(
|
43
|
+
anonymization_strategy = double('AnonymizationStrategy')
|
44
44
|
anonymization_strategy.should_not_receive(:anonymize_document)
|
45
45
|
field = DataAnon::Core::Field.new('boolean_field',false,1,nil)
|
46
46
|
anonymize_field = DataAnon::Strategy::MongoDB::AnonymizeField.new(field,FieldStrategy::RandomBoolean.new,anonymization_strategy)
|
data/spec/utils/database_spec.rb
CHANGED
@@ -16,10 +16,10 @@ describe 'Utils' do
|
|
16
16
|
album.all.length > 0
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
it 'ignores inherited constants when creating a table with matching name' do
|
20
|
+
conditionals = DataAnon::Utils::SourceTable.create 'Conditionals'
|
21
|
+
conditionals.count.should == 0
|
22
|
+
conditionals.all.length == 0
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Template Helper' do
|
4
4
|
|
5
|
-
it
|
6
|
-
connection_hash = {:
|
5
|
+
it 'should return a correctly formatted string based on input connection hash for source' do
|
6
|
+
connection_hash = {adapter: 'test_adapter', port: 5000}
|
7
7
|
DataAnon::Utils::TemplateHelper.source_connection_specs_rdbms(connection_hash).should eq(":adapter => 'test_adapter', :port => 5000")
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
connection_hash = {:
|
10
|
+
it 'should return a correctly formatted string based on input connection hash for destination' do
|
11
|
+
connection_hash = {adapter: 'test_adapter', port: 5000}
|
12
12
|
DataAnon::Utils::TemplateHelper.destination_connection_specs_rdbms(connection_hash).should eq(":adapter => '<enter_value>', :port => '<enter_value>'")
|
13
13
|
end
|
14
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data-anonymization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunit Parekh
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,70 +18,70 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '6.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '6.0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: composite_primary_keys
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '12.0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '12.0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: activesupport
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '6.0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '6.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rgeo
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0
|
63
|
+
version: '1.0'
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version: '0
|
70
|
+
version: '1.0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rgeo-geojson
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
77
|
+
version: '2.0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
82
|
- - "~>"
|
83
83
|
- !ruby/object:Gem::Version
|
84
|
-
version: '0
|
84
|
+
version: '2.0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: powerbar
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,28 +102,28 @@ dependencies:
|
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: '1.
|
105
|
+
version: '1.12'
|
106
106
|
type: :runtime
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: '1.
|
112
|
+
version: '1.12'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: thor
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - "~>"
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
119
|
+
version: 0.20.3
|
120
120
|
type: :runtime
|
121
121
|
prerelease: false
|
122
122
|
version_requirements: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - "~>"
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
126
|
+
version: 0.20.3
|
127
127
|
description: Data anonymization tool for RDBMS and MongoDB databases
|
128
128
|
email:
|
129
129
|
- parekh.sunit@gmail.com
|
@@ -146,11 +146,13 @@ files:
|
|
146
146
|
- README.md
|
147
147
|
- Rakefile
|
148
148
|
- bin/datanon
|
149
|
+
- commands.txt
|
149
150
|
- data-anonymization.gemspec
|
150
151
|
- examples/blacklist_dsl.rb
|
151
152
|
- examples/mongodb_blacklist_dsl.rb
|
152
153
|
- examples/mongodb_whitelist_dsl.rb
|
153
154
|
- examples/whitelist_dsl.rb
|
155
|
+
- examples/whitelist_dsl_threads.rb
|
154
156
|
- lib/core/database.rb
|
155
157
|
- lib/core/dsl.rb
|
156
158
|
- lib/core/field.rb
|
@@ -296,8 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
298
|
- !ruby/object:Gem::Version
|
297
299
|
version: '0'
|
298
300
|
requirements: []
|
299
|
-
|
300
|
-
rubygems_version: 2.5.1
|
301
|
+
rubygems_version: 3.1.2
|
301
302
|
signing_key:
|
302
303
|
specification_version: 4
|
303
304
|
summary: Tool to create anonymized production data dump to use for performance and
|