chef-vault 2.2.4 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4351149f0cc1799f646d5770543d739833e780ce
4
+ data.tar.gz: eb943ba515a6cd941ce240c8568f75a806f23d14
5
+ SHA512:
6
+ metadata.gz: a566185392ade755d34d44810c64ebab7d8e47db20b2081282004fc3495426d140e72026bd27111e1b0df72ae81b4c984e4e06fa19104ade67ed909fa5951136
7
+ data.tar.gz: aedb76eb1d0447f4fbc0ce5ba88230d19c9e4f47a7d55015acd1681c1e5f230411472d457d5828a75ca6e7cc91c367448384f0d96bdeed913b1d9133bb8b0d11
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - "1.9.3"
3
+ - "1.9.3-p547"
4
+ - "2.0.0-p576"
5
+ - "2.1.3"
6
+ install: bundle install --binstubs
7
+ env: TRAVIS_BUILD=true
@@ -1,6 +1,11 @@
1
1
  ## Planned (Unreleased)
2
2
 
3
3
  ## Released
4
+ ## v2.3.0 / 2014-10-22
5
+ * add --clean switch to knife update (thanks to Matt Brimstone)
6
+ * added aruba CLI testing framework (just for --clean option for now)
7
+ * add Ruby 2.0.x and 2.1.x to Travis platforms
8
+
4
9
  ## v2.2.2 / 2014-06-03
5
10
  * Add knife vault refresh command
6
11
  * Use node_name as a default admin
@@ -132,6 +132,11 @@ Decrypt the entire root item in the passwords vault and open it in json format i
132
132
 
133
133
  knife vault edit passwords root
134
134
 
135
+ ### download
136
+ Decrypt and download an encrypted file to the specified path.
137
+
138
+ knife vault download certs user_pem ~/downloaded_user_pem
139
+
135
140
  ### rotate keys
136
141
  Rotate the shared key for the vault passwords and item root. The shared key is that which is used for the chef encrypted data bag item.
137
142
 
data/README.md CHANGED
@@ -40,12 +40,13 @@ NOTE: chef-vault 1.0 knife commands are not supported! Please use chef-vault 2.
40
40
  knife vault create VAULT ITEM VALUES
41
41
  knife vault edit VAULT ITEM
42
42
  knife vault refresh VAULT ITEM
43
- knife vault update VAULT ITEM VALUES
43
+ knife vault update VAULT ITEM VALUES [--clean]
44
44
  knife vault remove VAULT ITEM VALUES
45
45
  knife vault delete VAULT ITEM
46
46
  knife vault rotate keys VAULT ITEM
47
47
  knife vault rotate all keys
48
48
  knife vault show VAULT ITEM [VALUES]
49
+ knife vault download VAULT ITEM PATH
49
50
 
50
51
  <i>Global Options:</i>
51
52
  <table>
@@ -113,6 +114,14 @@ NOTE: chef-vault 1.0 knife commands are not supported! Please use chef-vault 2.
113
114
  <td>"summary", "json", "yaml", "pp"</td>
114
115
  <td>show</td>
115
116
  </tr>
117
+ <tr>
118
+ <td>nil</td>
119
+ <td>--clean</td>
120
+ <td>Remove all client keys before re-encrypting with saved or specified search</td>
121
+ <td>nil</td>
122
+ <td>nil</td>
123
+ <td>update</td>
124
+ </tr>
116
125
  </table>
117
126
 
118
127
  ## USAGE IN RECIPES
@@ -150,7 +159,7 @@ Author:: Kevin Moser - @moserke<br>
150
159
  Author:: Eli Klein - @eliklein<br>
151
160
  Author:: Joey Geiger - @jgeiger<br>
152
161
  Author:: Joshua Timberman - @jtimberman<br>
153
- Copyright:: Copyright (c) 2013 Nordstrom, Inc.<br>
162
+ Copyright:: Copyright (c) 2013-14 Nordstrom, Inc.<br>
154
163
  License:: Apache License, Version 2.0
155
164
 
156
165
  Licensed under the Apache License, Version 2.0 (the "License");
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task default: :spec
8
+ Cucumber::Rake::Task.new(:features)
9
+
10
+ task default: [:spec, :features]
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.email = ['kevin.moser@nordstrom.com']
26
26
  s.summary = 'Data encryption support for Chef using data bags'
27
27
  s.description = s.summary
28
- s.homepage = 'https://github.com/Nordstrom/chef-vault'
28
+ s.homepage = 'https://github.com/Nordstrom/chef-vault'
29
29
 
30
30
  s.license = 'Apache License, v2.0'
31
31
 
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_development_dependency 'bundler', '~> 1.3'
38
38
  s.add_development_dependency 'rake'
