attr_encrypted 3.0.0 → 4.0.0

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.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +14 -16
  3. data/CHANGELOG.md +60 -14
  4. data/README.md +27 -9
  5. data/Rakefile +3 -0
  6. data/attr_encrypted.gemspec +6 -13
  7. data/checksum/attr_encrypted-3.0.0.gem.sha256 +1 -0
  8. data/checksum/attr_encrypted-3.0.0.gem.sha512 +1 -0
  9. data/checksum/attr_encrypted-3.0.1.gem.sha256 +1 -0
  10. data/checksum/attr_encrypted-3.0.1.gem.sha512 +1 -0
  11. data/checksum/attr_encrypted-3.0.2.gem.sha256 +1 -0
  12. data/checksum/attr_encrypted-3.0.2.gem.sha512 +1 -0
  13. data/checksum/attr_encrypted-3.0.3.gem.sha256 +1 -0
  14. data/checksum/attr_encrypted-3.0.3.gem.sha512 +1 -0
  15. data/checksum/attr_encrypted-3.1.0.gem.sha256 +1 -0
  16. data/checksum/attr_encrypted-3.1.0.gem.sha512 +1 -0
  17. data/lib/attr_encrypted/adapters/active_record.rb +58 -30
  18. data/lib/attr_encrypted/adapters/data_mapper.rb +3 -1
  19. data/lib/attr_encrypted/adapters/sequel.rb +3 -1
  20. data/lib/attr_encrypted/version.rb +3 -1
  21. data/lib/attr_encrypted.rb +160 -129
  22. data/test/active_record_test.rb +130 -104
  23. data/test/attr_encrypted_test.rb +113 -16
  24. data/test/compatibility_test.rb +21 -21
  25. data/test/data_mapper_test.rb +2 -0
  26. data/test/legacy_active_record_test.rb +9 -9
  27. data/test/legacy_attr_encrypted_test.rb +8 -6
  28. data/test/legacy_compatibility_test.rb +15 -15
  29. data/test/legacy_data_mapper_test.rb +2 -0
  30. data/test/legacy_sequel_test.rb +2 -0
  31. data/test/run.sh +15 -7
  32. data/test/sequel_test.rb +2 -0
  33. data/test/test_helper.rb +11 -5
  34. metadata +27 -50
  35. checksums.yaml.gz.sig +0 -0
  36. data/certs/saghaulor.pem +0 -21
  37. data.tar.gz.sig +0 -0
  38. metadata.gz.sig +0 -0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- encoding: utf-8 -*-
2
4
  require_relative 'test_helper'
3
5
 
@@ -56,11 +58,11 @@ end
56
58
  class LegacyAttrEncryptedTest < Minitest::Test
57
59
 
58
60
  def test_should_store_email_in_encrypted_attributes
59
- assert LegacyUser.encrypted_attributes.include?(:email)
61
+ assert LegacyUser.attr_encrypted_encrypted_attributes.include?(:email)
60
62
  end
61
63
 
62
64
  def test_should_not_store_salt_in_encrypted_attributes
63
- assert !LegacyUser.encrypted_attributes.include?(:salt)
65
+ assert !LegacyUser.attr_encrypted_encrypted_attributes.include?(:salt)
64
66
  end
65
67
 
66
68
  def test_attr_encrypted_should_return_true_for_email
@@ -68,7 +70,7 @@ class LegacyAttrEncryptedTest < Minitest::Test
68
70
  end
69
71
 
70
72
  def test_attr_encrypted_should_not_use_the_same_attribute_name_for_two_attributes_in_the_same_line
71
- refute_equal LegacyUser.encrypted_attributes[:email][:attribute], LegacyUser.encrypted_attributes[:without_encoding][:attribute]
73
+ refute_equal LegacyUser.attr_encrypted_encrypted_attributes[:email][:attribute], LegacyUser.attr_encrypted_encrypted_attributes[:without_encoding][:attribute]
72
74
  end
