data_anonymizer 0.1.1 → 0.1.2
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/data_anonymizer.rb +8 -2
- data/lib/data_anonymizer/version.rb +1 -1
- 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: ef81af52f5dae8a633b40b17b7fc282acfc2d36f
|
4
|
+
data.tar.gz: 81e5df03b5356e39eb80b54680f09240c4119436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca5dfdd80ea8e63b50f09d935d410370987265a8aeddf85c005481843431f54d2c631f4e16ea53450618bdcb6ab414538df59c9f73bb62dd0b1ee5b8226622cc
|
7
|
+
data.tar.gz: 2011e7fba58a84424f62ba9dfd0f773879c6c91b8fe20e9b84af947ecdc5891ce7e1dbcf3a18e96b328c10826351a53d7ce853ce22b00f3dc24d7a7e605bee1b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
`DataAnonymizer.instance.anonymize_common_attributes(["Person", "CensusMember", "CuramUser"], ["first_name", "last_name", "ssn"])`
|
23
|
+
`DataAnonymizer::Sanitize.instance.anonymize_common_attributes(["Person", "CensusMember", "CuramUser"], ["first_name", "last_name", "ssn"])`
|
24
24
|
|
25
25
|
where ["Person", "CensusMember", "CuramUser"] are the model names and ["first_name", "last_name", "ssn"] are the common attributes in these models that we want to anonymize and sync up.
|
26
26
|
|
data/lib/data_anonymizer.rb
CHANGED
@@ -34,8 +34,11 @@ module DataAnonymizer
|
|
34
34
|
begin
|
35
35
|
instance.update_attributes(attribute => encrypt_characters(cipher_hash, instance.send(attribute))) if instance.send(attribute).present?
|
36
36
|
updated = true
|
37
|
+
rescue Mongoid::Errors::Validations => e
|
38
|
+
puts " - Validation Error while updating [#{attribute}] for [#{instance.class}, ID: #{instance.id}]. Retrying with a new shuffled value...(Error Message: #{e.message})"
|
37
39
|
rescue Exception => e
|
38
|
-
puts "
|
40
|
+
puts " - Failed to anonymize record [#{attribute}] for [#{instance.class}, ID: #{instance.id}] (Error Message: #{e.message})"
|
41
|
+
break
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
@@ -71,7 +74,10 @@ module DataAnonymizer
|
|
71
74
|
def encrypt_characters(cipher_hash, attribute_value)
|
72
75
|
encrypted_value = ""
|
73
76
|
attribute_value.gsub!(/[^0-9A-Za-z]/, '') # remove non-alphanumeric characters from string.
|
74
|
-
attribute_value.downcase.split('').each {|char| encrypted_value << cipher_hash[char]}
|
77
|
+
#attribute_value.downcase.split('').each {|char| encrypted_value << cipher_hash[char]}
|
78
|
+
attribute_value.downcase.split('').each do |char|
|
79
|
+
encrypted_value << (cipher_hash[char].present? ? cipher_hash[char] : char)
|
80
|
+
end
|
75
81
|
encrypted_value
|
76
82
|
end
|
77
83
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data_anonymizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pranab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|