Skip to content

Commit

Permalink
Add validation to winrm shell type option
Browse files Browse the repository at this point in the history
Signed-off-by: Catriona Malone <[email protected]>
  • Loading branch information
catriona1 committed Sep 25, 2020
1 parent 81518e4 commit 90a380a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/train-winrm/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Transport < Train.plugin(1) # rubocop:disable Metrics/ClassLength

# ref: https://github.com/winrb/winrm#transports
SUPPORTED_WINRM_TRANSPORTS = %i{negotiate ssl plaintext kerberos}.freeze
SUPPORTED_WINRM_SHELL_TYPES = %i{powershell elevated cmd}.freeze

# common target configuration
option :host, required: true
Expand Down Expand Up @@ -106,6 +107,11 @@ def validate_options(opts)
raise Train::ClientError, "Unsupported transport type: #{winrm_transport.inspect}"
end

winrm_shell_type = opts[:winrm_shell_type].to_sym
unless SUPPORTED_WINRM_SHELL_TYPES.include?(winrm_shell_type)
raise Train::ClientError, "Unsupported winrm shell type: #{winrm_shell_type.inspect}"
end

# remove leading '/'
path = (opts[:path] || "").sub(%r{^/+}, "")

Expand Down

0 comments on commit 90a380a

Please sign in to comment.