chef-vault 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
- *.gem
1
+ *.gem
2
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
@@ -1,23 +1,30 @@
1
1
  ## Unreleased
2
2
 
3
+ ## v1.2.4 / 2013-07-01
4
+ * Move compat include into the lazy-load deps
5
+ * Modify open file commands in knife commands to avoid file locking on windows
3
6
 
4
- ## v1.2.2 / 2012-04-23
7
+ ## v1.2.3 / 2013-04-30
8
+ * Update to use attr_accessor in chef_vault
9
+ * Add rspec tests
10
+
11
+ ## v1.2.2 / 2013-04-23
5
12
  * Update to create data bag folder if it does not already exist
6
13
 
7
- ## v1.2.1 / 2012-04-23
14
+ ## v1.2.1 / 2013-04-23
8
15
  * Clarify Readme
9
16
 
10
- ## v1.0.1 / 2012-04-12
17
+ ## v1.0.1 / 2013-04-12
11
18
  * Compatibility with Chef 10/11 (Shef vs Chef-Shell)
12
19
 
13
- ## v1.0.0 / 2012-04-08
20
+ ## v1.0.0 / 2013-04-08
14
21
  * Rename from Chef-Keepass to Chef-Vault
15
22
 
16
- ## v0.2.1 / 2012-04/05
23
+ ## v0.2.1 / 2013-04/05
17
24
  * Add Certificate class
18
25
 
19
- ## v0.2.0 / 2012-04-05
26
+ ## v0.2.0 / 2013-04-05
20
27
  * Add encrypt cert
21
28
 
22
- ## v0.1.1 / 2012-03-14
29
+ ## v0.1.1 / 2013-03-14
23
30
 
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
1
  source "https://rubygems.org/"
2
2
 
3
3
  gemspec
