data-anonymization 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +4 -5
- data/README.md +1 -1
- data/lib/core/database.rb +6 -2
- data/lib/core/fields_missing_strategy.rb +4 -0
- data/lib/strategy/base.rb +3 -0
- data/lib/strategy/field/string/random_url.rb +2 -2
- data/lib/strategy/field/string/select_from_database.rb +3 -3
- data/lib/version.rb +1 -1
- data/spec/strategy/field/string/random_url_spec.rb +12 -4
- 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: 066880fbf97030bf79f2365fa16cf2a64488861e
|
4
|
+
data.tar.gz: fb799b830d294413448e8bd3026fb23a8aff8519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3836066283d02a2be8886e97879f2de7d79f7c5d94b073cf021d7ff67d64ad11d655c17f268469053114e0be6226bb1e11f27f0243207dd400d0a096eac149e9
|
7
|
+
data.tar.gz: 4e4a9847744419a73aea031c77d5e74f495b8dab9015b818e07abb65a5eeb7cd27e31f067e13ac404526199103a43bf056c438053e2b4bd1f5506a99be5d1add
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.3.1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -501,7 +501,7 @@ has following attribute accessor
|
|
501
501
|
<tr>
|
502
502
|
<td align="left">Last name</td>
|
503
503
|
<td align="left"><a href="http://rubydoc.info/github/sunitparekh/data-anonymization/DataAnon/Strategy/Field/RandomLastName">RandomLastName</a></td>
|
504
|
-
<td align="left">Randomly picks up
|
504
|
+
<td align="left">Randomly picks up last name from the predefined list in the file. Default <a href="https://raw.github.com/sunitparekh/data-anonymization/master/resources/last_names.txt">file</a> is part of the gem.</td>
|
505
505
|
</tr>
|
506
506
|
<tr>
|
507
507
|
<td align="left">Full Name</td>
|
data/lib/core/database.rb
CHANGED
@@ -48,8 +48,12 @@ module DataAnon
|
|
48
48
|
logger.error "\n#{e.message} \n #{e.backtrace}"
|
49
49
|
end
|
50
50
|
if @strategy.whitelist?
|
51
|
-
|
52
|
-
|
51
|
+
@tables.each do |table|
|
52
|
+
if table.fields_missing_strategy.present?
|
53
|
+
logger.info('Fields missing the anonymization strategy:')
|
54
|
+
table.fields_missing_strategy.print
|
55
|
+
end
|
56
|
+
end
|
53
57
|
end
|
54
58
|
|
55
59
|
@tables.each { |table| table.errors.print }
|
data/lib/strategy/base.rb
CHANGED
@@ -13,7 +13,7 @@ module DataAnon
|
|
13
13
|
|
14
14
|
url = field.value
|
15
15
|
randomized_url = ""
|
16
|
-
protocols = url.scan(/
|
16
|
+
protocols = url.scan(/https?:\/\/|www\./)
|
17
17
|
protocols.each do |token|
|
18
18
|
url = url.gsub(token,"")
|
19
19
|
randomized_url += token
|
@@ -33,4 +33,4 @@ module DataAnon
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
@@ -5,8 +5,8 @@ module DataAnon
|
|
5
5
|
# Similar to SelectFromList with difference is the list of values are collected from the database table using distinct column query.
|
6
6
|
#
|
7
7
|
# !!!ruby
|
8
|
-
# # values are collected using `select distinct state from customers` query
|
9
|
-
# anonymize('State').using FieldStrategy::SelectFromDatabase.new('customers','state')
|
8
|
+
# # values are collected using `select distinct state from customers` query connecting to specified database in connection_spec
|
9
|
+
# anonymize('State').using FieldStrategy::SelectFromDatabase.new('customers','state', connection_spec)
|
10
10
|
|
11
11
|
class SelectFromDatabase < SelectFromFile
|
12
12
|
include Utils::Logging
|
@@ -14,7 +14,7 @@ module DataAnon
|
|
14
14
|
def initialize table_name, field_name, connection_spec
|
15
15
|
DataAnon::Utils::SourceDatabase.establish_connection connection_spec
|
16
16
|
source = Utils::SourceTable.create table_name, []
|
17
|
-
@values = source.select(field_name).
|
17
|
+
@values = source.select(field_name).distinct.collect { |record| record[field_name]}
|
18
18
|
logger.debug "For field strategy #{table_name}:#{field_name} using values #{@values} "
|
19
19
|
|
20
20
|
end
|
data/lib/version.rb
CHANGED
@@ -5,11 +5,19 @@ describe FieldStrategy::RandomUrl do
|
|
5
5
|
RandomUrl = FieldStrategy::RandomUrl
|
6
6
|
|
7
7
|
describe 'anonymized url must not be the same as original url' do
|
8
|
-
let(:
|
8
|
+
let(:url) { 'http://example.org' }
|
9
|
+
|
10
|
+
let(:field) {DataAnon::Core::Field.new('string_field',url,1,nil)}
|
9
11
|
let(:anonymized_url) {RandomUrl.new.anonymize(field)}
|
10
12
|
|
11
13
|
it {anonymized_url.should_not equal field.value}
|
12
|
-
it {anonymized_url.should match /
|
13
|
-
end
|
14
|
+
it {anonymized_url.should match /http:\/\/[\S]+/}
|
14
15
|
|
15
|
-
|
16
|
+
context 'with https url' do
|
17
|
+
let(:url) { 'https://example.org' }
|
18
|
+
|
19
|
+
it {anonymized_url.should_not equal field.value}
|
20
|
+
it {anonymized_url.should match /https:\/\/[\S]+/}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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.7.
|
4
|
+
version: 0.7.4
|
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: 2016-
|
13
|
+
date: 2016-10-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|