39
39
  s.add_development_dependency 'rspec', '~> 2.14'
40
- # needed for rspec
41
- s.add_development_dependency 'chef', '~> 11.12'
40
+ s.add_development_dependency 'rspec-its', '~> 1.0'
41
+ s.add_development_dependency 'aruba', '~> 0.6'
42
+ s.add_development_dependency 'chef', '>= 0.10.10'
42
43
  end
@@ -0,0 +1,24 @@
1
+ Feature: clean client keys
2
+
3
+ When updating a vault item, chef-vault normally performs the
4
+ saved or specified query and encrypts the item for all nodes
5
+ returned. It does not remove old client keys from the vault
6
+ item keys data bag, which will grow over time. Using the
7
+ --clean switch will cause all client keys to be removed from
8
+ the data bag before encrypting the item for all clients
9
+ returned by the query
10
+
11
+ Scenario: Do not clean client keys on update
12
+ Given a local mode chef repo with nodes 'one,two,three'
13
+ And I create a vault item 'test/item' containing the JSON '{"foo": "bar"}' encrypted for 'one,two'
14
+ Then the vault item 'test/item' should be encrypted for 'one,two'
15
+ And I update the vault item 'test/item' to be encrypted for 'two,three'
16
+ Then the vault item 'test/item' should be encrypted for 'one,two,three'
17
+
18
+ Scenario: Clean client keys on update
19
+ Given a local mode chef repo with nodes 'one,two,three'
20
+ And I create a vault item 'test/item' containing the JSON '{"foo": "bar"}' encrypted for 'one,two'
21
+ Then the vault item 'test/item' should be encrypted for 'one,two'
22
+ And I update the vault item 'test/item' to be encrypted for 'two,three' with the clean option
23
+ Then the vault item 'test/item' should be encrypted for 'two,three'
24
+ And the vault item 'test/item' should not be encrypted for 'one'
@@ -0,0 +1,26 @@
1
+ Given /^a local mode chef repo with nodes '(.+)'$/ do |nodelist|
2
+ # create the repo directory hierarchy
3
+ %w(cookbooks clients nodes data_bags).each do |dir|
4
+ create_dir dir
5
+ end
6
+ # create a basic knife.rb
7
+ write_file 'knife.rb', <<EOF
8
+ local_mode true
9
+ chef_repo_path '.'
10
+ chef_zero.enabled true
11
+ EOF
12
+ # create the admin user and capture its private key
13
+ in_current_dir do
14
+ system 'knife client create admin -z -d -a -c knife.rb > admin.pem'
15
+ end
16
+ # add the admin key to the knife configuration
17
+ append_to_file 'knife.rb', <<EOF
18
+ node_name 'admin'
19
+ client_key 'admin.pem'
20
+ EOF
21
+ # create the requested nodes
22
+ nodelist.split(/,/).each do |node|
23
+ run_simple "knife client create #{node} -z -d -c knife.rb"
24
+ run_simple "knife node create #{node} -z -d -c knife.rb"
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'json'
2
+
3
+ When /^I create a vault item '(.+)\/(.+)' containing the JSON '(.+)' encrypted for '(.+)'$/ do |vault, item, json, nodelist|
4
+ write_file 'item.json', json
5
+ query = nodelist.split(/,/).map{|e| "name:#{e}"}.join(' OR ')
6
+ run_simple "knife vault create #{vault} #{item} -z -c knife.rb -A admin -S '#{query}' -J item.json"
7
+ end
8
+
9
+ When /^I update the vault item '(.+)\/(.+)' to be encrypted for '(.+)'( with the clean option)?$/ do |vault, item, nodelist, cleanopt|
10
+ query = nodelist.split(/,/).map{|e| "name:#{e}"}.join(' OR ')
11
+ run_simple "knife vault update #{vault} #{item} -S '#{query}' #{cleanopt ? '--clean' : ''}"
12
+ end
13
+
14
+ Then /^the vault item '(.+)\/(.+)' should( not)? be encrypted for '(.+)'$/ do |vault, item, neg, nodelist|
15
+ nodes = nodelist.split(/,/)
16
+ run_simple("knife vault show #{vault} #{item} -z -c knife.rb -p clients -F json")
17
+ output = output_from("knife vault show #{vault} #{item} -z -c knife.rb -p clients -F json")
18
+ nodes.each do |node|
19
+ if neg
20
+ assert_no_partial_output(node, output)
21
+ else
22
+ assert_partial_output(node, output)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'aruba/cucumber'
2
+
3
+ # Travis runs tests in a limited environment which takes a long time to invoke
4
+ # the knife command. Up the timeout when we're in a travis build based on the
5
+ # environment variable set in .travis.yml
6
+ if ENV['TRAVIS_BUILD']
7
+ Before do
8
+ @aruba_timeout_seconds = 15
9
+ end
10
+ end
@@ -14,6 +14,6 @@
14
14
  # limitations under the License.
