chef-vault 4.0.12 → 4.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/bin/chef-vault +2 -2
- data/chef-vault.gemspec +1 -1
- data/lib/chef/knife/mixin/helper.rb +28 -0
- data/lib/chef/knife/vault_admins.rb +1 -1
- data/lib/chef/knife/vault_base.rb +15 -8
- data/lib/chef/knife/vault_delete.rb +3 -1
- data/lib/chef-vault/exceptions.rb +3 -0
- data/lib/chef-vault/item.rb +10 -1
- data/lib/chef-vault/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dbf90bc269d6b9c3f76c53410d110c12f39fb82d7639c7f330fc44fe908b010
|
4
|
+
data.tar.gz: 01bbe6b31cf4afd76eaaac84abe62ec19d09ce56f8f77e85085c2a8fee0a34da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10fd270fdbc62c7389eb81bc28426490df2ba0dee4cec0e40f6ff316e4a5368949dd315ccde9ed80b325f596f8eea59d7e8d506ee56fdf3c4a84b5e31ea1961
|
7
|
+
data.tar.gz: '08aa808060b961b10594f92c48f3bdb7098fe3f9d2a9bc9fc1a35b1053aa4dd6b289c68d53a23eb874099203db873969497dda4c0678c42440261b6b1af57725'
|
data/Gemfile
CHANGED
@@ -9,6 +9,8 @@ group :development do
|
|
9
9
|
gem "rspec", "~> 3.4"
|
10
10
|
gem "aruba", "~> 0.6"
|
11
11
|
gem "chef", "~> 14.0" # avoids test failures on license acceptance
|
12
|
+
gem "contracts", "~> 0.16.1" # pin until we drop ruby < 2.7
|
13
|
+
gem "chef-utils", "= 16.6.14" # pin until we drop ruby 2.5
|
12
14
|
end
|
13
15
|
|
14
16
|
group :docs do
|
data/bin/chef-vault
CHANGED
@@ -79,7 +79,7 @@ options_config.each do |option, config|
|
|
79
79
|
end
|
80
80
|
|
81
81
|
options_config.each do |option, config|
|
82
|
-
options[option] = options[option]
|
82
|
+
options[option] = options[option] || config[:default]
|
83
83
|
end
|
84
84
|
|
85
85
|
require "rubygems" unless defined?(Gem)
|
@@ -88,7 +88,7 @@ require "chef-vault"
|
|
88
88
|
|
89
89
|
ChefVault::Log.init(STDOUT)
|
90
90
|
ChefVault.load_config(options[:chef])
|
91
|
-
item = ChefVault::Item.load(options[:vault], options[:item])
|
91
|
+
item = ChefVault::Item.load(options[:vault], options[:item], options)
|
92
92
|
|
93
93
|
ChefVault::Log.info "#{options[:vault]}/#{options[:item]}"
|
94
94
|
|
data/chef-vault.gemspec
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
$:.push File.expand_path("
|
17
|
+
$:.push File.expand_path("lib", __dir__)
|
18
18
|
require "chef-vault/version"
|
19
19
|
|
20
20
|
Gem::Specification.new do |s|
|
@@ -39,10 +39,38 @@ class ChefVault
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def values_from_json(json)
|
42
|
+
validate_json(json)
|
42
43
|
JSON.parse(json)
|
43
44
|
rescue JSON::ParserError
|
44
45
|
raise JSON::ParserError, "#{json} is not valid JSON!"
|
45
46
|
end
|
47
|
+
|
48
|
+
# I/P: json string
|
49
|
+
# Raises `InvalidValue` if any of the json's values contain non-printable characters.
|
50
|
+
def validate_json(json)
|
51
|
+
begin
|
52
|
+
evaled_json = eval(json) # rubocop: disable Security/Eval
|
53
|
+
rescue SyntaxError
|
54
|
+
raise ChefVault::Exceptions::InvalidValue, "#{json} is not valid JSON!"
|
55
|
+
end
|
56
|
+
|
57
|
+
if evaled_json.is_a?(Hash)
|
58
|
+
evaled_json.each do |key, value|
|
59
|
+
next unless printable?(value.to_s)
|
60
|
+
|
61
|
+
msg = "Value '#{value}' of key '#{key}' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\\\Windows) in double-quoted strings."
|
62
|
+
ChefVault::Log.warn(msg)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# I/P: String
|
68
|
+
# O/P: true/false
|
69
|
+
# returns true if string is free of non-printable characters (escape sequences)
|
70
|
+
# this returns false for whitespace escape sequences as well, e.g. \n\t
|
71
|
+
def printable?(string)
|
72
|
+
/[^[:print:]]|[[:space:]]/.match(string)
|
73
|
+
end
|
46
74
|
end
|
47
75
|
end
|
48
76
|
end
|
@@ -13,6 +13,7 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
+
require "set" unless defined?(::Set)
|
16
17
|
require "chef/knife"
|
17
18
|
require_relative "../../chef-vault"
|
18
19
|
|
@@ -23,7 +24,7 @@ class Chef
|
|
23
24
|
includer.class_eval do
|
24
25
|
deps do
|
25
26
|
require "chef/search/query"
|
26
|
-
require File.expand_path("
|
27
|
+
require File.expand_path("mixin/helper", __dir__)
|
27
28
|
include ChefVault::Mixin::Helper
|
28
29
|
end
|
29
30
|
|
@@ -70,13 +71,19 @@ class Chef
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def split_vault_keys(bag)
|
73
|
-
|
74
|
-
keys =
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
74
|
+
items = []
|
75
|
+
keys = ::Set.new
|
76
|
+
possible_sparses = ::Set.new
|
77
|
+
|
78
|
+
# spread bag keys into 3 categories: items, keys or possible sparse items
|
79
|
+
bag.each_key do |key|
|
80
|
+
next keys << key if key.end_with?("_keys")
|
81
|
+
next possible_sparses << key if key.include?("_key_")
|
82
|
+
|
83
|
+
items << key
|
84
|
+
end
|
85
|
+
# 2nd pass "sparse" items to avoid false positive when items have "_key" in their name
|
86
|
+
possible_sparses.each { |key| items << key if keys.include?("#{key}_keys") }
|
80
87
|
# return item keys and items
|
81
88
|
[keys, items]
|
82
89
|
end
|
@@ -30,13 +30,15 @@ class Chef
|
|
30
30
|
|
31
31
|
if vault && item
|
32
32
|
delete_object(ChefVault::Item, "#{vault}/#{item}", "chef_vault_item") do
|
33
|
+
# rubocop:disable all
|
33
34
|
begin
|
34
35
|
ChefVault::Item.load(vault, item).destroy
|
35
36
|
rescue ChefVault::Exceptions::KeysNotFound,
|
36
|
-
|
37
|
+
ChefVault::Exceptions::ItemNotFound
|
37
38
|
raise ChefVault::Exceptions::ItemNotFound,
|
38
39
|
"#{vault}/#{item} not found."
|
39
40
|
end
|
41
|
+
# rubocop:enable all
|
40
42
|
end
|
41
43
|
else
|
42
44
|
show_usage
|
data/lib/chef-vault/item.rb
CHANGED
@@ -89,12 +89,14 @@ class ChefVault
|
|
89
89
|
handle_client_action(search_or_client, action)
|
90
90
|
else
|
91
91
|
search_or_client.each do |name|
|
92
|
+
# rubocop:disable all
|
92
93
|
begin
|
93
94
|
client = load_actor(name, "clients")
|
94
95
|
handle_client_action(client, action)
|
95
96
|
rescue ChefVault::Exceptions::ClientNotFound
|
96
97
|
ChefVault::Log.warn "node '#{name}' has no 'default' public key; skipping"
|
97
98
|
end
|
99
|
+
# rubocop:enable all
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
@@ -304,10 +306,17 @@ class ChefVault
|
|
304
306
|
raise ChefVault::Exceptions::ItemNotFound,
|
305
307
|
"#{vault}/#{name} could not be found"
|
306
308
|
end
|
307
|
-
|
309
|
+
format_output(opts[:values], item) if opts[:values]
|
308
310
|
item
|
309
311
|
end
|
310
312
|
|
313
|
+
def self.format_output(values, item)
|
314
|
+
values.split(",").each do |value|
|
315
|
+
value.strip!
|
316
|
+
$stdout.puts("#{value}: #{item[value]}")
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
311
320
|
def delete_client(client_name)
|
312
321
|
client_key = load_actor(client_name, "clients")
|
313
322
|
keys.delete(client_key)
|
data/lib/chef-vault/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Data encryption support for Chef Infra using data bags
|
14
14
|
email:
|
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.1.4
|
72
72
|
signing_key:
|
73
73
|
specification_version: 4
|
74
74
|
summary: Data encryption support for Chef Infra using data bags
|