test-kitchen 3.3.0 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f0f59e09f9a2d65a94c33e6c0e833b7fc86958d88d42ef71f4934196cd809f
4
- data.tar.gz: aa0bcc30665a7628da122d74354f113965dbdc86e0b68faa1b275fd30cdbbeb5
3
+ metadata.gz: cbe0ba6a501464b8f253beca9d017b7d09a90fa5f4407e775d5fe31b81f610da
4
+ data.tar.gz: c7e0c062a903e1be1fd5425f692fecdd28d29841a5bee156b89a0d7149a25b10
5
5
  SHA512:
6
- metadata.gz: 726d1016370af32c8a40f8877a51a9ff5c3bc4e7f57952318bdfdb3cd8356c0fe3b326ea67596299447cdbd9c5cf915f1c3f2ec41ea0b88b4427526ff0c99a32
7
- data.tar.gz: 40d835a7607f6de437bbdb8cd03c720891bc6d8e9417c986f2e9ef5abeded7c7c4957ef0fff727d16152d0e4a967cfe76e9507b02bfff9489498d02d31c6447a
6
+ metadata.gz: abb1d27365dcdbfe5eaccffe717d7391f63a8784a75ee79bb44b8a5ba23d72d17bd7bd01a3d375454111ddcd0425874f0fa7b14dcdd2cf461ccdf978426f99c3
7
+ data.tar.gz: 6bd22f60e9f13a0b74f1c4c4598be74071640f5593f7039f030aa5c95de1a595e5a6401eb092eee2f165715d28202bb0b43324e16b5393a96dc256b993d05109
data/lib/kitchen/ssh.rb CHANGED
@@ -23,6 +23,7 @@ require "socket" unless defined?(Socket)
23
23
 
24
24
  require_relative "errors"
25
25
  require_relative "login_command"
26
+ require_relative "util"
26
27
 
27
28
  module Kitchen
28
29
  # Wrapped exception for any internally raised SSH-related errors.
@@ -75,7 +76,9 @@ module Kitchen
75
76
  # @param cmd [String] command string to execute
76
77
  # @raise [SSHFailed] if the command does not exit with a 0 code
77
78
  def exec(cmd)
78
- logger.debug("[SSH] #{self} (#{cmd})")
79
+ string_to_mask = "[SSH] #{self} (#{cmd})"
80
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
81
+ logger.debug(masked_string)
79
82
  exit_code = exec_with_exit(cmd)
80
83
 
81
84
  if exit_code != 0
@@ -137,7 +140,9 @@ module Kitchen
137
140
  def shutdown
138
141
  return if @session.nil?
139
142
 
140
- logger.debug("[SSH] closing connection to #{self}")
143
+ string_to_mask = "[SSH] closing connection to #{self}"
144
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
145
+ logger.debug(masked_string)
141
146
  session.shutdown!
142
147
  ensure
143
148
  @session = nil
@@ -212,7 +217,9 @@ module Kitchen
212
217
  retries = options[:ssh_retries] || 3
213
218
 
214
219
  begin
215
- logger.debug("[SSH] opening connection to #{self}")
220
+ string_to_mask = "[SSH] opening connection to #{self}"
221
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
222
+ logger.debug(masked_string)
216
223
  Net::SSH.start(hostname, username, options)
217
224
  rescue *rescue_exceptions => e
218
225
  retries -= 1
@@ -16,6 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require_relative "../../kitchen"
19
+ require_relative "../util"
19
20
 
20
21
  require "fileutils" unless defined?(FileUtils)
21
22
  require "net/ssh" unless defined?(Net::SSH)
@@ -102,7 +103,9 @@ module Kitchen
102
103
  # (see Base#cleanup!)
103
104
  def cleanup!
104
105
  if @connection
105
- logger.debug("[SSH] shutting previous connection #{@connection}")
106
+ string_to_mask = "[SSH] shutting previous connection #{@connection}"
107
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
108
+ logger.debug(masked_string)
106
109
  @connection.close
107
110
  @connection = @connection_options = nil
108
111
  end
@@ -125,7 +128,9 @@ module Kitchen
125
128
  def close
126
129
  return if @session.nil?
127
130
 
128
- logger.debug("[SSH] closing connection to #{self}")
131
+ string_to_mask = "[SSH] closing connection to #{self}"
132
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
133
+ logger.debug(masked_string)
129
134
  session.close
130
135
  ensure
131
136
  @session = nil
@@ -135,7 +140,9 @@ module Kitchen
135
140
  def execute(command)
136
141
  return if command.nil?
137
142
 
138
- logger.debug("[SSH] #{self} (#{command})")
143
+ string_to_mask = "[SSH] #{self} (#{command})"
144
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
145
+ logger.debug(masked_string)
139
146
  exit_code = execute_with_exit_code(command)
140
147
 
141
148
  if exit_code != 0
@@ -352,7 +359,9 @@ module Kitchen
352
359
  def retry_connection(opts)
