chef-winrm 2.3.11 → 2.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef-winrm/connection.rb +6 -6
  3. data/lib/chef-winrm/connection_opts.rb +7 -7
  4. data/lib/chef-winrm/exceptions.rb +1 -1
  5. data/lib/chef-winrm/http/response_handler.rb +3 -3
  6. data/lib/chef-winrm/http/transport.rb +47 -47
  7. data/lib/chef-winrm/http/transport_factory.rb +4 -4
  8. data/lib/chef-winrm/psrp/fragment.rb +10 -9
  9. data/lib/chef-winrm/psrp/message.rb +7 -7
  10. data/lib/chef-winrm/psrp/message_data/base.rb +1 -1
  11. data/lib/chef-winrm/psrp/message_data/error_record.rb +10 -10
  12. data/lib/chef-winrm/psrp/message_data/pipeline_output.rb +6 -6
  13. data/lib/chef-winrm/psrp/message_data/session_capability.rb +3 -3
  14. data/lib/chef-winrm/psrp/message_data.rb +9 -9
  15. data/lib/chef-winrm/psrp/message_defragmenter.rb +13 -13
  16. data/lib/chef-winrm/psrp/message_factory.rb +5 -5
  17. data/lib/chef-winrm/psrp/message_fragmenter.rb +9 -6
  18. data/lib/chef-winrm/psrp/powershell_output_decoder.rb +25 -29
  19. data/lib/chef-winrm/psrp/receive_response_reader.rb +5 -5
  20. data/lib/chef-winrm/shells/base.rb +17 -16
  21. data/lib/chef-winrm/shells/cmd.rb +2 -2
  22. data/lib/chef-winrm/shells/power_shell.rb +18 -18
  23. data/lib/chef-winrm/shells/retryable.rb +1 -1
  24. data/lib/chef-winrm/shells/shell_factory.rb +5 -5
  25. data/lib/chef-winrm/version.rb +1 -1
  26. data/lib/chef-winrm/wsmv/base.rb +7 -7
  27. data/lib/chef-winrm/wsmv/cleanup_command.rb +8 -8
  28. data/lib/chef-winrm/wsmv/close_shell.rb +5 -5
  29. data/lib/chef-winrm/wsmv/command.rb +15 -15
  30. data/lib/chef-winrm/wsmv/command_output.rb +15 -15
  31. data/lib/chef-winrm/wsmv/command_output_decoder.rb +4 -4
  32. data/lib/chef-winrm/wsmv/configuration.rb +3 -3
  33. data/lib/chef-winrm/wsmv/create_pipeline.rb +8 -8
  34. data/lib/chef-winrm/wsmv/create_shell.rb +19 -19
  35. data/lib/chef-winrm/wsmv/header.rb +56 -56
  36. data/lib/chef-winrm/wsmv/init_runspace_pool.rb +22 -22
  37. data/lib/chef-winrm/wsmv/iso8601_duration.rb +2 -2
  38. data/lib/chef-winrm/wsmv/keep_alive.rb +11 -11
  39. data/lib/chef-winrm/wsmv/receive_response_reader.rb +9 -9
  40. data/lib/chef-winrm/wsmv/send_data.rb +5 -5
  41. data/lib/chef-winrm/wsmv/soap.rb +22 -22
  42. data/lib/chef-winrm/wsmv/wql_pull.rb +4 -4
  43. data/lib/chef-winrm/wsmv/wql_query.rb +6 -6
  44. data/lib/chef-winrm/wsmv/write_stdin.rb +18 -18
  45. data/lib/chef-winrm.rb +10 -10
  46. metadata +96 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfe8924446478cc291356770089cd09b389d37cd281397be0ee14cf8c7f4618e
4
- data.tar.gz: e7995603a7937840c0f8429d1fd721d02d00cacd11c03ee3f6ba1cf4e9e15e99
3
+ metadata.gz: 53783559fd592d6506745a28e356e40cb9e38272432b7d2a026f74b7e0b9cbdd
4
+ data.tar.gz: 7a7051fe6db091e6d94c3d8e5e4e09c52c91052f7ee704e1603813b5f4f311e8
5
5
  SHA512:
