knife-bastion 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +5 -0
- data/lib/knife-bastion/activate.rb +6 -1
- data/lib/knife-bastion/base_socks_proxy.rb +10 -0
- data/lib/knife-bastion/berkshelf_socks_proxy.rb +18 -0
- data/lib/knife-bastion/chef_socks_proxy.rb +2 -16
- data/lib/knife-bastion/client_proxy.rb +8 -2
- data/lib/knife-bastion/version.rb +1 -1
- metadata +5 -3
- metadata.gz.sig +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b24716fc37c04b006176389326e4ec86c082c96
|
4
|
+
data.tar.gz: a5846efa9fdc348f6362ce22bcedc8a225509c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd0ba2173642ef7a4d657a3526a5ed68d6106f572868c6e5e882071a4f9ea07b427b07fa54b3e52c0439642e63cbe607746d1587a35861a51e9d576260232ef3
|
7
|
+
data.tar.gz: a497fc9cd48866a20663ff1e097ef04857c5add9936c212e509869c428cd804dcbec61ae71c4c098585c0c79298a469a063edc2311124c6170e705999f0c86bc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# Activate socks proxy for Knife
|
2
2
|
if defined?(Chef::Application::Knife)
|
3
3
|
require_relative 'chef_socks_proxy'
|
4
4
|
end
|
5
|
+
|
6
|
+
# Activate socks proxy for Berkshelf
|
7
|
+
if defined?(Berkshelf)
|
8
|
+
require_relative 'berkshelf_socks_proxy'
|
9
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'client_proxy'
|
2
|
+
|
3
|
+
# Load socksify gem, required to make Chef work with SOCKS proxy
|
4
|
+
begin
|
5
|
+
require 'socksify'
|
6
|
+
rescue LoadError
|
7
|
+
puts HighLine.color("FATAL:", [:bold, :red]) + " Failed to load #{HighLine.color("socksify", [:bold, :magenta])} gem. Please run #{HighLine.color("bundle install", [:bold, :magenta])} to continue"
|
8
|
+
# Hard exit to skip Chef exception reporting
|
9
|
+
exit! 1
|
10
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'base_socks_proxy'
|
2
|
+
|
3
|
+
# Override `ridley_connection` method in `Berkshelf` to enable Socks proxy
|
4
|
+
# for the connection.
|
5
|
+
Berkshelf.module_eval do
|
6
|
+
class << self
|
7
|
+
alias_method :ridley_connection_without_bastion, :ridley_connection
|
8
|
+
|
9
|
+
def ridley_connection(*args, &block)
|
10
|
+
options = {
|
11
|
+
local_port: ::ChefConfig::Config[:knife][:bastion_local_port],
|
12
|
+
server_type: 'Chef',
|
13
|
+
}
|
14
|
+
proxy = ::KnifeBastion::ClientProxy.new(Berkshelf, options)
|
15
|
+
proxy.ridley_connection_without_bastion(*args, &block)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,13 +1,4 @@
|
|
1
|
-
require_relative '
|
2
|
-
|
3
|
-
# Load socksify gem, required to make Chef work with SOCKS proxy
|
4
|
-
begin
|
5
|
-
require 'socksify'
|
6
|
-
rescue LoadError
|
7
|
-
puts HighLine.color("FATAL:", [:bold, :red]) + " Failed to load #{HighLine.color("socksify", [:bold, :magenta])} gem. Please run #{HighLine.color("bundle install", [:bold, :magenta])} to continue"
|
8
|
-
# Hard exit to skip Chef exception reporting
|
9
|
-
exit! 1
|
10
|
-
end
|
1
|
+
require_relative 'base_socks_proxy'
|
11
2
|
|
12
3
|
# Override `http_client` method in `Chef::HTTP` to return proxy object instead
|
13
4
|
# of normal client object.
|
@@ -21,12 +12,7 @@ Chef::HTTP.class_eval do
|
|
21
12
|
client = http_client_without_bastion(*args)
|
22
13
|
options = {
|
23
14
|
local_port: ::Chef::Config[:knife][:bastion_local_port],
|
24
|
-
|
25
|
-
puts ::HighLine.color("WARNING:", [:bold, :red]) + " Failed to contact Chef server!"
|
26
|
-
puts "You might need to start bastion connection with #{::HighLine.color("knife bastion start", [:bold, :magenta])} to access Chef."
|
27
|
-
puts
|
28
|
-
raise
|
29
|
-
}
|
15
|
+
server_type: 'Chef',
|
30
16
|
}
|
31
17
|
KnifeBastion::ClientProxy.new(client, options)
|
32
18
|
end
|
@@ -15,7 +15,8 @@ module KnifeBastion
|
|
15
15
|
::Errno::ECONNREFUSED,
|
16
16
|
::Timeout::Error,
|
17
17
|
::OpenSSL::SSL::SSLError,
|
18
|
-
|
18
|
+
defined?(::Berkshelf::ChefConnectionError) ? ::Berkshelf::ChefConnectionError : nil,
|
19
|
+
].compact.freeze
|
19
20
|
|
20
21
|
# Initializes an instance of the generic client proxy which sends all the
|
21
22
|
# network traffic through the SOCKS proxy.
|
@@ -31,9 +32,14 @@ module KnifeBastion
|
|
31
32
|
@client = client
|
32
33
|
|
33
34
|
@local_port = options[:local_port] || 4443
|
35
|
+
|
36
|
+
server_type = ::HighLine.color("#{options[:server_type]} ", [:bold, :cyan]) if options[:server_type]
|
34
37
|
@network_errors_handler = options[:error_handler] || -> (_) {
|
35
|
-
::Kernel.puts
|
38
|
+
::Kernel.puts
|
39
|
+
::Kernel.puts '-' * 80
|
40
|
+
::Kernel.puts ::HighLine.color("WARNING:", [:bold, :red]) + " Failed to contact #{server_type}server!"
|
36
41
|
::Kernel.puts "You might need to start bastion connection with #{::HighLine.color("knife bastion start", [:bold, :magenta])} to access server."
|
42
|
+
::Kernel.puts '-' * 80
|
37
43
|
::Kernel.puts
|
38
44
|
::Kernel.raise
|
39
45
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-bastion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmytro Shteflyuk
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
DHSQkPQADqf52XlDQ7I6fBAn6E2bH38Wvwpu593AvE02KRKqaK8XEtBBldE4d/It
|
31
31
|
2ysZ/sPJras9LFb2MpjJNRCdXr3z2ed6QwuLnsyEfuk=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
33
|
+
date: 2017-08-02 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: chef
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- lib/chef/knife/bastion_status.rb
|
126
126
|
- lib/chef/knife/bastion_stop.rb
|
127
127
|
- lib/knife-bastion/activate.rb
|
128
|
+
- lib/knife-bastion/base_socks_proxy.rb
|
129
|
+
- lib/knife-bastion/berkshelf_socks_proxy.rb
|
128
130
|
- lib/knife-bastion/chef_socks_proxy.rb
|
129
131
|
- lib/knife-bastion/client_proxy.rb
|
130
132
|
- lib/knife-bastion/version.rb
|
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
150
|
version: '0'
|
149
151
|
requirements: []
|
150
152
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.6.7
|
152
154
|
signing_key:
|
153
155
|
specification_version: 4
|
154
156
|
summary: Access Chef securely via bastion server.
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
}�-T5Z/6 �
|
2
|
+
�V�D�^,�M�J�F�}���D�w�#�����Qns�W�rEgƛ{����,��~_��?�S+�����o��͈7���P�O� �Z�q=u�`}���(��{�ʕ P��E�E��A�|����p�E���7�,��t�[ f��~
|