data-anonymization 0.6.7 → 0.7.0
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 +4 -4
- data/README.md +6 -0
- data/lib/strategy/base.rb +5 -5
- data/lib/strategy/blacklist.rb +1 -1
- data/lib/strategy/mongodb/whitelist.rb +1 -1
- data/lib/strategy/whitelist.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/acceptance/mongodb_blacklist_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05181aca5f0046f53ca999bbe73aea0360f013b6
|
4
|
+
data.tar.gz: d538308e3ccb427af3860b657362f3de2e6aff5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83a63960a9dcd64cd74ba4aa01117f94f813a118af79b5e9ca57eb333fbc143699b07ba801909ff22f03e276ff268b84b6b2c70030ce3eaa06526eb3abacb91e
|
7
|
+
data.tar.gz: 25fc3f8467d4ce3dc6c0ea455a9fa1660113f0a94e2a39edf48e953d87af3519cf03c0a253c8e7d23b6beb4e195f033f3664d0a70bf83b2d1fa89e86f3bb30e4
|
data/README.md
CHANGED
@@ -70,6 +70,11 @@ Postgresql database having **composite primary key**
|
|
70
70
|
|
71
71
|
## Changelog
|
72
72
|
|
73
|
+
#### 0.7.0 (Mar 9, 2015)
|
74
|
+
1. Removed downcase from field name since it was causing issues with upper case field names. So now for databsae where case matters field name case should be maintained.
|
75
|
+
2. Upgraded gems to latest version
|
76
|
+
|
77
|
+
|
73
78
|
#### 0.6.7 (Jan 17, 2015)
|
74
79
|
1. Upgraded gems to latest version including activerecord to 4.2. Please try it out and provide feedback.
|
75
80
|
|
@@ -194,6 +199,7 @@ Read more about [blacklist and whitelist here](http://sunitspace.blogspot.in/201
|
|
194
199
|
2. Change [default field strategies](#default-field-strategies) to avoid using same strategy again and again in your DSL.
|
195
200
|
3. To run anonymization in parallel at Table level, provided no FK constraint on tables use DataAnon::Parallel::Table strategy
|
196
201
|
4. For large table to load them in batches from table set 'batch_size' and it will use RoR's batch mode processing. Checkout [example](https://github.com/sunitparekh/data-anonymization/blob/master/examples/whitelist_dsl.rb) on how to use batch processing.
|
202
|
+
5. Make sure to give proper case for fields and table names.
|
197
203
|
|
198
204
|
## DSL Generation
|
199
205
|
|
data/lib/strategy/base.rb
CHANGED
@@ -34,27 +34,27 @@ module DataAnon
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def whitelist *fields
|
37
|
-
fields.each { |f| @fields[f
|
37
|
+
fields.each { |f| @fields[f] = DataAnon::Strategy::Field::Whitelist.new }
|
38
38
|
end
|
39
39
|
|
40
40
|
def anonymize *fields, &block
|
41
41
|
if block.nil?
|
42
|
-
fields.each { |f| @fields[f
|
42
|
+
fields.each { |f| @fields[f] = DataAnon::Strategy::Field::DefaultAnon.new(@user_strategies) }
|
43
43
|
temp = self
|
44
44
|
return Class.new do
|
45
45
|
@temp_fields = fields
|
46
46
|
@table_fields = temp.fields
|
47
47
|
def self.using field_strategy
|
48
|
-
@temp_fields.each { |f| @table_fields[f
|
48
|
+
@temp_fields.each { |f| @table_fields[f] = field_strategy }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
else
|
52
|
-
fields.each { |f| @fields[f
|
52
|
+
fields.each { |f| @fields[f] = DataAnon::Strategy::Field::Anonymous.new(&block) }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def is_primary_key? field
|
57
|
-
@primary_keys.select { |key| field
|
57
|
+
@primary_keys.select { |key| field == key }.length > 0
|
58
58
|
end
|
59
59
|
|
60
60
|
def default_strategy field_name
|
data/lib/strategy/blacklist.rb
CHANGED
@@ -4,7 +4,7 @@ module DataAnon
|
|
4
4
|
|
5
5
|
def process_record index, record
|
6
6
|
@fields.each do |field, strategy|
|
7
|
-
database_field_name = record.attributes.select { |k,v| k
|
7
|
+
database_field_name = record.attributes.select { |k,v| k == field }.keys[0]
|
8
8
|
field_value = record.attributes[database_field_name]
|
9
9
|
unless field_value.nil? || is_primary_key?(database_field_name)
|
10
10
|
field = DataAnon::Core::Field.new(database_field_name, field_value, index, record, @name)
|
@@ -45,7 +45,7 @@ module DataAnon
|
|
45
45
|
def anonymize_document document, index, field_strategies = {}
|
46
46
|
anonymized_document = {}
|
47
47
|
document.each do |field_name, field_value|
|
48
|
-
field_strategy = field_strategies[field_name
|
48
|
+
field_strategy = field_strategies[field_name] if field_strategies.kind_of?(Hash)
|
49
49
|
unless field_value.nil?
|
50
50
|
field = DataAnon::Core::Field.new(field_name, field_value, index, document, @name)
|
51
51
|
anonymized_document[field.name] = AnonymizeField.new(field, field_strategy, self).anonymize
|
data/lib/strategy/whitelist.rb
CHANGED
@@ -11,7 +11,7 @@ module DataAnon
|
|
11
11
|
record.attributes.each do |field_name, field_value|
|
12
12
|
unless field_value.nil? || is_primary_key?(field_name)
|
13
13
|
field = DataAnon::Core::Field.new(field_name, field_value, index, record, @name)
|
14
|
-
field_strategy = @fields[field_name
|
14
|
+
field_strategy = @fields[field_name] || default_strategy(field_name)
|
15
15
|
dest_record_map[field_name] = field_strategy.anonymize(field)
|
16
16
|
end
|
17
17
|
end
|
data/lib/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe "End 2 End MongoDB Blacklist Acceptance Test" do
|
|
8
8
|
users = [
|
9
9
|
{
|
10
10
|
"_id" => 1,
|
11
|
-
"
|
11
|
+
"USER_ID" => "sunitparekh",
|
12
12
|
"date_of_birth" => Time.new(2012, 7, 14, 13, 1, 0),
|
13
13
|
"email" => "parekh.sunit@gmail.com",
|
14
14
|
"password" => "TfqIK8Pd8GlbMDFZCX4l/5EtnOkfLCeynOL85tJQuxum&382knaflk@@",
|
@@ -45,7 +45,7 @@ describe "End 2 End MongoDB Blacklist Acceptance Test" do
|
|
45
45
|
|
46
46
|
collection 'users' do
|
47
47
|
anonymize('date_of_birth').using FieldStrategy::TimeDelta.new(5,30)
|
48
|
-
anonymize('
|
48
|
+
anonymize('USER_ID').using FieldStrategy::StringTemplate.new('user-#{row_number}')
|
49
49
|
anonymize('email').using FieldStrategy::RandomMailinatorEmail.new
|
50
50
|
anonymize('password') { |field| "password" }
|
51
51
|
anonymize('first_name').using FieldStrategy::RandomFirstName.new
|
@@ -59,7 +59,7 @@ describe "End 2 End MongoDB Blacklist Acceptance Test" do
|
|
59
59
|
user = users_coll.find_one({'_id' => 1})
|
60
60
|
|
61
61
|
user['_id'].should == 1
|
62
|
-
user['
|
62
|
+
user['USER_ID'].should == "user-1"
|
63
63
|
user['date_of_birth'].to_i.should_not == Time.new(2012, 7, 14, 13, 1, 0).to_i
|
64
64
|
user['email'].should_not == "parekh.sunit@gmail.com"
|
65
65
|
user['password'].should == "password"
|
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.
|
4
|
+
version: 0.7.0
|
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: 2015-
|
13
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|