stderr-sentry 0.5.4
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/.gemspec +78 -0
- data/.gitignore +3 -0
- data/CHANGELOG +58 -0
- data/MIT-LICENSE +20 -0
- data/README +94 -0
- data/RUNNING_UNIT_TESTS +42 -0
- data/Rakefile +197 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/active_record/sentry.rb +105 -0
- data/lib/sentry.rb +71 -0
- data/lib/sentry/asymmetric_sentry.rb +192 -0
- data/lib/sentry/asymmetric_sentry_callback.rb +17 -0
- data/lib/sentry/sha_sentry.rb +41 -0
- data/lib/sentry/symmetric_sentry.rb +82 -0
- data/lib/sentry/symmetric_sentry_callback.rb +17 -0
- data/sentry.gemspec +82 -0
- data/tasks/sentry.rake +9 -0
- data/test/abstract_unit.rb +44 -0
- data/test/asymmetric_sentry_callback_test.rb +122 -0
- data/test/asymmetric_sentry_test.rb +97 -0
- data/test/database.yml +18 -0
- data/test/fixtures/user.rb +26 -0
- data/test/fixtures/users.yml +9 -0
- data/test/keys/encrypted_private +12 -0
- data/test/keys/encrypted_public +4 -0
- data/test/keys/private +9 -0
- data/test/keys/public +4 -0
- data/test/rsa_key_test.rb +11 -0
- data/test/schema.rb +10 -0
- data/test/sha_sentry_test.rb +35 -0
- data/test/symmetric_sentry_callback_test.rb +38 -0
- data/test/symmetric_sentry_test.rb +37 -0
- data/test/tests.rb +2 -0
- metadata +97 -0
data/test/keys/private
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIIBOwIBAAJBAL/xeY6aqFx6z1ThNOwgPgxv3tsonTlCj8VkN3Ikumg6SzBuLxlV
|
3
|
+
i9gFQZ7K9Pv9o/7+xUTYODqBpVhwgLBeu2cCAwEAAQJAHyjFMfg7Yp/xLndMzxRA
|
4
|
+
3mX+yJckRtpeWo31TktWE3syks1r9OrfmxKiStM9kFRubeBHTihZrW92TYkROLxh
|
5
|
+
uQIhAPuftVTJZFDNxeYDKIMIMqwR8KZgtuf25cv4pTxYwPqLAiEAw0gNwDJHBkvo
|
6
|
+
da4402pZNQmBA6qCSf0svDXqoEoaShUCIGBma340Oe6LJ0pb42Vv+pnZtazIWMq9
|
7
|
+
2IQwmn1oM2bJAiEAhgP869mVRIzzi091UCG79tn+4DU0FPLasI+P5VD1mcECIQDb
|
8
|
+
3ndvbPcElVvdJgabxyWJJsNtBBNZYPsuc6NrQyShOw==
|
9
|
+
-----END RSA PRIVATE KEY-----
|
data/test/keys/public
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class RsaKeyTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@public_key = OpenSSL::PKey::RSA.new(File.open(File.dirname(__FILE__) + '/keys/encrypted_public') { |f| f.read })
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_can_find_max_encoded_length_for_key
|
9
|
+
assert_equal 53, @public_key.max_encryptable_length
|
10
|
+
end
|
11
|
+
end
|
data/test/schema.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 1) do
|
2
|
+
|
3
|
+
create_table "users", :force => true do |t|
|
4
|
+
t.column :password, :string, :limit => 255
|
5
|
+
t.column :creditcard, :string, :limit => 255
|
6
|
+
t.column :login, :string, :limit => 50
|
7
|
+
t.column :type, :string, :limit => 20
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'fixtures/user'
|
3
|
+
|
4
|
+
class ShaSentryTest < Test::Unit::TestCase
|
5
|
+
def test_foo
|
6
|
+
assert true
|
7
|
+
end
|
8
|
+
|
9
|
+
#def setup
|
10
|
+
# Sentry::ShaSentry.salt = 'salt'
|
11
|
+
#end
|
12
|
+
#
|
13
|
+
#def test_should_encrypt
|
14
|
+
# assert_equal 'f438229716cab43569496f3a3630b3727524b81b', Sentry::ShaSentry.encrypt('test')
|
15
|
+
#end
|
16
|
+
#
|
17
|
+
#def test_should_encrypt_with_salt
|
18
|
+
# Sentry::ShaSentry.salt = 'different salt'
|
19
|
+
# assert_equal '18e3256d71529db8fa65b2eef24a69ddad7070f3', Sentry::ShaSentry.encrypt('test')
|
20
|
+
#end
|
21
|
+
#
|
22
|
+
#def test_should_encrypt_user_password
|
23
|
+
# u = ShaUser.new :login => 'bob'
|
24
|
+
# u.password = u.password_confirmation = 'test'
|
25
|
+
# assert u.save
|
26
|
+
# assert u.crypted_password = 'f438229716cab43569496f3a3630b3727524b81b'
|
27
|
+
#end
|
28
|
+
#
|
29
|
+
#def test_should_encrypt_user_password_without_confirmation
|
30
|
+
# u = DangerousUser.new :login => 'bob'
|
31
|
+
# u.password = 'test'
|
32
|
+
# assert u.save
|
33
|
+
# assert u.crypted_password = 'f438229716cab43569496f3a3630b3727524b81b'
|
34
|
+
#end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
require 'fixtures/user'
|
3
|
+
|
4
|
+
class SymmetricSentryCallbackTest < ActiveSupport::TestCase
|
5
|
+
#fixtures :users
|
6
|
+
#
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
@str = 'sentry'
|
10
|
+
Sentry::SymmetricSentry.default_key = @key = 'secret'
|
11
|
+
@encrypted = "0XlmUuNpE2k=\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_foo
|
15
|
+
assert true
|
16
|
+
end
|
17
|
+
#
|
18
|
+
#def test_should_encrypt_user_password
|
19
|
+
# u = SymmetricUser.new :login => 'bob'
|
20
|
+
# u.password = @str
|
21
|
+
# assert u.save
|
22
|
+
# assert_equal @encrypted, u.crypted_password
|
23
|
+
#end
|
24
|
+
#
|
25
|
+
#def test_should_decrypted_user_password
|
26
|
+
# assert_equal @str, users(:user_1).password
|
27
|
+
#end
|
28
|
+
#
|
29
|
+
#def test_should_return_nil_on_invalid_key
|
30
|
+
# Sentry::SymmetricSentry.default_key = 'other secret'
|
31
|
+
# assert_nil users(:user_1).password
|
32
|
+
#end
|
33
|
+
#
|
34
|
+
#def test_should_raise_error_on_invalid_key
|
35
|
+
# Sentry::SymmetricSentry.default_key = 'other secret'
|
36
|
+
# assert_raises(OpenSSL::CipherError) { users(:user_1).password! }
|
37
|
+
#end
|
38
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'abstract_unit'
|
2
|
+
|
3
|
+
class SymmetricSentryTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@str = 'sentry'
|
6
|
+
@key = 'secret'
|
7
|
+
@encrypted = "0XlmUuNpE2k=\n"
|
8
|
+
@sentry = Sentry::SymmetricSentry.new
|
9
|
+
Sentry::SymmetricSentry.default_key = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_should_encrypt
|
13
|
+
assert_equal @encrypted, @sentry.encrypt_to_base64(@str, @key)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_decrypt
|
17
|
+
assert_equal @str, @sentry.decrypt_from_base64(@encrypted, @key)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_should_encrypt_with_default_key
|
21
|
+
Sentry::SymmetricSentry.default_key = @key
|
22
|
+
assert_equal @encrypted, @sentry.encrypt_to_base64(@str)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_should_decrypt_with_default_key
|
26
|
+
Sentry::SymmetricSentry.default_key = @key
|
27
|
+
assert_equal @str, @sentry.decrypt_from_base64(@encrypted)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_raise_error_when_encrypt_with_no_key
|
31
|
+
assert_raises(Sentry::NoKeyError) { @sentry.encrypt_to_base64(@str) }
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_raise_error_when_decrypt_with_no_key
|
35
|
+
assert_raises(Sentry::NoKeyError) { @sentry.decrypt_from_base64(@str) }
|
36
|
+
end
|
37
|
+
end
|
data/test/tests.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stderr-sentry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Fenio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-04-02 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Asymmetric / Symmetric encryption of active record fields
|
17
|
+
email: stderr@truedat.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- .gemspec
|
26
|
+
- .gitignore
|
27
|
+
- CHANGELOG
|
28
|
+
- MIT-LICENSE
|
29
|
+
- README
|
30
|
+
- RUNNING_UNIT_TESTS
|
31
|
+
- Rakefile
|
32
|
+
- VERSION
|
33
|
+
- init.rb
|
34
|
+
- lib/active_record/sentry.rb
|
35
|
+
- lib/sentry.rb
|
36
|
+
- lib/sentry/asymmetric_sentry.rb
|
37
|
+
- lib/sentry/asymmetric_sentry_callback.rb
|
38
|
+
- lib/sentry/sha_sentry.rb
|
39
|
+
- lib/sentry/symmetric_sentry.rb
|
40
|
+
- lib/sentry/symmetric_sentry_callback.rb
|
41
|
+
- sentry.gemspec
|
42
|
+
- tasks/sentry.rake
|
43
|
+
- test/abstract_unit.rb
|
44
|
+
- test/asymmetric_sentry_callback_test.rb
|
45
|
+
- test/asymmetric_sentry_test.rb
|
46
|
+
- test/database.yml
|
47
|
+
- test/fixtures/user.rb
|
48
|
+
- test/fixtures/users.yml
|
49
|
+
- test/keys/encrypted_private
|
50
|
+
- test/keys/encrypted_public
|
51
|
+
- test/keys/private
|
52
|
+
- test/keys/public
|
53
|
+
- test/rsa_key_test.rb
|
54
|
+
- test/schema.rb
|
55
|
+
- test/sha_sentry_test.rb
|
56
|
+
- test/symmetric_sentry_callback_test.rb
|
57
|
+
- test/symmetric_sentry_test.rb
|
58
|
+
- test/tests.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/pivotal/sentry
|
61
|
+
licenses: []
|
62
|
+
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options:
|
65
|
+
- --charset=UTF-8
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.5
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: Asymmetric encryption of active record fields
|
87
|
+
test_files:
|
88
|
+
- test/abstract_unit.rb
|
89
|
+
- test/asymmetric_sentry_callback_test.rb
|
90
|
+
- test/asymmetric_sentry_test.rb
|
91
|
+
- test/fixtures/user.rb
|
92
|
+
- test/rsa_key_test.rb
|
93
|
+
- test/schema.rb
|
94
|
+
- test/sha_sentry_test.rb
|
95
|
+
- test/symmetric_sentry_callback_test.rb
|
96
|
+
- test/symmetric_sentry_test.rb
|
97
|
+
- test/tests.rb
|