crypt_keeper_providers 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +11 -2
- data/Appraisals +14 -0
- data/Guardfile +1 -1
- data/README.md +2 -0
- data/Rakefile +1 -0
- data/crypt_keeper_providers.gemspec +8 -2
- data/gemfiles/activerecord_3_0.gemfile +8 -0
- data/gemfiles/activerecord_3_0.gemfile.lock +68 -0
- data/gemfiles/activerecord_3_1.gemfile +8 -0
- data/gemfiles/activerecord_3_1.gemfile.lock +68 -0
- data/gemfiles/activerecord_3_2.gemfile +8 -0
- data/gemfiles/activerecord_3_2.gemfile.lock +68 -0
- data/lib/crypt_keeper_providers/aes.rb +18 -12
- data/lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb +27 -0
- data/lib/crypt_keeper_providers/postgres_pgp.rb +38 -0
- data/lib/crypt_keeper_providers/version.rb +1 -1
- data/lib/crypt_keeper_providers.rb +1 -0
- data/spec/aes_spec.rb +5 -1
- data/spec/default.database.yml +8 -0
- data/spec/postgres_sql_log_subscriber_spec.rb +25 -0
- data/spec/postgres_sql_spec.rb +33 -0
- data/spec/support/active_record.rb +22 -0
- metadata +69 -4
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
gemfile:
|
3
|
+
- gemfiles/activerecord_3_0.gemfile
|
4
|
+
- gemfiles/activerecord_3_1.gemfile
|
5
|
+
- gemfiles/activerecord_3_2.gemfile
|
6
|
+
before_script:
|
7
|
+
- cp spec/default.database.yml spec/database.yml
|
8
|
+
- psql -c 'CREATE DATABASE crypt_keeper_providers;' -U postgres
|
9
|
+
- psql crypt_keeper_providers -c 'CREATE EXTENSION IF NOT EXISTS pgcrypto;' -U postgres
|
3
10
|
notifications:
|
4
11
|
email:
|
5
12
|
recipients:
|
@@ -9,4 +16,6 @@ notifications:
|
|
9
16
|
rvm:
|
10
17
|
- 1.9.2
|
11
18
|
- 1.9.3
|
12
|
-
|
19
|
+
|
20
|
+
jdk:
|
21
|
+
- openjdk7
|
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,
|
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
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/jmazzi/crypt_keeper_providers.png?branch=master)](http://travis-ci.org/jmazzi/crypt_keeper_providers)
|
2
|
+
|
1
3
|
# CryptKeeperProviders
|
2
4
|
|
3
5
|
Provides encryption classes for use with [crypt_keeper](https://github.com/jmazzi/crypt_keeper)
|
data/Rakefile
CHANGED
@@ -19,7 +19,13 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'guard', '~> 1.2.0'
|
20
20
|
gem.add_development_dependency 'guard-rspec', '~> 1.1.0'
|
21
21
|
gem.add_development_dependency 'rake', '~> 0.9.2.2'
|
22
|
-
gem.add_development_dependency '
|
23
|
-
|
22
|
+
gem.add_development_dependency 'activerecord', '>= 3.0'
|
23
|
+
gem.add_development_dependency 'appraisal', '~> 0.4.1'
|
24
24
|
|
25
|
+
if RUBY_PLATFORM == 'java'
|
26
|
+
gem.add_development_dependency 'jruby-openssl', '~> 0.7.7'
|
27
|
+
gem.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
|
28
|
+
else
|
29
|
+
gem.add_development_dependency 'pg', '~> 0.14.0'
|
30
|
+
end
|
25
31
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/justin/work/ruby/crypt_keeper_providers
|
3
|
+
specs:
|
4
|
+
crypt_keeper_providers (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.7)
|
10
|
+
activesupport (= 3.2.7)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.7)
|
13
|
+
activemodel (= 3.2.7)
|
14
|
+
activesupport (= 3.2.7)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.7)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
appraisal (0.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (3.0.2)
|
24
|
+
builder (3.0.0)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
ffi (1.1.1)
|
27
|
+
guard (1.2.3)
|
28
|
+
listen (>= 0.4.2)
|
29
|
+
thor (>= 0.14.6)
|
30
|
+
guard-rspec (1.1.0)
|
31
|
+
guard (>= 1.1)
|
32
|
+
i18n (0.6.0)
|
33
|
+
listen (0.4.7)
|
34
|
+
rb-fchange (~> 0.0.5)
|
35
|
+
rb-fsevent (~> 0.9.1)
|
36
|
+
rb-inotify (~> 0.8.8)
|
37
|
+
multi_json (1.3.6)
|
38
|
+
pg (0.14.0)
|
39
|
+
rake (0.9.2.2)
|
40
|
+
rb-fchange (0.0.5)
|
41
|
+
ffi
|
42
|
+
rb-fsevent (0.9.1)
|
43
|
+
rb-inotify (0.8.8)
|
44
|
+
ffi (>= 0.5.0)
|
45
|
+
rspec (2.10.0)
|
46
|
+
rspec-core (~> 2.10.0)
|
47
|
+
rspec-expectations (~> 2.10.0)
|
48
|
+
rspec-mocks (~> 2.10.0)
|
49
|
+
rspec-core (2.10.1)
|
50
|
+
rspec-expectations (2.10.0)
|
51
|
+
diff-lcs (~> 1.1.3)
|
52
|
+
rspec-mocks (2.10.1)
|
53
|
+
thor (0.15.4)
|
54
|
+
tzinfo (0.3.33)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
activerecord (~> 3.0)
|
61
|
+
activesupport (~> 3.0)
|
62
|
+
appraisal (~> 0.4.1)
|
63
|
+
crypt_keeper_providers!
|
64
|
+
guard (~> 1.2.0)
|
65
|
+
guard-rspec (~> 1.1.0)
|
66
|
+
pg (~> 0.14.0)
|
67
|
+
rake (~> 0.9.2.2)
|
68
|
+
rspec (~> 2.10.0)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/justin/work/ruby/crypt_keeper_providers
|
3
|
+
specs:
|
4
|
+
crypt_keeper_providers (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.7)
|
10
|
+
activesupport (= 3.2.7)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.7)
|
13
|
+
activemodel (= 3.2.7)
|
14
|
+
activesupport (= 3.2.7)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.7)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
appraisal (0.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (3.0.2)
|
24
|
+
builder (3.0.0)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
ffi (1.1.1)
|
27
|
+
guard (1.2.3)
|
28
|
+
listen (>= 0.4.2)
|
29
|
+
thor (>= 0.14.6)
|
30
|
+
guard-rspec (1.1.0)
|
31
|
+
guard (>= 1.1)
|
32
|
+
i18n (0.6.0)
|
33
|
+
listen (0.4.7)
|
34
|
+
rb-fchange (~> 0.0.5)
|
35
|
+
rb-fsevent (~> 0.9.1)
|
36
|
+
rb-inotify (~> 0.8.8)
|
37
|
+
multi_json (1.3.6)
|
38
|
+
pg (0.14.0)
|
39
|
+
rake (0.9.2.2)
|
40
|
+
rb-fchange (0.0.5)
|
41
|
+
ffi
|
42
|
+
rb-fsevent (0.9.1)
|
43
|
+
rb-inotify (0.8.8)
|
44
|
+
ffi (>= 0.5.0)
|
45
|
+
rspec (2.10.0)
|
46
|
+
rspec-core (~> 2.10.0)
|
47
|
+
rspec-expectations (~> 2.10.0)
|
48
|
+
rspec-mocks (~> 2.10.0)
|
49
|
+
rspec-core (2.10.1)
|
50
|
+
rspec-expectations (2.10.0)
|
51
|
+
diff-lcs (~> 1.1.3)
|
52
|
+
rspec-mocks (2.10.1)
|
53
|
+
thor (0.15.4)
|
54
|
+
tzinfo (0.3.33)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
activerecord (~> 3.1)
|
61
|
+
activesupport (~> 3.1)
|
62
|
+
appraisal (~> 0.4.1)
|
63
|
+
crypt_keeper_providers!
|
64
|
+
guard (~> 1.2.0)
|
65
|
+
guard-rspec (~> 1.1.0)
|
66
|
+
pg (~> 0.14.0)
|
67
|
+
rake (~> 0.9.2.2)
|
68
|
+
rspec (~> 2.10.0)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/justin/work/ruby/crypt_keeper_providers
|
3
|
+
specs:
|
4
|
+
crypt_keeper_providers (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (3.2.7)
|
10
|
+
activesupport (= 3.2.7)
|
11
|
+
builder (~> 3.0.0)
|
12
|
+
activerecord (3.2.7)
|
13
|
+
activemodel (= 3.2.7)
|
14
|
+
activesupport (= 3.2.7)
|
15
|
+
arel (~> 3.0.2)
|
16
|
+
tzinfo (~> 0.3.29)
|
17
|
+
activesupport (3.2.7)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
multi_json (~> 1.0)
|
20
|
+
appraisal (0.4.1)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
arel (3.0.2)
|
24
|
+
builder (3.0.0)
|
25
|
+
diff-lcs (1.1.3)
|
26
|
+
ffi (1.1.1)
|
27
|
+
guard (1.2.3)
|
28
|
+
listen (>= 0.4.2)
|
29
|
+
thor (>= 0.14.6)
|
30
|
+
guard-rspec (1.1.0)
|
31
|
+
guard (>= 1.1)
|
32
|
+
i18n (0.6.0)
|
33
|
+
listen (0.4.7)
|
34
|
+
rb-fchange (~> 0.0.5)
|
35
|
+
rb-fsevent (~> 0.9.1)
|
36
|
+
rb-inotify (~> 0.8.8)
|
37
|
+
multi_json (1.3.6)
|
38
|
+
pg (0.14.0)
|
39
|
+
rake (0.9.2.2)
|
40
|
+
rb-fchange (0.0.5)
|
41
|
+
ffi
|
42
|
+
rb-fsevent (0.9.1)
|
43
|
+
rb-inotify (0.8.8)
|
44
|
+
ffi (>= 0.5.0)
|
45
|
+
rspec (2.10.0)
|
46
|
+
rspec-core (~> 2.10.0)
|
47
|
+
rspec-expectations (~> 2.10.0)
|
48
|
+
rspec-mocks (~> 2.10.0)
|
49
|
+
rspec-core (2.10.1)
|
50
|
+
rspec-expectations (2.10.0)
|
51
|
+
diff-lcs (~> 1.1.3)
|
52
|
+
rspec-mocks (2.10.1)
|
53
|
+
thor (0.15.4)
|
54
|
+
tzinfo (0.3.33)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
ruby
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
activerecord (~> 3.2)
|
61
|
+
activesupport (~> 3.2)
|
62
|
+
appraisal (~> 0.4.1)
|
63
|
+
crypt_keeper_providers!
|
64
|
+
guard (~> 1.2.0)
|
65
|
+
guard-rspec (~> 1.1.0)
|
66
|
+
pg (~> 0.14.0)
|
67
|
+
rake (~> 0.9.2.2)
|
68
|
+
rspec (~> 2.10.0)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'digest/
|
1
|
+
require 'digest/sha2'
|
2
2
|
require 'openssl'
|
3
3
|
require 'base64'
|
4
4
|
|
@@ -6,39 +6,45 @@ module CryptKeeperProviders
|
|
6
6
|
class Aes
|
7
7
|
SEPARATOR = ":crypt_keeper:"
|
8
8
|
|
9
|
-
|
9
|
+
# Public: The encryption key
|
10
|
+
attr_accessor :key
|
11
|
+
|
12
|
+
# Public: An instance of OpenSSL::Cipher::Cipher
|
13
|
+
attr_accessor :aes
|
10
14
|
|
11
15
|
# Public: Initializes the class
|
12
16
|
#
|
13
|
-
# options - A hash of options. :
|
17
|
+
# options - A hash of options. :key is required
|
14
18
|
def initialize(options = {})
|
15
|
-
@key = options[:passphrase]
|
16
19
|
@aes = ::OpenSSL::Cipher::Cipher.new("AES-256-CBC")
|
17
20
|
@aes.padding = 1
|
18
|
-
|
21
|
+
|
22
|
+
key = options.fetch(:key) do
|
23
|
+
raise ArgumentError, "Missing :key"
|
24
|
+
end
|
25
|
+
|
26
|
+
@key = Digest::SHA256.digest(key)
|
19
27
|
end
|
20
28
|
|
21
29
|
# Public: Encrypt a string
|
22
30
|
#
|
23
31
|
# Returns a string
|
24
32
|
def encrypt(value)
|
25
|
-
value = value.to_s
|
26
33
|
aes.encrypt
|
27
34
|
aes.key = key
|
28
|
-
iv
|
29
|
-
aes.iv
|
30
|
-
Base64::encode64("#{iv}#{SEPARATOR}#{aes.update(value) + aes.final}")
|
35
|
+
iv = rand.to_s
|
36
|
+
aes.iv = iv
|
37
|
+
Base64::encode64("#{iv}#{SEPARATOR}#{aes.update(value.to_s) + aes.final}")
|
31
38
|
end
|
32
39
|
|
33
40
|
# Public: Decrypt a string
|
34
41
|
#
|
35
42
|
# Returns a string
|
36
43
|
def decrypt(value)
|
37
|
-
value = Base64::decode64(value.to_s)
|
38
|
-
iv, value = value.split(SEPARATOR)
|
44
|
+
iv, value = Base64::decode64(value.to_s).split(SEPARATOR)
|
39
45
|
aes.decrypt
|
40
46
|
aes.key = key
|
41
|
-
aes.iv
|
47
|
+
aes.iv = iv
|
42
48
|
aes.update(value) + aes.final
|
43
49
|
end
|
44
50
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
require 'active_support/lazy_load_hooks'
|
3
|
+
|
4
|
+
module CryptKeeperProviders
|
5
|
+
module PostgresPgpLogSubscriber
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method_chain :sql, :filter
|
10
|
+
end
|
11
|
+
|
12
|
+
# Public: Prevents sensitive data from being logged
|
13
|
+
def sql_with_filter(event)
|
14
|
+
filter = /(pgp_sym_(encrypt|decrypt))\(((.|\n)*?)\)/i
|
15
|
+
|
16
|
+
event.payload[:sql] = event.payload[:sql].gsub(filter) do |_|
|
17
|
+
"#{$1}([FILTERED])"
|
18
|
+
end
|
19
|
+
|
20
|
+
sql_without_filter(event)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveSupport.on_load :active_record do
|
26
|
+
ActiveRecord::LogSubscriber.send :include, CryptKeeperProviders::PostgresPgpLogSubscriber
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'crypt_keeper_providers/postgres_pgp/log_subscriber'
|
2
|
+
|
3
|
+
module CryptKeeperProviders
|
4
|
+
class PostgresPgp
|
5
|
+
attr_accessor :key
|
6
|
+
|
7
|
+
# Public: Initializes the encryptor
|
8
|
+
#
|
9
|
+
# options - A hash, :key is required
|
10
|
+
def initialize(options = {})
|
11
|
+
@key = options.fetch(:key) do
|
12
|
+
raise ArgumentError, "Missing :key"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Public: Encrypts a string
|
17
|
+
#
|
18
|
+
# Returns an encrypted string
|
19
|
+
def encrypt(value)
|
20
|
+
escape_and_execute_sql(["SELECT pgp_sym_encrypt(?, ?)", value, key])['pgp_sym_encrypt']
|
21
|
+
end
|
22
|
+
|
23
|
+
# Public: Decrypts a string
|
24
|
+
#
|
25
|
+
# Returns a plaintext string
|
26
|
+
def decrypt(value)
|
27
|
+
escape_and_execute_sql(["SELECT pgp_sym_decrypt(?, ?)", value, key])['pgp_sym_decrypt']
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Private: Sanitize an sql query and then execute it
|
33
|
+
def escape_and_execute_sql(query)
|
34
|
+
query = ::ActiveRecord::Base.send :sanitize_sql_array, query
|
35
|
+
::ActiveRecord::Base.connection.execute(query).first
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/aes_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module CryptKeeperProviders
|
4
4
|
describe Aes do
|
5
|
-
subject { Aes.new(
|
5
|
+
subject { Aes.new(key: 'cake') }
|
6
6
|
|
7
7
|
describe "#initialize" do
|
8
8
|
let(:hexed_key) do
|
@@ -12,6 +12,10 @@ module CryptKeeperProviders
|
|
12
12
|
it "should extract the key and digest it" do
|
13
13
|
subject.key.should == hexed_key
|
14
14
|
end
|
15
|
+
|
16
|
+
it "should raise an exception with a missing key" do
|
17
|
+
expect { Aes.new }.to raise_error(ArgumentError, "Missing :key")
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
describe "#encrypt" do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CryptKeeperProviders
|
4
|
+
describe PostgresPgpLogSubscriber do
|
5
|
+
use_postgres
|
6
|
+
|
7
|
+
subject { ::ActiveRecord::LogSubscriber.new }
|
8
|
+
|
9
|
+
let(:input_query) do
|
10
|
+
"SELECT pgp_sym_encrypt('encrypt_value', 'encrypt_key'), pgp_sym_decrypt('decrypt_value', 'decrypt_key') FROM DUAL;"
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:output_query) do
|
14
|
+
"SELECT pgp_sym_encrypt([FILTERED]), pgp_sym_decrypt([FILTERED]) FROM DUAL;"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "filters pgp functions" do
|
18
|
+
subject.should_receive(:sql_without_filter).with do |event|
|
19
|
+
event.payload[:sql].should == output_query
|
20
|
+
end
|
21
|
+
|
22
|
+
subject.sql(ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: output_query }))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CryptKeeperProviders
|
4
|
+
describe PostgresPgp do
|
5
|
+
use_postgres
|
6
|
+
|
7
|
+
let(:cipher_text) { '\\xc30d0407030283b15f71b6a7d0296cd23501bd2c8fe3c7a56005ff4619527c4291509a78c77a6758cddd2a14acbde589fa10b3e0686865182d3beadaf237b9f928e7ba1810b8' }
|
8
|
+
let(:plain_text) { 'test' }
|
9
|
+
|
10
|
+
subject { PostgresPgp.new key: 'candy' }
|
11
|
+
|
12
|
+
its(:key) { should == 'candy' }
|
13
|
+
|
14
|
+
describe "#initialize" do
|
15
|
+
it "should raise an exception with a missing key" do
|
16
|
+
expect { PostgresPgp.new }.to raise_error(ArgumentError, "Missing :key")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#encrypt" do
|
21
|
+
it "should encrypt the string" do
|
22
|
+
subject.encrypt(plain_text).should_not == plain_text
|
23
|
+
subject.encrypt(plain_text).should_not be_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#decrypt" do
|
28
|
+
it "should decrypt the string" do
|
29
|
+
subject.decrypt(cipher_text).should == plain_text
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'logger'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module CryptKeeperProviders
|
6
|
+
module ActiveRecord
|
7
|
+
# extend self
|
8
|
+
|
9
|
+
def use_postgres
|
10
|
+
before :all do
|
11
|
+
config = YAML.load_file SPEC_ROOT.join('database.yml')
|
12
|
+
::ActiveRecord::Base.establish_connection(config['test'])
|
13
|
+
::ActiveRecord::Base.logger = Logger.new SPEC_ROOT.join('debug.log').to_s
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.extend CryptKeeperProviders::ActiveRecord
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypt_keeper_providers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-
|
12
|
+
date: 2012-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -75,6 +75,54 @@ dependencies:
|
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: 0.9.2.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: activerecord
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '3.0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: appraisal
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.4.1
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.4.1
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: pg
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.14.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.14.0
|
78
126
|
description: Encryption providers for crypt_keeper
|
79
127
|
email:
|
80
128
|
- jmazzi@gmail.com
|
@@ -85,17 +133,30 @@ files:
|
|
85
133
|
- .gitignore
|
86
134
|
- .rspec
|
87
135
|
- .travis.yml
|
136
|
+
- Appraisals
|
88
137
|
- Gemfile
|
89
138
|
- Guardfile
|
90
139
|
- LICENSE
|
91
140
|
- README.md
|
92
141
|
- Rakefile
|
93
142
|
- crypt_keeper_providers.gemspec
|
143
|
+
- gemfiles/activerecord_3_0.gemfile
|
144
|
+
- gemfiles/activerecord_3_0.gemfile.lock
|
145
|
+
- gemfiles/activerecord_3_1.gemfile
|
146
|
+
- gemfiles/activerecord_3_1.gemfile.lock
|
147
|
+
- gemfiles/activerecord_3_2.gemfile
|
148
|
+
- gemfiles/activerecord_3_2.gemfile.lock
|
94
149
|
- lib/crypt_keeper_providers.rb
|
95
150
|
- lib/crypt_keeper_providers/aes.rb
|
151
|
+
- lib/crypt_keeper_providers/postgres_pgp.rb
|
152
|
+
- lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb
|
96
153
|
- lib/crypt_keeper_providers/version.rb
|
97
154
|
- spec/aes_spec.rb
|
155
|
+
- spec/default.database.yml
|
156
|
+
- spec/postgres_sql_log_subscriber_spec.rb
|
157
|
+
- spec/postgres_sql_spec.rb
|
98
158
|
- spec/spec_helper.rb
|
159
|
+
- spec/support/active_record.rb
|
99
160
|
homepage: ''
|
100
161
|
licenses: []
|
101
162
|
post_install_message:
|
@@ -110,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
171
|
version: '0'
|
111
172
|
segments:
|
112
173
|
- 0
|
113
|
-
hash:
|
174
|
+
hash: 533015026195049068
|
114
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
176
|
none: false
|
116
177
|
requirements:
|
@@ -119,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
180
|
version: '0'
|
120
181
|
segments:
|
121
182
|
- 0
|
122
|
-
hash:
|
183
|
+
hash: 533015026195049068
|
123
184
|
requirements: []
|
124
185
|
rubyforge_project:
|
125
186
|
rubygems_version: 1.8.23
|
@@ -128,4 +189,8 @@ specification_version: 3
|
|
128
189
|
summary: Encryption providers for crypt_keeper
|
129
190
|
test_files:
|
130
191
|
- spec/aes_spec.rb
|
192
|
+
- spec/default.database.yml
|
193
|
+
- spec/postgres_sql_log_subscriber_spec.rb
|
194
|
+
- spec/postgres_sql_spec.rb
|
131
195
|
- spec/spec_helper.rb
|
196
|
+
- spec/support/active_record.rb
|