winrm 2.3.1 → 2.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc2dfd4574c525ca194a12eb9cbc41b8bc0213b5927c5a7bf570d3010e58d9c8
4
- data.tar.gz: f3a9877260b7fd617653d7665136534c5e3761da289ab51d89bbd674cefd80d6
3
+ metadata.gz: a061a4268806508794101cac5635f765ec8defa1d647296004d4b1607ec1b64c
4
+ data.tar.gz: d575acfd046a94dda410222996a3dff67607060f1ff2369f3f58823881b6aeb6
5
5
  SHA512:
6
- metadata.gz: ac8268cd7fad1e4d9a04deddbe4fdb097e4869fb52304d27fb23f55b79a0b44a00028f6c1e7fa3833d45f5d59f350c16c2f23d3cd105ccfe7e76b6f4d27c2936
7
- data.tar.gz: 271f9696f1d960a19ad73315b363f626cd8d51eda1ce742d499b5419b57c58665612b196add8e43fd8dfd5a7461822676bf3bb03b374b09cf8aa2db6cc667d77
6
+ metadata.gz: 461e7c9afd0256b3a4324f179fde3c34de3181af134ed036298abb8aa4e5cf9d1fd7d09bd924cb9cb7cc604a31f85f7d27fe10fcd999b66c2659883637ce846e
7
+ data.tar.gz: 240f3d9a873e1b872dc58176e348476a98b95d41286933e6d3ec489621f4ab2ee6da1728a78e27ada7e4dc247dfc11a01c98fb1429f30f5f54a8f098c3b84914
@@ -435,7 +435,7 @@ module WinRM
435
435
  str.sub!(%r{^.*Content-Type: application\/octet-stream\r\n(.*)--Encrypted.*$}m, '\1')
436
436
 
437
437
  len = str.unpack('L').first
438
- iov_data = str.unpack("LA#{len}A*")
438
+ iov_data = str.unpack("La#{len}a*")
439
439
  iov0[:buffer].value = iov_data[1]
440
440
  iov1[:buffer].value = iov_data[2]
441
441
 
