crypt_keeper 0.2.0 → 0.3.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.
data/.travis.yml CHANGED
@@ -1,5 +1,9 @@
1
+ branches: master
1
2
  language: ruby
2
- script: "bundle exec rake spec"
3
+ gemfile:
4
+ - gemfiles/activerecord_3_0.gemfile
5
+ - gemfiles/activerecord_3_1.gemfile
6
+ - gemfiles/activerecord_3_2.gemfile
3
7
  notifications:
4
8
  email:
5
9
  recipients:
@@ -9,4 +13,3 @@ notifications:
9
13
  rvm:
10
14
  - 1.9.2
11
15
  - 1.9.3
12
- - jruby-19mode
data/Appraisals ADDED
@@ -0,0 +1,14 @@
1
+ appraise "activerecord_3_0" do
2
+ gem 'activerecord', '~> 3.0'
3
+ gem 'activesupport', '~> 3.0'
4
+ end
5
+
6
+ appraise "activerecord_3_1" do
7
+ gem 'activerecord', '~> 3.1'
8
+ gem 'activesupport', '~> 3.1'
9
+ end
10
+
11
+ appraise "activerecord_3_2" do
12
+ gem 'activerecord', '~> 3.2'
13
+ gem 'activesupport', '~> 3.2'
14
+ end
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', version: 2, fail_fast: true, all_on_start: false, all_after_pass: false do
4
+ guard 'rspec', version: 2, all_on_start: false, all_after_pass: false, cli: '--fail-fast' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
data/README.md CHANGED
@@ -15,7 +15,7 @@ is a simple class that does 3 things.
15
15
  Note: Any options defined using `crypt_keeper` will be passed to `new` as a
16
16
  hash.
17
17
 
