polo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.ruby-version +0 -0
- data/.travis.yml +0 -0
- data/Appraisals +0 -0
- data/CHANGELOG.md +10 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +11 -5
- data/Rakefile +0 -0
- data/gemfiles/rails32.gemfile +0 -0
- data/gemfiles/rails40.gemfile +0 -0
- data/gemfiles/rails41.gemfile +0 -0
- data/gemfiles/rails42.gemfile +0 -0
- data/lib/polo.rb +0 -0
- data/lib/polo/adapters/mysql.rb +0 -0
- data/lib/polo/adapters/postgres.rb +0 -0
- data/lib/polo/collector.rb +0 -0
- data/lib/polo/configuration.rb +0 -0
- data/lib/polo/sql_translator.rb +0 -0
- data/lib/polo/translator.rb +5 -4
- data/lib/polo/version.rb +1 -1
- data/polo.gemspec +0 -0
- 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: 483557d0954078851b9347111a7a12f0b05c8e0f
|
4
|
+
data.tar.gz: 2b8a51a7311f52430395643d5e0ec87ed5aecd3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 040ec1e967f3b2fd5d05f161da7d9690949c4e1aa0afe34d302c9fc35237b34ac54aaa6c3ff629191c1848c888588d58993dcd594fc7fe7a1f9a07f824025c21
|
7
|
+
data.tar.gz: c4b15706f954e20f09f7a59048bf4d999cdd7b5000d5fcbcd0c22f2860ca2eb95a20592a46e11c27d543f2add93782d531d07d3fa43c7ea3d6efb80003b9a00d
|
data/.gitignore
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Appraisals
CHANGED
File without changes
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -137,7 +137,7 @@ Warning: This is not a security feature. Fields can still easily be rearranged b
|
|
137
137
|
|
138
138
|
#### Advanced Obfuscation
|
139
139
|
|
140
|
-
For more advanced obfuscation, you can pass in a custom obfuscation strategy. Polo will take in a lambda that can be used to transform sensitive data.
|
140
|
+
For more advanced obfuscation, you can pass in a custom obfuscation strategy. Polo will take in a lambda that can be used to transform sensitive data.
|
141
141
|
|
142
142
|
Using a `:symbol` as an obfuscate key targets all columns of that name. Passing an SQL selector as a `String` will target columns within the specified table.
|
143
143
|
|
@@ -148,14 +148,21 @@ Polo.configure do
|
|
148
148
|
first_part = email.split("@")[0]
|
149
149
|
"#{first_part}@test.com"
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
credit_card_strategy = lambda do |credit_card|
|
153
153
|
"4123 4567 8910 1112"
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
|
+
# If you need the context of the record for its fields, it is accessible
|
157
|
+
# in the second argument of the strategy
|
158
|
+
social_security_strategy = lambda do |ssn, instance|
|
159
|
+
sprintf("%09d", instance.id)
|
160
|
+
end
|
161
|
+
|
156
162
|
obfuscate({
|
157
163
|
'chefs.email' => email_strategy, # This only applies to the "email" column in the "chefs" table
|
158
|
-
:credit_card => credit_card_strategy # This applies to any column named "credit_card" across every table
|
164
|
+
:credit_card => credit_card_strategy, # This applies to any column named "credit_card" across every table
|
165
|
+
:ssn_strategy => social_security_strategy
|
159
166
|
})
|
160
167
|
end
|
161
168
|
|
@@ -200,4 +207,3 @@ $ bundle exec appraisal rake
|
|
200
207
|
## License
|
201
208
|
|
202
209
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
203
|
-
|
data/Rakefile
CHANGED
File without changes
|
data/gemfiles/rails32.gemfile
CHANGED
File without changes
|
data/gemfiles/rails40.gemfile
CHANGED
File without changes
|
data/gemfiles/rails41.gemfile
CHANGED
File without changes
|
data/gemfiles/rails42.gemfile
CHANGED
File without changes
|
data/lib/polo.rb
CHANGED
File without changes
|
data/lib/polo/adapters/mysql.rb
CHANGED
File without changes
|
File without changes
|
data/lib/polo/collector.rb
CHANGED
File without changes
|
data/lib/polo/configuration.rb
CHANGED
File without changes
|
data/lib/polo/sql_translator.rb
CHANGED
File without changes
|
data/lib/polo/translator.rb
CHANGED
@@ -46,8 +46,8 @@ module Polo
|
|
46
46
|
|
47
47
|
correct_table = table.nil? || instance.class.table_name == table
|
48
48
|
|
49
|
-
if correct_table &&
|
50
|
-
instance.send("#{field}=", new_field_value(field, strategy,
|
49
|
+
if correct_table && instance.attributes[field]
|
50
|
+
instance.send("#{field}=", new_field_value(field, strategy, instance))
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -65,11 +65,12 @@ module Polo
|
|
65
65
|
attrs & fields.map { |pair| field_name(pair.first) }
|
66
66
|
end
|
67
67
|
|
68
|
-
def new_field_value(field, strategy,
|
68
|
+
def new_field_value(field, strategy, instance)
|
69
|
+
value = instance.attributes[field]
|
69
70
|
if strategy.nil?
|
70
71
|
value.split("").shuffle.join
|
71
72
|
else
|
72
|
-
strategy.call(value)
|
73
|
+
strategy.arity == 1 ? strategy.call(value) : strategy.call(value, instance)
|
73
74
|
end
|
74
75
|
end
|
75
76
|
end
|
data/lib/polo/version.rb
CHANGED
data/polo.gemspec
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Netto Farah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|