data-anonymization 0.8.2 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +5 -4
- data/README.md +3 -0
- data/commands.txt +4 -0
- data/data-anonymization.gemspec +8 -8
- data/lib/strategy/blacklist.rb +3 -2
- data/lib/strategy/field/datetime/anonymize_time.rb +3 -3
- data/lib/strategy/field/number/random_big_decimal_delta.rb +1 -1
- data/lib/utils/database.rb +1 -1
- data/lib/utils/random_int.rb +2 -2
- data/lib/version.rb +1 -1
- data/spec/acceptance/mongodb_whitelist_spec.rb +1 -1
- data/spec/strategy/field/default_anon_spec.rb +2 -2
- data/spec/strategy/field/number/random_big_decimal_delta_spec.rb +1 -1
- data/spec/utils/database_spec.rb +4 -4
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b68a0165fb4a1e2d34cbb026f48b1bfe7fcdb78f14528d6df3882c8de0ef3cab
|
4
|
+
data.tar.gz: e3c810e9c58f27486fc28bb7f5c1dbd293da16c3c7e814bbd465598c3b245b02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aabc744c832fa3bda18d9d20884792bc1870733e5dbb1dad328e611243359f237b419be686f1ac58eab6d45516a112ee4f05a1499ae621fc59bb252964d2cd7
|
7
|
+
data.tar.gz: 6376e641eecf9c113ef330ca40f72bc1f8b26ce9f16894aa35374e2258e65ee559a374a277f8462bcd839cc53568f61bedcaf98988715fbb3a6116488322102a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -81,6 +81,9 @@ Postgresql database having **composite primary key**
|
|
81
81
|
|
82
82
|
## Changelog
|
83
83
|
|
84
|
+
#### 0.8.5 (May 28, 2020)
|
85
|
+
1. Upgraded to rails 6.x
|
86
|
+
|
84
87
|
#### 0.8.1 (Aug 19, 2017)
|
85
88
|
1. Multi-threading support added by [stanislav-tyutin](https://github.com/stanislav-tyutin) using Pull Request.
|
86
89
|
2. Fixed to work with Ruby 2.4.x, issue with Integer data type
|
data/commands.txt
ADDED
data/data-anonymization.gemspec
CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
20
|
gem.require_paths = ['lib']
|
21
21
|
|
22
|
-
gem.add_dependency('activerecord', '~>
|
23
|
-
gem.add_dependency('
|
24
|
-
gem.add_dependency('
|
25
|
-
gem.add_dependency('
|
26
|
-
gem.add_dependency('
|
27
|
-
gem.add_dependency('
|
28
|
-
gem.add_dependency('
|
29
|
-
gem.add_dependency('thor', '~>
|
22
|
+
gem.add_dependency('activerecord', '~> 6.1')
|
23
|
+
gem.add_dependency('activesupport', '~> 6.1')
|
24
|
+
gem.add_dependency('composite_primary_keys', '~> 13.0')
|
25
|
+
gem.add_dependency('parallel', '~> 1.20')
|
26
|
+
gem.add_dependency('powerbar', '~> 2.0')
|
27
|
+
gem.add_dependency('rgeo', '~> 2.3')
|
28
|
+
gem.add_dependency('rgeo-geojson', '~> 2.1')
|
29
|
+
gem.add_dependency('thor', '~> 1.1')
|
30
30
|
end
|
data/lib/strategy/blacklist.rb
CHANGED
@@ -3,15 +3,16 @@ module DataAnon
|
|
3
3
|
class Blacklist < DataAnon::Strategy::Base
|
4
4
|
|
5
5
|
def process_record index, record
|
6
|
+
updates = {}
|
6
7
|
@fields.each do |field, strategy|
|
7
8
|
database_field_name = record.attributes.select { |k,v| k == field }.keys[0]
|
8
9
|
field_value = record.attributes[database_field_name]
|
9
10
|
unless field_value.nil? || is_primary_key?(database_field_name)
|
10
11
|
field = DataAnon::Core::Field.new(database_field_name, field_value, index, record, @name)
|
11
|
-
|
12
|
+
updates[database_field_name] = strategy.anonymize(field)
|
12
13
|
end
|
13
14
|
end
|
14
|
-
record.
|
15
|
+
record.update_columns(updates) if updates.any?
|
15
16
|
end
|
16
17
|
|
17
18
|
end
|
@@ -58,8 +58,8 @@ module DataAnon
|
|
58
58
|
month = @anonymize_month? DataAnon::Utils::RandomInt.generate(1,12) : original_time.month
|
59
59
|
days_in_month = Time.new(year,month,1,1,1,1).end_of_month.day
|
60
60
|
day = @anonymize_day? DataAnon::Utils::RandomInt.generate(1,days_in_month) : original_time.day
|
61
|
-
hour = @anonymize_hour? DataAnon::Utils::RandomInt.generate(
|
62
|
-
min = @anonymize_min? DataAnon::Utils::RandomInt.generate(
|
61
|
+
hour = @anonymize_hour? DataAnon::Utils::RandomInt.generate(0,23) : original_time.hour
|
62
|
+
min = @anonymize_min? DataAnon::Utils::RandomInt.generate(0,59) : original_time.min
|
63
63
|
sec = original_time.sec
|
64
64
|
|
65
65
|
create_object(year, month, day, hour, min, sec)
|
@@ -74,4 +74,4 @@ module DataAnon
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
end
|
77
|
+
end
|
@@ -16,7 +16,7 @@ module DataAnon
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def anonymize field
|
19
|
-
return BigDecimal
|
19
|
+
return BigDecimal("#{field.value + DataAnon::Utils::RandomFloat.generate(-@delta, +@delta)}")
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
data/lib/utils/database.rb
CHANGED
@@ -25,7 +25,7 @@ module DataAnon
|
|
25
25
|
|
26
26
|
def self.create_table database, table_name, primary_keys = []
|
27
27
|
klass_name = table_name.to_s.downcase.capitalize
|
28
|
-
return database.const_get
|
28
|
+
return database.const_get(klass_name, false) if database.const_defined?(klass_name, false)
|
29
29
|
database.const_set(klass_name, Class.new(database) do
|
30
30
|
self.table_name = table_name
|
31
31
|
self.primary_keys = primary_keys if primary_keys.length > 1
|
data/lib/utils/random_int.rb
CHANGED
data/lib/version.rb
CHANGED
@@ -95,7 +95,7 @@ describe 'End 2 End MongoDB Whitelist Acceptance Test' do
|
|
95
95
|
feature1 = plan['features'][0]
|
96
96
|
[10737418240, 21474836480, 53687091200].should include(feature1['max_storage'])
|
97
97
|
feature1['type'].should == 'AmazonS3'
|
98
|
-
feature1['users']['max'].should be_kind_of(
|
98
|
+
feature1['users']['max'].should be_kind_of(Integer)
|
99
99
|
[true,false].should include(feature1['users']['additional'])
|
100
100
|
|
101
101
|
|
@@ -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)}
|
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
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunit Parekh
|
8
8
|
- Anand Agrawal
|
9
9
|
- Satyam Agarwala
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,58 +18,58 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '6.1'
|
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.1'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: activesupport
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '6.1'
|
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: '6.1'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: composite_primary_keys
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '13.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: '13.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: parallel
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '1.
|
63
|
+
version: '1.20'
|
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: '1.
|
70
|
+
version: '1.20'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: powerbar
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - "~>"
|
@@ -83,47 +83,47 @@ dependencies:
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '2.0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: rgeo
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - "~>"
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: '
|
91
|
+
version: '2.3'
|
92
92
|
type: :runtime
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
96
|
- - "~>"
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
98
|
+
version: '2.3'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
100
|
+
name: rgeo-geojson
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
|
-
version: '1
|
105
|
+
version: '2.1'
|
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: '2.1'
|
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: '1.1'
|
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: '1.1'
|
127
127
|
description: Data anonymization tool for RDBMS and MongoDB databases
|
128
128
|
email:
|
129
129
|
- parekh.sunit@gmail.com
|
@@ -146,6 +146,7 @@ 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
|
@@ -282,7 +283,7 @@ homepage: http://sunitparekh.github.com/data-anonymization
|
|
282
283
|
licenses:
|
283
284
|
- MIT
|
284
285
|
metadata: {}
|
285
|
-
post_install_message:
|
286
|
+
post_install_message:
|
286
287
|
rdoc_options: []
|
287
288
|
require_paths:
|
288
289
|
- lib
|
@@ -297,9 +298,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
298
|
- !ruby/object:Gem::Version
|
298
299
|
version: '0'
|
299
300
|
requirements: []
|
300
|
-
|
301
|
-
|
302
|
-
signing_key:
|
301
|
+
rubygems_version: 3.1.6
|
302
|
+
signing_key:
|
303
303
|
specification_version: 4
|
304
304
|
summary: Tool to create anonymized production data dump to use for performance and
|
305
305
|
testing environments.
|