15
15
 
16
16
  class ChefVault
17
- VERSION = "2.2.4"
17
+ VERSION = "2.3.0"
18
18
  MAJOR, MINOR, TINY = VERSION.split('.')
19
19
  end
@@ -0,0 +1,45 @@
1
+ # Description: Chef-Vault VaultDownload class
2
+ # Copyright 2014, Nordstrom, Inc.
3
+
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'chef/knife/vault_base'
17
+
18
+ class Chef
19
+ class Knife
20
+ class VaultDownload < Knife
21
+
22
+ include Chef::Knife::VaultBase
23
+
24
+ banner "knife vault download VAULT ITEM PATH (options)"
25
+
26
+ def run
27
+ vault = @name_args[0]
28
+ item = @name_args[1]
29
+ path = @name_args[2]
30
+
31
+ set_mode(config[:vault_mode])
32
+
33
+ if vault && item && path
34
+ vault_item = ChefVault::Item.load(vault, item)
35
+ File.open(path, "w") do |file|
36
+ file.write(vault_item['file-content'])
37
+ end
38
+ ui.info("Saved #{vault_item['file-name']} as #{path}")
39
+ else
40
+ show_usage
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -44,6 +44,10 @@ class Chef
44
44
  :long => '--file FILE',
45
45
  :description => 'File to be added to vault item as file-content'
46
46
 
47
+ option :clean,
48
+ :long => '--clean',
49
+ :description => 'Clean clients before performing search'
50
+
47
51
  def run
48
52
  vault = @name_args[0]
49
53
  item = @name_args[1]
@@ -51,6 +55,7 @@ class Chef
51
55
  search = config[:search]
52
56
  json_file = config[:json]
53
57
  file = config[:file]
58
+ clean = config[:clean]
54
59
 
55
60
  set_mode(config[:vault_mode])
56
61
 
@@ -67,6 +72,13 @@ class Chef
67
72
  vault_item["file-content"] = File.open(file) { |f| f.read() }
68
73
  end
69
74
 
75
+ if clean
76
+ clients = vault_item.clients().clone().sort()
77
+ clients.each do |client|
78
+ print "Deleting #{client}\n"
79
+ vault_item.keys.delete(client, "clients")
80
+ end
81
+ end
70
82
  vault_item.search(search) if search
71
83
  vault_item.clients(search) if search
72
84
  vault_item.admins(admins) if admins
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe ChefVault::Certificate do
4
+ let(:item) { double(ChefVault::Item) }
5
+ let(:cert) { ChefVault::Certificate.new("foo", "bar") }
6
+
7
+ before do
8
+ allow(ChefVault::Item).to receive(:load).with("foo", "bar"){ item }
9
+ allow(item).to receive(:[]).with("id"){ "bar" }
10
+ allow(item).to receive(:[]).with("contents"){ "baz" }
11
+ end
12
+
13
+ describe '#new' do
14
+ it 'loads item' do
15
+ expect(ChefVault::Item).to receive(:load).with("foo", "bar")
16
+
17
+ ChefVault::Certificate.new("foo", "bar")
18
+ end
19
+ end
20
+
21
+ describe '#[]' do
22
+ specify { cert["id"].should eq "bar" }
23
+ end
24
+
25
+ describe 'decrypt_contents' do
26
+
27
+ it 'echoes warning' do
28
+ STDOUT.should_receive(:puts).with("WARNING: This method is deprecated, please switch to item['value'] calls")
29
+
30
+ cert.decrypt_contents
31
+ end
32
+
33
+ it 'returns items contents' do
34
+ expect(item).to receive(:[]).with("contents")
35
+
36
+ cert.decrypt_contents.should eq "baz"
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe ChefVault::User do
4
+ let(:item) { double(ChefVault::Item) }
5
+ let(:user) { ChefVault::User.new("foo", "bar") }
6
+
7
+ before do
8
+ allow(ChefVault::Item).to receive(:load).with("foo", "bar"){ item }
9
+ allow(item).to receive(:[]).with("id"){ "bar" }
10
+ allow(item).to receive(:[]).with("password"){ "baz" }
11
+ end
12
+
13
+ describe '#new' do
14
+ it 'loads item' do
15
+ expect(ChefVault::Item).to receive(:load).with("foo", "bar")
16
+
17
+ ChefVault::User.new("foo", "bar")
18
+ end
19
+ end
20
+
21
+ describe '#[]' do
22
+ specify { user["id"].should eq "bar" }
23
+ end
24
+
25
+ describe 'decrypt_password' do
26
+
27
+ it 'echoes warning' do
28
+ STDOUT.should_receive(:puts).with("WARNING: This method is deprecated, please switch to item['value'] calls")
29
+
30
+ user.decrypt_password
31
+ end
32
+
33
+ it 'returns items password' do
34
+ expect(item).to receive(:[]).with("password")
35
+
36
+ user.decrypt_password.should eq "baz"
37
+ end
38
+ end
39
+
40
+ end
@@ -1,5 +1,7 @@
1
1
  require_relative '../lib/chef-vault'
