train-core 3.2.37 → 3.3.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/train.rb +1 -2
  3. data/lib/train/errors.rb +0 -1
  4. data/lib/train/extras.rb +0 -1
  5. data/lib/train/extras/command_wrapper.rb +0 -1
  6. data/lib/train/extras/stat.rb +0 -1
  7. data/lib/train/file.rb +0 -1
  8. data/lib/train/file/local.rb +0 -2
  9. data/lib/train/file/local/unix.rb +1 -3
  10. data/lib/train/file/local/windows.rb +0 -2
  11. data/lib/train/file/remote.rb +0 -2
  12. data/lib/train/file/remote/aix.rb +0 -2
  13. data/lib/train/file/remote/linux.rb +0 -2
  14. data/lib/train/file/remote/qnx.rb +0 -1
  15. data/lib/train/file/remote/unix.rb +1 -1
  16. data/lib/train/file/remote/windows.rb +0 -2
  17. data/lib/train/options.rb +0 -1
  18. data/lib/train/platforms.rb +0 -2
  19. data/lib/train/platforms/common.rb +0 -2
  20. data/lib/train/platforms/detect.rb +0 -2
  21. data/lib/train/platforms/detect/helpers/os_common.rb +17 -9
  22. data/lib/train/platforms/detect/helpers/os_linux.rb +0 -2
  23. data/lib/train/platforms/detect/scanner.rb +0 -2
  24. data/lib/train/platforms/detect/specifications/api.rb +0 -2
  25. data/lib/train/platforms/detect/specifications/os.rb +3 -2
  26. data/lib/train/platforms/detect/uuid.rb +2 -2
  27. data/lib/train/platforms/family.rb +0 -2
  28. data/lib/train/platforms/platform.rb +1 -3
  29. data/lib/train/plugin_test_helper.rb +5 -5
  30. data/lib/train/plugins.rb +1 -2
  31. data/lib/train/plugins/base_connection.rb +1 -3
  32. data/lib/train/plugins/transport.rb +0 -1
  33. data/lib/train/transports/cisco_ios_connection.rb +3 -2
  34. data/lib/train/transports/local.rb +5 -6
  35. data/lib/train/transports/ssh.rb +14 -4
  36. data/lib/train/transports/ssh_connection.rb +2 -3
  37. data/lib/train/version.rb +1 -2
  38. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c0010a7ddc9d245cfa156fee62ec62a666e781517cb8fefa255ad91782a72f
4
- data.tar.gz: 90ebeee368d746e51c7c1d1b1d415aed70560e0175690ca47fc14fcde853b71a
3
+ metadata.gz: 731da693988617c1fba632079b251048ff772e266341a405f9d7fa668081c460
4
+ data.tar.gz: e2f44528bdaeab154923632381ea82ab7393b58800c92ed2ce34665b5c87922e
5
5
  SHA512:
6
- metadata.gz: 555cc40edf25a6a6a745e64f65f5bc95419e0a7d267932044f6cec8c3911675e6035f202b913b688bb381d60912a1838523df4cfe781699d3913a486d5f32b1e
7
- data.tar.gz: 848799176b28a076141ee65a011ae8fa1fcdafbaa713074ac66c40055e77d2f0cb4a57ffe900c0a066cbda2271e322af61323cc3c5a3f74bb63e8919cc44cd01
6
+ metadata.gz: 4faaad47791222859169e2e7eaca6e641b1b0645b206966200ab303da77565a54fc052640583317f6505f74816fe141284d0f06eff45c5d7c638e6580aa6d26f
7
+ data.tar.gz: 87fe382ff4951bad855289e72e4687d69a71c70733d7240edbde19d773e6b5caee446a17b3aef2c621f33e403badb8ee68aaaa8583fca17f0c08f86fdaea0d7e
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
 
@@ -7,7 +6,7 @@ require_relative "train/options"
7
6
  require_relative "train/plugins"
8
7
  require_relative "train/errors"
9
8
  require_relative "train/platforms"
10
- require "addressable/uri"
9
+ require "addressable/uri" unless defined?(Addressable::URI)
11
10
 
12
11
  module Train
13
12
  # Create a new transport instance, with the plugin indicated by the
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # author: Dominik Richter
3
2
  # author: Christoph Hartmann
4
3
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # author: Dominik Richter
3
2
  # author: Christoph Hartmann
4
3
  module Train::Extras
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # author: Christoph Hartmann
4
3
  # author: Dominik Richter
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train
4
2
  class File
5
3
  class Local < Train::File
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require "shellwords"
1
+ require "shellwords" unless defined?(Shellwords)
4
2
  require_relative "../../extras/stat"