@@ -1,142 +1,142 @@
1
- # Copyright 2016 Matt Wrock <matt@mattwrock.com>
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- require 'base64'
16
- require_relative 'message'
17
- require_relative 'message_data/pipeline_state'
18
-
19
- module WinRM
20
- module PSRP
21
- # Handles decoding a raw powershell output response
22
- class PowershellOutputDecoder
23
- # rubocop:disable Metrics/CyclomaticComplexity
24
- # Decode the raw SOAP output into decoded PSRP message,
25
- # Removes BOM and replaces encoded line endings
26
- # @param raw_output [String] The raw encoded output
27
- # @return [String] The decoded output
28
- def decode(message)
29
- case message.type
30
- when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_output]
31
- decode_pipeline_output(message)
32
- when WinRM::PSRP::Message::MESSAGE_TYPES[:runspacepool_host_call]
33
- decode_host_call(message)
34
- when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_host_call]
35
- decode_host_call(message)
36
- when WinRM::PSRP::Message::MESSAGE_TYPES[:error_record]
37
- decode_error_record(message)
38
- when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_state]
39
- if message.parsed_data.pipeline_state == WinRM::PSRP::MessageData::PipelineState::FAILED
40
- decode_error_record(message)
41
- end
42
- end
43
- end
44
- # rubocop:enable Metrics/CyclomaticComplexity
45
-
46
- protected
47
-
48
- def decode_pipeline_output(message)
49
- message.parsed_data.output
50
- end
51
-
52
- def decode_host_call(message)
53
- text = begin
54
- case message.parsed_data.method_identifier
55
- when /WriteLine/, 'WriteErrorLine'
56
- "#{message.parsed_data.method_parameters[:s]}\r\n"
57
- when 'WriteDebugLine'
58
- "Debug: #{message.parsed_data.method_parameters[:s]}\r\n"
59
- when 'WriteWarningLine'
60
- "Warning: #{message.parsed_data.method_parameters[:s]}\r\n"
61
- when 'WriteVerboseLine'
62
- "Verbose: #{message.parsed_data.method_parameters[:s]}\r\n"
63
- when /Write[1-2]/
64
- message.parsed_data.method_parameters[:s]
65
- end
66
- end
67
-
68
- hex_decode(text)
69
- end
70
-
71
- def decode_error_record(message)
72
- parsed = message.parsed_data
73
- text = begin
74
- if message.type == WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_state]
75
- render_exception_as_error_record(parsed.exception_as_error_record)
76
- else
77
- case parsed.fully_qualified_error_id
78
- when 'Microsoft.PowerShell.Commands.WriteErrorException'
79
- render_write_error_exception(parsed)
80
- when 'NativeCommandError'
81
- render_native_command_error(parsed)
82
- when 'NativeCommandErrorMessage'
83
- parsed.exception[:message]
84
- else
85
- render_exception(parsed)
86
- end
87
- end
88
- end
89
-
90
- hex_decode(text)
91
- end
92
-
93
- def render_write_error_exception(parsed)
94
- <<EOH
95
- #{parsed.invocation_info[:line]} : #{parsed.exception[:message]}
96
- + CategoryInfo : #{parsed.error_category_message}
97
- + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
98
- EOH
99
- end
100
-
101
- def render_exception(parsed)
102
- <<EOH
103
- #{parsed.exception[:message]}
104
- #{parsed.invocation_info[:position_message]}
105
- + CategoryInfo : #{parsed.error_category_message}
106
- + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
107
- EOH
108
- end
109
-
110
- def render_native_command_error(parsed)
111
- <<EOH
112
- #{parsed.invocation_info[:my_command]} : #{parsed.exception[:message]}
113
- + CategoryInfo : #{parsed.error_category_message}
114
- + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
115
- EOH
116
- end
117
-
118
- def render_exception_as_error_record(parsed)
119
- <<EOH
120
- #{parsed.exception[:message]}
121
- + CategoryInfo : #{parsed.error_category_message}
122
- + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
123
- EOH
124
- end
125
-
126
- private
127
-
128
- def hex_decode(text)
129
- return unless text
130
-
131
- text.gsub(/_x(\h\h\h\h)_/) do
132
- decoded_text = Regexp.last_match[1].hex.chr.force_encoding('utf-8')
133
- if decoded_text.respond_to?(:scrub)
134
- decoded_text.scrub
135
- else
136
- decoded_text.encode('utf-16', invalid: :replace, undef: :replace).encode('utf-8')
137
- end
138
- end
139
- end
140
- end
141
- end
142
- end
1
+ # Copyright 2016 Matt Wrock <matt@mattwrock.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'base64'
16
+ require_relative 'message'
17
+ require_relative 'message_data/pipeline_state'
18
+
19
+ module WinRM
20
+ module PSRP
21
+ # Handles decoding a raw powershell output response
22
+ class PowershellOutputDecoder
23
+ # rubocop:disable Metrics/CyclomaticComplexity
24
+ # Decode the raw SOAP output into decoded PSRP message,
25
+ # Removes BOM and replaces encoded line endings
26
+ # @param raw_output [String] The raw encoded output
27
+ # @return [String] The decoded output
28
+ def decode(message)
29
+ case message.type
30
+ when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_output]
31
+ decode_pipeline_output(message)
32
+ when WinRM::PSRP::Message::MESSAGE_TYPES[:runspacepool_host_call]
33
+ decode_host_call(message)
34
+ when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_host_call]
35
+ decode_host_call(message)
36
+ when WinRM::PSRP::Message::MESSAGE_TYPES[:error_record]
37
+ decode_error_record(message)
38
+ when WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_state]
39
+ if message.parsed_data.pipeline_state == WinRM::PSRP::MessageData::PipelineState::FAILED
40
+ decode_error_record(message)
41
+ end
42
+ end
43
+ end
44
+ # rubocop:enable Metrics/CyclomaticComplexity
45
+
46
+ protected
47
+
48
+ def decode_pipeline_output(message)
49
+ message.parsed_data.output
50
+ end
51
+
52
+ def decode_host_call(message)
53
+ text = begin
54
+ case message.parsed_data.method_identifier
55
+ when /WriteLine/, 'WriteErrorLine'
56
+ "#{message.parsed_data.method_parameters[:s]}\r\n"
57
+ when 'WriteDebugLine'
58
+ "Debug: #{message.parsed_data.method_parameters[:s]}\r\n"
59
+ when 'WriteWarningLine'
60
+ "Warning: #{message.parsed_data.method_parameters[:s]}\r\n"
61
+ when 'WriteVerboseLine'
62
+ "Verbose: #{message.parsed_data.method_parameters[:s]}\r\n"
63
+ when /Write[1-2]/
64
+ message.parsed_data.method_parameters[:s]
65
+ end
66
+ end
67
+
68
+ hex_decode(text)
69
+ end
70
+
71
+ def decode_error_record(message)
72
+ parsed = message.parsed_data
73
+ text = begin
74
+ if message.type == WinRM::PSRP::Message::MESSAGE_TYPES[:pipeline_state]
75
+ render_exception_as_error_record(parsed.exception_as_error_record)
76
+ else
77
+ case parsed.fully_qualified_error_id
78
+ when 'Microsoft.PowerShell.Commands.WriteErrorException'
79
+ render_write_error_exception(parsed)
80
+ when 'NativeCommandError'
81
+ render_native_command_error(parsed)
82
+ when 'NativeCommandErrorMessage'
83
+ parsed.exception[:message]
84
+ else
85
+ render_exception(parsed)
86
+ end
87
+ end
88
+ end
89
+
90
+ hex_decode(text)
91
+ end
92
+
93
+ def render_write_error_exception(parsed)
94
+ <<EOH
95
+ #{parsed.invocation_info[:line]} : #{parsed.exception[:message]}
96
+ + CategoryInfo : #{parsed.error_category_message}
97
+ + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
98
+ EOH
99
+ end
100
+
101
+ def render_exception(parsed)
102
+ <<EOH
103
+ #{parsed.exception[:message]}
104
+ #{parsed.invocation_info[:position_message]}
105
+ + CategoryInfo : #{parsed.error_category_message}
106
+ + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
107
+ EOH
108
+ end
109
+
110
+ def render_native_command_error(parsed)
111
+ <<EOH
112
+ #{parsed.invocation_info[:my_command]} : #{parsed.exception[:message]}
113
+ + CategoryInfo : #{parsed.error_category_message}
114
+ + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
115
+ EOH
116
+ end
117
+
118
+ def render_exception_as_error_record(parsed)
119
+ <<EOH
120
+ #{parsed.exception[:message]}
121
+ + CategoryInfo : #{parsed.error_category_message}
122
+ + FullyQualifiedErrorId : #{parsed.fully_qualified_error_id}
123
+ EOH
124
+ end
125
+
126
+ private
127
+
128
+ def hex_decode(text)
129
+ return unless text
130
+
131
+ text.gsub(/_x(\h\h\h\h)_/) do
132
+ decoded_text = Regexp.last_match[1].hex.chr.force_encoding('utf-8')
133
+ if decoded_text.respond_to?(:scrub)
134
+ decoded_text.scrub
135
+ else
136
+ decoded_text.encode('utf-16', invalid: :replace, undef: :replace).encode('utf-8')
137
+ end
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
@@ -1,5 +1,5 @@
1
1
  # WinRM module
2
2
  module WinRM
3
3
  # The version of the WinRM library
4
- VERSION = '2.3.1'.freeze
4
+ VERSION = '2.3.2'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Wanek
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-12-19 00:00:00.000000000 Z
14
+ date: 2019-04-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: builder
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  version: '0'
313
313
  requirements: []
314
314
  rubyforge_project:
315
- rubygems_version: 2.7.6
315
+ rubygems_version: 2.7.8
316
316
  signing_key:
317
317
  specification_version: 4
318
318
  summary: Ruby library for Windows Remote Management