6
- metadata.gz: c7b900b03ad11b098451e478d9462f0f6ecbf0da7ec0459be8700ca73583111f6740bc8a504b4a96aa2c258320b5e2110bce02481ec6f61f0fa74dbffd2c12f9
7
- data.tar.gz: 52b653bef46489551e339388f5aeb2f4d0811e20dee376b96661c6b2185b71820e5d3dc3fcb197b960418ce9ccb82bbc7710b8a49a80fd89c2591d9d51a31aac
6
+ metadata.gz: 046a737f2af6c0e7a78fd5b66f5473490099fd39971a7841628cbd22ed326f6b4415c417e5c9495d89a9f7dc5d8b6808c368c0dd8ff3760f7c88237f57576ccf
7
+ data.tar.gz: efebd000fa453e153ce17b2141f7e806b54b0736c530f8987467ee5d4e4fd1bef1dc0d9374aaeb46e1ec72573a3525b486fb9fd4d65c8ed813b7796304c5e792
@@ -12,11 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'connection_opts'
16
- require_relative 'http/transport_factory'
17
- require_relative 'shells/shell_factory'
18
- require_relative 'wsmv/wql_query'
19
- require_relative 'wsmv/wql_pull'
15
+ require_relative "connection_opts"
16
+ require_relative "http/transport_factory"
17
+ require_relative "shells/shell_factory"
18
+ require_relative "wsmv/wql_query"
19
+ require_relative "wsmv/wql_pull"
20
20
 
21
21
  module WinRM
22
22
  # WinRM connection used to establish a session with the remote WinRM service.
@@ -53,7 +53,7 @@ module WinRM
53
53
  # @param namespace [String] namespace for query - default is root/cimv2/*
54
54
  # @return [Hash] Hash representation of wql query response (Hash is empty if a block is given)
55
55
  # @yeild [type, item] Yields the time name and item for every item
56
- def run_wql(wql, namespace = 'root/cimv2/*', &block)
56
+ def run_wql(wql, namespace = "root/cimv2/*", &block)
57
57
  query = WinRM::WSMV::WqlQuery.new(transport, @connection_opts, wql, namespace)
58
58
  query.process_response(transport.send_request(query.build), &block)
59
59
  end
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'securerandom'
15
+ require "securerandom" unless defined?(SecureRandom)
16
16
 
17
17
  module WinRM
18
18
  # WinRM connection options, provides defaults and validation.
@@ -20,10 +20,10 @@ module WinRM
20
20
  DEFAULT_OPERATION_TIMEOUT = 60
21
21
  DEFAULT_RECEIVE_TIMEOUT = DEFAULT_OPERATION_TIMEOUT + 10
22
22
  DEFAULT_MAX_ENV_SIZE = 153600
23
- DEFAULT_LOCALE = 'en-US'.freeze
23
+ DEFAULT_LOCALE = "en-US".freeze
24
24
  DEFAULT_RETRY_DELAY = 10
25
25
  DEFAULT_RETRY_LIMIT = 3
26
- DEFAULT_USER_AGENT = 'Ruby WinRM Client'.freeze
26
+ DEFAULT_USER_AGENT = "Ruby WinRM Client".freeze
27
27
 
28
28
  class << self
29
29
  def create_with_defaults(overrides)
@@ -65,13 +65,13 @@ module WinRM
65
65
  private
66
66
 
67
67
  def validate_required_fields
68
- raise 'endpoint is a required option' unless self[:endpoint]
68
+ raise "endpoint is a required option" unless self[:endpoint]
69
69
 
70
70
  if self[:client_cert]
71
- raise 'path to client key is required' unless self[:client_key]
71
+ raise "path to client key is required" unless self[:client_key]
72
72
  else
73
- raise 'user is a required option' unless self[:user]
74
- raise 'password is a required option' unless self[:password]
73
+ raise "user is a required option" unless self[:user]
74
+ raise "password is a required option" unless self[:password]
75
75
  end
76
76
  end
77
77
 
@@ -33,7 +33,7 @@ module WinRM
33
33
  @invalid_transport = invalid_transport
34
34
  super(
35
35
  "Invalid transport '#{invalid_transport}' specified" \
36
- ", expected: #{valid_transports.join(', ')}."
36
+ ", expected: #{valid_transports.join(", ")}."
37
37
  )
38
38
  end
39
39
  end
