secret-keeper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -0
- data/spec/secret-keeper_spec.rb +50 -0
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbd2fa36c693a0c02dfdb01eece37e1f0467d78a
|
4
|
+
data.tar.gz: c1ae32d09ed3d1ac0cff3af984c5bd68b62af31f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0ac28f552387514b3e0dbe85983debd485b670172f635d04a82b548a60e9ebed7136d3d41122fc328ddbb7e1dff0562df9a3fcc4216eeedc4ded007be7bcce
|
7
|
+
data.tar.gz: 50bc5aac70bd82875d69d6153a6f18745608c993933dc2d1c4237127ac9d33255be9e4b0eae383160a67b05389fb8d6a91785625bc9d0c1a318ca42b76485d7b
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Secret Keeper
|
2
|
+
|
3
|
+
Keep all your secret files within openssl
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
from console
|
8
|
+
|
9
|
+
gem install secret-keeper
|
10
|
+
|
11
|
+
with bundler, write follwing line in your Gemfile
|
12
|
+
|
13
|
+
gem 'secret-keeper', require: false
|
14
|
+
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
using environment variable OPENSSL_PASS to be your key of cipher
|
18
|
+
|
19
|
+
$> OPENSSL_PASS=[YOUR-CIPHER-KEY-HERE] irb
|
20
|
+
|
21
|
+
require on demand
|
22
|
+
|
23
|
+
irb> require 'secret-keeper'
|
24
|
+
|
25
|
+
encrypt files based on your tasks defined in config/secret-keeper.yml
|
26
|
+
|
27
|
+
irb> SecretKeeper.encrypt_files
|
28
|
+
# Encrypting...
|
29
|
+
# * example/database.yml --> example/database.yml.enc, ok
|
30
|
+
# * example/secrets.yml --> example/secrets.yml.enc, ok
|
31
|
+
# Over!
|
32
|
+
|
33
|
+
decrypt files based on your tasks defined in config/secret-keeper.yml
|
34
|
+
|
35
|
+
irb> SecretKeeper.decrypt_files
|
36
|
+
# Decrypting...
|
37
|
+
# * example/database.yml.enc --> example/database.yml, ok
|
38
|
+
# * example/secrets.yml.enc --> example/secrets.yml, ok
|
39
|
+
# Over!
|
40
|
+
|
41
|
+
## Available Ciphers
|
42
|
+
|
43
|
+
OpenSSL::Cipher.ciphers
|
44
|
+
|
45
|
+
## Config Example
|
46
|
+
|
47
|
+
development: &development
|
48
|
+
cipher: AES-256-CBC
|
49
|
+
tasks:
|
50
|
+
-
|
51
|
+
encrypt_from: example/database.yml
|
52
|
+
encrypt_to: example/database.yml.enc
|
53
|
+
# decrypt_from: example/database.yml.enc
|
54
|
+
# decrypt_to: example/database.yml
|
55
|
+
-
|
56
|
+
encrypt_from: example/secrets_from_other_source.yml
|
57
|
+
encrypt_to: example/secrets.yml.enc
|
58
|
+
# decrypt_from: example/secrets.yml.enc
|
59
|
+
decrypt_to: example/secrets.yml
|
60
|
+
test:
|
61
|
+
<<: *development
|
62
|
+
production:
|
63
|
+
<<: *development
|
@@ -0,0 +1,50 @@
|
|
1
|
+
describe SecretKeeper do
|
2
|
+
before(:each) do
|
3
|
+
ENV['OPENSSL_PASS'] = 'PASSWORD'
|
4
|
+
end
|
5
|
+
|
6
|
+
describe '.encrypt_files' do
|
7
|
+
it 'should return true' do
|
8
|
+
result = SecretKeeper.encrypt_files
|
9
|
+
expect(result).to eq(true)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.decrypt_files' do
|
14
|
+
it 'should return true' do
|
15
|
+
result = SecretKeeper.decrypt_files
|
16
|
+
expect(result).to eq(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should be false, if OPENSSL_PASS incorrect' do
|
20
|
+
ENV['OPENSSL_PASS'] = 'incorrect'
|
21
|
+
result = SecretKeeper.decrypt_files
|
22
|
+
expect(result).to eq(false)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should raise error, if OPENSSL_PASS nil' do
|
26
|
+
ENV['OPENSSL_PASS'] = nil
|
27
|
+
expect{ SecretKeeper.decrypt_files }.to raise_error(RuntimeError)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should raise error, if config file not found' do
|
31
|
+
FileUtils.mv('config/secret-keeper.yml', 'config/secret-keeper-tmp.yml')
|
32
|
+
expect{ SecretKeeper.decrypt_files }.to raise_error(Errno::ENOENT)
|
33
|
+
FileUtils.mv('config/secret-keeper-tmp.yml', 'config/secret-keeper.yml')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should raise error, if config file format incorrect' do
|
37
|
+
FileUtils.mv('config/secret-keeper.yml', 'config/secret-keeper-tmp.yml')
|
38
|
+
FileUtils.cp('config/secret-keeper-incorrect-format.yml', 'config/secret-keeper.yml')
|
39
|
+
expect{ SecretKeeper.decrypt_files }.to raise_error(Psych::SyntaxError)
|
40
|
+
FileUtils.mv('config/secret-keeper-tmp.yml', 'config/secret-keeper.yml')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should raise error, if config file lack enviorment' do
|
44
|
+
FileUtils.mv('config/secret-keeper.yml', 'config/secret-keeper-tmp.yml')
|
45
|
+
FileUtils.cp('config/secret-keeper-lack-env.yml', 'config/secret-keeper.yml')
|
46
|
+
expect{ SecretKeeper.decrypt_files }.to raise_error(RuntimeError)
|
47
|
+
FileUtils.mv('config/secret-keeper-tmp.yml', 'config/secret-keeper.yml')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret-keeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Lee
|
@@ -14,36 +14,40 @@ dependencies:
|
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '3.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '3.0'
|
27
27
|
description: A Secret keeper
|
28
28
|
email: ray-lee@kdanmobile.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
|
-
extra_rdoc_files:
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
32
33
|
files:
|
34
|
+
- README.md
|
33
35
|
- lib/secret-keeper.rb
|
36
|
+
- spec/secret-keeper_spec.rb
|
34
37
|
homepage: https://github.com/redtear1115/secret-keeper
|
35
38
|
licenses:
|
36
39
|
- MIT
|
37
40
|
metadata: {}
|
38
41
|
post_install_message:
|
39
|
-
rdoc_options:
|
42
|
+
rdoc_options:
|
43
|
+
- "--charset=UTF-8"
|
40
44
|
require_paths:
|
41
45
|
- lib
|
42
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
43
47
|
requirements:
|
44
48
|
- - ">="
|
45
49
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
50
|
+
version: 2.3.1
|
47
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
52
|
requirements:
|
49
53
|
- - ">="
|
@@ -55,4 +59,5 @@ rubygems_version: 2.6.14
|
|
55
59
|
signing_key:
|
56
60
|
specification_version: 4
|
57
61
|
summary: Keep all your secret files within openssl
|
58
|
-
test_files:
|
62
|
+
test_files:
|
63
|
+
- spec/secret-keeper_spec.rb
|