5
3
 
6
4
  module Train
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train
4
2
  class File
5
3
  class Local
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train
4
2
  class File
5
3
  class Remote < Train::File
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "unix"
4
2
 
5
3
  module Train
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "unix"
4
2
 
5
3
  module Train
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # author: Christoph Hartmann
4
3
  # author: Dominik Richter
@@ -1,4 +1,4 @@
1
- require "shellwords"
1
+ require "shellwords" unless defined?(Shellwords)
2
2
 
3
3
  module Train
4
4
  class File
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train
4
2
  class File
5
3
  class Remote
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
  # Author:: Christoph Hartmann (<chris@lollyrock.com>)
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "platforms/common"
4
2
  require_relative "platforms/detect"
5
3
  require_relative "platforms/detect/scanner"
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms
4
2
  module Common
5
3
  # Add a family connection. This will create a family
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms
4
2
  module Detect
5
3
  # Main detect method to scan all platforms for a match
@@ -1,6 +1,6 @@
1
1
  require_relative "os_linux"
2
2
  require_relative "os_windows"
3
- require "rbconfig"
3
+ require "rbconfig" unless defined?(RbConfig)
4
4
 
5
5
  module Train::Platforms::Detect::Helpers
6
6
  module OSCommon
@@ -34,16 +34,24 @@ module Train::Platforms::Detect::Helpers
34
34
  end
35
35
 
36
36
  def command_output(cmd)
37
- res = @backend.run_command(cmd).stdout
38
- # When you try to execute command using ssh connction as root user and you have provided ssh user identity file
39
- # it gives standard output to login as authorised user other than root. To show this standard ouput as an error
37
+ res = @backend.run_command(cmd)
38
+ stdout = res.stdout
39
+ stderr = res.stderr
40
+ # When you try to execute command using ssh connection as root user and you have provided ssh user identity file
41
+ # it gives standard output to login as authorized user other than root. To show this standard output as an error
40
42
  # to user we are matching the string of stdout and raising the error here so that user gets exact information.
41
- if @backend.class.to_s == "Train::Transports::SSH::Connection" && res =~ /Please login as the user/
42
- raise Train::UserError, "SSH failed: #{res}"
43
+ if @backend.class.to_s == "Train::Transports::SSH::Connection"
44
+ if stdout =~ /Please login as the user/
45
+ raise Train::UserError, "SSH failed: #{stdout}"
46
+ end
47
+
48
+ if stderr =~ /WARNING: Your password has expired/
49
+ raise Train::UserError, "SSH failed: #{stderr}"
50
+ end
43
51
  end
44
52
 
45
- res.strip! unless res.nil?
46
- res
53
+ stdout.strip! unless stdout.nil?
54
+ stdout
47
55
  end
48
56
 
49
57
  def unix_uname_s
@@ -157,7 +165,7 @@ module Train::Platforms::Detect::Helpers
157
165
  def json_cmd(cmd)
158
166
  cmd = @backend.run_command(cmd)
159
167
  if cmd.exit_status == 0 && !cmd.stdout.empty?
160
- require "json"
168
+ require "json" unless defined?(JSON)
161
169
  eos_ver = JSON.parse(cmd.stdout)
162
170
  @platform[:release] = eos_ver["version"]
163
171
  @platform[:arch] = eos_ver["architecture"]
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms::Detect::Helpers
4
2
  module Linux
5
3
  def redhatish_platform(conf)
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "helpers/os_common"
4
2
 
5
3
  module Train::Platforms::Detect
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms::Detect::Specifications
4
2
  class Api
5
3
  def self.load
@@ -128,7 +128,7 @@ module Train::Platforms::Detect::Specifications
128
128
 
129
129
  declare_lsb("scientific", "Scientific Linux", "redhat", /scientific/i)
130
130
 
131
- declare_lsb("xenserver", "Xenserer Linux", "redhat", /xenserver/i)
131
+ declare_lsb("xenserver", "Xenserver Linux", "redhat", /xenserver/i)
132
132
 
133
133
  declare_instance("parallels-release", "Parallels Linux", "redhat") do
134
134
  if (raw = unix_file_contents("/etc/parallels-release"))
@@ -357,7 +357,7 @@ module Train::Platforms::Detect::Specifications
357
357
  declare_instance("mac_os_x", "macOS X", "darwin") do
358
358
  cmd = unix_file_contents("/System/Library/CoreServices/SystemVersion.plist")
359
359
  @platform[:uuid_command] = "system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'"
360
- cmd =~ /Mac OS X/i
360
+ cmd =~ /Mac OS X|macOS/i
361
361
  end
362
362
 
