Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose additional WinRM options for transport, basic auth, and SSPI #3669

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inspec-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.3'

spec.add_dependency 'train-core', '~> 1.5', '>= 1.5.11'
spec.add_dependency 'train-core', '~> 1.5', '>= 1.6.3'
spec.add_dependency 'thor', '~> 0.20'
spec.add_dependency 'json', '>= 1.8', '< 3.0'
spec.add_dependency 'method_source', '~> 0.8'
Expand Down
2 changes: 1 addition & 1 deletion inspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.3'

spec.add_dependency 'train', '~> 1.5', '>= 1.5.11'
spec.add_dependency 'train', '~> 1.5', '>= 1.6.3'
spec.add_dependency 'thor', '~> 0.20'
spec.add_dependency 'json', '>= 1.8', '< 3.0'
spec.add_dependency 'method_source', '~> 0.8'
Expand Down
6 changes: 6 additions & 0 deletions lib/inspec/base_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def self.target_options # rubocop:disable MethodLength
desc: 'Use SSL for transport layer encryption (WinRM).'
option :self_signed, type: :boolean,
desc: 'Allow remote scans with self-signed certificates (WinRM).'
option :winrm_transport, type: :string, default: 'negotiate',
desc: 'Specify which transport to use, defaults to negotiate (WinRM).'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we add a list of valid transport names. Also, the help text says it defaults to :negotiate, but the Thor option doesn't have a default (perhaps omission causes the WinRM library to negotiate - but if so, a comment would be good)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved.

option :winrm_disable_sspi, type: :boolean,
desc: 'Whether to use disable sspi authentication, defaults to false (WinRM).'
option :winrm_basic_auth, type: :boolean,
desc: 'Whether to use basic authentication, defaults to false (WinRM).'
option :json_config, type: :string,
desc: 'Read configuration from JSON file (`-` reads from stdin).'
option :proxy_command, type: :string,
Expand Down
8 changes: 8 additions & 0 deletions test/functional/inspec_exec_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@
end
end

describe 'when --winrm-transport is used' do
it 'raises an exception when an invalid transport is given' do
out = inspec('exec ' + example_profile + ' -t winrm://administrator@dummy --password dummy --winrm-transport kerberos')
out.exit_status.must_equal 1
out.stderr.must_include "Client error, can't connect to 'winrm' backend: Unsupported transport type: :kerberos\n"
end
end

describe 'with sensitive resources' do
it 'hides sensitive output' do
out = inspec('exec ' + sensitive_profile + ' --no-create-lockfile')
Expand Down