crypt_keeper 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemfiles/activerecord_3_1.gemfile.lock +1 -1
- data/gemfiles/activerecord_3_2.gemfile.lock +1 -1
- data/gemfiles/activerecord_4_0.gemfile.lock +1 -1
- data/gemfiles/activerecord_4_1.gemfile.lock +1 -1
- data/gemfiles/activerecord_4_2.gemfile.lock +1 -1
- data/lib/crypt_keeper/model.rb +16 -0
- data/lib/crypt_keeper/version.rb +1 -1
- data/spec/model_spec.rb +15 -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: 941281e7dbbeec5e9380afe59ebc80cf7b92a443
|
4
|
+
data.tar.gz: 05793997e6ffe8a14542b248a557a88cdd48a0ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a9bdf5f2b7a272aa6cfdf9e4d88b5b356bb93f1a1bc4651f62c17f529d934719e6225d23358be88994f71228d96b16ceb7757fc0f47538a30d956e0a87213aa
|
7
|
+
data.tar.gz: 6ea7b91da4c33a85b17ffacc98235c67c75929528ae45894e4618420481666b5029c27dab4b69e128c4536c0a145146983cd2b5e774046035c6e204d6f0c8064
|
data/lib/crypt_keeper/model.rb
CHANGED
@@ -98,6 +98,22 @@ module CryptKeeper
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
# Public: Decrypt a table (reverse of encrypt_table!)
|
102
|
+
def decrypt_table!
|
103
|
+
enc = encryptor_klass.new(crypt_keeper_options)
|
104
|
+
tmp_table = Class.new(ActiveRecord::Base).tap { |c| c.table_name = self.table_name }
|
105
|
+
|
106
|
+
transaction do
|
107
|
+
tmp_table.find_each do |r|
|
108
|
+
crypt_keeper_fields.each do |field|
|
109
|
+
r.send("#{field}=", enc.decrypt(r[field])) if r[field].present?
|
110
|
+
end
|
111
|
+
|
112
|
+
r.save!
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
101
117
|
private
|
102
118
|
|
103
119
|
# Private: The encryptor class
|
data/lib/crypt_keeper/version.rb
CHANGED
data/spec/model_spec.rb
CHANGED
@@ -124,6 +124,21 @@ module CryptKeeper
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
context "Table Decryption (Reverse of Initial Table Encryption)" do
|
128
|
+
subject { create_encrypted_model :storage, key: 'tool', salt: 'salt', encryptor: :aes_new }
|
129
|
+
let!(:storage_entries) { 5.times.map { |i| "testing#{i}" } }
|
130
|
+
|
131
|
+
before do
|
132
|
+
subject.delete_all
|
133
|
+
storage_entries.each { |entry| subject.create! storage: entry}
|
134
|
+
end
|
135
|
+
|
136
|
+
it "decrypts the table" do
|
137
|
+
subject.decrypt_table!
|
138
|
+
expect( create_model.first(5).map(&:storage) ).to eq( storage_entries )
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
127
142
|
context "Missing Attributes" do
|
128
143
|
subject { create_encrypted_model :storage, key: 'tool', salt: 'salt', encryptor: :aes_new, encoding: 'utf-8' }
|
129
144
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypt_keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Mazzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|