@@ -12,8 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'rexml/document' unless defined?(REXML::Document)
16
- require_relative '../wsmv/soap'
15
+ require "rexml/document" unless defined?(REXML::Document)
16
+ require_relative "../wsmv/soap"
17
17
 
18
18
  module WinRM
19
19
  # Handles the raw WinRM HTTP response. Returns the body as an XML doc
@@ -70,7 +70,7 @@ module WinRM
70
70
  soap_errors,
71
71
  "//*[local-name() = 'WSManFault']"
72
72
  )
73
- raise WinRMWSManFault.new(fault.to_s, fault.attributes['Code']) unless fault.nil?
73
+ raise WinRMWSManFault.new(fault.to_s, fault.attributes["Code"]) unless fault.nil?
74
74
  end
75
75
 
76
76
  def raise_if_wmi_error
@@ -12,8 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'httpclient'
16
- require_relative 'response_handler'
15
+ require "httpclient"
16
+ require_relative "response_handler"
17
17
 
18
18
  module WinRM
19
19
  module HTTP
@@ -39,11 +39,11 @@ module WinRM
39
39
  def send_request(message)
40
40
  ssl_peer_fingerprint_verification!
41
41
  log_soap_message(message)
42
- hdr = { 'Content-Type' => 'application/soap+xml;charset=UTF-8',
43
- 'Content-Length' => message.bytesize }
42
+ hdr = { "Content-Type" => "application/soap+xml;charset=UTF-8",
43
+ "Content-Length" => message.bytesize }
44
44
  # We need to add this header if using Client Certificate authentication
45
45
  unless @httpcli.ssl_config.client_cert.nil?
46
- hdr['Authorization'] = 'http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/https/mutual'
46
+ hdr["Authorization"] = "http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/https/mutual"
47
47
  end
48
48
 
49
49
  resp = @httpcli.post(@endpoint, message, hdr)
@@ -55,13 +55,13 @@ module WinRM
55
55
 
56
56
  # We'll need this to force basic authentication if desired
57
57
  def basic_auth_only!
58
- auths = @httpcli.www_auth.instance_variable_get('@authenticator')
58
+ auths = @httpcli.www_auth.instance_variable_get("@authenticator")
59
59
  auths.delete_if { |i| i.scheme !~ /basic/i }
60
60
  end
61
61
 
62
62
  # Disable SSPI Auth
63
63
  def no_sspi_auth!
64
- auths = @httpcli.www_auth.instance_variable_get('@authenticator')
64
+ auths = @httpcli.www_auth.instance_variable_get("@authenticator")
65
65
  auths.delete_if { |i| i.is_a? HTTPClient::SSPINegotiateAuth }
66
66
  end
67
67
 
@@ -109,14 +109,14 @@ module WinRM
109
109
 
110
110
  protected
111
111
 
112
- def body(message, length, type = 'application/HTTP-SPNEGO-session-encrypted')
112
+ def body(message, length, type = "application/HTTP-SPNEGO-session-encrypted")
113
113
  [
114
- '--Encrypted Boundary',
114
+ "--Encrypted Boundary",
115
115
  "Content-Type: #{type}",
116
116
  "OriginalContent: type=application/soap+xml;charset=UTF-8;Length=#{length}",
117
- '--Encrypted Boundary',
118
- 'Content-Type: application/octet-stream',
119
- "#{message}--Encrypted Boundary--"
117
+ "--Encrypted Boundary",
118
+ "Content-Type: application/octet-stream",
119
+ "#{message}--Encrypted Boundary--",
120
120
  ].join("\r\n").concat("\r\n")
121
121
  end
122
122
 
@@ -148,10 +148,10 @@ module WinRM
148
148
  class HttpNegotiate < HttpTransport
149
149
  def initialize(endpoint, user, pass, opts)
150
150
  super(endpoint, opts)
151
- require 'rubyntlm'
151
+ require "rubyntlm"
152
152
  no_sspi_auth!
153
153
 
154
- user_parts = user.split('\\')
154
+ user_parts = user.split("\\")
155
155
  if user_parts.length > 1
156
156
  opts[:domain] = user_parts[0]
157
157
  user = user_parts[1]
@@ -171,8 +171,8 @@ module WinRM
171
171
  log_soap_message(message)