73
75
 
74
76
  def test_attr_encrypted_should_return_false_for_salt
@@ -199,7 +201,7 @@ class LegacyAttrEncryptedTest < Minitest::Test
199
201
  end
200
202
 
201
203
  def test_should_inherit_encrypted_attributes
202
- assert_equal [LegacyUser.encrypted_attributes.keys, :testing].flatten.collect { |key| key.to_s }.sort, LegacyAdmin.encrypted_attributes.keys.collect { |key| key.to_s }.sort
204
+ assert_equal [LegacyUser.attr_encrypted_encrypted_attributes.keys, :testing].flatten.collect { |key| key.to_s }.sort, LegacyAdmin.attr_encrypted_encrypted_attributes.keys.collect { |key| key.to_s }.sort
203
205
  end
204
206
 
205
207
  def test_should_inherit_attr_encrypted_options
@@ -209,7 +211,7 @@ class LegacyAttrEncryptedTest < Minitest::Test
209
211
 
210
212
  def test_should_not_inherit_unrelated_attributes
211
213
  assert LegacySomeOtherClass.attr_encrypted_options.empty?
212
- assert LegacySomeOtherClass.encrypted_attributes.empty?
214
+ assert LegacySomeOtherClass.attr_encrypted_encrypted_attributes.empty?
213
215
  end
214
216
 
215
217
  def test_should_evaluate_a_symbol_option
@@ -266,7 +268,7 @@ class LegacyAttrEncryptedTest < Minitest::Test
266
268
  end
267
269
 
268
270
  def test_should_work_with_aliased_attr_encryptor
269
- assert LegacyUser.encrypted_attributes.include?(:aliased)
271
+ assert LegacyUser.attr_encrypted_encrypted_attributes.include?(:aliased)
270
272
  end
271
273
 
272
274
  def test_should_always_reset_options
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- encoding: utf-8 -*-
2
4
  require_relative 'test_helper'
3
5
 
@@ -41,7 +43,7 @@ class LegacyCompatibilityTest < Minitest::Test
41
43
  end
42
44
 
43
45
  def setup
44
- ActiveRecord::Base.connection.tables.each { |table| ActiveRecord::Base.connection.drop_table(table) }
46
+ drop_all_tables
45
47
  create_tables
46
48
  end
47
49
 
@@ -73,20 +75,18 @@ class LegacyCompatibilityTest < Minitest::Test
73
75
  private
74
76
 
75
77
  def create_tables
76
- silence_stream(STDOUT) do
77
- ActiveRecord::Schema.define(:version => 1) do
78
- create_table :legacy_nonmarshalling_pets do |t|
79
- t.string :name
80
- t.string :encrypted_nickname
81
- t.string :encrypted_birthdate
82
- t.string :salt
83
- end
84
- create_table :legacy_marshalling_pets do |t|
85
- t.string :name
86
- t.string :encrypted_nickname
87
- t.string :encrypted_birthdate
88
- t.string :salt
89
- end
78
+ ActiveRecord::Schema.define(:version => 1) do
79
+ create_table :legacy_nonmarshalling_pets do |t|
80
+ t.string :name
81
+ t.string :encrypted_nickname
82
+ t.string :encrypted_birthdate
83
+ t.string :salt
84
+ end
85
+ create_table :legacy_marshalling_pets do |t|
86
+ t.string :name
87
+ t.string :encrypted_nickname
88
+ t.string :encrypted_birthdate
89
+ t.string :salt
90
90
  end
91
91
  end
92
92
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  DataMapper.setup(:default, 'sqlite3::memory:')
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  DB.create_table :legacy_humans do
data/test/run.sh CHANGED
@@ -1,12 +1,20 @@
1
- #!/usr/bin/env sh -e
1
+ #!/usr/bin/env bash
2
2
 
