attr_encrypted 4.0.0 → 4.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36ebe1f889eadcc15b60089547792d023a5b32e4877a17789da28bc2ca33b3c1
4
- data.tar.gz: 54540410056e0b49d7cc6af2077af4e45cf06aef354e0780757b93ff4af1e134
3
+ metadata.gz: 5a992ab4061d1d05c6de0891accee520006d545d727be49bd80c09ea4d55b44a
4
+ data.tar.gz: c6dcfb039445ce7128e0c610d5ca6a4efce02ed195fe754fbc947a99f7b8cef7
5
5
  SHA512:
6
- metadata.gz: 55a0639ffee8def55645e2444d063ab18df7030f74404289735b2e9329ff65461ac0af3dab29248c337f9b5344aeb7c78d72f3d9155edabde689997c519c88b2
7
- data.tar.gz: 22af4440292a3950cb2ca1ab4ed795972626fb974b962d5dc86ebec5492fb7f3a83b691d2432d691d39de66df0a244bfce31576af0b58ab65881b8faf1db8323
6
+ metadata.gz: 62299d9d34f907ef99464ca41c5de51f9b05d440b2210ba377e05ac4fe02978fa58893cdb0ce002cd25216dace37c5f67b8a8c97ef76259066ee6fc57b93fd08
7
+ data.tar.gz: f081aaebe945a24d2aff5fea11e671b700b8bf5a6513d36252c96f38e5134448efb9660d0fb6843418d926dcb3821ae1e9c23d2f2551ff2a0b261a678a6bb8f5
@@ -0,0 +1,43 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ name: Ruby ${{ matrix.ruby }} / ActiveRecord ${{ matrix.active_record }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ active_record:
17
+ - '6.0'
18
+ - '6.1'
19
+ - '7.0'
20
+ - '7.1'
21
+ ruby:
22
+ - '2.7'
23
+ - '3.0'
24
+ - '3.1'
25
+ - '3.2'
26
+ include:
27
+ - active_record: '5.1'
28
+ ruby: '2.7'
29
+ - active_record: '5.2'
30
+ ruby: '2.7'
31
+ - active_record: '7.1'
32
+ ruby: '3.3'
33
+ env:
34
+ ACTIVERECORD: ${{ matrix.active_record }}
35
+ steps:
36
+ - uses: actions/checkout@v3
37
+ - name: Set up Ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ ruby-version: ${{ matrix.ruby }}
41
+ bundler-cache: true
42
+ - run: |
43
+ bundle exec rake test
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # attr_encrypted
2
2
 
3
+ ## 4.1.0
4
+
5
+ * Changed: Dropped support for `datamapper` which has not had a release since October 2011. This is in an attempt to make
6
+ maintenance and testing easier moving forward.
7
+
3
8
  ## 4.0.0
4
9
 
5
10
  * Added: Support for Ruby >= 3.0.
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # attr_encrypted
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/attr-encrypted/attr_encrypted.svg)](https://travis-ci.org/attr-encrypted/attr_encrypted) [![Test Coverage](https://codeclimate.com/github/attr-encrypted/attr_encrypted/badges/coverage.svg)](https://codeclimate.com/github/attr-encrypted/attr_encrypted/coverage) [![Code Climate](https://codeclimate.com/github/attr-encrypted/attr_encrypted/badges/gpa.svg)](https://codeclimate.com/github/attr-encrypted/attr_encrypted) [![Gem Version](https://badge.fury.io/rb/attr_encrypted.svg)](https://badge.fury.io/rb/attr_encrypted) [![security](https://hakiri.io/github/attr-encrypted/attr_encrypted/master.svg)](https://hakiri.io/github/attr-encrypted/attr_encrypted/master)
3
+ ![workflow](https://github.com/attr-encrypted/attr_encrypted/actions/workflows/CI.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/attr_encrypted.svg)](https://badge.fury.io/rb/attr_encrypted)
4
4
 
5
5
  Generates attr_accessors that transparently encrypt and decrypt attributes.
6
6
 
7
- It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord`, `DataMapper`, or `Sequel`.
8
-
7
+ It works with ANY class, however, you get a few extra features when you're using it with `ActiveRecord` or `Sequel`.
9
8
 
10
9
  ## Installation
11
10
 
@@ -23,7 +22,7 @@ Then install the gem:
23
22
 
24
23
  ## Usage
25
24
 
26
- If you're using an ORM like `ActiveRecord`, `DataMapper`, or `Sequel`, using attr_encrypted is easy:
25
+ If you're using an ORM like `ActiveRecord` or `Sequel`, using attr_encrypted is easy:
27
26
 
28
27
  ```ruby
29
28
  class User
@@ -364,7 +363,7 @@ NOTE: This only works if all records are encrypted with the same encryption key
364
363
  __NOTE: This feature is deprecated and will be removed in the next major release.__
365
364
 
366
365
 
367
- ### DataMapper and Sequel
366
+ ### Sequel
368
367
 
369
368
  #### Default options
370
369
 
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.summary = 'Encrypt and decrypt attributes'
15
15
  s.description = 'Generates attr_accessors that encrypt and decrypt attributes transparently'
16
16
 
17
- s.authors = ['Sean Huber', 'S. Brent Faulkner', 'William Monk', 'Stephen Aghaulor']
18
- s.email = ['seah@shuber.io', 'sbfaulkner@gmail.com', 'billy.monk@gmail.com', 'saghaulor@gmail.com']
17
+ s.authors = ['Sean Huber', 'S. Brent Faulkner', 'William Monk', 'Stephen Aghaulor', 'Josh Branham', 'Mike Vastola']
18
+ s.email = ['seah@shuber.io', 'sbfaulkner@gmail.com', 'billy.monk@gmail.com', 'saghaulor@gmail.com', 'josh.php@gmail.com', 'Mike@Vasto.la']
19
19
  s.homepage = 'http://github.com/attr-encrypted/attr_encrypted'
20
20
  s.license = 'MIT'
21
21
 
@@ -29,13 +29,12 @@ Gem::Specification.new do |s|
29
29
  s.add_dependency('encryptor', ['~> 3.0.0'])
30
30
  # support for testing with specific active record version
31
31
  activerecord_version = if ENV.key?('ACTIVERECORD')
32
- "~> #{ENV['ACTIVERECORD']}"
32
+ "~> #{ENV['ACTIVERECORD']}.0"
33
33
  else
34
34
  '>= 2.0.0'
35
35
  end
36
36
  s.add_development_dependency('activerecord', activerecord_version)
37
37
  s.add_development_dependency('actionpack', activerecord_version)
38
- s.add_development_dependency('datamapper')
39
38
  s.add_development_dependency('rake')
40
39
  s.add_development_dependency('minitest')
41
40
  s.add_development_dependency('sequel')
@@ -4,7 +4,7 @@ module AttrEncrypted
4
4
  # Contains information about this gem's version
5
5
  module Version
6
6
  MAJOR = 4
7
- MINOR = 0
7
+ MINOR = 1
8
8
  PATCH = 0
9
9
 
10
10
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
@@ -54,7 +54,7 @@ module AttrEncrypted
54
54
  # string instead of just 'true'. See
55
55
  # http://www.ruby-doc.org/core/classes/Array.html#M002245
56
56
  # for more encoding directives.
57
- # Defaults to false unless you're using it with ActiveRecord, DataMapper, or Sequel.
57
+ # Defaults to false unless you're using it with ActiveRecord or Sequel.
58
58
  #
59
59
  # encode_iv: Defaults to true.
60
60
 
@@ -29,9 +29,15 @@ class LegacyPerson < ActiveRecord::Base
29
29
  attr_encrypted :email, :key => 'a secret key'
30
30
  attr_encrypted :credentials, :key => Proc.new { |user| Encryptor.encrypt(:value => user.salt, :key => 'some private key', insecure_mode: true, algorithm: 'aes-256-cbc') }, :marshal => true
31
31
 
32
- ActiveSupport::Deprecation.silenced = true
33
- def after_initialize; end
34
- ActiveSupport::Deprecation.silenced = false
32
+ if ActiveRecord.respond_to?(:deprecator)
33
+ ActiveRecord.deprecator.silence do
34
+ def after_initialize; end
35
+ end
36
+ else
37
+ ActiveSupport::Deprecation.silenced = true
38
+ def after_initialize; end
39
+ ActiveSupport::Deprecation.silenced = false
40
+ end
35
41
 
36
42
  after_initialize :initialize_salt_and_credentials
37
43
 
data/test/test_helper.rb CHANGED
@@ -16,17 +16,15 @@ SimpleCov.start do
16
16
  end
17
17
 
18
18
  require 'minitest/autorun'
19
-
20
- # Rails 4.0.x pins to an old minitest
21
- unless defined?(MiniTest::Test)
22
- MiniTest::Test = MiniTest::Unit::TestCase
23
- end
24
-
25
19
  require 'active_record'
26
- require 'data_mapper'
27
20
  require 'digest/sha2'
28
21
  require 'sequel'
29
- ActiveSupport::Deprecation.behavior = :raise
22
+
23
+ if ActiveRecord.respond_to?(:deprecator)
24
+ ActiveRecord.deprecator.behavior = :raise
25
+ else
26
+ ActiveSupport::Deprecation.behavior = :raise
27
+ end
30
28
 
31
29
  $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
32
30
  $:.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -1,17 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_encrypted
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
8
8
  - S. Brent Faulkner
9
9
  - William Monk
10
10
  - Stephen Aghaulor
11
- autorequire:
11
+ - Josh Branham
12
+ - Mike Vastola
13
+ autorequire:
12
14
  bindir: bin
13
15
  cert_chain: []
14
- date: 2023-04-06 00:00:00.000000000 Z
16
+ date: 2024-05-30 00:00:00.000000000 Z
15
17
  dependencies:
16
18
  - !ruby/object:Gem::Dependency
17
19
  name: encryptor
@@ -55,20 +57,6 @@ dependencies:
55
57
  - - ">="
56
58
  - !ruby/object:Gem::Version
57
59
  version: 2.0.0
58
- - !ruby/object:Gem::Dependency
59
- name: datamapper
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
60
  - !ruby/object:Gem::Dependency
73
61
  name: rake
74
62
  requirement: !ruby/object:Gem::Requirement
@@ -187,12 +175,14 @@ email:
187
175
  - sbfaulkner@gmail.com
188
176
  - billy.monk@gmail.com
189
177
  - saghaulor@gmail.com
178
+ - josh.php@gmail.com
179
+ - Mike@Vasto.la
190
180
  executables: []
191
181
  extensions: []
192
182
  extra_rdoc_files: []
193
183
  files:
184
+ - ".github/workflows/CI.yml"
194
185
  - ".gitignore"
195
- - ".travis.yml"
196
186
  - CHANGELOG.md
197
187
  - Gemfile
198
188
  - MIT-LICENSE
@@ -211,17 +201,14 @@ files:
211
201
  - checksum/attr_encrypted-3.1.0.gem.sha512
212
202
  - lib/attr_encrypted.rb
213
203
  - lib/attr_encrypted/adapters/active_record.rb
214
- - lib/attr_encrypted/adapters/data_mapper.rb
215
204
  - lib/attr_encrypted/adapters/sequel.rb
216
205
  - lib/attr_encrypted/version.rb
217
206
  - test/active_record_test.rb
218
207
  - test/attr_encrypted_test.rb
219
208
  - test/compatibility_test.rb
220
- - test/data_mapper_test.rb
221
209
  - test/legacy_active_record_test.rb
222
210
  - test/legacy_attr_encrypted_test.rb
223
211
  - test/legacy_compatibility_test.rb
224
- - test/legacy_data_mapper_test.rb
225
212
  - test/legacy_sequel_test.rb
226
213
  - test/run.sh
227
214
  - test/sequel_test.rb
@@ -252,20 +239,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
239
  - !ruby/object:Gem::Version
253
240
  version: '0'
254
241
  requirements: []
255
- rubygems_version: 3.0.3.1
256
- signing_key:
242
+ rubygems_version: 3.4.10
243
+ signing_key:
257
244
  specification_version: 4
258
245
  summary: Encrypt and decrypt attributes
259
246
  test_files:
260
247
  - test/active_record_test.rb
261
248
  - test/attr_encrypted_test.rb
262
249
  - test/compatibility_test.rb
263
- - test/data_mapper_test.rb
264
250
  - test/legacy_active_record_test.rb
265
251
  - test/legacy_attr_encrypted_test.rb
266
252
  - test/legacy_compatibility_test.rb
267
- - test/legacy_data_mapper_test.rb
268
253
  - test/legacy_sequel_test.rb
269
254
  - test/run.sh
270
255
  - test/sequel_test.rb
271
256
  - test/test_helper.rb
257
+ ...
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- language: ruby
2
- dist: focal
3
- os: linux
4
- cache: bundler
5
- rvm:
6
- - 2.6.10
7
- - 2.7.6
8
- env:
9
- - ACTIVERECORD=5.1.1
10
- - ACTIVERECORD=5.2.8
11
- - ACTIVERECORD=6.0.6
12
- - ACTIVERECORD=6.1.7
13
- - ACTIVERECORD=7.0.4
14
- jobs:
15
- fast_finish: false
16
- exclude:
17
- - rvm: 2.6.10
18
- env: ACTIVERECORD=7.0.4
19
-
20
- addons:
21
- code_climate:
22
- repo_token: a90435ed4954dd6e9f3697a20c5bc3754f67d94703f870e8fc7b00f69f5b2d06
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if defined?(DataMapper)
4
- module AttrEncrypted
5
- module Adapters
6
- module DataMapper
7
- def self.extended(base) # :nodoc:
8
- class << base
9
- alias_method :included_without_attr_encrypted, :included
10
- alias_method :included, :included_with_attr_encrypted
11
- end
12
- end
13
-
14
- def included_with_attr_encrypted(base)
15
- included_without_attr_encrypted(base)
16
- base.extend AttrEncrypted
17
- base.attr_encrypted_options[:encode] = true
18
- end
19
- end
20
- end
21
- end
22
-
23
- DataMapper::Resource.extend AttrEncrypted::Adapters::DataMapper
24
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'test_helper'
4
-
5
- DataMapper.setup(:default, 'sqlite3::memory:')
6
-
7
- class Client
8
- include DataMapper::Resource
9
-
10
- property :id, Serial
11
- property :encrypted_email, String
12
- property :encrypted_email_iv, String
13
- property :encrypted_email_salt, String
14
-
15
- property :encrypted_credentials, Text
16
- property :encrypted_credentials_iv, Text
17
- property :encrypted_credentials_salt, Text
18
-
19
- self.attr_encrypted_options[:mode] = :per_attribute_iv_and_salt
20
-
21
- attr_encrypted :email, :key => SECRET_KEY
22
- attr_encrypted :credentials, :key => SECRET_KEY, :marshal => true
23
-
24
- def initialize(attrs = {})
25
- super attrs
26
- self.credentials ||= { :username => 'example', :password => 'test' }
27
- end
28
- end
29
-
30
- DataMapper.auto_migrate!
31
-
32
- class DataMapperTest < Minitest::Test
33
-
34
- def setup
35
- Client.all.each(&:destroy)
36
- end
37
-
38
- def test_should_encrypt_email
39
- @client = Client.new :email => 'test@example.com'
40
- assert @client.save
41
- refute_nil @client.encrypted_email
42
- refute_equal @client.email, @client.encrypted_email
43
- assert_equal @client.email, Client.first.email
44
- end
45
-
46
- def test_should_marshal_and_encrypt_credentials
47
- @client = Client.new
48
- assert @client.save
49
- refute_nil @client.encrypted_credentials
50
- refute_equal @client.credentials, @client.encrypted_credentials
51
- assert_equal @client.credentials, Client.first.credentials
52
- assert Client.first.credentials.is_a?(Hash)
53
- end
54
-
55
- def test_should_encode_by_default
56
- assert Client.attr_encrypted_options[:encode]
57
- end
58
-
59
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'test_helper'
4
-
5
- DataMapper.setup(:default, 'sqlite3::memory:')
6
-
7
- class LegacyClient
8
- include DataMapper::Resource
9
- self.attr_encrypted_options[:insecure_mode] = true
10
- self.attr_encrypted_options[:algorithm] = 'aes-256-cbc'
11
- self.attr_encrypted_options[:mode] = :single_iv_and_salt
12
-
13
- property :id, Serial
14
- property :encrypted_email, String
15
- property :encrypted_credentials, Text
16
- property :salt, String
17
-
18
- attr_encrypted :email, :key => 'a secret key', mode: :single_iv_and_salt
19
- attr_encrypted :credentials, :key => Proc.new { |client| Encryptor.encrypt(:value => client.salt, :key => 'some private key', insecure_mode: true, algorithm: 'aes-256-cbc') }, :marshal => true, mode: :single_iv_and_salt
20
-
21
- def initialize(attrs = {})
22
- super attrs
23
- self.salt ||= Digest::SHA1.hexdigest((Time.now.to_i * rand(5)).to_s)
24
- self.credentials ||= { :username => 'example', :password => 'test' }
25
- end
26
- end
27
-
28
- DataMapper.auto_migrate!
29
-
30
- class LegacyDataMapperTest < Minitest::Test
31
-
32
- def setup
33
- LegacyClient.all.each(&:destroy)
34
- end
35
-
36
- def test_should_encrypt_email
37
- @client = LegacyClient.new :email => 'test@example.com'
38
- assert @client.save
39
- refute_nil @client.encrypted_email
40
- refute_equal @client.email, @client.encrypted_email
41
- assert_equal @client.email, LegacyClient.first.email
42
- end
43
-
44
- def test_should_marshal_and_encrypt_credentials
45
- @client = LegacyClient.new
46
- assert @client.save
47
- refute_nil @client.encrypted_credentials
48
- refute_equal @client.credentials, @client.encrypted_credentials
49
- assert_equal @client.credentials, LegacyClient.first.credentials
50
- assert LegacyClient.first.credentials.is_a?(Hash)
51
- end
52
-
53
- def test_should_encode_by_default
54
- assert LegacyClient.attr_encrypted_options[:encode]
55
- end
56
-
57
- end