conjur-cli 4.21.1 → 4.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/conjur.gemspec +1 -1
- data/lib/conjur/cli.rb +4 -2
- data/lib/conjur/command/plugin.rb +138 -0
- data/lib/conjur/config.rb +3 -3
- data/lib/conjur/version.rb +1 -1
- data/spec/command/variables_spec.rb +3 -3
- data/spec/config_spec.rb +17 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3327a3212d116f7989090b9a1aed6de2f202b698
|
4
|
+
data.tar.gz: 37954aa133694126b93021e5d57d7d90f8f15927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0855d2122e2af07cf868cb1da21f6e6426c2fa5e7c6f05d9a23528f6d7abcd73458b3d831377153275d0bdd39b65b566f2c8cde8d3a301b938ef20daa989676
|
7
|
+
data.tar.gz: bc1675b9fca3d60bf3ac5dfcb007649a872e370b441a41c4ede7294f5ab5fad1cf92a2adf605c92664d1164b634ba645da0d35c3bc2bebc2919f5d0253bedfbc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 4.22.0
|
2
|
+
|
3
|
+
* New 'plugin' subcommand to manage CLI plugins
|
4
|
+
* Configure SSL certificate from Conjur.configuration
|
5
|
+
* Print the error message if there's a problem loading a plugin
|
6
|
+
|
1
7
|
# 4.21.1
|
2
8
|
|
3
9
|
* Configure trust to the new certificate in `conjur init`, before attempting to contact the Conjur server
|
data/conjur.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
|
19
19
|
gem.add_dependency 'activesupport'
|
20
|
-
gem.add_dependency 'conjur-api', '~> 4.
|
20
|
+
gem.add_dependency 'conjur-api', '~> 4.16'
|
21
21
|
gem.add_dependency 'gli', '>=2.8.0'
|
22
22
|
gem.add_dependency 'highline'
|
23
23
|
gem.add_dependency 'netrc', '~> 0.10.2'
|
data/lib/conjur/cli.rb
CHANGED
@@ -75,8 +75,10 @@ module Conjur
|
|
75
75
|
begin
|
76
76
|
filename = "conjur-asset-#{plugin}"
|
77
77
|
require filename
|
78
|
-
rescue LoadError
|
79
|
-
warn "
|
78
|
+
rescue LoadError => err
|
79
|
+
warn "WARNING: #{err.message}\n" \
|
80
|
+
"Could not load plugin '#{plugin}' specified in your config file.\n"\
|
81
|
+
"Make sure you have the #{filename} gem installed."
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2015 Conjur Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'rubygems/commands/install_command'
|
24
|
+
require 'rubygems/commands/uninstall_command'
|
25
|
+
require 'yaml'
|
26
|
+
|
27
|
+
require 'conjur/command'
|
28
|
+
|
29
|
+
class Conjur::Command::Plugin < Conjur::Command
|
30
|
+
def self.assert_empty(args)
|
31
|
+
exit_now! 'Received extra command arguments' unless args.empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Manage plugins'
|
35
|
+
command :plugin do |cmd|
|
36
|
+
cmd.desc 'List installed plugins'
|
37
|
+
cmd.command :list do |c|
|
38
|
+
c.action do |_, _, args|
|
39
|
+
self.assert_empty(args)
|
40
|
+
Conjur::Config.plugins.each do |p|
|
41
|
+
begin
|
42
|
+
gem = Gem::Specification.find_by_name "conjur-asset-#{p}"
|
43
|
+
puts "#{p} (#{gem.version})"
|
44
|
+
rescue Gem::LoadError
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
cmd.desc 'Install a plugin'
|
52
|
+
cmd.arg_name 'name'
|
53
|
+
cmd.command :install do |c|
|
54
|
+
c.arg_name 'version'
|
55
|
+
c.desc 'Version of the plugin to install'
|
56
|
+
c.flag [:v, :version], :default_value => Gem::Requirement.default
|
57
|
+
|
58
|
+
c.action do |_, options, args|
|
59
|
+
install_plugin(require_arg(args, 'name'), options[:version])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
cmd.desc 'Uninstall a plugin'
|
64
|
+
cmd.arg_name 'name'
|
65
|
+
cmd.command :uninstall do |c|
|
66
|
+
c.action do |_, _, args|
|
67
|
+
name = require_arg(args, 'name')
|
68
|
+
uninstall_plugin(name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
cmd.desc "Show a plugin's details"
|
73
|
+
cmd.arg_name 'name'
|
74
|
+
cmd.command :show do |c|
|
75
|
+
c.action do |_, _, args|
|
76
|
+
name = require_arg(args, 'name')
|
77
|
+
begin
|
78
|
+
gem = Gem::Specification.find_by_name "conjur-asset-#{name}"
|
79
|
+
puts "Name: #{name}"
|
80
|
+
puts "Description: #{gem.summary}"
|
81
|
+
puts "Gem: #{gem.name}"
|
82
|
+
puts "Version: #{gem.version}"
|
83
|
+
rescue Gem::LoadError
|
84
|
+
puts "Plugin '#{name}' is not installed"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def install_plugin(name, version)
|
92
|
+
uninstall_plugin(name) rescue Exception
|
93
|
+
|
94
|
+
gem_name = name.start_with?('conjur-asset-') ? name : "conjur-asset-#{name}"
|
95
|
+
|
96
|
+
cmd = Gem::Commands::InstallCommand.new
|
97
|
+
cmd.handle_options ['--no-ri', '--no-rdoc', gem_name, '--version', "#{version}"]
|
98
|
+
|
99
|
+
begin
|
100
|
+
cmd.execute
|
101
|
+
rescue Gem::SystemExitException => e
|
102
|
+
if e.exit_code != 0
|
103
|
+
raise e
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
modify_plugin_list('add', name)
|
108
|
+
end
|
109
|
+
|
110
|
+
def uninstall_plugin(name)
|
111
|
+
if Conjur::Config.plugins.include?(name)
|
112
|
+
gem_name = name.start_with?('conjur-asset-') ? name : "conjur-asset-#{name}"
|
113
|
+
|
114
|
+
cmd = Gem::Commands::UninstallCommand.new
|
115
|
+
cmd.handle_options ['-x', '-I', '-a', gem_name]
|
116
|
+
cmd.execute
|
117
|
+
|
118
|
+
modify_plugin_list('remove', name)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def modify_plugin_list(op, plugin_name)
|
123
|
+
config_exists = false
|
124
|
+
Conjur::Config.default_config_files.each do |f|
|
125
|
+
if File.file?(f)
|
126
|
+
config_exists = true
|
127
|
+
config = YAML.load(IO.read(f)).stringify_keys rescue {}
|
128
|
+
|
129
|
+
config['plugins'] ||= {}
|
130
|
+
config['plugins'] += [plugin_name] if op == 'add'
|
131
|
+
config['plugins'] -= [plugin_name] if op == 'remove'
|
132
|
+
config['plugins'].uniq!
|
133
|
+
|
134
|
+
File.write(f, YAML.dump(config))
|
135
|
+
end
|
136
|
+
end
|
137
|
+
exit_now! 'No Conjur config file found, run "conjur init"' unless config_exists
|
138
|
+
end
|
data/lib/conjur/config.rb
CHANGED
@@ -97,11 +97,11 @@ module Conjur
|
|
97
97
|
raise $!
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
101
|
-
|
102
|
-
end
|
100
|
+
|
101
|
+
Conjur.config.apply_cert_config!
|
103
102
|
end
|
104
103
|
|
104
|
+
|
105
105
|
def inspect
|
106
106
|
@@attributes.inspect
|
107
107
|
end
|
data/lib/conjur/version.rb
CHANGED
@@ -45,19 +45,19 @@ describe Conjur::Command::Variables, logged_in: true do
|
|
45
45
|
expect { invoke }.to write({ id: 'the-id' }).to(:stdout)
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
describe_command "variable:create -v the-value-1 the-id the-value-2" do
|
50
50
|
it "complains about conflicting values" do
|
51
51
|
expect { invoke }.to raise_error("Received conflicting value arguments")
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
describe_command "variable:create the-id -v the-value" do
|
56
56
|
it "complains about extra arguments" do
|
57
57
|
expect { invoke }.to raise_error("Received extra arguments 'the-value'")
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
describe_command "variable:create" do
|
62
62
|
it "provides default values for optional parameters mime_type and kind" do
|
63
63
|
expect(RestClient::Request).to receive(:execute).with({
|
data/spec/config_spec.rb
CHANGED
@@ -107,10 +107,26 @@ describe Conjur::Config do
|
|
107
107
|
expect(Conjur::Config[:cert_file]).to eq(cert_path)
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
110
111
|
describe "#apply" do
|
111
112
|
before {
|
112
113
|
allow(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file)
|
113
114
|
}
|
115
|
+
|
116
|
+
context "ssl_certificate string" do
|
117
|
+
let(:ssl_certificate){ 'the certificate' }
|
118
|
+
let(:certificate){ double('Certificate') }
|
119
|
+
before{
|
120
|
+
Conjur::Config.class_variable_set('@@attributes', {'ssl_certificate' => ssl_certificate})
|
121
|
+
}
|
122
|
+
|
123
|
+
it 'trusts the certificate string' do
|
124
|
+
expect(OpenSSL::X509::Certificate).to receive(:new).with(ssl_certificate).once.and_return certificate
|
125
|
+
expect(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_cert).with(certificate).once
|
126
|
+
Conjur::Config.apply
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
114
130
|
context "cert_file" do
|
115
131
|
let(:cert_file) { "/path/to/cert.pem" }
|
116
132
|
before {
|
@@ -121,6 +137,7 @@ describe Conjur::Config do
|
|
121
137
|
expect(OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE).to receive(:add_file).with cert_file
|
122
138
|
Conjur::Config.apply
|
123
139
|
end
|
140
|
+
|
124
141
|
it "propagates the cert_file to Configuration.cert_file" do
|
125
142
|
Conjur::Config.apply
|
126
143
|
expect(Conjur.configuration.cert_file).to eq(cert_file)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conjur-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafal Rzepecki
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '4.
|
34
|
+
version: '4.16'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '4.
|
41
|
+
version: '4.16'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: gli
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -313,6 +313,7 @@ files:
|
|
313
313
|
- lib/conjur/command/ids.rb
|
314
314
|
- lib/conjur/command/init.rb
|
315
315
|
- lib/conjur/command/layers.rb
|
316
|
+
- lib/conjur/command/plugin.rb
|
316
317
|
- lib/conjur/command/policy.rb
|
317
318
|
- lib/conjur/command/pubkeys.rb
|
318
319
|
- lib/conjur/command/resources.rb
|