data-anonymization 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/Rakefile +2 -1
- data/data-anonymization.gemspec +1 -1
- data/lib/strategy/whitelist.rb +1 -1
- data/lib/tasks/rake_tasks.rb +3 -3
- data/lib/version.rb +1 -1
- data/spec/acceptance/rdbms_whitelist_spec.rb +47 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -68,6 +68,10 @@ Postgresql database having **composite primary key**
|
|
68
68
|
|
69
69
|
## Changelog
|
70
70
|
|
71
|
+
#### 0.5.2 (Jan 20, 2013)
|
72
|
+
|
73
|
+
1. Upgraded all gem to latest and greatest including Rails activerecord and activesupport.
|
74
|
+
|
71
75
|
#### 0.5.1 (Oct 26, 2012)
|
72
76
|
|
73
77
|
1. Minor fixes release, no major functionality or feature added.
|
data/Rakefile
CHANGED
data/data-anonymization.gemspec
CHANGED
@@ -24,5 +24,5 @@ Gem::Specification.new do |gem|
|
|
24
24
|
gem.add_dependency('rgeo-geojson', '~> 0.2.3')
|
25
25
|
gem.add_dependency('powerbar', '~> 1.0.11')
|
26
26
|
gem.add_dependency('parallel', '~> 0.6.1')
|
27
|
-
gem.add_dependency('thor', '~> 0.
|
27
|
+
gem.add_dependency('thor', '~> 0.17.0')
|
28
28
|
end
|
data/lib/strategy/whitelist.rb
CHANGED
@@ -15,7 +15,7 @@ module DataAnon
|
|
15
15
|
dest_record_map[field_name] = field_strategy.anonymize(field)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
dest_record = dest_table.new dest_record_map
|
18
|
+
dest_record = dest_table.new dest_record_map, without_protection: true
|
19
19
|
@primary_keys.each do |key|
|
20
20
|
dest_record[key] = record[key]
|
21
21
|
end
|
data/lib/tasks/rake_tasks.rb
CHANGED
@@ -6,10 +6,10 @@ module DataAnonymization
|
|
6
6
|
include Rake::DSL if defined? Rake::DSL
|
7
7
|
|
8
8
|
def initialize
|
9
|
-
desc
|
9
|
+
desc 'Task to build the clean empty destination database'
|
10
10
|
task :empty_dest do
|
11
|
-
system
|
12
|
-
system
|
11
|
+
system 'rm sample-data/chinook-empty.sqlite'
|
12
|
+
system 'sqlite3 sample-data/chinook-empty.sqlite < sample-data/chinook_schema.sql'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
data/lib/version.rb
CHANGED
@@ -51,4 +51,50 @@ describe "End 2 End RDBMS Whitelist Acceptance Test using SQLite database" do
|
|
51
51
|
new_rec.created_at.should == Time.new(2010,10,10)
|
52
52
|
new_rec.updated_at.should == Time.new(2010,5,5)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
|
+
context "when whitelisting attributes" do
|
56
|
+
|
57
|
+
# This is intended to replicate what happens when
|
58
|
+
#
|
59
|
+
# config.active_record.whitelist_attributes = true
|
60
|
+
#
|
61
|
+
# is set in your application.
|
62
|
+
|
63
|
+
default_active_authorizer = nil
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
default_active_authorizer = ActiveRecord::Base.active_authorizers[:default]
|
67
|
+
ActiveRecord::Base.active_authorizers[:default] = ActiveModel::MassAssignmentSecurity::WhiteList.new
|
68
|
+
end
|
69
|
+
|
70
|
+
after(:each) do
|
71
|
+
ActiveRecord::Base.active_authorizers[:default] = default_active_authorizer
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should copy the customer table data" do
|
75
|
+
|
76
|
+
database "Customer" do
|
77
|
+
strategy DataAnon::Strategy::Whitelist
|
78
|
+
source_db source_connection_spec
|
79
|
+
destination_db dest_connection_spec
|
80
|
+
|
81
|
+
table 'customers' do
|
82
|
+
whitelist 'cust_id', 'address', 'zipcode', 'blog_url'
|
83
|
+
anonymize('first_name').using FieldStrategy::RandomFirstName.new
|
84
|
+
anonymize('last_name').using FieldStrategy::RandomLastName.new
|
85
|
+
anonymize('state').using FieldStrategy::SelectFromList.new(['Gujrat','Karnataka'])
|
86
|
+
anonymize('phone').using FieldStrategy::RandomPhoneNumber.new
|
87
|
+
anonymize('email').using FieldStrategy::StringTemplate.new('test+#{row_number}@gmail.com')
|
88
|
+
anonymize 'terms_n_condition', 'age', 'longitude'
|
89
|
+
anonymize('latitude').using FieldStrategy::RandomFloatDelta.new(2.0)
|
90
|
+
whitelist 'created_at','updated_at'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
DataAnon::Utils::DestinationDatabase.establish_connection dest_connection_spec
|
95
|
+
dest_table = DataAnon::Utils::DestinationTable.create 'customers'
|
96
|
+
new_rec = dest_table.all.first
|
97
|
+
new_rec.address.should == 'F 501 Shanti Nagar'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: 0.
|
135
|
+
version: 0.17.0
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ dependencies:
|
|
140
140
|
requirements:
|
141
141
|
- - ~>
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: 0.
|
143
|
+
version: 0.17.0
|
144
144
|
description: Data anonymization tool for RDBMS databases
|
145
145
|
email:
|
146
146
|
- parekh.sunit@gmail.com
|