353
360
  log_msg = "[SSH] opening connection to #{self}"
354
361
  log_msg += " via #{ssh_gateway_username}@#{ssh_gateway}:#{ssh_gateway_port}" if ssh_gateway
355
- logger.debug(log_msg)
362
+ masked_string = Util.mask_values(log_msg, %w{password ssh_http_proxy_password})
363
+
364
+ logger.debug(masked_string)
356
365
  yield
357
366
  rescue *RESCUE_EXCEPTIONS_ON_ESTABLISH => e
358
367
  if (opts[:retries] -= 1) > 0
@@ -541,7 +550,7 @@ module Kitchen
541
550
  # Creates a new SSH Connection instance and save it for potential future
542
551
  # reuse.
543
552
  #
544
- # @param options [Hash] conneciton options
553
+ # @param options [Hash] connection options
545
554
  # @return [Ssh::Connection] an SSH Connection instance
546
555
  # @api private
547
556
  def create_new_connection(options, &block)
@@ -555,7 +564,9 @@ module Kitchen
555
564
  # @return [Ssh::Connection] an SSH Connection instance
556
565
  # @api private
557
566
  def reuse_connection
558
- logger.debug("[SSH] reusing existing connection #{@connection}")
567
+ string_to_mask = "[SSH] reusing existing connection #{@connection}"
568
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
569
+ logger.debug(masked_string)
559
570
  yield @connection if block_given?
560
571
  @connection
561
572
  end
@@ -20,6 +20,7 @@
20
20
  require "rbconfig" unless defined?(RbConfig)
21
21
  require "uri" unless defined?(URI)
22
22
  require_relative "../../kitchen"
23
+ require_relative "../util"
23
24
  require "winrm" unless defined?(WinRM::Connection)
24
25
  require "winrm/exceptions" unless defined?(WinRM::WinRMHTTPTransportError)
25
26
 
@@ -104,7 +105,9 @@ module Kitchen
104
105
  def execute(command)
105
106
  return if command.nil?
106
107
 
107
- logger.debug("[WinRM] #{self} (#{command})")
108
+ string_to_mask = "[WinRM] #{self} (#{command})"
109
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
110
+ logger.debug(masked_string)
108
111
 
109
112
  exit_code, stderr = execute_with_exit_code(command)
110
113
 
@@ -494,12 +497,14 @@ module Kitchen
494
497
  # Creates a new WinRM Connection instance and save it for potential
495
498
  # future reuse.
496
499
  #
497
- # @param options [Hash] conneciton options
500
+ # @param options [Hash] connection options
498
501
  # @return [Ssh::Connection] a WinRM Connection instance
499
502
  # @api private
500
503
  def create_new_connection(options, &block)
501
504
  if @connection
502
- logger.debug("[WinRM] shutting previous connection #{@connection}")
505
+ string_to_mask = "[WinRM] shutting previous connection #{@connection}"
506
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
507
+ logger.debug(masked_string)
503
508
  @connection.close
504
509
  end
505
510
 
@@ -559,7 +564,9 @@ module Kitchen
559
564
  # @return [Winrm::Connection] a WinRM Connection instance
560
565
  # @api private
561
566
  def reuse_connection
562
- logger.debug("[WinRM] reusing existing connection #{@connection}")
567
+ string_to_mask = "[WinRM] reusing existing connection #{@connection}"
568
+ masked_string = Util.mask_values(string_to_mask, %w{password ssh_http_proxy_password})
569
+ logger.debug(masked_string)
563
570
  yield @connection if block_given?
564
571
  @connection
565
572
  end
data/lib/kitchen/util.rb CHANGED
@@ -88,6 +88,19 @@ module Kitchen
88
88
  end
89
89
  end
90
90
 
91
+ # Returns a string with masked values for specified parameters.
92
+ #
93
+ # @param string_to_mask [String] the object whose string representation is parsed
94
+ # @param [Array] the list of keys whose values should be masked
95
+ # @return [String] the string representation of passed object with masked values
96
+ def self.mask_values(string_to_mask, keys)
97
+ masked_string = string_to_mask
98
+ keys.each do |key|
99
+ masked_string.gsub!(/:#{key}=>"([^"]*)"/, %{:#{key}=>"******"})
100
+ end
101
+ masked_string
102
+ end
103
+
91
104
  # Returns a formatted string representing a duration in seconds.
92
105
  #
93
106
  # @param total [Integer] the total number of seconds
@@ -16,5 +16,5 @@
16
16
  # limitations under the License.
17
17
 
18
18
  module Kitchen
19
- VERSION = "3.3.0".freeze
19
+ VERSION = "3.3.1".freeze
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -520,7 +520,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
520
520
  - !ruby/object:Gem::Version
521
521
  version: '0'
522
522
  requirements: []
523
- rubygems_version: 3.3.7
523
+ rubygems_version: 3.3.11
524
524
  signing_key:
525
525
  specification_version: 4
526
526
  summary: Test Kitchen is an integration tool for developing and testing infrastructure