nimbussecure 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +20 -20
- data/Rakefile +18 -3
- data/bin/nimbussecure +2 -0
- data/bin/nimbussecure_setup +138 -0
- data/lib/nimbussecure/config.rb +1 -1
- data/lib/nimbussecure/crypt_key.rb +1 -0
- data/lib/nimbussecure/version.rb +1 -1
- data/nimbussecure.gemspec +3 -1
- data/{test → spec}/fixtures/vcr_cassettes/accounts/test.yml +0 -0
- data/{test → spec}/fixtures/vcr_cassettes/lookup/key1.yml +0 -0
- data/{test → spec}/fixtures/vcr_cassettes/lookup/key2.yml +0 -0
- data/{test → spec}/fixtures/vcr_cassettes/lookup/key3.yml +0 -0
- data/{test → spec/requests}/accounts_spec.rb +5 -5
- data/{test → spec/requests}/basic_key_lookup_spec.rb +8 -8
- data/spec/spec_helper.rb +17 -0
- metadata +29 -29
- data/test/minitest_helper.rb +0 -10
- data/test/run_tests.rb +0 -6
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -70,34 +70,34 @@ setup service, you can dynamically grab all your sensitive credentials
|
|
70
70
|
and data needed to run your application. This typically happens during
|
71
71
|
your application boot up process.
|
72
72
|
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
# Setup
|
74
|
+
For a complete set of instructions on how to setup and use Nimbus Secure,
|
75
|
+
please go to https://www.nimbussecure.com, login, and click on "Instructions"
|
76
|
+
in the top menu bar.
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
key1: <my_secret_value_for_key1>
|
82
|
-
key2: <my_secret_value_for_key2>
|
78
|
+
# Command Line
|
79
|
+
You must complete the set of instructions under 'Setup' above for this to work
|
80
|
+
properly.
|
83
81
|
|
84
|
-
|
85
|
-
access Nmbus Secure. So, for example, if the URL you use to access Nimbus Secure is this:
|
82
|
+
Once ready, you can do things like this:
|
86
83
|
|
87
|
-
|
84
|
+
nimbussecure account
|
88
85
|
|
89
|
-
|
90
|
-
Nimbus Secure.
|
86
|
+
will return a list of information about your account.
|
91
87
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
Assuming you have a stored key with a name "testmessage" setup, with an approprate encryption key.
|
89
|
+
Then the following can be used to retrieve and decrypt a stored key:
|
90
|
+
|
91
|
+
nimbussecure lookup testmessage
|
92
|
+
|
93
|
+
The decrypted value in the stored key will be sent to stdout.
|
96
94
|
|
97
95
|
# Using in Ruby
|
96
|
+
You must complete the set of instructions under 'Setup' above for this to work
|
97
|
+
properly.
|
98
|
+
|
98
99
|
Assuming you have a stored key with a name "testmessage" setup, with an approprate encryption key.
|
99
|
-
|
100
|
-
and the encryption key value. Then the following can be used to retrieve and decrypt a stored key:
|
100
|
+
Then the following can be used to retrieve and decrypt a stored key:
|
101
101
|
|
102
102
|
require 'nimbussecure'
|
103
103
|
stored_value=nimbussecure.lookup_value "testmessage"
|
data/Rakefile
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc 'Default: run specs.'
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
desc "Run specs"
|
10
|
+
RSpec::Core::RakeTask.new do |t|
|
11
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
12
|
+
# Put spec opts in a file named .rspec in root
|
6
13
|
end
|
14
|
+
|
15
|
+
desc "Generate code coverage"
|
16
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
17
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
18
|
+
t.rcov = true
|
19
|
+
t.rcov_opts = ['--exclude', 'spec']
|
20
|
+
end
|
21
|
+
|
data/bin/nimbussecure
CHANGED
@@ -42,6 +42,8 @@ NOTE:
|
|
42
42
|
This is a set of key/value pairs. The key is the name as defined in your
|
43
43
|
Nimbus Secure \"Encryption Keys\" section, and the value is the secret value
|
44
44
|
you used when you created your encryption key.
|
45
|
+
|
46
|
+
Version: #{NimbusSecure::VERSION}
|
45
47
|
"
|
46
48
|
exit 1
|
47
49
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
3
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
4
|
+
require 'nimbussecure'
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This program will create a new ~/.nimbussecure.yml file (or equivalent in a different filename).
|
8
|
+
#
|
9
|
+
#
|
10
|
+
def usage
|
11
|
+
puts "
|
12
|
+
Usage:
|
13
|
+
nimbussecure_setup <account_id> <apikey> [filename]
|
14
|
+
|
15
|
+
This program will generate a default ~/.nimbussecure.yml file for use by the Nimbus Secure
|
16
|
+
Gem. It will fill in all the basic information needed, and will access Nimbus Secure to get
|
17
|
+
a complete list of your encryption keys, adding a line for each.
|
18
|
+
|
19
|
+
See https://www.nimbussecure.com for more information.
|
20
|
+
|
21
|
+
NOTE:
|
22
|
+
account_id:
|
23
|
+
The account ident can be found based on the URL you use to access Nimbus Secure. If your URL is:
|
24
|
+
|
25
|
+
https://www.nimbussecure.com/my_acct/
|
26
|
+
|
27
|
+
Then the <account_id> value to use should be \"my_acct\"
|
28
|
+
apikey:
|
29
|
+
You can find your API Key by clicking on \"API Keys\" when you are logged into
|
30
|
+
the Nimbus Secure website.
|
31
|
+
filename:
|
32
|
+
Optional filename to store the configuration file to. The default is ~/.nimbussecure.yml.
|
33
|
+
"
|
34
|
+
exit 1
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def main
|
39
|
+
usage unless (ARGV.size==2) or (ARGV.size==3)
|
40
|
+
filename="~/.nimbussecure.yml"
|
41
|
+
filename=ARGV[2] if ARGV.size==3
|
42
|
+
|
43
|
+
expand_file=File.expand_path filename
|
44
|
+
setup_file expand_file,ARGV[0],ARGV[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# Create New File
|
49
|
+
#
|
50
|
+
def setup_file filename,account_id,apikey
|
51
|
+
crypt_key_hash_list={}
|
52
|
+
existing_content=read_old_config_file filename
|
53
|
+
if existing_content
|
54
|
+
if existing_content["account"]!=account_id or existing_content["apikey"]!=apikey
|
55
|
+
puts "ERROR: There is an existing file that refers to a different account or API Key."
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
crypt_key_hash_list=existing_content["crypt_keys"]
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
ns=NimbusSecure.new account: account_id,apikey: apikey
|
63
|
+
crypt_keys=ns.crypt_keys
|
64
|
+
unless ns.success? and crypt_keys
|
65
|
+
puts "Error: #{ns.last_error_message}"
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
ns.crypt_keys.each do |ck|
|
70
|
+
crypt_key_hash_list[ck.ident.to_s]||=nil
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
content=config_file_contents account_id,apikey,crypt_key_hash_list
|
76
|
+
if File.exists?(filename)
|
77
|
+
newfilename=filename+"_old#{Time.now.to_i}"
|
78
|
+
puts "Moved existing file to #{newfilename}"
|
79
|
+
File.rename filename,newfilename
|
80
|
+
end
|
81
|
+
File.open filename, File::CREAT|File::TRUNC|File::RDWR, 0644 do |f|
|
82
|
+
f.write content+"\n"
|
83
|
+
end
|
84
|
+
puts "Created #{filename}"
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
#
|
89
|
+
# Get old content if it exists
|
90
|
+
#
|
91
|
+
def read_old_config_file filename
|
92
|
+
return nil unless File.exist?(filename)
|
93
|
+
content=File.read(filename)
|
94
|
+
unless content
|
95
|
+
puts "The Configuration file is invalid: #{filename}"
|
96
|
+
exit 1
|
97
|
+
end
|
98
|
+
YAML.load(content)
|
99
|
+
end
|
100
|
+
|
101
|
+
#
|
102
|
+
# Create a configuration file from specified parameters
|
103
|
+
#
|
104
|
+
def config_file_contents account_id,apikey,crypt_key_hash_list
|
105
|
+
content=[]
|
106
|
+
content<<"#"
|
107
|
+
content<<"# Nimbus Secure Configuration File"
|
108
|
+
content<<"# https://www.nimbussecure.com"
|
109
|
+
content<<"# This file was auto-generated on: #{Time.now.strftime '%b %e, %Y %H:%M:%S %Z'}"
|
110
|
+
content<<"# Nimbus Secure Client Version Number: #{NimbusSecure::VERSION}"
|
111
|
+
content<<"#"
|
112
|
+
content<<"account: #{account_id}"
|
113
|
+
content<<"apikey: #{apikey}"
|
114
|
+
#
|
115
|
+
# See if we have any secret values setup...
|
116
|
+
#
|
117
|
+
any_values=false
|
118
|
+
crypt_key_hash_list.each do |key,value|
|
119
|
+
any_values=true unless value.nil?
|
120
|
+
end
|
121
|
+
if any_values
|
122
|
+
content<<"#"
|
123
|
+
content<<"# Note: Please fill in any remaining crypt key secret values yourself."
|
124
|
+
content<<"#"
|
125
|
+
else
|
126
|
+
content<<"#"
|
127
|
+
content<<"# Note: The crypt key names are filled in here, but you must add the"
|
128
|
+
content<<"# crypt key secret values yourself."
|
129
|
+
content<<"#"
|
130
|
+
end
|
131
|
+
content<<"crypt_keys:"
|
132
|
+
crypt_key_hash_list.each do |key,value|
|
133
|
+
content<<" #{key}: #{value||"<put secret value here>"}"
|
134
|
+
end
|
135
|
+
content.join("\n")
|
136
|
+
end
|
137
|
+
|
138
|
+
main
|
data/lib/nimbussecure/config.rb
CHANGED
data/lib/nimbussecure/version.rb
CHANGED
data/nimbussecure.gemspec
CHANGED
@@ -18,7 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_development_dependency "minitest"
|
21
|
+
#s.add_development_dependency "minitest"
|
22
|
+
#s.add_development_dependency "minitest-reporters"
|
23
|
+
s.add_development_dependency "rspec"
|
22
24
|
s.add_development_dependency "vcr"
|
23
25
|
s.add_development_dependency "fakeweb"
|
24
26
|
s.add_runtime_dependency "faraday"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe NimbusSecure::Account do
|
3
|
+
describe "NimbusSecure::Account" do
|
4
4
|
before do
|
5
5
|
@ns=NimbusSecure.new({endpoint: "http://localhost:3000",
|
6
6
|
account: "vcrtest",
|
@@ -10,9 +10,9 @@ describe NimbusSecure::Account do
|
|
10
10
|
it "should get a list of all accounts (when there is just one)" do
|
11
11
|
VCR.use_cassette "accounts/test" do
|
12
12
|
acct=@ns.account
|
13
|
-
acct.name.
|
14
|
-
acct.num_crypt_keys.
|
15
|
-
acct.num_stored_keys.
|
13
|
+
acct.name.should eq "VCR Account"
|
14
|
+
acct.num_crypt_keys.should eq 23
|
15
|
+
acct.num_stored_keys.should eq 34
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
describe "Key Lookup" do
|
3
3
|
before do
|
4
4
|
@ns=NimbusSecure.new({endpoint: "http://localhost:3000",
|
@@ -8,22 +8,22 @@ describe "Key Lookup" do
|
|
8
8
|
end
|
9
9
|
it "should be able to lookup a key and decrypt it" do
|
10
10
|
VCR.use_cassette "lookup/key1" do
|
11
|
-
@ns.lookup_value(:test1).
|
11
|
+
@ns.lookup_value(:test1).should eq "This is a test stored key"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
it "should be able to lookup a second key and decrypt it" do
|
15
15
|
VCR.use_cassette "lookup/key2" do
|
16
|
-
code=@ns.lookup_value(:test1).
|
17
|
-
code=@ns.lookup_value(:test2).
|
16
|
+
code=@ns.lookup_value(:test1).should eq "This is a test stored key"
|
17
|
+
code=@ns.lookup_value(:test2).should eq "This is another test stored key"
|
18
18
|
end
|
19
19
|
end
|
20
20
|
it "should be able to fail gracefully if key is not found" do
|
21
21
|
VCR.use_cassette "lookup/key3" do
|
22
22
|
code=@ns.lookup_value :invalidkey
|
23
|
-
code.
|
24
|
-
@ns.success?.
|
25
|
-
@ns.last_error_message.
|
26
|
-
@ns.last_error_details.
|
23
|
+
code.should be_nil
|
24
|
+
@ns.success?.should eq false
|
25
|
+
@ns.last_error_message.should eq "Could not locate Stored Key invalidkey"
|
26
|
+
@ns.last_error_details.should be_nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require 'vcr'
|
4
|
+
require 'nimbussecure'
|
5
|
+
|
6
|
+
root_dir=File.expand_path("../..", __FILE__)
|
7
|
+
Dir["#{root_dir}spec/support/**/*.rb"].each {|f| require f}
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.mock_with :rspec
|
11
|
+
end
|
12
|
+
|
13
|
+
VCR.configure do |c|
|
14
|
+
c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
15
|
+
c.hook_into :fakeweb
|
16
|
+
# c.stub_with :fakeweb
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nimbussecure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: rspec
|
16
|
+
requirement: &70345215642340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70345215642340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: vcr
|
27
|
-
requirement: &
|
27
|
+
requirement: &70345215641920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70345215641920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: fakeweb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70345215641480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70345215641480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday
|
49
|
-
requirement: &
|
49
|
+
requirement: &70345215641000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70345215641000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: gibberish
|
60
|
-
requirement: &
|
60
|
+
requirement: &70345215640540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,12 +65,13 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70345215640540
|
69
69
|
description: Client library for NimbusSecure
|
70
70
|
email:
|
71
71
|
- lee@nimbussecure.com
|
72
72
|
executables:
|
73
73
|
- nimbussecure
|
74
|
+
- nimbussecure_setup
|
74
75
|
extensions: []
|
75
76
|
extra_rdoc_files: []
|
76
77
|
files:
|
@@ -79,6 +80,7 @@ files:
|
|
79
80
|
- README.md
|
80
81
|
- Rakefile
|
81
82
|
- bin/nimbussecure
|
83
|
+
- bin/nimbussecure_setup
|
82
84
|
- lib/nimbussecure.rb
|
83
85
|
- lib/nimbussecure/accounts.rb
|
84
86
|
- lib/nimbussecure/attr_accessor.rb
|
@@ -92,14 +94,13 @@ files:
|
|
92
94
|
- lib/nimbussecure/version.rb
|
93
95
|
- nimbussecure.gemspec
|
94
96
|
- pry_load.rb
|
95
|
-
- test
|
96
|
-
-
|
97
|
-
-
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
- test/run_tests.rb
|
97
|
+
- spec/fixtures/vcr_cassettes/accounts/test.yml
|
98
|
+
- spec/fixtures/vcr_cassettes/lookup/key1.yml
|
99
|
+
- spec/fixtures/vcr_cassettes/lookup/key2.yml
|
100
|
+
- spec/fixtures/vcr_cassettes/lookup/key3.yml
|
101
|
+
- spec/requests/accounts_spec.rb
|
102
|
+
- spec/requests/basic_key_lookup_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
103
104
|
homepage: ''
|
104
105
|
licenses: []
|
105
106
|
post_install_message:
|
@@ -125,11 +126,10 @@ signing_key:
|
|
125
126
|
specification_version: 3
|
126
127
|
summary: Client library for NimbusSecure
|
127
128
|
test_files:
|
128
|
-
- test
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
- test/run_tests.rb
|
129
|
+
- spec/fixtures/vcr_cassettes/accounts/test.yml
|
130
|
+
- spec/fixtures/vcr_cassettes/lookup/key1.yml
|
131
|
+
- spec/fixtures/vcr_cassettes/lookup/key2.yml
|
132
|
+
- spec/fixtures/vcr_cassettes/lookup/key3.yml
|
133
|
+
- spec/requests/accounts_spec.rb
|
134
|
+
- spec/requests/basic_key_lookup_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
data/test/minitest_helper.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
$LOAD_PATH << File.dirname(File.expand_path(__FILE__).to_s).to_s+"/../lib/"
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'vcr'
|
4
|
-
require 'nimbussecure'
|
5
|
-
|
6
|
-
VCR.configure do |c|
|
7
|
-
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
8
|
-
c.hook_into :fakeweb
|
9
|
-
# c.stub_with :fakeweb
|
10
|
-
end
|