3
- for RUBY in 1.9.3 2.0.0 2.1 2.2
3
+ set -e
4
+
5
+ for RUBY in 2.6.10 2.7.6
4
6
  do
5
- for RAILS in 2.3.8 3.0.0 3.1.0 3.2.0 4.0.0 4.1.0 4.2.0
7
+ for ACTIVERECORD in 5.1.1 5.2.8
6
8
  do
7
- if [[ $RUBY -gt 1.9.3 && $RAILS -lt 4.0.0 ]]; then
8
- continue
9
- fi
10
- RBENV_VERSION=$RUBY ACTIVERECORD=$RAILS bundle && bundle exec rake
9
+ echo ">>> Testing with Ruby ${RUBY} and ActiveRecord ${ACTIVERECORD}."
10
+ export RBENV_VERSION=$RUBY
11
+ export ACTIVERECORD=$ACTIVERECORD
12
+
13
+ rbenv install $RUBY --skip-existing
14
+ bundle install
15
+ bundle check
16
+ bundle exec rake test
17
+ rm Gemfile.lock
18
+ echo ">>> Finished testing with Ruby ${RUBY} and ActiveRecord ${ACTIVERECORD}."
11
19
  done
12
20
  done
data/test/sequel_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  DB.create_table :humans do
data/test/test_helper.rb CHANGED
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
1
4
  require 'simplecov'
2
5
  require 'simplecov-rcov'
3
- require "codeclimate-test-reporter"
4
6
 
5
7
  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
6
8
  [
7
9
  SimpleCov::Formatter::HTMLFormatter,
8
- SimpleCov::Formatter::RcovFormatter,
9
- CodeClimate::TestReporter::Formatter
10
+ SimpleCov::Formatter::RcovFormatter
10
11
  ]
11
12
  )
12
13
 
@@ -14,8 +15,6 @@ SimpleCov.start do
14
15
  add_filter 'test'
15
16
  end
16
17
 
17
- CodeClimate::TestReporter.start
18
-
19
18
  require 'minitest/autorun'
20
19
 
21
20
  # Rails 4.0.x pins to an old minitest
@@ -27,6 +26,7 @@ require 'active_record'
27
26
  require 'data_mapper'
28
27
  require 'digest/sha2'
29
28
  require 'sequel'
29
+ ActiveSupport::Deprecation.behavior = :raise
30
30
 
31
31
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
32
32
  $:.unshift(File.dirname(__FILE__))
@@ -49,3 +49,9 @@ SECRET_KEY = SecureRandom.random_bytes(32)
49
49
  def base64_encoding_regex
50
50
  /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$/
51
51
  end
52
+
53
+ def drop_all_tables
54
+ connection = ActiveRecord::Base.connection
55
+ tables = (ActiveRecord::VERSION::MAJOR >= 5 ? connection.data_sources : connection.tables)
56
+ tables.each { |table| ActiveRecord::Base.connection.drop_table(table) }
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_encrypted
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
@@ -10,30 +10,8 @@ authors:
10
10
  - Stephen Aghaulor
11
11
  autorequire:
12
12
  bindir: bin
13
- cert_chain:
14
- - |
15
- -----BEGIN CERTIFICATE-----
16
- MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlzYWdo
17
- Y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aYNmeWU0wsPpDyhPYxOUgU
33
- ZjeLmnSDiwL6doiP5IiwALH/dcHU67ck3NGf6XyqNwQrrmtPY0mv1WVVL4Uh+vYE
34
- kHoFzE2no0BfBg78Re8fY69P5yES5ncC
35
- -----END CERTIFICATE-----
36
- date: 2016-03-29 00:00:00.000000000 Z
13
+ cert_chain: []
14
+ date: 2023-04-06 00:00:00.000000000 Z
37
15
  dependencies:
38
16
  - !ruby/object:Gem::Dependency
39
17
  name: encryptor