172
172
 
173
173
  hdr = {
174
- 'Content-Type' => 'multipart/encrypted;'\
175
- 'protocol="application/HTTP-SPNEGO-session-encrypted";boundary="Encrypted Boundary"'
174
+ "Content-Type" => "multipart/encrypted;" \
175
+ 'protocol="application/HTTP-SPNEGO-session-encrypted";boundary="Encrypted Boundary"',
176
176
  }
177
177
 
178
178
  resp = @httpcli.post(@endpoint, body(seal(message), message.bytesize), hdr)
@@ -199,29 +199,29 @@ module WinRM
199
199
 
200
200
  def winrm_decrypt(resp)
201
201
  # OMI server doesn't always respond to encrypted messages with encrypted responses over SSL
202
- return resp.body if resp.header['Content-Type'].first =~ %r{\Aapplication\/soap\+xml}i
203
- return '' if resp.body.empty?
202
+ return resp.body if resp.header["Content-Type"].first =~ %r{\Aapplication\/soap\+xml}i
203
+ return "" if resp.body.empty?
204
204
 
205
- str = resp.body.force_encoding('BINARY')
205
+ str = resp.body.force_encoding("BINARY")
206
206
  str.sub!(%r{^.*Content-Type: application\/octet-stream\r\n(.*)--Encrypted.*$}m, '\1')
207
207
 
208
208
  signature = str[4..19]
209
209
  message = @ntlmcli.session.unseal_message str[20..-1]
210
210
  return message if @ntlmcli.session.verify_signature(signature, message)
211
211
 
212
- raise WinRMHTTPTransportError, 'Could not decrypt NTLM message.'
212
+ raise WinRMHTTPTransportError, "Could not decrypt NTLM message."
213
213
  end
214
214
 
215
215
  def issue_challenge_response(negotiate)
216
216
  auth_header = {
217
- 'Authorization' => "Negotiate #{negotiate.encode64}",
218
- 'Content-Type' => 'application/soap+xml;charset=UTF-8'
217
+ "Authorization" => "Negotiate #{negotiate.encode64}",
218
+ "Content-Type" => "application/soap+xml;charset=UTF-8",
219
219
  }
220
220
 
221
221
  # OMI Server on Linux requires an empty payload with the new auth header to proceed
222
222
  # because the config check for max payload size will otherwise break the auth handshake
223
223
  # given the OMI server does not support that check
224
- @httpcli.post(@endpoint, '', auth_header)
224
+ @httpcli.post(@endpoint, "", auth_header)
225
225
 
226
226
  # return an empty hash of headers for subsequent requests to use
227
227
  {}
@@ -231,13 +231,13 @@ module WinRM
231
231
  @logger.debug "Initializing Negotiate for #{@endpoint}"
232
232
  auth1 = @ntlmcli.init_context
233
233
  hdr = {
234
- 'Authorization' => "Negotiate #{auth1.encode64}",
235
- 'Content-Type' => 'application/soap+xml;charset=UTF-8'
234
+ "Authorization" => "Negotiate #{auth1.encode64}",
235
+ "Content-Type" => "application/soap+xml;charset=UTF-8",
236
236
  }
237
- @logger.debug 'Sending HTTP POST for Negotiate Authentication'
238
- r = @httpcli.post(@endpoint, '', hdr)
237
+ @logger.debug "Sending HTTP POST for Negotiate Authentication"
238
+ r = @httpcli.post(@endpoint, "", hdr)
239
239
  verify_ssl_fingerprint(r.peer_cert)
240
- auth_header = r.header['WWW-Authenticate'].pop
240
+ auth_header = r.header["WWW-Authenticate"].pop
241
241
  unless auth_header
242
242
  msg = "Unable to parse authorization header. Headers: #{r.headers}\r\nBody: #{r.body}"
243
243
  raise WinRMHTTPTransportError.new(msg, r.status_code)
@@ -251,7 +251,7 @@ module WinRM
251
251
  if response.peer_cert.nil?
252
252
  nil
253
253
  else
254
- cert = if RUBY_PLATFORM == 'java'
254
+ cert = if RUBY_PLATFORM == "java"
255
255
  OpenSSL::X509::Certificate.new(response.peer_cert.cert.getEncoded)
