attr_cipher 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '028e1e05b611dc3e8076d5c4df72906eaeb140f7'
4
- data.tar.gz: 79154ae0e9ae0d7fd2ea7e9fed7cd0de31d6347b
3
+ metadata.gz: 6a896f093962e62296aec6818f68b36736daff46
4
+ data.tar.gz: 37ef1ffb2afbd1c8d5754c470ca7626897f8dd57
5
5
  SHA512:
6
- metadata.gz: fceb794e899feeaf99ca4aeefcdc9709541425d6b4852c9b1d674cbca82c2a667370321264e109477bb49d2f3ab05dc89f78e8e07b00c04588d83cbe7ade5d2c
7
- data.tar.gz: b11e01c3de37fd7f23b455fe9af84aeb8d0055d94c06bfc294072cb1ba7ea218d0cf7b8d3d36f7210c14a09b10dee51247886964087c602cfead72a43e167f26
6
+ metadata.gz: dbb6c823857f19d4d9fd51ca1f5b2e2a6bd1a9d08c03bf17ea4469d3ec476115baf855f0e021f2600c62bd3870a440add418bcfc028129ac4a23f721e33070e3
7
+ data.tar.gz: 0fc52af26991b33c20c25345a342012d630df41cb8650e79e94242e9e785db31ea23ed96b9549d2fe90fe5ce8e4903a2419260e8a03237134d8491746459b5ed
data/CHANGELOG.md CHANGED
@@ -1,4 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ##v1.3.0
4
+ - Loosened ActiveRecord version to >= 4.2.6 only.
5
+ - Loosened ActiveSupport version to >= 4.2.6 only.
6
+ - Moved secret length validator to encrypt and decrypt functions of Cipher module to remove false positive warnings at startup.
7
+ - Updated specs with changes.
8
+
9
+ ##v1.2.0
10
+ - Updated README.
11
+ - Updated Gem description.
12
+
13
+ ##v1.1.0
14
+ - Updated Gem description.
15
+
3
16
  ##v1.0.0
4
17
  - Initial release.
data/README.md CHANGED
@@ -22,8 +22,8 @@ And run `bundle install`.
22
22
  ## Dependencies
23
23
 
24
24
  Runtime:
25
- - activerecord (>= 4.2.6, < 5.2.0)
26
- - activesupport (>= 4.2.6, < 5.2.0)
25
+ - activerecord (>= 4.2.6)
26
+ - activesupport (>= 4.2.6)
27
27
 
28
28
  Development/Test:
29
29
  - rake (~> 10.5)
@@ -115,7 +115,7 @@ bundle exec rake
115
115
 
116
116
  ## Credit
117
117
 
118
- I would like to thank [Nando Vieira](http://nandovieira.com/) for his [encrypt_attr](https://github.com/fnando/encrypt_attr) gem from which some of the code was derived.
118
+ I would like to thank [Nando Vieira](http://nandovieira.com/) for his [encrypt_attr](https://github.com/fnando/encrypt_attr) gem from which some of the code was derived. The `encrypt_attr` gem is a better fit for non-ActiveRecord use.
119
119
 
120
120
  This gem was written and is maintained by [Jurgen Jocubeit](https://github.com/JurgenJocubeit), CEO and President Brightcommerce, Inc.
121
121
 
@@ -4,31 +4,26 @@ require 'active_support/all'
4
4
  module AttrCipher
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ class Error < ::StandardError
8
+ end
9
+
10
+ class SecretTooShortException < Error
11
+ end
12
+
7
13
  class << self
8
14
  attr_accessor :cipher
9
15
  attr_reader :secret
10
16
  end
11
17
 
12
18
  def self.secret=(value)
13
- validate_secret(value.to_s)
14
19
  @secret = value.to_s
15
20
  end
16
21
 
17
- def self.validate_secret(value)
18
- if value.size < 100
19
- offending_line = caller.reject { |entry|
20
- entry.include?(__dir__) || entry.include?("forwardable.rb")
21
- }.first[/^(.*?:\d+)/, 1]
22
- warn "[attr_cipher] secret must have at least 100 characters (called from #{offending_line})"
23
- end
24
- end
25
-
26
22
  self.cipher = Cipher
27
23
  self.secret = ''
28
24
 
29
25
  module ClassMethods
30
26
  def attr_cipher(*args, secret: AttrCipher.secret, cipher: AttrCipher.cipher)
31
- AttrCipher.validate_secret(secret)
32
27
  args.each do |attribute|
33
28
  define_cipher_attribute(attribute, secret, cipher)
34
29
  end
@@ -25,6 +25,9 @@ module AttrCipher
25
25
  end
26
26
 
27
27
  def decrypt(value)
28
+ raise ::AttrCipher::SecretTooShortException.new(
29
+ "Secret must have at least 100 characters"
30
+ ) if @secret.size < 100
28
31
  cipher(:decrypt, decode(value))
29
32
  end
30
33
 
@@ -33,6 +36,9 @@ module AttrCipher
33
36
  end
34
37
 
35
38
  def encrypt(value)
39
+ raise ::AttrCipher::SecretTooShortException.new(
40
+ "Secret must have at least 100 characters"
41
+ ) if @secret.size < 100
36
42
  encode(cipher(:encrypt, value))
37
43
  end
38
44
 
@@ -1,7 +1,7 @@
1
1
  module AttrCipher
2
2
  module VERSION
3
3
  MAJOR = 1
4
- MINOR = 2
4
+ MINOR = 3
5
5
  TINY = 0
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_cipher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgen Jocubeit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-25 00:00:00.000000000 Z
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.6
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 5.2.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 4.2.6
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 5.2.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activerecord
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -37,9 +31,6 @@ dependencies:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
33
  version: 4.2.6
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: 5.2.0
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,9 +38,6 @@ dependencies:
47
38
  - - ">="
48
39
  - !ruby/object:Gem::Version
49
40
  version: 4.2.6
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: 5.2.0
53
41
  - !ruby/object:Gem::Dependency
54
42
  name: rake
55
43
  requirement: !ruby/object:Gem::Requirement
@@ -159,5 +147,5 @@ rubyforge_project:
159
147
  rubygems_version: 2.5.1
160
148
  signing_key:
161
149
  specification_version: 4
162
- summary: AttrCipher v1.2.0
150
+ summary: AttrCipher v1.3.0
163
151
  test_files: []