@@ -137,16 +115,16 @@ dependencies:
137
115
  name: sqlite3
138
116
  requirement: !ruby/object:Gem::Requirement
139
117
  requirements:
140
- - - ">="
118
+ - - '='
141
119
  - !ruby/object:Gem::Version
142
- version: '0'
120
+ version: 1.5.4
143
121
  type: :development
144
122
  prerelease: false
145
123
  version_requirements: !ruby/object:Gem::Requirement
146
124
  requirements:
147
- - - ">="
125
+ - - '='
148
126
  - !ruby/object:Gem::Version
149
- version: '0'
127
+ version: 1.5.4
150
128
  - !ruby/object:Gem::Dependency
151
129
  name: dm-sqlite-adapter
152
130
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +140,7 @@ dependencies:
162
140
  - !ruby/object:Gem::Version
163
141
  version: '0'
164
142
  - !ruby/object:Gem::Dependency
165
- name: simplecov
143
+ name: pry
166
144
  requirement: !ruby/object:Gem::Requirement
167
145
  requirements:
168
146
  - - ">="
@@ -176,7 +154,7 @@ dependencies:
176
154
  - !ruby/object:Gem::Version
177
155
  version: '0'
178
156
  - !ruby/object:Gem::Dependency
179
- name: simplecov-rcov
157
+ name: simplecov
180
158
  requirement: !ruby/object:Gem::Requirement
181
159
  requirements:
182
160
  - - ">="
@@ -190,7 +168,7 @@ dependencies:
190
168
  - !ruby/object:Gem::Version
191
169
  version: '0'
192
170
  - !ruby/object:Gem::Dependency
193
- name: codeclimate-test-reporter
171
+ name: simplecov-rcov
194
172
  requirement: !ruby/object:Gem::Requirement
195
173
  requirements:
196
174
  - - ">="
@@ -221,7 +199,16 @@ files:
221
199
  - README.md
222
200
  - Rakefile
223
201
  - attr_encrypted.gemspec
224
- - certs/saghaulor.pem
202
+ - checksum/attr_encrypted-3.0.0.gem.sha256
203
+ - checksum/attr_encrypted-3.0.0.gem.sha512
204
+ - checksum/attr_encrypted-3.0.1.gem.sha256
205
+ - checksum/attr_encrypted-3.0.1.gem.sha512
206
+ - checksum/attr_encrypted-3.0.2.gem.sha256
207
+ - checksum/attr_encrypted-3.0.2.gem.sha512
208
+ - checksum/attr_encrypted-3.0.3.gem.sha256
209
+ - checksum/attr_encrypted-3.0.3.gem.sha512
210
+ - checksum/attr_encrypted-3.1.0.gem.sha256
211
+ - checksum/attr_encrypted-3.1.0.gem.sha512
225
212
  - lib/attr_encrypted.rb
226
213
  - lib/attr_encrypted/adapters/active_record.rb
227
214
  - lib/attr_encrypted/adapters/data_mapper.rb
@@ -240,41 +227,32 @@ files:
240
227
  - test/sequel_test.rb
241
228
  - test/test_helper.rb
242
229
  homepage: http://github.com/attr-encrypted/attr_encrypted
243
- licenses: []
230
+ licenses:
231
+ - MIT
244
232
  metadata: {}
245
233
  post_install_message: |2+
246
234
 
247
235
 
248
236
 
249
- WARNING: Several insecure default options and features were deprecated in attr_encrypted v2.0.0.
250
-
251
- Additionally, there was a bug in Encryptor v2.0.0 that insecurely encrypted data when using an AES-*-GCM algorithm.
252
-
253
- This bug was fixed but introduced breaking changes between v2.x and v3.x.
254
-
255
- Please see the README for more information regarding upgrading to attr_encrypted v3.0.0.
237
+ WARNING: Using `#encrypted_attributes` is no longer supported. Instead, use `#attr_encrypted_encrypted_attributes` to avoid
238
+ collision with Active Record 7 native encryption.
256
239
 