256
256
  else
257
257
  response.peer_cert
@@ -279,7 +279,7 @@ module WinRM
279
279
  def initialize(endpoint, client_cert, client_key, key_pass, opts)
280
280
  super(endpoint, opts)
281
281
  @httpcli.ssl_config.set_client_cert_file(client_cert, client_key, key_pass)
282
- @httpcli.www_auth.instance_variable_set('@authenticator', [])
282
+ @httpcli.www_auth.instance_variable_set("@authenticator", [])
283
283
  no_ssl_peer_verification! if opts[:no_ssl_peer_verification]
284
284
  @ssl_peer_fingerprint = opts[:ssl_peer_fingerprint]
285
285
  @httpcli.ssl_config.set_trust_ca(opts[:ca_trust_path]) if opts[:ca_trust_path]
@@ -293,13 +293,13 @@ module WinRM
293
293
  # @param [String] realm the Kerberos realm we are authenticating to
294
294
  # @param [String<optional>] service the service name, default is HTTP
295
295
  def initialize(endpoint, realm, opts, service = nil)
296
- require 'gssapi'
297
- require 'gssapi/extensions'
296
+ require "gssapi"
297
+ require "gssapi/extensions"
298
298
 
299
299
  super(endpoint, opts)
300
300
  # Remove the GSSAPI auth from HTTPClient because we are doing our own thing
301
301
  no_sspi_auth!
302
- service ||= 'HTTP'
302
+ service ||= "HTTP"
303
303
  @service = "#{service}/#{@endpoint.host}@#{realm}"
304
304
  no_ssl_peer_verification! if opts[:no_ssl_peer_verification]
305
305
  init_krb
@@ -314,7 +314,7 @@ module WinRM
314
314
  resp = send_kerberos_request(message)
315
315
 
316
316
  if resp.status == 401
317
- @logger.debug 'Got 401 - reinitializing Kerberos and retrying one more time'
317
+ @logger.debug "Got 401 - reinitializing Kerberos and retrying one more time"
318
318
  init_krb
319
319
  resp = send_kerberos_request(message)
320
320
  end
@@ -336,14 +336,14 @@ module WinRM
336
336
  pad_len, emsg = winrm_encrypt(message)
337
337
  req_length = original_length + pad_len
338
338
  hdr = {
339
- 'Connection' => 'Keep-Alive',
340
- 'Content-Type' => 'multipart/encrypted;' \
341
- 'protocol="application/HTTP-Kerberos-session-encrypted";boundary="Encrypted Boundary"'
339
+ "Connection" => "Keep-Alive",
340
+ "Content-Type" => "multipart/encrypted;" \
341
+ 'protocol="application/HTTP-Kerberos-session-encrypted";boundary="Encrypted Boundary"',
342
342
  }
343
343
 
344
344
  resp = @httpcli.post(
345
345
  @endpoint,
346
- body(emsg, req_length, 'application/HTTP-Kerberos-session-encrypted'),
346
+ body(emsg, req_length, "application/HTTP-Kerberos-session-encrypted"),
347
347
  hdr
348
348
  )
349
349
  log_soap_message(resp.http_body.content)
@@ -357,13 +357,13 @@ module WinRM
357
357
  auth = Base64.strict_encode64 token
358
358
 
359
359
  hdr = {
360
- 'Authorization' => "Kerberos #{auth}",
361
- 'Connection' => 'Keep-Alive',
362
- 'Content-Type' => 'application/soap+xml;charset=UTF-8'
360
+ "Authorization" => "Kerberos #{auth}",
361
+ "Connection" => "Keep-Alive",
362
+ "Content-Type" => "application/soap+xml;charset=UTF-8",
363
363
  }
364
- @logger.debug 'Sending HTTP POST for Kerberos Authentication'
365
- r = @httpcli.post(@endpoint, '', hdr)
366
- itok = r.header['WWW-Authenticate'].pop
364
+ @logger.debug "Sending HTTP POST for Kerberos Authentication"
365
+ r = @httpcli.post(@endpoint, "", hdr)
366
+ itok = r.header["WWW-Authenticate"].pop
367
367
  itok = itok.split.last
368
368
  itok = Base64.strict_decode64(itok)
369
369
  @gsscli.init_context(itok)
