attr_encrypted 4.0.0 → 4.2.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 +4 -4
- data/.github/workflows/CI.yml +53 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -0
- data/README.md +4 -5
- data/attr_encrypted.gemspec +10 -8
- data/lib/attr_encrypted/adapters/active_record.rb +11 -11
- data/lib/attr_encrypted/version.rb +1 -1
- data/lib/attr_encrypted.rb +1 -1
- data/test/legacy_active_record_test.rb +9 -3
- data/test/test_helper.rb +6 -8
- metadata +16 -44
- data/.travis.yml +0 -22
- data/lib/attr_encrypted/adapters/data_mapper.rb +0 -24
- data/test/data_mapper_test.rb +0 -59
- data/test/legacy_data_mapper_test.rb +0 -57
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f575e6c6da0da72cae27e9cdf4032e895005775ea44e15f33f2ff461b54e90b
|
|
4
|
+
data.tar.gz: c3a80d92586c59dac539d6bd7136249d53c7e022e6624c9c5c34035f7a6079f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6389590ba9c038c2c9ea6fef5dd5766f406b1a9d6fdaf711209d977981bea4476605a5b89b2c37c83d5adfd11d733fef56994f4d0843011b6dbd25290d753d08
|
|
7
|
+
data.tar.gz: 4472de6edcd25f0ac3742d33d54afb8fa3fd6ffb11a8c0ae06982734e699dd49591e464899c641c26fc28b5ef36ad9c12107634e43c59817fe41f7e41cd1f397
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
include:
|
|
17
|
+
- { active_record: '5.1', ruby: '2.7' }
|
|
18
|
+
- { active_record: '5.2', ruby: '2.7' }
|
|
19
|
+
- { active_record: '6.0', ruby: '2.7' }
|
|
20
|
+
- { active_record: '6.0', ruby: '3.0' }
|
|
21
|
+
- { active_record: '6.0', ruby: '3.1' }
|
|
22
|
+
- { active_record: '6.0', ruby: '3.2' }
|
|
23
|
+
- { active_record: '6.1', ruby: '2.7' }
|
|
24
|
+
- { active_record: '6.1', ruby: '3.0' }
|
|
25
|
+
- { active_record: '6.1', ruby: '3.1' }
|
|
26
|
+
- { active_record: '6.1', ruby: '3.2' }
|
|
27
|
+
- { active_record: '7.0', ruby: '2.7' }
|
|
28
|
+
- { active_record: '7.0', ruby: '3.0' }
|
|
29
|
+
- { active_record: '7.0', ruby: '3.1' }
|
|
30
|
+
- { active_record: '7.0', ruby: '3.2' }
|
|
31
|
+
- { active_record: '7.1', ruby: '2.7' }
|
|
32
|
+
- { active_record: '7.1', ruby: '3.0' }
|
|
33
|
+
- { active_record: '7.1', ruby: '3.1' }
|
|
34
|
+
- { active_record: '7.1', ruby: '3.2' }
|
|
35
|
+
- { active_record: '7.1', ruby: '3.3' }
|
|
36
|
+
- { active_record: '7.2', ruby: '3.1' }
|
|
37
|
+
- { active_record: '7.2', ruby: '3.2' }
|
|
38
|
+
- { active_record: '7.2', ruby: '3.3' }
|
|
39
|
+
- { active_record: '7.2', ruby: '3.4' }
|
|
40
|
+
- { active_record: '8.0', ruby: '3.2' }
|
|
41
|
+
- { active_record: '8.0', ruby: '3.3' }
|
|
42
|
+
- { active_record: '8.0', ruby: '3.4' }
|
|
43
|
+
env:
|
|
44
|
+
ACTIVERECORD: ${{ matrix.active_record }}
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
- name: Set up Ruby
|
|
48
|
+
uses: ruby/setup-ruby@v1
|
|
49
|
+
with:
|
|
50
|
+
ruby-version: ${{ matrix.ruby }}
|
|
51
|
+
bundler-cache: true
|
|
52
|
+
- run: |
|
|
53
|
+
bundle exec rake test
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# attr_encrypted
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
* Changed: Set minimum Ruby version as 2.7.
|
|
6
|
+
* Added: Rails 7.2 and 8.0 support.
|
|
7
|
+
* Fixed: Further removal of `datamapper` support.
|
|
8
|
+
|
|
9
|
+
## 4.1.1
|
|
10
|
+
|
|
11
|
+
* Fixed: Fix SystemStackError when extending the reload method with Module#prepend.
|
|
12
|
+
|
|
13
|
+
## 4.1.0
|
|
14
|
+
|
|
15
|
+
* Changed: Dropped support for `datamapper` which has not had a release since October 2011. This is in an attempt to make
|
|
16
|
+
maintenance and testing easier moving forward.
|
|
17
|
+
|
|
3
18
|
## 4.0.0
|
|
4
19
|
|
|
5
20
|
* Added: Support for Ruby >= 3.0.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# attr_encrypted
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 [](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
|
|
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
|
|
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
|
-
###
|
|
366
|
+
### Sequel
|
|
368
367
|
|
|
369
368
|
#### Default options
|
|
370
369
|
|
data/attr_encrypted.gemspec
CHANGED
|
@@ -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
|
|
|
@@ -24,18 +24,17 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
s.files = `git ls-files`.split("\n")
|
|
25
25
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
|
26
26
|
|
|
27
|
-
s.required_ruby_version = '>= 2.
|
|
27
|
+
s.required_ruby_version = '>= 2.7.0'
|
|
28
28
|
|
|
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
|
+
'>= 6.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')
|
|
@@ -43,9 +42,12 @@ Gem::Specification.new do |s|
|
|
|
43
42
|
s.add_development_dependency('activerecord-jdbcsqlite3-adapter')
|
|
44
43
|
s.add_development_dependency('jdbc-sqlite3', '< 3.8.7') # 3.8.7 is nice and broke
|
|
45
44
|
else
|
|
46
|
-
|
|
45
|
+
if ENV['ACTIVERECORD'] && Gem::Version.new(ENV['ACTIVERECORD']) >= Gem::Version.new('8.0')
|
|
46
|
+
s.add_development_dependency('sqlite3', '> 2.1.0')
|
|
47
|
+
else
|
|
48
|
+
s.add_development_dependency('sqlite3', '= 1.5.4')
|
|
49
|
+
end
|
|
47
50
|
end
|
|
48
|
-
s.add_development_dependency('dm-sqlite-adapter')
|
|
49
51
|
s.add_development_dependency('pry')
|
|
50
52
|
s.add_development_dependency('simplecov')
|
|
51
53
|
s.add_development_dependency('simplecov-rcov')
|
|
@@ -6,19 +6,18 @@ if defined?(ActiveRecord::Base)
|
|
|
6
6
|
module ActiveRecord
|
|
7
7
|
RAILS_VERSION = Gem::Version.new(::ActiveRecord::VERSION::STRING).freeze
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def reload(*args, &block)
|
|
15
|
-
result = reload_without_attr_encrypted(*args, &block)
|
|
16
|
-
self.class.attr_encrypted_encrypted_attributes.keys.each do |attribute_name|
|
|
17
|
-
instance_variable_set("@#{attribute_name}", nil)
|
|
18
|
-
end
|
|
19
|
-
result
|
|
9
|
+
module Reload
|
|
10
|
+
def reload(...)
|
|
11
|
+
result = super
|
|
12
|
+
self.class.attr_encrypted_encrypted_attributes.keys.each do |attribute_name|
|
|
13
|
+
instance_variable_set("@#{attribute_name}", nil)
|
|
20
14
|
end
|
|
15
|
+
result
|
|
16
|
+
end
|
|
17
|
+
end
|
|
21
18
|
|
|
19
|
+
def self.extended(base) # :nodoc:
|
|
20
|
+
base.class_eval do
|
|
22
21
|
attr_encrypted_options[:encode] = true
|
|
23
22
|
|
|
24
23
|
class << self
|
|
@@ -148,5 +147,6 @@ if defined?(ActiveRecord::Base)
|
|
|
148
147
|
ActiveSupport.on_load(:active_record) do
|
|
149
148
|
extend AttrEncrypted
|
|
150
149
|
extend AttrEncrypted::Adapters::ActiveRecord
|
|
150
|
+
prepend AttrEncrypted::Adapters::ActiveRecord::Reload
|
|
151
151
|
end
|
|
152
152
|
end
|
data/lib/attr_encrypted.rb
CHANGED
|
@@ -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
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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.
|
|
4
|
+
version: 4.2.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
|
-
|
|
11
|
+
- Josh Branham
|
|
12
|
+
- Mike Vastola
|
|
13
|
+
autorequire:
|
|
12
14
|
bindir: bin
|
|
13
15
|
cert_chain: []
|
|
14
|
-
date:
|
|
16
|
+
date: 2025-01-23 00:00:00.000000000 Z
|
|
15
17
|
dependencies:
|
|
16
18
|
- !ruby/object:Gem::Dependency
|
|
17
19
|
name: encryptor
|
|
@@ -33,42 +35,28 @@ dependencies:
|
|
|
33
35
|
requirements:
|
|
34
36
|
- - ">="
|
|
35
37
|
- !ruby/object:Gem::Version
|
|
36
|
-
version:
|
|
38
|
+
version: 6.0.0
|
|
37
39
|
type: :development
|
|
38
40
|
prerelease: false
|
|
39
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
42
|
requirements:
|
|
41
43
|
- - ">="
|
|
42
44
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
45
|
+
version: 6.0.0
|
|
44
46
|
- !ruby/object:Gem::Dependency
|
|
45
47
|
name: actionpack
|
|
46
48
|
requirement: !ruby/object:Gem::Requirement
|
|
47
49
|
requirements:
|
|
48
50
|
- - ">="
|
|
49
51
|
- !ruby/object:Gem::Version
|
|
50
|
-
version:
|
|
52
|
+
version: 6.0.0
|
|
51
53
|
type: :development
|
|
52
54
|
prerelease: false
|
|
53
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
54
56
|
requirements:
|
|
55
57
|
- - ">="
|
|
56
58
|
- !ruby/object:Gem::Version
|
|
57
|
-
version:
|
|
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'
|
|
59
|
+
version: 6.0.0
|
|
72
60
|
- !ruby/object:Gem::Dependency
|
|
73
61
|
name: rake
|
|
74
62
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -125,20 +113,6 @@ dependencies:
|
|
|
125
113
|
- - '='
|
|
126
114
|
- !ruby/object:Gem::Version
|
|
127
115
|
version: 1.5.4
|
|
128
|
-
- !ruby/object:Gem::Dependency
|
|
129
|
-
name: dm-sqlite-adapter
|
|
130
|
-
requirement: !ruby/object:Gem::Requirement
|
|
131
|
-
requirements:
|
|
132
|
-
- - ">="
|
|
133
|
-
- !ruby/object:Gem::Version
|
|
134
|
-
version: '0'
|
|
135
|
-
type: :development
|
|
136
|
-
prerelease: false
|
|
137
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
138
|
-
requirements:
|
|
139
|
-
- - ">="
|
|
140
|
-
- !ruby/object:Gem::Version
|
|
141
|
-
version: '0'
|
|
142
116
|
- !ruby/object:Gem::Dependency
|
|
143
117
|
name: pry
|
|
144
118
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -187,12 +161,14 @@ email:
|
|
|
187
161
|
- sbfaulkner@gmail.com
|
|
188
162
|
- billy.monk@gmail.com
|
|
189
163
|
- saghaulor@gmail.com
|
|
164
|
+
- josh.php@gmail.com
|
|
165
|
+
- Mike@Vasto.la
|
|
190
166
|
executables: []
|
|
191
167
|
extensions: []
|
|
192
168
|
extra_rdoc_files: []
|
|
193
169
|
files:
|
|
170
|
+
- ".github/workflows/CI.yml"
|
|
194
171
|
- ".gitignore"
|
|
195
|
-
- ".travis.yml"
|
|
196
172
|
- CHANGELOG.md
|
|
197
173
|
- Gemfile
|
|
198
174
|
- MIT-LICENSE
|
|
@@ -211,17 +187,14 @@ files:
|
|
|
211
187
|
- checksum/attr_encrypted-3.1.0.gem.sha512
|
|
212
188
|
- lib/attr_encrypted.rb
|
|
213
189
|
- lib/attr_encrypted/adapters/active_record.rb
|
|
214
|
-
- lib/attr_encrypted/adapters/data_mapper.rb
|
|
215
190
|
- lib/attr_encrypted/adapters/sequel.rb
|
|
216
191
|
- lib/attr_encrypted/version.rb
|
|
217
192
|
- test/active_record_test.rb
|
|
218
193
|
- test/attr_encrypted_test.rb
|
|
219
194
|
- test/compatibility_test.rb
|
|
220
|
-
- test/data_mapper_test.rb
|
|
221
195
|
- test/legacy_active_record_test.rb
|
|
222
196
|
- test/legacy_attr_encrypted_test.rb
|
|
223
197
|
- test/legacy_compatibility_test.rb
|
|
224
|
-
- test/legacy_data_mapper_test.rb
|
|
225
198
|
- test/legacy_sequel_test.rb
|
|
226
199
|
- test/run.sh
|
|
227
200
|
- test/sequel_test.rb
|
|
@@ -245,27 +218,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
245
218
|
requirements:
|
|
246
219
|
- - ">="
|
|
247
220
|
- !ruby/object:Gem::Version
|
|
248
|
-
version: 2.
|
|
221
|
+
version: 2.7.0
|
|
249
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
223
|
requirements:
|
|
251
224
|
- - ">="
|
|
252
225
|
- !ruby/object:Gem::Version
|
|
253
226
|
version: '0'
|
|
254
227
|
requirements: []
|
|
255
|
-
rubygems_version: 3.
|
|
256
|
-
signing_key:
|
|
228
|
+
rubygems_version: 3.5.22
|
|
229
|
+
signing_key:
|
|
257
230
|
specification_version: 4
|
|
258
231
|
summary: Encrypt and decrypt attributes
|
|
259
232
|
test_files:
|
|
260
233
|
- test/active_record_test.rb
|
|
261
234
|
- test/attr_encrypted_test.rb
|
|
262
235
|
- test/compatibility_test.rb
|
|
263
|
-
- test/data_mapper_test.rb
|
|
264
236
|
- test/legacy_active_record_test.rb
|
|
265
237
|
- test/legacy_attr_encrypted_test.rb
|
|
266
238
|
- test/legacy_compatibility_test.rb
|
|
267
|
-
- test/legacy_data_mapper_test.rb
|
|
268
239
|
- test/legacy_sequel_test.rb
|
|
269
240
|
- test/run.sh
|
|
270
241
|
- test/sequel_test.rb
|
|
271
242
|
- test/test_helper.rb
|
|
243
|
+
...
|
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
|
data/test/data_mapper_test.rb
DELETED
|
@@ -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
|