data-anonymization 0.5.5 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +5 -1
- data/data-anonymization.gemspec +5 -4
- data/lib/utils/database.rb +3 -2
- data/lib/version.rb +1 -1
- data/spec/acceptance/rdbms_whitelist_spec.rb +8 -53
- data/spec/support/customer_sample.rb +2 -0
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fff46e6cfe9dba97f7a67b56a32bd02e82a57d0
|
4
|
+
data.tar.gz: a007c623821dea4f354a61ec5e936178c81ee417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357063d6464c1b3fab918b770be2e3086915b4b485890acb227c5160b72f4dd9a4412f3110200e5a8b90de3d8de805514e1e8746d86603ebff1388335a78bc4a
|
7
|
+
data.tar.gz: dd1c34c33437cee85aca05bbd79d521876d3904af3e0a391419f1bacde63af1caba3534732d77684d159cf5807d027d20da0b6e83234efc9dea0877126e3f1f5
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Data::Anonymization
|
2
|
-
Afraid of getting production data due to privacy issues. Data Anonymization tool
|
2
|
+
Afraid of getting production data due to privacy issues. Data Anonymization tool can help you to build anonymized production data dump to use for performance and security testing, debugging production issues and development purpose.
|
3
3
|
|
4
4
|
[<img src="https://secure.travis-ci.org/sunitparekh/data-anonymization.png?branch=master">](http://travis-ci.org/sunitparekh/data-anonymization)
|
5
5
|
[<img src="https://gemnasium.com/sunitparekh/data-anonymization.png?travis">](https://gemnasium.com/sunitparekh/data-anonymization)
|
@@ -69,6 +69,10 @@ Postgresql database having **composite primary key**
|
|
69
69
|
|
70
70
|
## Changelog
|
71
71
|
|
72
|
+
#### 0.6.0 (Dec --, 2013)
|
73
|
+
In Progress...
|
74
|
+
1. Upgraded rails activerecord gem to latest versions
|
75
|
+
|
72
76
|
#### 0.5.5 (Dec 4, 2013)
|
73
77
|
1. Upgraded gems to latest versions
|
74
78
|
|
data/data-anonymization.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = 'data-anonymization'
|
8
8
|
gem.version = DataAnonymization::VERSION
|
9
9
|
gem.authors = ['Sunit Parekh', 'Anand Agrawal', 'Satyam Agarwala']
|
10
|
-
gem.email =
|
10
|
+
gem.email = %w(parekh.sunit@gmail.com anand.agrawal84@gmail.com satyamag@gmail.com)
|
11
11
|
gem.description = %q{Data anonymization tool for RDBMS databases}
|
12
12
|
gem.summary = %q{Tool to create anonymized production data dump to use for PREF and other TEST environments.}
|
13
13
|
gem.homepage = 'http://sunitparekh.github.com/data-anonymization'
|
@@ -19,9 +19,10 @@ 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('
|
22
|
+
gem.add_dependency('activerecord', '~> 4.0.2')
|
23
|
+
gem.add_dependency('protected_attributes', '~> 1.0.5')
|
24
|
+
gem.add_dependency('composite_primary_keys', '~> 6.0.1')
|
25
|
+
gem.add_dependency('activesupport', '~> 4.0.2')
|
25
26
|
gem.add_dependency('rgeo', '~> 0.3.20')
|
26
27
|
gem.add_dependency('rgeo-geojson', '~> 0.2.3')
|
27
28
|
gem.add_dependency('powerbar', '~> 1.0.11')
|
data/lib/utils/database.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_record'
|
2
|
+
require 'protected_attributes'
|
2
3
|
require 'composite_primary_keys'
|
3
4
|
require 'logger'
|
4
5
|
|
@@ -6,7 +7,7 @@ module DataAnon
|
|
6
7
|
module Utils
|
7
8
|
|
8
9
|
class MassAssignmentIgnoreSanitizer < ActiveModel::MassAssignmentSecurity::Sanitizer
|
9
|
-
def process_removed_attributes(attrs)
|
10
|
+
def process_removed_attributes(klass, attrs)
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -35,7 +36,7 @@ module DataAnon
|
|
35
36
|
self.primary_key = primary_keys[0] if primary_keys.length == 1
|
36
37
|
self.primary_key = nil if primary_keys.length == 0
|
37
38
|
self.inheritance_column = :_type_disabled
|
38
|
-
self.mass_assignment_sanitizer = MassAssignmentIgnoreSanitizer.new
|
39
|
+
self.mass_assignment_sanitizer = MassAssignmentIgnoreSanitizer.new
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
data/lib/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'End 2 End RDBMS Whitelist Acceptance Test using SQLite database' do
|
4
4
|
|
5
5
|
source_connection_spec = {:adapter => 'sqlite3', :database => 'tmp/customer.sqlite'}
|
6
6
|
dest_connection_spec = {:adapter => 'sqlite3', :database => 'tmp/customer-dest.sqlite'}
|
@@ -13,9 +13,9 @@ describe "End 2 End RDBMS Whitelist Acceptance Test using SQLite database" do
|
|
13
13
|
CustomerSample.create_schema dest_connection_spec
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'should anonymize customer table record ' do
|
17
17
|
|
18
|
-
database
|
18
|
+
database 'Customer' do
|
19
19
|
strategy DataAnon::Strategy::Whitelist
|
20
20
|
source_db source_connection_spec
|
21
21
|
destination_db dest_connection_spec
|
@@ -35,14 +35,14 @@ describe "End 2 End RDBMS Whitelist Acceptance Test using SQLite database" do
|
|
35
35
|
|
36
36
|
DataAnon::Utils::DestinationDatabase.establish_connection dest_connection_spec
|
37
37
|
dest_table = DataAnon::Utils::DestinationTable.create 'customers'
|
38
|
-
new_rec = dest_table.where(
|
39
|
-
new_rec.first_name.should_not be(
|
40
|
-
new_rec.last_name.should_not be(
|
38
|
+
new_rec = dest_table.where('cust_id' => CustomerSample::SAMPLE_DATA[:cust_id]).first
|
39
|
+
new_rec.first_name.should_not be('Sunit')
|
40
|
+
new_rec.last_name.should_not be('Parekh')
|
41
41
|
new_rec.birth_date.should_not be(Date.new(1977,7,8))
|
42
42
|
new_rec.address.should == 'F 501 Shanti Nagar'
|
43
|
-
|
43
|
+
%w(Gujrat Karnataka).should include(new_rec.state)
|
44
44
|
new_rec.zipcode.should == '411048'
|
45
|
-
new_rec.phone.should_not be
|
45
|
+
new_rec.phone.should_not be '9923700662'
|
46
46
|
new_rec.email.should == 'test+1@gmail.com'
|
47
47
|
[true,false].should include(new_rec.terms_n_condition)
|
48
48
|
new_rec.age.should be_between(0,100)
|
@@ -52,49 +52,4 @@ describe "End 2 End RDBMS Whitelist Acceptance Test using SQLite database" do
|
|
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
55
|
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.
|
4
|
+
version: 0.6.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: 2013-12-
|
13
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -18,42 +18,56 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 4.0.2
|
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: 4.0.2
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: protected_attributes
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.0.5
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.0.5
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
44
|
name: composite_primary_keys
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
47
|
- - ~>
|
34
48
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
49
|
+
version: 6.0.1
|
36
50
|
type: :runtime
|
37
51
|
prerelease: false
|
38
52
|
version_requirements: !ruby/object:Gem::Requirement
|
39
53
|
requirements:
|
40
54
|
- - ~>
|
41
55
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
56
|
+
version: 6.0.1
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: activesupport
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
61
|
- - ~>
|
48
62
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
63
|
+
version: 4.0.2
|
50
64
|
type: :runtime
|
51
65
|
prerelease: false
|
52
66
|
version_requirements: !ruby/object:Gem::Requirement
|
53
67
|
requirements:
|
54
68
|
- - ~>
|
55
69
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
70
|
+
version: 4.0.2
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: rgeo
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|