@@ -407,7 +407,7 @@ module WinRM
407
407
  iov_cnt
408
408
  )
409
409
 
410
- token = [iov0[:buffer].length].pack('L')
410
+ token = [iov0[:buffer].length].pack("L")
411
411
  token += iov0[:buffer].value
412
412
  token += iov1[:buffer].value
413
413
  pad_len = iov2[:buffer].length
@@ -435,10 +435,10 @@ module WinRM
435
435
  )
436
436
  iov2[:type] = GSSAPI::LibGSSAPI::GSS_IOV_BUFFER_TYPE_DATA
437
437
 
438
- str.force_encoding('BINARY')
438
+ str.force_encoding("BINARY")
439
439
  str.sub!(%r{^.*Content-Type: application\/octet-stream\r\n(.*)--Encrypted.*$}m, '\1')
440
440
 
441
- len = str.unpack('L').first
441
+ len = str.unpack("L").first
442
442
  iov_data = str.unpack("La#{len}a*")
443
443
  iov0[:buffer].value = iov_data[1]
444
444
  iov1[:buffer].value = iov_data[2]
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'transport'
15
+ require_relative "transport"
16
16
 
17
17
  module WinRM
18
18
  module HTTP
@@ -46,7 +46,7 @@ module WinRM
46
46
  HTTP::BasicAuthSSL.new(opts[:endpoint], opts[:user], opts[:password], opts)
47
47
  elsif opts[:client_cert]
48
48
  HTTP::ClientCertAuthSSL.new(opts[:endpoint], opts[:client_cert],
49
- opts[:client_key], opts[:key_pass], opts)
49
+ opts[:client_key], opts[:key_pass], opts)
50
50
  else
51
51
  HTTP::HttpNegotiate.new(opts[:endpoint], opts[:user], opts[:password], opts)
52
52
  end
@@ -54,8 +54,8 @@ module WinRM
54
54
 
55
55
  def validate_transport!(transport)
56
56
  valid = private_methods
57
- .select { |m| m.to_s.start_with?('init_') && m.to_s.end_with?('_transport') }
58
- .map { |tm| tm.to_s.split('_')[1] }
57
+ .select { |m| m.to_s.start_with?("init_") && m.to_s.end_with?("_transport") }
58
+ .map { |tm| tm.to_s.split("_")[1] }
59
59
 
60
60
  raise WinRM::InvalidTransportError.new(transport, valid) unless valid.include?(transport.to_s)
61
61
  end
@@ -18,32 +18,33 @@ module WinRM
18
18
  module PSRP
19
19
  # PowerShell Remoting Protocol message fragment.
20
20
  class Fragment
21
+
22
+ attr_reader :psrp_object_id, :fragment_id, :end_fragment, :start_fragment, :blob
23
+
21
24
  # Creates a new PSRP message fragment
22
- # @param object_id [Integer] The id of the fragmented message.
25
+ # @param psrp_object_id [Integer] The id of the fragmented message.
23
26
  # @param blob [Array] Array of fragmented bytes.
24
27
  # @param fragment_id [Integer] The id of this fragment
25
28
  # @param start_fragment [Boolean] If the fragment is the first fragment
26
29
  # @param end_fragment [Boolean] If the fragment is the last fragment
27
- def initialize(object_id, blob, fragment_id = 0, start_fragment = true, end_fragment = true)
28
- @object_id = object_id
30
+ def initialize(psrp_object_id, blob, fragment_id = 0, start_fragment = true, end_fragment = true)
31
+ @psrp_object_id = psrp_object_id
29
32
  @blob = blob
30
33
  @fragment_id = fragment_id
31
34
  @start_fragment = start_fragment
32
35
  @end_fragment = end_fragment
33
36
  end
34
37
 
35
- attr_reader :object_id, :fragment_id, :end_fragment, :start_fragment, :blob
36
-
37
38
  # Returns the raw PSRP message bytes ready for transfer to Windows inside a
38
39
  # WinRM message.
39
40
  # @return [Array<Byte>] Unencoded raw byte array of the PSRP message.
40
41
  def bytes
41
42
  [
42
- int64be(object_id),
43
+ int64be(psrp_object_id),
43
44
  int64be(fragment_id),
44
45
  end_start_fragment,
45
46
  int16be(blob.length),
46
- blob
47
+ blob,
47
48
  ].flatten