363
363
  declare_instance("darwin", "Darwin", "darwin") do
@@ -369,6 +369,7 @@ module Train::Platforms::Detect::Specifications
369
369
  declare_bsd("freebsd", "Freebsd", "bsd", /freebsd/i)
370
370
  declare_bsd("openbsd", "Openbsd", "bsd", /openbsd/i)
371
371
  declare_bsd("netbsd", "Netbsd", "bsd", /netbsd/i)
372
+ declare_bsd("dragonflybsd", "Dragonflybsd", "bsd", /dragonfly/i)
372
373
  end
373
374
 
374
375
  def self.load_other
@@ -1,6 +1,6 @@
1
1
  require "digest/sha1"
2
- require "securerandom"
3
- require "json"
2
+ require "securerandom" unless defined?(SecureRandom)
3
+ require "json" unless defined?(JSON)
4
4
 
5
5
  module Train::Platforms::Detect
6
6
  class UUID
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms
4
2
  class Family
5
3
  include Train::Platforms::Common
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Train::Platforms
4
2
  class Platform
5
3
  include Train::Platforms::Common
@@ -47,7 +45,7 @@ module Train::Platforms
47
45
  @uuid ||= Train::Platforms::Detect::UUID.new(self).find_or_create_uuid.downcase
48
46
  end
49
47
 
50
- # This is for backwords compatability with
48
+ # This is for backwards compatibility with
51
49
  # the current inspec os resource.
52
50
  def[](name)
53
51
  if respond_to?(name)
@@ -13,13 +13,13 @@ require "minitest/spec"
13
13
  require "minitest/autorun"
14
14
 
15
15
  # Data formats commonly used in testing
16
- require "json"
17
- require "ostruct"
16
+ require "json" unless defined?(JSON)
17
+ require "ostruct" unless defined?(OpenStruct)
18
18
 
19
19
  # Utilities often needed
20
- require "fileutils"
21
- require "tmpdir"
22
- require "pathname"
20
+ require "fileutils" unless defined?(FileUtils)
21
+ require "tmpdir" unless defined?(Dir.mktmpdir)
22
+ require "pathname" unless defined?(Pathname)
23
23
 
24
24
  # You might want to put some debugging tools here. We run tests to find bugs,
25
25
  # after all.
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
  # Author:: Christoph Hartmann (<chris@lollyrock.com>)
@@ -24,7 +23,7 @@ module Train
24
23
  # Create a versioned plugin by providing the transport layer plugin version
25
24
  # to this method. It will then select the correct class to inherit from.
26
25
  #
27
- # The plugin version determins what methods will be available to your plugin.
26
+ # The plugin version determines what methods will be available to your plugin.
28
27
  #
29
28
  # @param [Int] version = 1 the plugin version to use
30
29
  # @return [Transport] the versioned transport base class
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require_relative "../errors"
4
2
  require_relative "../extras"
5
3
  require_relative "../file"
@@ -160,7 +158,7 @@ class Train::Plugins::Transport
160
158
  # service is preferred to simply waiting on a socket to become
161
159
  # available.
162
160
  def wait_until_ready
163
- # this method may be left unimplemented if that is applicablelog
161
+ # this method may be left unimplemented if that is applicable log
164
162
  end
165
163
 
166
164
  private
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
  # Author:: Christoph Hartmann (<chris@lollyrock.com>)
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  class Train::Transports::SSH
4
2
  class CiscoIOSConnection < BaseConnection
5
3
  class BadEnablePassword < Train::TransportError; end
@@ -16,6 +14,9 @@ class Train::Transports::SSH
16
14
  # Use all options left that are not `nil` for `Net::SSH.start` later
17
15
  @ssh_options = options.reject { |_key, value| value.nil? }
18
16
 