4
-
5
- group :test do
6
- gem 'rspec'
7
- end
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # Chef-Vault
2
+ [![Gem Version](https://badge.fury.io/rb/chef-vault.png)](http://badge.fury.io/rb/chef-vault)
3
+
4
+ [![Build Status](https://travis-ci.org/Nordstrom/chef-vault.png?branch=master)](https://travis-ci.org/Nordstrom/chef-vault)
2
5
 
3
6
  ## DESCRIPTION:
4
7
 
@@ -28,7 +28,12 @@ Gem::Specification.new do |s|
28
28
  s.license = 'Apache License, v2.0'
29
29
 
30
30
  s.files = `git ls-files`.split("\n")
31
- s.add_dependency "chef", ">= 0.10.10"
31
+ s.add_dependency "chef", ">= 0.10.10"
32
+
33
+ # tests
34
+ s.add_development_dependency 'rake'
35
+ s.add_development_dependency 'rspec'
36
+
32
37
  s.require_paths = ["lib"]
33
38
 
34
39
  s.bindir = "bin"
@@ -14,6 +14,6 @@
14
14
  # limitations under the License.
15
15
 
16
16
  class ChefVault
17
- VERSION = "1.2.3"
17
+ VERSION = "1.2.4"
18
18
  MAJOR, MINOR, TINY = VERSION.split('.')
19
19
  end
@@ -20,15 +20,15 @@ class DecryptCert < Chef::Knife
20
20
  require 'chef/search/query'
21
21
  require 'json'
22
22
  require File.expand_path('../compat', __FILE__)
23
+ include ChefVault::Compat
23
24
  end
24
- include ChefVault::Compat
25
25
 
26
26
  banner "knife decrypt cert --name NAME"
27
27
 
28
28
  option :name,
29
29
  :short => '-N NAME',
30
30
  :long => '--name NAME',
31
- :description => 'Certificate data bag name'
31
+ :description => 'Certificate data bag name'
32
32
 
33
33
  def run
34
34
  unless config[:name]
@@ -20,15 +20,15 @@ class DecryptPassword < Chef::Knife
20
20
  require 'chef/search/query'
21
21
  require 'json'
22
22
  require File.expand_path('../compat', __FILE__)
23
+ include ChefVault::Compat
23
24
  end
24
- include ChefVault::Compat
25
25
 
26
26
  banner "knife decrypt password --username USERNAME"
27
27
 
28
28
  option :username,
29
29
  :short => '-U USERNAME',
30
30
  :long => '--username USERNAME',
31
- :description => 'username of account to encrypt'
31
+ :description => 'username of account to encrypt'
32
32
 
33
33
  def run
34
34
  unless config[:username]
@@ -19,15 +19,15 @@ class EncryptCert < Chef::Knife
19
19
  deps do
20
20
  require 'chef/search/query'
21
21
  require File.expand_path('../compat', __FILE__)
22
+ include ChefVault::Compat
22
23
  end
23
- include ChefVault::Compat
24
24
 
25
25
  banner "knife encrypt cert --search SEARCH --cert CERT --password PASSWORD --name NAME --admins ADMINS"
26
26
 
27
27
  option :search,
28
28
  :short => '-S SEARCH',
29
29
  :long => '--search SEARCH',
30
- :description => 'node search for nodes to encrypt to'
30
+ :description => 'node search for nodes to encrypt to'
31
31
 
32
32
  option :cert,
33
33
  :short => '-C CERT',
@@ -42,12 +42,12 @@ class EncryptCert < Chef::Knife
42
42
  option :password,
43
43
  :short => '-P PASSWORD',
44
44
  :long => '--password PASSWORD',
45
- :description => 'optional pfx password'
45
+ :description => 'optional pfx password'
46
46
 
47
47
  option :name,
48
48
  :short => '-N NAME',
49
49
  :long => '--name NAME',
50
- :description => 'optional data bag name'
50
+ :description => 'optional data bag name'
51
51
 
52
52
  def run
53
53
  unless config[:search]
@@ -79,12 +79,12 @@ class EncryptCert < Chef::Knife
79
79
  file_to_encrypt = config[:cert]
80
80
  contents = open(file_to_encrypt, "rb").read
81
81
  name = config[:name] ? config[:name].gsub(".", "_") : File.basename(file_to_encrypt, ".*").gsub(".", "_")
82
-
82
+
83
83
  current_dbi = Hash.new
84
84
  current_dbi_keys = Hash.new
85
85
  if File.exists?("#{data_bag_path}/#{name}_keys.json") && File.exists?("#{data_bag_path}/#{name}.json")
86
- current_dbi_keys = JSON.parse(open("#{data_bag_path}/#{name}_keys.json").read())
87
- current_dbi = JSON.parse(open("#{data_bag_path}/#{name}.json").read())
86
+ current_dbi_keys = JSON.parse(File.open("#{data_bag_path}/#{name}_keys.json"){ |file| file.read() })
87
+ current_dbi = JSON.parse(File.open("#{data_bag_path}/#{name}_keys.json"){ |file| file.read() })
88
88
 
89
89
  unless equal?(data_bag, name, "contents", contents)
90
90
  puts("FATAL: Content in #{data_bag_path}/#{name}.json does not match content in file supplied!")
@@ -109,7 +109,7 @@ class EncryptCert < Chef::Knife
109
109
  puts("WARNING: Caught exception: #{node_error.message} while processing #{client}, so skipping...")
110
110
  end
111
111
  end
112
-
112
+
113
113
  # Get the public keys for the admin users, skipping users already in the data bag
114
114
  public_keys << admins.split(/[\s,]+/).map do |user|
115
115
  begin
@@ -126,7 +126,7 @@ class EncryptCert < Chef::Knife
126
126
  end
127
127
 
128
128
  if public_keys.length == 0
129
- puts "A node search for #{node_search} returned no results"
129
+ puts "A node search for #{node_search} returned no results"
130
130
  exit 1
131
131
  end
132
132
 
@@ -144,7 +144,7 @@ class EncryptCert < Chef::Knife
144
144
  # Delete existing keys data bag and rewrite the whole bag from memory
145
145
  puts("INFO: Writing #{data_bag_path}/#{name}_keys.json...")
146
146
  File.delete("#{data_bag_path}/#{name}_keys.json") if File.exists?("#{data_bag_path}/#{name}_keys.json")
147
- File.open("#{data_bag_path}/#{name}_keys.json",'w').write(JSON.pretty_generate(enc_db_key_dbi))
147
+ File.open("#{data_bag_path}/#{name}_keys.json",'w'){ |file| file.write(JSON.pretty_generate(enc_db_key_dbi)) }
148
148
 
149
149
  # If the existing certificate bag does not exist, write it out with the correct certificate
150
150
  # Otherwise leave the existing bag alone
@@ -155,7 +155,7 @@ class EncryptCert < Chef::Knife
155
155
  edbi = Chef::EncryptedDataBagItem.encrypt_data_bag_item(dbi, data_bag_shared_key)
156
156
 
157
157
  puts("INFO: Writing #{data_bag_path}/#{name}.json...")
158
- open("#{data_bag_path}/#{name}.json",'w').write(JSON.pretty_generate(edbi))
158
+ File.open("#{data_bag_path}/#{name}.json",'w'){ |file| file.write(JSON.pretty_generate(edbi)) }
159
159
  end
160
160
 
161
161
  puts("INFO: Successfully wrote #{data_bag_path}/#{name}.json & #{data_bag_path}/#{name}_keys.json!")
@@ -165,7 +165,7 @@ class EncryptCert < Chef::Knife
165
165
  data_bag_path = "./data_bags/#{db}"
166
166
 
167
167
  shared_secret = get_shared_secret(db, dbi)
168
- dbi = JSON.parse(open("#{data_bag_path}/#{dbi}.json").read())
168
+ dbi = JSON.parse(File.open("#{data_bag_path}/#{dbi}.json") { |file| file.read() })
169
169
  dbi = Chef::EncryptedDataBagItem.new dbi, shared_secret
170
170
 
171
171
  dbi[key] == value
@@ -175,7 +175,7 @@ class EncryptCert < Chef::Knife
175
175
  data_bag_path = "./data_bags/#{db}"
176
176
 
177
177
  private_key = OpenSSL::PKey::RSA.new(open(Chef::Config[:client_key]).read())
178
- key = File.exists?("#{data_bag_path}/#{dbi}_keys.json") ? JSON.parse(open("#{data_bag_path}/#{dbi}_keys.json").read()) : nil
178
+ key = File.exists?("#{data_bag_path}/#{dbi}_keys.json") ? JSON.parse(File.open("#{data_bag_path}/#{dbi}_keys.json"){ |file| file.read() }) : nil
179
179
 
180
180
  begin
181
181
  private_key.private_decrypt(Base64.decode64(key[Chef::Config[:node_name]]))
@@ -19,20 +19,20 @@ class EncryptPassword < Chef::Knife
19
19
  deps do
20
20
  require 'chef/search/query'
21
21
  require File.expand_path('../compat', __FILE__)
22
+ include ChefVault::Compat
22
23
  end
23
- include ChefVault::Compat
24
24
 
25
25
  banner "knife encrypt password --search SEARCH --username USERNAME --password PASSWORD --admins ADMINS"
26
26
 
27
27
  option :search,
28
28
  :short => '-S SEARCH',
29
29
  :long => '--search SEARCH',
30
- :description => 'node search for nodes to encrypt for'
30
+ :description => 'node search for nodes to encrypt for'
31
31
 
32
32
  option :username,
33
33
  :short => '-U USERNAME',
34
34
  :long => '--username USERNAME',
35
- :description => 'username of account to encrypt'
35
+ :description => 'username of account to encrypt'
36
36
 
37
37
  option :password,
38
38
  :short => '-P PASSWORD',
@@ -61,7 +61,7 @@ class EncryptPassword < Chef::Knife
61
61
  puts("You must supply either -A or --admins")
62
62
  exit 1
63
63
  end
64
-
64
+
65
65
  extend_context_object(self)
66
66
 
67
67
  data_bag = "passwords"
@@ -81,8 +81,8 @@ class EncryptPassword < Chef::Knife
81
81
  current_dbi = Hash.new
82
82
  current_dbi_keys = Hash.new
83
83
  if File.exists?("#{data_bag_path}/#{username}_keys.json") && File.exists?("#{data_bag_path}/#{username}.json")
84
- current_dbi_keys = JSON.parse(open("#{data_bag_path}/#{username}_keys.json").read())
85
- current_dbi = JSON.parse(open("#{data_bag_path}/#{username}.json").read())
84
+ current_dbi_keys = JSON.parse(File.open("#{data_bag_path}/#{username}_keys.json"){ |file| file.read() })
85
+ current_dbi = JSON.parse(File.open("#{data_bag_path}/#{username}.json"){ |file| file.read() })
86
86
 
87
87
  unless equal?(data_bag, username, "password", password)
88
88
  puts("FATAL: Password in #{data_bag_path}/#{username}.json does not match password supplied!")
@@ -107,7 +107,7 @@ class EncryptPassword < Chef::Knife
107
107
  puts("WARNING: Caught exception: #{node_error.message} while processing #{client}, so skipping...")
108
108
  end
109
109
  end
110
-
110
+
111
111
  # Get the public keys for the admin users, skipping users already in the data bag
112
112
  public_keys << admins.split(/[\s,]+/).map do |user|
113
113
  begin
@@ -124,7 +124,7 @@ class EncryptPassword < Chef::Knife
124
124
  end
125
125
 
126
126
  if public_keys.length == 0
127
- puts "A node search for #{node_search} returned no results"
127
+ puts "A node search for #{node_search} returned no results"
128
128
  exit 1
129
129
  end
130
130
 
@@ -142,7 +142,7 @@ class EncryptPassword < Chef::Knife
142
142
  # Delete existing keys data bag and rewrite the whole bag from memory
143
143
  puts("INFO: Writing #{data_bag_path}/#{username}_keys.json...")
144
144
  File.delete("#{data_bag_path}/#{username}_keys.json") if File.exists?("#{data_bag_path}/#{username}_keys.json")
145
- File.open("#{data_bag_path}/#{username}_keys.json",'w').write(JSON.pretty_generate(enc_db_key_dbi))
145
+ File.open("#{data_bag_path}/#{username}_keys.json",'w'){ |file| file.write(JSON.pretty_generate(enc_db_key_dbi)) }
146
146
 
147
147
  # If the existing password bag does not exist, write it out with the correct password
148
148
  # Otherwise leave the existing bag alone
@@ -152,7 +152,7 @@ class EncryptPassword < Chef::Knife
152
152
  edbi = Chef::EncryptedDataBagItem.encrypt_data_bag_item(dbi, data_bag_shared_key)
153
153
 
154
154
  puts("INFO: Writing #{data_bag_path}/#{username}.json...")
155
- open("#{data_bag_path}/#{username}.json",'w').write(JSON.pretty_generate(edbi))
155
+ File.open("#{data_bag_path}/#{username}.json",'w'){ |file| file.write(JSON.pretty_generate(edbi)) }
156
156
  end
157
157
 
158
158
  puts("INFO: Successfully wrote #{data_bag_path}/#{username}.json & #{data_bag_path}/#{username}_keys.json!")
@@ -172,7 +172,7 @@ class EncryptPassword < Chef::Knife
172
172
  data_bag_path = "./data_bags/#{db}"
173
173
 
174
174
  private_key = OpenSSL::PKey::RSA.new(open(Chef::Config[:client_key]).read())
175
- key = File.exists?("#{data_bag_path}/#{dbi}_keys.json") ? JSON.parse(open("#{data_bag_path}/#{dbi}_keys.json").read()) : nil
175
+ key = File.exists?("#{data_bag_path}/#{dbi}_keys.json") ? JSON.parse(File.open("#{data_bag_path}/#{dbi}_keys.json"){ |file| file.read() }) : nil
176
176
 
177
177
  begin
178
178
  private_key.private_decrypt(Base64.decode64(key[Chef::Config[:node_name]]))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
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: 2013-04-30 00:00:00.000000000 Z
12
+ date: 2013-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.10.10
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
30
62
  description: Data encryption support for chef using data bags
31
63
  email:
32
64
  - kevin.moser@nordstrom.com
@@ -37,10 +69,10 @@ extra_rdoc_files: []
37
69
  files:
38
70
  - .gitignore
39
71
  - .rspec
72
+ - .travis.yml
40
73
  - CONTRIBUTING.md
41
74
  - Changelog.md
42
75
  - Gemfile
43
- - Gemfile.lock
44
76
  - LICENSE
45
77
  - README.md
46
78
  - Rakefile
@@ -1,73 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- bunny (0.7.9)
5
- chef (10.16.6)
6
- bunny (>= 0.6.0, < 0.8.0)
7
- erubis
8
- highline (>= 1.6.9)
9
- json (>= 1.4.4, <= 1.6.1)
10
- mixlib-authentication (>= 1.3.0)
11
- mixlib-cli (>= 1.1.0)
12
- mixlib-config (>= 1.1.2)
13
- mixlib-log (>= 1.3.0)
14
- mixlib-shellout
15
- moneta (< 0.7.0)
16
- net-ssh (~> 2.2.2)
17
- net-ssh-multi (~> 1.1.0)
18
- ohai (>= 0.6.0)
19
- rest-client (>= 1.0.4, < 1.7.0)
20
- treetop (~> 1.4.9)
21
- uuidtools
22
- yajl-ruby (~> 1.1)
23
- diff-lcs (1.2.4)
24
- erubis (2.7.0)
25
- highline (1.6.18)
26
- ipaddress (0.8.0)
27
- json (1.6.1)
28
- mime-types (1.23)
29
- mixlib-authentication (1.3.0)
30
- mixlib-log
31
- mixlib-cli (1.3.0)
32
- mixlib-config (1.1.2)
33
- mixlib-log (1.6.0)
34
- mixlib-shellout (1.1.0)
35
- moneta (0.6.0)
36
- net-ssh (2.2.2)
37
- net-ssh-gateway (1.1.0)
38
- net-ssh (>= 1.99.1)
39
- net-ssh-multi (1.1)
40
- net-ssh (>= 2.1.4)
41
- net-ssh-gateway (>= 0.99.0)
42
- ohai (6.16.0)
43
- ipaddress
44
- mixlib-cli
45
- mixlib-config
46
- mixlib-log
47
- mixlib-shellout
48
- systemu
49
- yajl-ruby
50
- polyglot (0.3.3)
51
- rest-client (1.6.7)
52
- mime-types (>= 1.16)
53
- rspec (2.13.0)
54
- rspec-core (~> 2.13.0)
55
- rspec-expectations (~> 2.13.0)
56
- rspec-mocks (~> 2.13.0)
57
- rspec-core (2.13.1)
58
- rspec-expectations (2.13.0)
59
- diff-lcs (>= 1.1.3, < 2.0)
60
- rspec-mocks (2.13.1)
61
- systemu (2.5.2)
62
- treetop (1.4.12)
63
- polyglot
64
- polyglot (>= 0.3.1)
65
- uuidtools (2.1.3)
66
- yajl-ruby (1.1.0)
67
-
68
- PLATFORMS
69
- ruby
70
-
71
- DEPENDENCIES
72
- chef
73
- rspec