48
49
  end
49
50
 
@@ -57,11 +58,11 @@ module WinRM
57
58
  end
58
59
 
59
60
  def int64be(int64)
60
- [int64 >> 32, int64 & 0x00000000ffffffff].pack('N2').unpack('C8')
61
+ [int64 >> 32, int64 & 0x00000000ffffffff].pack("N2").unpack("C8")
61
62
  end
62
63
 
63
64
  def int16be(int16)
64
- [int16].pack('N').unpack('C4')
65
+ [int16].pack("N").unpack("C4")
65
66
  end
66
67
  end
67
68
  end
@@ -13,8 +13,8 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- require_relative 'uuid'
17
- require_relative 'message_data'
16
+ require_relative "uuid"
17
+ require_relative "message_data"
18
18
 
19
19
  module WinRM
20
20
  # PowerShell Remoting Protcol module
@@ -62,7 +62,7 @@ module WinRM
62
62
  progress_record: 0x00041010,
63
63
  information_record: 0x00041011,
64
64
  pipeline_host_call: 0x00041100,
65
- pipeline_host_response: 0x00041101
65
+ pipeline_host_response: 0x00041101,
66
66
  }.freeze
67
67
 
68
68
  # Creates a new PSRP message instance
@@ -79,7 +79,7 @@ module WinRM
79
79
  pipeline_id = nil,
80
80
  destination = SERVER_DESTINATION
81
81
  )
82
- raise 'invalid message type' unless MESSAGE_TYPES.value?(type)
82
+ raise "invalid message type" unless MESSAGE_TYPES.value?(type)
83
83
 
84
84
  @data = data
85
85
  @destination = destination
@@ -100,7 +100,7 @@ module WinRM
100
100
  uuid_to_windows_guid_bytes(runspace_pool_id),
101
101
  uuid_to_windows_guid_bytes(pipeline_id),
102
102
  byte_order_mark,
103
- data_bytes
103
+ data_bytes,
104
104
  ].flatten
105
105
  end
106
106
 
@@ -117,11 +117,11 @@ module WinRM
117
117
  end
118
118
 
119
119
  def data_bytes
120
- @data_bytes ||= data.force_encoding('utf-8').bytes
120
+ @data_bytes ||= data.force_encoding("utf-8").bytes
121
121
  end
122
122
 
123
123
  def int16le(int16)
124
- [int16].pack('N').unpack('C4').reverse
124
+ [int16].pack("N").unpack("C4").reverse
125
125
  end
126
126
  end
127
127
  end
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'nori'
15
+ require "nori"
16
16
 
17
17
  module WinRM
18
18
  # PowerShell Remoting Protcol module
@@ -18,23 +18,23 @@ module WinRM
18
18
  # error record message type
19
19
  class ErrorRecord < Base
20
20
  def exception
21
- @exception ||= property_hash('Exception')
21
+ @exception ||= property_hash("Exception")
22
22
  end
23
23
 
24
24
  def fully_qualified_error_id
25
- @fully_qualified_error_id ||= string_prop('FullyQualifiedErrorId')
25
+ @fully_qualified_error_id ||= string_prop("FullyQualifiedErrorId")
26
26
  end
27
27
 
28
28
  def invocation_info
29
- @invocation_info ||= property_hash('InvocationInfo')
29
+ @invocation_info ||= property_hash("InvocationInfo")
30
30
  end
31
31
 
32
32
  def error_category_message
33
- @error_category_message ||= string_prop('ErrorCategory_Message')
33
+ @error_category_message ||= string_prop("ErrorCategory_Message")
34
34
  end
35
35
 
36
36
  def error_details_script_stack_trace
37
- @error_details_script_stack_trace ||= string_prop('ErrorDetails_ScriptStackTrace')
37
+ @error_details_script_stack_trace ||= string_prop("ErrorDetails_ScriptStackTrace")
38
38
  end
39
39
 
40
40
  def doc
@@ -51,16 +51,16 @@ module WinRM
51
51
  return {} if prop_nodes.nil?
52
52
 
53
53
  prop_nodes.elements.each_with_object({}) do |node, props|