2
2
 
3
+ require 'rspec/its'
4
+
3
5
  # This file was generated by the `rspec --init` command. Conventionally, all
4
6
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
7
  # Require this file using `require "spec_helper"` to ensure that it is only
metadata CHANGED
@@ -1,80 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
5
- prerelease:
4
+ version: 2.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kevin Moser
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '2.14'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-its
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
62
83
  - !ruby/object:Gem::Dependency
63
84
  name: chef
64
85
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
86
  requirements:
67
- - - ~>
87
+ - - ">="
68
88
  - !ruby/object:Gem::Version
69
- version: '11.12'
89
+ version: 0.10.10
70
90
  type: :development
71
91
  prerelease: false
72
92
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
93
  requirements:
75
- - - ~>
94
+ - - ">="
76
95
  - !ruby/object:Gem::Version
77
- version: '11.12'
96
+ version: 0.10.10
78
97
  description: Data encryption support for Chef using data bags
79
98
  email:
80
99
  - kevin.moser@nordstrom.com
@@ -83,9 +102,9 @@ executables:
83
102
  extensions: []
84
103
  extra_rdoc_files: []
85
104
  files:
86
- - .gitignore
87
- - .rspec
88
- - .travis.yml
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
89
108
  - CONTRIBUTING.md
90
109
  - Changelog.md
91
110
  - DEMO.md
@@ -96,6 +115,10 @@ files:
96
115
  - Rakefile
97
116
  - bin/chef-vault
98
117
  - chef-vault.gemspec
118
+ - features/clean.feature
119
+ - features/step_definitions/chef-repo.rb
120
+ - features/step_definitions/chef-vault.rb
121
+ - features/support/env.rb
99
122
  - lib/chef-vault.rb
100
123
  - lib/chef-vault/certificate.rb
101
124
  - lib/chef-vault/chef_patch/api_client.rb
@@ -118,6 +141,7 @@ files:
118
141
  - lib/chef/knife/vault_create.rb
119
142
  - lib/chef/knife/vault_decrypt.rb
120
143
  - lib/chef/knife/vault_delete.rb
144
+ - lib/chef/knife/vault_download.rb
121
145
  - lib/chef/knife/vault_edit.rb
122
146
  - lib/chef/knife/vault_refresh.rb
123
147
  - lib/chef/knife/vault_remove.rb
@@ -125,33 +149,35 @@ files:
125
149
  - lib/chef/knife/vault_rotate_keys.rb
126
150
  - lib/chef/knife/vault_show.rb
127
151
  - lib/chef/knife/vault_update.rb
152
+ - spec/chef-vault/certificate_spec.rb
153
+ - spec/chef-vault/item_keys_spec.rb
154
+ - spec/chef-vault/item_spec.rb
155
+ - spec/chef-vault/user_spec.rb
128
156
  - spec/chef-vault_spec.rb
129
- - spec/item_keys_spec.rb
130
- - spec/item_spec.rb
131
157
  - spec/spec_helper.rb
132
158
  homepage: https://github.com/Nordstrom/chef-vault
133
159
  licenses:
134
160
  - Apache License, v2.0
161
+ metadata: {}
135
162
  post_install_message:
136
163
  rdoc_options: []
137
164
  require_paths:
138
165
  - lib
139
166
  required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
167
  requirements:
142
- - - ! '>='
168
+ - - ">="
143
169
  - !ruby/object:Gem::Version
144
170
  version: '0'
145
171
  required_rubygems_version: !ruby/object:Gem::Requirement
146
- none: false
147
172
  requirements:
148
- - - ! '>='
173
+ - - ">="
149
174
  - !ruby/object:Gem::Version
150
175
  version: '0'
151
176
  requirements: []
152
177
  rubyforge_project:
153
- rubygems_version: 1.8.23.2
178
+ rubygems_version: 2.4.1
154
179
  signing_key:
155
- specification_version: 3
180
+ specification_version: 4
156
181
  summary: Data encryption support for Chef using data bags
157
182
  test_files: []
183
+ has_rdoc: true