18
- Use can see an AES example here [here](https://github.com/jmazzi/crypt_keeper_providers/blob/master/lib/crypt_keeper_providers/aes.rb)
18
+ You can see an AES example [here](https://github.com/jmazzi/crypt_keeper_providers/blob/master/lib/crypt_keeper_providers/aes.rb).
19
19
 
20
20
  ## Why?
21
21
 
@@ -27,7 +27,7 @@ simple that *just works*.
27
27
 
28
28
  ```ruby
29
29
  class MyModel < ActiveRecord::Base
30
- crypt_keeper :field, :other_field, :encryptor => :aes, :passphrase => 'super_good_password'
30
+ crypt_keeper :field, :other_field, :encryptor => :aes, :key => 'super_good_password'
31
31
  end
32
32
 
33
33
  model = MyModel.new(field: 'sometext')
@@ -35,8 +35,16 @@ model.save! #=> Your data is now encrypted
35
35
  model.field #=> 'sometext'
36
36
  ```
37
37
 
38
- It works with all persistences methods: `update_attribute`, `update_attributes`,
39
- `create`, `save` etc.
38
+ It works with all persistences methods: `update_attributes`, `create`, `save`
39
+ etc.
40
+
41
+ Note: `update_attribute` is deprecated in ActiveRecord 3.2.7. It is superseded
42
+ by [update_column](http://apidock.com/rails/ActiveRecord/Persistence/update_column) which _skips_ all validations, callbacks.
43
+
44
+ That means using `update_column` will not perform any encryption. This is
45
+ expected behavior, and has it's use cases. An example would be migrating from
46
+ one type of encryption to another. Using `update_column` would allow you to
47
+ update the content without going through the current encryptor.
40
48
 
41
49
  ## Creating your own encryptor
42
50
 
@@ -60,15 +68,32 @@ end
60
68
  ```
61
69
 
62
70
  Just require your code and setup your model to use it. Just pass the class name
63
- as an underscored symbol
71
+ as a string or an underscored symbol
64
72
 
65
73
 
66
74
  ```ruby
67
75
  class MyModel < ActiveRecord::Base
68
- crypt_keeper :field, :other_field, :encryptor => :my_encryptor, :passphrase => 'super_good_password'
76
+ crypt_keeper :field, :other_field, :encryptor => :my_encryptor, :key => 'super_good_password'
69
77
  end
70
78
  ```
71
79
 
80
+ ## Available Encryptors
81
+
82
+ There are two included encryptors.
83
+
84
+ * [AES](https://github.com/jmazzi/crypt_keeper_providers/blob/master/lib/crypt_keeper_providers/aes.rb)
85
+ * Encryption is peformed using AES-256 via OpenSSL.
86
+
87
+ * [PostgreSQL PGP](https://github.com/jmazzi/crypt_keeper_providers/blob/master/lib/crypt_keeper_providers/postgres_pgp.rb).
88
+ * Encryption is performed using PostgresSQL's native [PGP functions](http://www.postgresql.org/docs/9.1/static/pgcrypto.html).
89
+ * It requires the `pgcrypto` PostgresSQL extension. `CREATE EXTENSION IF NOT EXISTS pgcrypto`
90
+ * ActiveRecord logs are [automatically](https://github.com/jmazzi/crypt_keeper_providers/blob/master/lib/crypt_keeper_providers/postgres_pgp_log_subscriber.rb) filtered for you to protect senitive data from being logged.
91
+
92
+ ## Requirements
93
+
94
+ Crypt Keeper has been tested against ActiveRecord 3.0, 3.1, and 3.2 using ruby
95
+ 1.9.2, 1.9.3 and jruby in 1.9 mode.
96
+
72
97
  ## Installation
73
98
 
74
99
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
3
  require 'rspec/core/rake_task'
4
+ require 'appraisal'
4
5
 
5
6
  RSpec::Core::RakeTask.new :spec
6
7
  Bundler::GemHelper.install_tasks
data/crypt_keeper.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.email = ["jmazzi@gmail.com"]
7
7
  gem.description = %q{Transparent encryption for ActiveRecord that isn't over-engineered}
8
8
  gem.summary = gem.description
9
- gem.homepage = ""
9
+ gem.homepage = "http://jmazzi.github.com/crypt_keeper/"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
12
12
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -15,14 +15,16 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = CryptKeeper::VERSION
17
17
 
18
- gem.add_runtime_dependency 'activerecord', '>= 3.0'
19
- gem.add_runtime_dependency 'activesupport', '>= 3.0'
20
- gem.add_runtime_dependency 'crypt_keeper_providers', '~> 0.1.0'
18
+ gem.add_runtime_dependency 'activerecord', '>= 3.0'
19
+ gem.add_runtime_dependency 'activesupport', '>= 3.0'
20
+ gem.add_runtime_dependency 'crypt_keeper_providers', '~> 0.2.0'
21
+ gem.add_runtime_dependency 'appraisal', '~> 0.4.1'
21
22
 
22
- gem.add_development_dependency 'rspec', '~> 2.10.0'
23
- gem.add_development_dependency 'guard', '~> 1.2.0'
23
+ gem.add_development_dependency 'rspec', '~> 2.10.0'
24
+ gem.add_development_dependency 'guard', '~> 1.2.0'
24
25
  gem.add_development_dependency 'guard-rspec', '~> 1.1.0'
25
- gem.add_development_dependency 'rake', '~> 0.9.2.2'
26
+ gem.add_development_dependency 'rake', '~> 0.9.2.2'
27
+
26
28
  if RUBY_PLATFORM == 'java'
27
29
  gem.add_development_dependency 'jruby-openssl', '~> 0.7.7'
28
30
  gem.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.0"
6
+ gem "activesupport", "~> 3.0"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: /home/justin/work/ruby/crypt_keeper
3
+ specs:
4
+ crypt_keeper (0.2.0)
5
+ activerecord (>= 3.0)
6
+ activesupport (>= 3.0)
7
+ appraisal (~> 0.4.1)
8
+ crypt_keeper_providers (~> 0.1.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (3.2.7)
14
+ activesupport (= 3.2.7)
15
+ builder (~> 3.0.0)
16
+ activerecord (3.2.7)
17
+ activemodel (= 3.2.7)
18
+ activesupport (= 3.2.7)
19
+ arel (~> 3.0.2)
20
+ tzinfo (~> 0.3.29)
21
+ activesupport (3.2.7)
22
+ i18n (~> 0.6)
23
+ multi_json (~> 1.0)
24
+ appraisal (0.4.1)
25
+ bundler
26
+ rake
27
+ arel (3.0.2)
28
+ builder (3.0.0)
29
+ crypt_keeper_providers (0.1.0)
30
+ diff-lcs (1.1.3)
31
+ ffi (1.1.0)
32
+ guard (1.2.3)
33
+ listen (>= 0.4.2)
34
+ thor (>= 0.14.6)
35
+ guard-rspec (1.1.0)
36
+ guard (>= 1.1)
37
+ i18n (0.6.0)
38
+ listen (0.4.7)
39
+ rb-fchange (~> 0.0.5)
40
+ rb-fsevent (~> 0.9.1)
41
+ rb-inotify (~> 0.8.8)
42
+ multi_json (1.3.6)
43
+ rake (0.9.2.2)
44
+ rb-fchange (0.0.5)
45
+ ffi
46
+ rb-fsevent (0.9.1)
47
+ rb-inotify (0.8.8)
48
+ ffi (>= 0.5.0)
49
+ rspec (2.10.0)
50
+ rspec-core (~> 2.10.0)
51
+ rspec-expectations (~> 2.10.0)
52
+ rspec-mocks (~> 2.10.0)
53
+ rspec-core (2.10.1)
54
+ rspec-expectations (2.10.0)
55
+ diff-lcs (~> 1.1.3)
56
+ rspec-mocks (2.10.1)
57
+ sqlite3 (1.3.6)
58
+ thor (0.15.4)
59
+ tzinfo (0.3.33)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ activerecord (~> 3.0)
66
+ activesupport (~> 3.0)
67
+ crypt_keeper!
68
+ guard (~> 1.2.0)
69
+ guard-rspec (~> 1.1.0)
70
+ rake (~> 0.9.2.2)
71
+ rspec (~> 2.10.0)
72
+ sqlite3
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.1"
6
+ gem "activesupport", "~> 3.1"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: /home/justin/work/ruby/crypt_keeper
3
+ specs:
4
+ crypt_keeper (0.2.0)
5
+ activerecord (>= 3.0)
6
+ activesupport (>= 3.0)
7
+ appraisal (~> 0.4.1)
8
+ crypt_keeper_providers (~> 0.1.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (3.2.7)
14
+ activesupport (= 3.2.7)
15
+ builder (~> 3.0.0)
16
+ activerecord (3.2.7)
17
+ activemodel (= 3.2.7)
18
+ activesupport (= 3.2.7)
19
+ arel (~> 3.0.2)
20
+ tzinfo (~> 0.3.29)
21
+ activesupport (3.2.7)
22
+ i18n (~> 0.6)
23
+ multi_json (~> 1.0)
24
+ appraisal (0.4.1)
25
+ bundler
26
+ rake
27
+ arel (3.0.2)
28
+ builder (3.0.0)
29
+ crypt_keeper_providers (0.1.0)
30
+ diff-lcs (1.1.3)
31
+ ffi (1.1.0)
32
+ guard (1.2.3)
33
+ listen (>= 0.4.2)
34
+ thor (>= 0.14.6)
35
+ guard-rspec (1.1.0)
36
+ guard (>= 1.1)
37
+ i18n (0.6.0)
38
+ listen (0.4.7)
39
+ rb-fchange (~> 0.0.5)
40
+ rb-fsevent (~> 0.9.1)
41
+ rb-inotify (~> 0.8.8)
42
+ multi_json (1.3.6)
43
+ rake (0.9.2.2)
44
+ rb-fchange (0.0.5)
45
+ ffi
46
+ rb-fsevent (0.9.1)
47
+ rb-inotify (0.8.8)
48
+ ffi (>= 0.5.0)
49
+ rspec (2.10.0)
50
+ rspec-core (~> 2.10.0)
51
+ rspec-expectations (~> 2.10.0)
52
+ rspec-mocks (~> 2.10.0)
53
+ rspec-core (2.10.1)
54
+ rspec-expectations (2.10.0)
55
+ diff-lcs (~> 1.1.3)
56
+ rspec-mocks (2.10.1)
57
+ sqlite3 (1.3.6)
58
+ thor (0.15.4)
59
+ tzinfo (0.3.33)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ activerecord (~> 3.1)
66
+ activesupport (~> 3.1)
67
+ crypt_keeper!
68
+ guard (~> 1.2.0)
69
+ guard-rspec (~> 1.1.0)
70
+ rake (~> 0.9.2.2)
71
+ rspec (~> 2.10.0)
72
+ sqlite3
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2"
6
+ gem "activesupport", "~> 3.2"
7
+
8
+ gemspec :path=>"../"
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: /home/justin/work/ruby/crypt_keeper
3
+ specs:
4
+ crypt_keeper (0.2.0)
5
+ activerecord (>= 3.0)
6
+ activesupport (>= 3.0)
7
+ appraisal (~> 0.4.1)
8
+ crypt_keeper_providers (~> 0.1.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activemodel (3.2.7)
14
+ activesupport (= 3.2.7)
15
+ builder (~> 3.0.0)
16
+ activerecord (3.2.7)
17
+ activemodel (= 3.2.7)
18
+ activesupport (= 3.2.7)
19
+ arel (~> 3.0.2)
20
+ tzinfo (~> 0.3.29)
21
+ activesupport (3.2.7)
22
+ i18n (~> 0.6)
23
+ multi_json (~> 1.0)
24
+ appraisal (0.4.1)
25
+ bundler
26
+ rake
27
+ arel (3.0.2)
28
+ builder (3.0.0)
29
+ crypt_keeper_providers (0.1.0)
30
+ diff-lcs (1.1.3)
31
+ ffi (1.1.0)
32
+ guard (1.2.3)
33
+ listen (>= 0.4.2)
34
+ thor (>= 0.14.6)
35
+ guard-rspec (1.1.0)
36
+ guard (>= 1.1)
37
+ i18n (0.6.0)
38
+ listen (0.4.7)
39
+ rb-fchange (~> 0.0.5)
40
+ rb-fsevent (~> 0.9.1)
41
+ rb-inotify (~> 0.8.8)
42
+ multi_json (1.3.6)
43
+ rake (0.9.2.2)
44
+ rb-fchange (0.0.5)
45
+ ffi
46
+ rb-fsevent (0.9.1)
47
+ rb-inotify (0.8.8)
48
+ ffi (>= 0.5.0)
49
+ rspec (2.10.0)
50
+ rspec-core (~> 2.10.0)
51
+ rspec-expectations (~> 2.10.0)
52
+ rspec-mocks (~> 2.10.0)
53
+ rspec-core (2.10.1)
54
+ rspec-expectations (2.10.0)
55
+ diff-lcs (~> 1.1.3)
56
+ rspec-mocks (2.10.1)
57
+ sqlite3 (1.3.6)
58
+ thor (0.15.4)
59
+ tzinfo (0.3.33)
60
+
61
+ PLATFORMS
62
+ ruby
63
+
64
+ DEPENDENCIES
65
+ activerecord (~> 3.2)
66
+ activesupport (~> 3.2)
67
+ crypt_keeper!
68
+ guard (~> 1.2.0)
69
+ guard-rspec (~> 1.1.0)
70
+ rake (~> 0.9.2.2)
71
+ rspec (~> 2.10.0)
72
+ sqlite3
@@ -33,7 +33,7 @@ module CryptKeeper
33
33
  # Example
34
34
  #
35
35
  # class MyModel < ActiveRecord::Base
36
- # crypt_keeper :field, :other_field, :encryptor => :aes, :passphrase => 'super_good_password'
36
+ # crypt_keeper :field, :other_field, :encryptor => :aes, :key => 'super_good_password'
37
37
  # end
38
38
  #
39
39
  def crypt_keeper(*args)
@@ -1,3 +1,3 @@
1
1
  module CryptKeeper
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/spec/model_spec.rb CHANGED
@@ -4,6 +4,11 @@ module CryptKeeper
4
4
  describe Model do
5
5
  subject { SensitiveData }
6
6
  describe "#crypt_keeper" do
7
+ after(:each) do
8
+ subject.instance_variable_set(:@encryptor_klass, nil)
9
+ subject.instance_variable_set(:@encryptor, nil)
10
+ end
11
+
7
12
  context "Fields" do
8
13
  it "should set the fields" do
9
14
  subject.crypt_keeper :storage, :secret, encryptor: :fake_encryptor
@@ -21,6 +26,13 @@ module CryptKeeper
21
26
  subject.crypt_keeper :storage, :secret, key1: 1, key2: 2, encryptor: :fake_encryptor
22
27
  subject.crypt_keeper_options.should == { key1: 1, key2: 2 }
23
28
  end
29
+
30
+ it "should accept class name (as string) for encryptor option" do
31
+ subject.crypt_keeper :storage, :secret, key1: 1, key2: 2, encryptor: "FakeEncryptor"
32
+ subject.send(:encryptor_klass).should == CryptKeeperProviders::FakeEncryptor
33
+
34
+ subject.instance_variable_set(:@encryptor_klass, nil)
35
+ end
24
36
  end
25
37
  end
26
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crypt_keeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-27 00:00:00.000000000 Z
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 0.1.0
53
+ version: 0.2.0
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,23 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0
61
+ version: 0.2.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: appraisal
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 0.4.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.4.1
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: rspec
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -149,12 +165,19 @@ files:
149
165
  - .gitignore
150
166
  - .rspec
151
167
  - .travis.yml
168
+ - Appraisals
152
169
  - Gemfile
153
170
  - Guardfile
154
171
  - LICENSE
155
172
  - README.md
156
173
  - Rakefile
157
174
  - crypt_keeper.gemspec
175
+ - gemfiles/activerecord_3_0.gemfile
176
+ - gemfiles/activerecord_3_0.gemfile.lock
177
+ - gemfiles/activerecord_3_1.gemfile
178
+ - gemfiles/activerecord_3_1.gemfile.lock
179
+ - gemfiles/activerecord_3_2.gemfile
180
+ - gemfiles/activerecord_3_2.gemfile.lock
158
181
  - lib/crypt_keeper.rb
159
182
  - lib/crypt_keeper/model.rb
160
183
  - lib/crypt_keeper/version.rb
@@ -162,7 +185,7 @@ files:
162
185
  - spec/spec_helper.rb
163
186
  - spec/support/active_record.rb
164
187
  - spec/support/encryptors.rb
165
- homepage: ''
188
+ homepage: http://jmazzi.github.com/crypt_keeper/
166
189
  licenses: []
167
190
  post_install_message:
168
191
  rdoc_options: []
@@ -176,7 +199,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
199
  version: '0'
177
200
  segments:
178
201
  - 0
179
- hash: -4294679024711639404
202
+ hash: 868846789855728654
180
203
  required_rubygems_version: !ruby/object:Gem::Requirement
181
204
  none: false
182
205
  requirements:
@@ -185,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
208
  version: '0'
186
209
  segments:
187
210
  - 0
188
- hash: -4294679024711639404
211
+ hash: 868846789855728654
189
212
  requirements: []
190
213
  rubyforge_project:
191
214
  rubygems_version: 1.8.23