17
+ # Allow older algorithms
18
+ @ssh_options[:append_all_supported_algorithms] = true
19
+
19
20
  @prompt = /^\S+[>#]\r\n.*$/
20
21
  end
21
22
 
@@ -1,11 +1,10 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # author: Dominik Richter
4
3
  # author: Christoph Hartmann
5
4
 
6
5
  require_relative "../plugins"
7
6
  require_relative "../errors"
8
- require "mixlib/shellout"
7
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
9
8
 
10
9
  module Train::Transports
11
10
  class Local < Train.plugin(1)
@@ -112,7 +111,7 @@ module Train::Transports
112
111
  end
113
112
 
114
113
  class WindowsShellRunner
115
- require "json"
114
+ require "json" unless defined?(JSON)
116
115
  require "base64"
117
116
 
118
117
  def initialize(powershell_cmd = "powershell")
@@ -136,9 +135,9 @@ module Train::Transports
136
135
  end
137
136
 
138
137
  class WindowsPipeRunner
139
- require "json"
138
+ require "json" unless defined?(JSON)
140
139
  require "base64"
141
- require "securerandom"
140
+ require "securerandom" unless defined?(SecureRandom)
142
141
 
143
142
  def initialize(powershell_cmd = "powershell")
144
143
  @powershell_cmd = powershell_cmd
@@ -147,7 +146,7 @@ module Train::Transports
147
146
  end
148
147
 
149
148
  # @param cmd The command to execute
150
- # @return Local::ComandResult with stdout, stderr and exitstatus
149
+ # @return Local::CommandResult with stdout, stderr and exitstatus
151
150
  # Note that exitstatus ($?) in PowerShell is boolean, but we use a numeric exit code.
152
151
  # A command that succeeds without setting an exit code will have exitstatus 0
153
152
  # A command that exits with an exit code will have that value as exitstatus
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
@@ -18,7 +17,7 @@
18
17
  # See the License for the specific language governing permissions and
19
18
  # limitations under the License.
20
19
 
21
- require "net/ssh"
20
+ require "net/ssh" unless defined?(Net::SSH)
22
21
  require "net/scp"
23
22
  require_relative "../errors"
24
23
 
@@ -65,6 +64,9 @@ module Train::Transports
65
64
  option :non_interactive, default: false
66
65
  option :verify_host_key, default: false
67
66
 
67
+ # Allow connecting with older algorithms
68
+ option :append_all_supported_algorithms, default: true
69
+
68
70
  option :compression_level do |opts|
69
71
  # on nil or false: set compression level to 0
70
72
  opts[:compression] ? 6 : 0
@@ -76,7 +78,7 @@ module Train::Transports
76
78
  validate_options(opts)
77
79
  conn_opts = connection_options(opts)
78
80
 
79
- if defined?(@connection) && @connection_options == conn_opts
81
+ if defined?(@connection) && reusable_connection?(conn_opts)
80
82
  reuse_connection(&block)
81
83
  else
82
84
  create_new_connection(conn_opts, &block)
@@ -85,6 +87,13 @@ module Train::Transports
85
87
 
86
88
  private
87
89
 
90
+ def reusable_connection?(conn_opts)
91
+ return false unless @connection_options
92
+
93
+ # Do requested options match their current settings
94
+ @connection_options.all? { |k, v| conn_opts[k] == v }
95
+ end
96
+
88
97
  def validate_options(options)
89
98
  super(options)
90
99
 
@@ -167,6 +176,7 @@ module Train::Transports
167
176
  bastion_user: opts[:bastion_user],
168
177
  bastion_port: opts[:bastion_port],
169
178
  non_interactive: opts[:non_interactive],
179
+ append_all_supported_algorithms: opts[:append_all_supported_algorithms],
170
180
  transport_options: opts,
171
181
  }
172
182
  # disable host key verification. The hash key and value to use
@@ -227,7 +237,7 @@ module Train::Transports
227
237
  # Creates a new SSH Connection instance and save it for potential future
228
238
  # reuse.
229
239
  #
230
- # @param options [Hash] conneciton options
240
+ # @param options [Hash] connection options
231
241
  # @return [Ssh::Connection] an SSH Connection instance
232
242
  # @api private
233
243
  def create_new_connection(options, &block)
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
@@ -18,9 +17,9 @@
18
17
  # See the License for the specific language governing permissions and
19
18
  # limitations under the License.
20
19
 
21
- require "net/ssh"
20
+ require "net/ssh" unless defined?(Net::SSH)
22
21
  require "net/scp"
23
- require "timeout"
22
+ require "timeout" unless defined?(Timeout)
24
23
 
25
24
  class Train::Transports::SSH
26
25
  # A Connection instance can be generated and re-generated, given new
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  #
3
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
3
 
5
4
  module Train
6
- VERSION = "3.2.37".freeze
5
+ VERSION = "3.3.16".freeze
7
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.37
4
+ version: 3.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-05 00:00:00.000000000 Z
11
+ date: 2020-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: ffi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "<"
31
+ - - "!="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.13'
33
+ version: 1.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "<"
38
+ - - "!="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.13'
40
+ version: 1.13.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '2.9'
108
108
  - - "<"
109
109
  - !ruby/object:Gem::Version
110
- version: '6.0'
110
+ version: '7.0'
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '2.9'
118
118
  - - "<"
119
119
  - !ruby/object:Gem::Version
120
- version: '6.0'
120
+ version: '7.0'
121
121
  description: A minimal Train with a backends for ssh and winrm.
122
122
  email:
123
123
  - inspec@chef.io