knife-crypt 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -1
- data/CHANGELOG.md +6 -1
- data/features/decrypt.feature +15 -3
- data/features/encrypt.feature +30 -18
- data/features/step_definitions/knife_encryption_steps.rb +11 -0
- data/features/support/env.rb +1 -0
- data/gemfiles/chef_10_10.gemfile +5 -0
- data/gemfiles/chef_10_32.gemfile +5 -0
- data/gemfiles/chef_11.gemfile +5 -0
- data/knife-crypt.gemspec +1 -1
- data/lib/chef/knife/decrypt.rb +11 -1
- data/lib/chef/knife/encrypt.rb +12 -1
- data/lib/knife-crypt/version.rb +1 -1
- metadata +29 -42
- data/.rvmrc +0 -52
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91e0e2e5cc933ecd3ebd7aeb056ac5ff9bd2967c
|
4
|
+
data.tar.gz: 60cd25e0f6b9ffacfcc120a7595115f669ea570e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a4d9585c880207c52f1c3254266b2610ac27d03558f6be8d21a6897eb76a0eb26ca3e4b6e547c3fe431ee134b8475606ea10915a63603d9d1f6a6cd6f935f3b4
|
7
|
+
data.tar.gz: eb6c71e619c361d55a89ab1afef71c5b1e79b1b53c828607c684ae7680da86f9a92072339d20d1665443db8ffa5974bd68a0dcc81c25737f8ab4dbb4300e89a1
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/features/decrypt.feature
CHANGED
@@ -10,9 +10,21 @@ Scenario: Command List
|
|
10
10
|
knife decrypt DATA (options)
|
11
11
|
"""
|
12
12
|
|
13
|
+
Scenario: Usage
|
14
|
+
When I run `knife decrypt`
|
15
|
+
Then the output should contain:
|
16
|
+
"""
|
17
|
+
USAGE: knife decrypt DATA (options)
|
18
|
+
"""
|
19
|
+
And the output should contain:
|
20
|
+
"""
|
21
|
+
FATAL: You must specify data to decrypt
|
22
|
+
"""
|
23
|
+
And the exit status should not be 0
|
24
|
+
|
13
25
|
Scenario: Decrypting a String
|
14
26
|
Given a knife configuration with en encrypted data bag secret "my secret"
|
15
|
-
When I successfully run `knife decrypt e4ibEHAinGltDjYNQPV4rw==`
|
27
|
+
When I successfully run `knife decrypt -c .chef/knife.rb e4ibEHAinGltDjYNQPV4rw==`
|
16
28
|
Then the stdout should contain exactly:
|
17
29
|
"""
|
18
30
|
"foo"
|
@@ -21,7 +33,7 @@ Scenario: Decrypting a String
|
|
21
33
|
|
22
34
|
Scenario: Decrypting an Array
|
23
35
|
Given a knife configuration with en encrypted data bag secret "my secret"
|
24
|
-
When I successfully run `knife decrypt 7wrizj9MAjmSVWWq69DUql0hNHFv7Hp/1tnQ/NJuD08=`
|
36
|
+
When I successfully run `knife decrypt -c .chef/knife.rb 7wrizj9MAjmSVWWq69DUql0hNHFv7Hp/1tnQ/NJuD08=`
|
25
37
|
Then the stdout should contain exactly:
|
26
38
|
"""
|
27
39
|
["foo", "bar"]
|
@@ -30,7 +42,7 @@ Scenario: Decrypting an Array
|
|
30
42
|
|
31
43
|
Scenario: Decrypting a Hash
|
32
44
|
Given a knife configuration with en encrypted data bag secret "my secret"
|
33
|
-
When I successfully run `knife decrypt nsXFeAANrmnBNu+QPfOHZFB5szSRA+Ezu94fmrJnNhk=`
|
45
|
+
When I successfully run `knife decrypt -c .chef/knife.rb nsXFeAANrmnBNu+QPfOHZFB5szSRA+Ezu94fmrJnNhk=`
|
34
46
|
Then the stdout should contain exactly:
|
35
47
|
"""
|
36
48
|
{"foo"=>{"bar"=>"baz"}}
|
data/features/encrypt.feature
CHANGED
@@ -10,29 +10,41 @@ Scenario: Command List
|
|
10
10
|
knife encrypt DATA (options)
|
11
11
|
"""
|
12
12
|
|
13
|
-
Scenario:
|
14
|
-
|
15
|
-
|
16
|
-
Then the stdout should contain exactly:
|
13
|
+
Scenario: Usage
|
14
|
+
When I run `knife encrypt`
|
15
|
+
Then the output should contain:
|
17
16
|
"""
|
18
|
-
|
19
|
-
|
17
|
+
USAGE: knife encrypt DATA (options)
|
20
18
|
"""
|
19
|
+
And the output should contain:
|
20
|
+
"""
|
21
|
+
FATAL: You must specify data to encrypt
|
22
|
+
"""
|
23
|
+
And the exit status should not be 0
|
21
24
|
|
22
|
-
Scenario: Encrypting
|
25
|
+
Scenario: Encrypting a String
|
23
26
|
Given a knife configuration with en encrypted data bag secret "my secret"
|
24
|
-
When I successfully run `knife encrypt '
|
25
|
-
Then the stdout should
|
26
|
-
|
27
|
-
|
27
|
+
When I successfully run `knife encrypt -c .chef/knife.rb '"foo"' '"3EnQL7IItwtknz5p7TVlTQ=="'`
|
28
|
+
Then the stdout should be one of:
|
29
|
+
|chef_version|encrypted_string |
|
30
|
+
|0.10.10 |e4ibEHAinGltDjYNQPV4rw==\n |
|
31
|
+
|10.32.2 |e4ibEHAinGltDjYNQPV4rw==\n |
|
32
|
+
|11.12.4 |9ZgVemCtbgVxJO8gmP7y8oXDUaYAYxQzkI5acgHm4Kw=\n|
|
28
33
|
|
29
|
-
|
34
|
+
Scenario: Encrypting an Array
|
35
|
+
Given a knife configuration with en encrypted data bag secret "my secret"
|
36
|
+
When I successfully run `knife encrypt -c .chef/knife.rb '["foo", "bar"]' '"3EnQL7IItwtknz5p7TVlTQ=="'`
|
37
|
+
Then the stdout should be one of:
|
38
|
+
|chef_version|encrypted_string |
|
39
|
+
|0.10.10 |7wrizj9MAjmSVWWq69DUql0hNHFv7Hp/1tnQ/NJuD08=\n|
|
40
|
+
|10.32.2 |7wrizj9MAjmSVWWq69DUql0hNHFv7Hp/1tnQ/NJuD08=\n|
|
41
|
+
|11.12.4 |9ZgVemCtbgVxJO8gmP7y8uGwkFOaRPd0s74enPmPLhg=\n|
|
30
42
|
|
31
43
|
Scenario: Encrypting a Hash
|
32
44
|
Given a knife configuration with en encrypted data bag secret "my secret"
|
33
|
-
When I successfully run `knife encrypt '{"foo"=>{"bar"=>"baz"}}'`
|
34
|
-
Then the stdout should
|
35
|
-
|
36
|
-
nsXFeAANrmnBNu+QPfOHZFB5szSRA+Ezu94fmrJnNhk
|
37
|
-
|
38
|
-
|
45
|
+
When I successfully run `knife encrypt -c .chef/knife.rb '{"foo"=>{"bar"=>"baz"}}' '"3EnQL7IItwtknz5p7TVlTQ=="'`
|
46
|
+
Then the stdout should be one of:
|
47
|
+
|chef_version|encrypted_string |
|
48
|
+
|0.10.10 |nsXFeAANrmnBNu+QPfOHZFB5szSRA+Ezu94fmrJnNhk=\n|
|
49
|
+
|10.32.2 |nsXFeAANrmnBNu+QPfOHZFB5szSRA+Ezu94fmrJnNhk=\n|
|
50
|
+
|11.12.4 |9ZgVemCtbgVxJO8gmP7y8qJWD5s+Mz808peVZbMfalYVzNylYukjQTf+h791\nOdSv\n|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Then(/^the stdout should be one of:$/) do |table|
|
2
|
+
latest_chef = "11.12.4"
|
3
|
+
# table is a Cucumber::Ast::Table
|
4
|
+
data = table.rows_hash
|
5
|
+
begin
|
6
|
+
puts "unknown Chef version, attempting #{latest_chef} encrypted string"
|
7
|
+
data[Chef::VERSION] = data[latest_chef]
|
8
|
+
end unless data[Chef::VERSION]
|
9
|
+
|
10
|
+
step("the stdout should contain exactly:", data[Chef::VERSION] ? data[Chef::VERSION] : data["11.12.4"])
|
11
|
+
end
|
data/features/support/env.rb
CHANGED
data/knife-crypt.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Knife::Crypt::VERSION
|
17
17
|
|
18
|
-
gem.add_runtime_dependency "chef", ">= 0.10.8", "<
|
18
|
+
gem.add_runtime_dependency "chef", ">= 0.10.8", "< 12.0.0"
|
19
19
|
|
20
20
|
gem.add_development_dependency "aruba", "~> 0.4.11"
|
21
21
|
gem.add_development_dependency "bundler", "~> 1.0"
|
data/lib/chef/knife/decrypt.rb
CHANGED
@@ -6,9 +6,19 @@ class Chef
|
|
6
6
|
banner "knife decrypt DATA (options)"
|
7
7
|
|
8
8
|
def run
|
9
|
+
if @name_args.empty?
|
10
|
+
show_usage
|
11
|
+
ui.fatal "You must specify data to decrypt"
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
9
15
|
encrypted_value = @name_args[0]
|
10
16
|
secret = Chef::EncryptedDataBagItem.load_secret
|
11
|
-
decrypted_value = Chef::EncryptedDataBagItem.decrypt_value
|
17
|
+
decrypted_value = if Chef::EncryptedDataBagItem.methods.include?(:decrypt_value)
|
18
|
+
Chef::EncryptedDataBagItem.decrypt_value encrypted_value, secret
|
19
|
+
else
|
20
|
+
Chef::EncryptedDataBagItem::Decryptor.for(encrypted_value, secret).for_decrypted_item
|
21
|
+
end
|
12
22
|
puts decrypted_value.inspect
|
13
23
|
end
|
14
24
|
end
|
data/lib/chef/knife/encrypt.rb
CHANGED
@@ -6,9 +6,20 @@ class Chef
|
|
6
6
|
banner "knife encrypt DATA (options)"
|
7
7
|
|
8
8
|
def run
|
9
|
+
if @name_args.empty?
|
10
|
+
show_usage
|
11
|
+
ui.fatal "You must specify data to encrypt"
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
9
15
|
decrypted_value = eval @name_args[0]
|
16
|
+
initialization_vector = @name_args[1]
|
10
17
|
secret = Chef::EncryptedDataBagItem.load_secret
|
11
|
-
encrypted_value = Chef::EncryptedDataBagItem.encrypt_value
|
18
|
+
encrypted_value = if Chef::EncryptedDataBagItem.methods.include? :encrypt_value
|
19
|
+
Chef::EncryptedDataBagItem.encrypt_value(decrypted_value, secret)
|
20
|
+
else
|
21
|
+
Chef::EncryptedDataBagItem::Encryptor.new(decrypted_value, secret, initialization_vector).for_encrypted_item["encrypted_data"]
|
22
|
+
end
|
12
23
|
puts encrypted_value
|
13
24
|
end
|
14
25
|
end
|
data/lib/knife-crypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,100 +1,89 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-crypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Griego
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-05-15 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: chef
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.10.8
|
22
|
-
- - <
|
20
|
+
- - "<"
|
23
21
|
- !ruby/object:Gem::Version
|
24
|
-
version:
|
22
|
+
version: 12.0.0
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 0.10.8
|
33
|
-
- - <
|
30
|
+
- - "<"
|
34
31
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
32
|
+
version: 12.0.0
|
36
33
|
- !ruby/object:Gem::Dependency
|
37
34
|
name: aruba
|
38
35
|
requirement: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
36
|
requirements:
|
41
|
-
- - ~>
|
37
|
+
- - "~>"
|
42
38
|
- !ruby/object:Gem::Version
|
43
39
|
version: 0.4.11
|
44
40
|
type: :development
|
45
41
|
prerelease: false
|
46
42
|
version_requirements: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
43
|
requirements:
|
49
|
-
- - ~>
|
44
|
+
- - "~>"
|
50
45
|
- !ruby/object:Gem::Version
|
51
46
|
version: 0.4.11
|
52
47
|
- !ruby/object:Gem::Dependency
|
53
48
|
name: bundler
|
54
49
|
requirement: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
50
|
requirements:
|
57
|
-
- - ~>
|
51
|
+
- - "~>"
|
58
52
|
- !ruby/object:Gem::Version
|
59
53
|
version: '1.0'
|
60
54
|
type: :development
|
61
55
|
prerelease: false
|
62
56
|
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
57
|
requirements:
|
65
|
-
- - ~>
|
58
|
+
- - "~>"
|
66
59
|
- !ruby/object:Gem::Version
|
67
60
|
version: '1.0'
|
68
61
|
- !ruby/object:Gem::Dependency
|
69
62
|
name: cucumber
|
70
63
|
requirement: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
64
|
requirements:
|
73
|
-
- - ~>
|
65
|
+
- - "~>"
|
74
66
|
- !ruby/object:Gem::Version
|
75
67
|
version: 1.2.0
|
76
68
|
type: :development
|
77
69
|
prerelease: false
|
78
70
|
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
71
|
requirements:
|
81
|
-
- - ~>
|
72
|
+
- - "~>"
|
82
73
|
- !ruby/object:Gem::Version
|
83
74
|
version: 1.2.0
|
84
75
|
- !ruby/object:Gem::Dependency
|
85
76
|
name: rake
|
86
77
|
requirement: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
78
|
requirements:
|
89
|
-
- - ~>
|
79
|
+
- - "~>"
|
90
80
|
- !ruby/object:Gem::Version
|
91
81
|
version: 0.9.0
|
92
82
|
type: :development
|
93
83
|
prerelease: false
|
94
84
|
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
85
|
requirements:
|
97
|
-
- - ~>
|
86
|
+
- - "~>"
|
98
87
|
- !ruby/object:Gem::Version
|
99
88
|
version: 0.9.0
|
100
89
|
description: Commands for Chef's Knife Command to Encrypt and Decrypt Data
|
@@ -104,9 +93,9 @@ executables: []
|
|
104
93
|
extensions: []
|
105
94
|
extra_rdoc_files: []
|
106
95
|
files:
|
107
|
-
- .gitignore
|
108
|
-
- .
|
109
|
-
- .travis.yml
|
96
|
+
- ".gitignore"
|
97
|
+
- ".ruby-version"
|
98
|
+
- ".travis.yml"
|
110
99
|
- CHANGELOG.md
|
111
100
|
- Gemfile
|
112
101
|
- Guardfile
|
@@ -117,43 +106,41 @@ files:
|
|
117
106
|
- features/decrypt.feature
|
118
107
|
- features/encrypt.feature
|
119
108
|
- features/step_definitions/knife_config_steps.rb
|
109
|
+
- features/step_definitions/knife_encryption_steps.rb
|
120
110
|
- features/support/env.rb
|
111
|
+
- gemfiles/chef_10_10.gemfile
|
112
|
+
- gemfiles/chef_10_32.gemfile
|
113
|
+
- gemfiles/chef_11.gemfile
|
121
114
|
- knife-crypt.gemspec
|
122
115
|
- lib/chef/knife/decrypt.rb
|
123
116
|
- lib/chef/knife/encrypt.rb
|
124
117
|
- lib/knife-crypt/version.rb
|
125
118
|
homepage: https://github.com/cgriego/knife-crypt
|
126
119
|
licenses: []
|
120
|
+
metadata: {}
|
127
121
|
post_install_message:
|
128
122
|
rdoc_options: []
|
129
123
|
require_paths:
|
130
124
|
- lib
|
131
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
126
|
requirements:
|
134
|
-
- -
|
127
|
+
- - ">="
|
135
128
|
- !ruby/object:Gem::Version
|
136
129
|
version: '0'
|
137
|
-
segments:
|
138
|
-
- 0
|
139
|
-
hash: -1267211087425992544
|
140
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
-
none: false
|
142
131
|
requirements:
|
143
|
-
- -
|
132
|
+
- - ">="
|
144
133
|
- !ruby/object:Gem::Version
|
145
134
|
version: '0'
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
hash: -1267211087425992544
|
149
135
|
requirements: []
|
150
136
|
rubyforge_project:
|
151
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.2.2
|
152
138
|
signing_key:
|
153
|
-
specification_version:
|
139
|
+
specification_version: 4
|
154
140
|
summary: Commands for Chef's Knife Command to Encrypt and Decrypt Data
|
155
141
|
test_files:
|
156
142
|
- features/decrypt.feature
|
157
143
|
- features/encrypt.feature
|
158
144
|
- features/step_definitions/knife_config_steps.rb
|
145
|
+
- features/step_definitions/knife_encryption_steps.rb
|
159
146
|
- features/support/env.rb
|
data/.rvmrc
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3@knife-crypt"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.12.2 (stable)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
if [[ $- == *i* ]] # check for interactive shells
|
29
|
-
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
30
|
-
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
|
31
|
-
fi
|
32
|
-
else
|
33
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
34
|
-
rvm --create use "$environment_id" || {
|
35
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
36
|
-
return 1
|
37
|
-
}
|
38
|
-
fi
|
39
|
-
|
40
|
-
# If you use bundler, this might be useful to you:
|
41
|
-
# if [[ -s Gemfile ]] && {
|
42
|
-
# ! builtin command -v bundle >/dev/null ||
|
43
|
-
# builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
|
44
|
-
# }
|
45
|
-
# then
|
46
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
47
|
-
# gem install bundler
|
48
|
-
# fi
|
49
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
50
|
-
# then
|
51
|
-
# bundle install | grep -vE '^Using|Your bundle is complete'
|
52
|
-
# fi
|