257
240
 
258
- rdoc_options:
259
- - "--line-numbers"
260
- - "--inline-source"
261
- - "--main"
262
- - README.rdoc
241
+ rdoc_options: []
263
242
  require_paths:
264
243
  - lib
265
244
  required_ruby_version: !ruby/object:Gem::Requirement
266
245
  requirements:
267
246
  - - ">="
268
247
  - !ruby/object:Gem::Version
269
- version: 2.0.0
248
+ version: 2.6.0
270
249
  required_rubygems_version: !ruby/object:Gem::Requirement
271
250
  requirements:
272
251
  - - ">="
273
252
  - !ruby/object:Gem::Version
274
253
  version: '0'
275
254
  requirements: []
276
- rubyforge_project:
277
- rubygems_version: 2.4.5.1
255
+ rubygems_version: 3.0.3.1
278
256
  signing_key:
279
257
  specification_version: 4
280
258
  summary: Encrypt and decrypt attributes
@@ -291,4 +269,3 @@ test_files:
291
269
  - test/run.sh
292
270
  - test/sequel_test.rb
293
271
  - test/test_helper.rb
294
- has_rdoc: false
checksums.yaml.gz.sig DELETED
Binary file
data/certs/saghaulor.pem DELETED
@@ -1,21 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlzYWdo
3
- YXVsb3IxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
4
- bTAeFw0xNjAxMTEyMjQyMDFaFw0xNzAxMTAyMjQyMDFaMEAxEjAQBgNVBAMMCXNh
5
- Z2hhdWxvcjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD
6
- Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx0xdQYk2GwCpQ1n/
7
- n2mPVYHLYqU5TAn/82t5kbqBUWjbcj8tHAi41tJ19+fT/hH0dog8JHvho1zmOr71
8
- ZIqreJQo60TqP6oE9a5HncUpjqbRp7tOmHo9E+mOW1yT4NiXqFf1YINExQKy2XND
9
- WPQ+T50ZNUsGMfHFWB4NAymejRWXlOEY3bvKW0UHFeNmouP5he51TjoP8uCc9536
10
- 4AIWVP/zzzjwrFtC7av7nRw4Y+gX2bQjrkK2k2JS0ejiGzKBIEMJejcI2B+t79zT
11
- kUQq9SFwp2BrKSIy+4kh4CiF20RT/Hfc1MbvTxSIl/bbIxCYEOhmtHExHi0CoCWs
12
- YCGCXQIDAQABo3kwdzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
13
- SCpVzSBvYbO6B3oT3n3RCZmurG8wHgYDVR0RBBcwFYETc2FnaGF1bG9yQGdtYWls
14
- LmNvbTAeBgNVHRIEFzAVgRNzYWdoYXVsb3JAZ21haWwuY29tMA0GCSqGSIb3DQEB
15
- BQUAA4IBAQAeiGdC3e0WiZpm0cF/b7JC6hJYXC9Yv9VsRAWD9ROsLjFKwOhmonnc
16
- +l/QrmoTjMakYXBCai/Ca3L+k5eRrKilgyITILsmmFxK8sqPJXUw2Jmwk/dAky6x
17
- hHKVZAofT1OrOOPJ2USoZyhR/VI8epLaD5wUmkVDNqtZWviW+dtRa55aPYjRw5Pj
18
- wuj9nybhZr+BbEbmZE//2nbfkM4hCuMtxxxilPrJ22aYNmeWU0wsPpDyhPYxOUgU
19
- ZjeLmnSDiwL6doiP5IiwALH/dcHU67ck3NGf6XyqNwQrrmtPY0mv1WVVL4Uh+vYE
20
- kHoFzE2no0BfBg78Re8fY69P5yES5ncC
21
- -----END CERTIFICATE-----
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
Binary file