54
- name = node.attributes['N']
54
+ name = node.attributes["N"]
55
55
  props[underscore(name).to_sym] = node.text if node.text
56
56
  end
57
57
  end
58
58
 
59
59
  def underscore(camel)
60
- camel.gsub(/::/, '/')
61
- .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
62
- .gsub(/([a-z\d])([A-Z])/, '\1_\2')
63
- .tr('-', '_').downcase
60
+ camel.gsub("::", "/")
61
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
62
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
63
+ .tr("-", "_").downcase
64
64
  end
65
65
  end
66
66
  end
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'rexml/document' unless defined?(REXML::Document)
15
+ require "rexml/document" unless defined?(REXML::Document)
16
16
 
17
17
  module WinRM
18
18
  module PSRP
@@ -20,19 +20,19 @@ module WinRM
20
20
  # Handles decoding a raw powershell output response
21
21
  class PipelineOutput < Base
22
22
  def output
23
- extract_out_string(remove_bom(raw.force_encoding('utf-8')))
23
+ extract_out_string(remove_bom(raw.force_encoding("utf-8")))
24
24
  end
25
25
 
26
26
  private
27
27
 
28
28
  def extract_out_string(text)
29
29
  doc = REXML::Document.new(text)
30
- doc.root.get_elements('//S').map do |node|
31
- text = ''
30
+ doc.root.get_elements("//S").map do |node|
31
+ text = ""
32
32
  if node.text
33
33
  text << node.text.gsub(/(_x\h\h\h\h_)+/) do |match|
34
34
  match.scan(/_x(\h\h\h\h)_/).flatten.map(&:hex)
35
- .pack('S*').force_encoding('utf-16le').encode('utf-8')
35
+ .pack("S*").force_encoding("utf-16le").encode("utf-8")
36
36
  end.chomp
37
37
  end
38
38
  text << "\r\n"
@@ -40,7 +40,7 @@ module WinRM
40
40
  end
41
41
 
42
42
  def remove_bom(text)
43
- text.sub("\xEF\xBB\xBF", '')
43
+ text.sub("\xEF\xBB\xBF", "")
44
44
  end
45
45
  end
46
46
  end
@@ -18,15 +18,15 @@ module WinRM
18
18
  # session capability message type
19
19
  class SessionCapability < Base
20
20
  def protocol_version
21
- clixml[:version].select { |v| v.attributes['N'] == 'protocolversion' }.first
21
+ clixml[:version].select { |v| v.attributes["N"] == "protocolversion" }.first
22
22
  end
23
23
 
24
24
  def ps_version
25
- clixml[:version].select { |v| v.attributes['N'] == 'PSVersion' }.first
25
+ clixml[:version].select { |v| v.attributes["N"] == "PSVersion" }.first
26
26
  end
27
27
 
28
28
  def serialization_version
29
- clixml[:version].select { |v| v.attributes['N'] == 'SerializationVersion' }.first
29
+ clixml[:version].select { |v| v.attributes["N"] == "SerializationVersion" }.first
30
30
  end
31
31
  end
32
32
  end
@@ -12,14 +12,14 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require_relative 'message_data/base'
16
- require_relative 'message_data/error_record'
17
- require_relative 'message_data/pipeline_output'
18
- require_relative 'message_data/pipeline_host_call'
19
- require_relative 'message_data/pipeline_state'
20
- require_relative 'message_data/runspacepool_host_call'
21
- require_relative 'message_data/runspacepool_state'
22
- require_relative 'message_data/session_capability'
15
+ require_relative "message_data/base"
16
+ require_relative "message_data/error_record"
17
+ require_relative "message_data/pipeline_output"
18
+ require_relative "message_data/pipeline_host_call"
19
+ require_relative "message_data/pipeline_state"
20
+ require_relative "message_data/runspacepool_host_call"
21
+ require_relative "message_data/runspacepool_state"
22
+ require_relative "message_data/session_capability"
23
23
 
24
24
  module WinRM
25
25
  # PowerShell Remoting Protcol module
@@ -33,7 +33,7 @@ module WinRM
33
33
  end
34
34
 
35
35
  def self.camelize(underscore)
36
- underscore.split('_').collect(&:capitalize).join
36
+ underscore.split("_").collect(&:capitalize).join
37
37
  end
38
38
  end
39
39
  end