winrm 2.2.3 → 2.3.6
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 +5 -5
- data/README.md +1 -1
- data/bin/rwinrm +90 -97
- data/lib/winrm/connection.rb +84 -86
- data/lib/winrm/connection_opts.rb +90 -91
- data/lib/winrm/exceptions.rb +14 -2
- data/lib/winrm/http/response_handler.rb +127 -96
- data/lib/winrm/http/transport.rb +462 -427
- data/lib/winrm/http/transport_factory.rb +1 -5
- data/lib/winrm/output.rb +1 -2
- data/lib/winrm/psrp/fragment.rb +0 -2
- data/lib/winrm/psrp/message.rb +128 -130
- data/lib/winrm/psrp/message_data/base.rb +0 -2
- data/lib/winrm/psrp/message_data/error_record.rb +2 -2
- data/lib/winrm/psrp/message_data/pipeline_host_call.rb +0 -2
- data/lib/winrm/psrp/message_data/pipeline_output.rb +48 -54
- data/lib/winrm/psrp/message_data/pipeline_state.rb +0 -2
- data/lib/winrm/psrp/message_data/runspacepool_host_call.rb +0 -2
- data/lib/winrm/psrp/message_data/runspacepool_state.rb +0 -2
- data/lib/winrm/psrp/message_data/session_capability.rb +0 -2
- data/lib/winrm/psrp/message_data.rb +0 -2
- data/lib/winrm/psrp/message_defragmenter.rb +2 -2
- data/lib/winrm/psrp/message_factory.rb +16 -5
- data/lib/winrm/psrp/message_fragmenter.rb +1 -3
- data/lib/winrm/psrp/powershell_output_decoder.rb +142 -144
- data/lib/winrm/psrp/receive_response_reader.rb +3 -5
- data/lib/winrm/psrp/uuid.rb +1 -2
- data/lib/winrm/shells/base.rb +7 -4
- data/lib/winrm/shells/cmd.rb +63 -65
- data/lib/winrm/shells/power_shell.rb +207 -202
- data/lib/winrm/shells/retryable.rb +44 -45
- data/lib/winrm/shells/shell_factory.rb +0 -2
- data/lib/winrm/version.rb +1 -3
- data/lib/winrm/wsmv/base.rb +0 -2
- data/lib/winrm/wsmv/cleanup_command.rb +1 -2
- data/lib/winrm/wsmv/close_shell.rb +1 -2
- data/lib/winrm/wsmv/command.rb +2 -3
- data/lib/winrm/wsmv/command_output.rb +2 -3
- data/lib/winrm/wsmv/command_output_decoder.rb +1 -2
- data/lib/winrm/wsmv/configuration.rb +0 -2
- data/lib/winrm/wsmv/create_pipeline.rb +0 -2
- data/lib/winrm/wsmv/create_shell.rb +2 -6
- data/lib/winrm/wsmv/header.rb +213 -215
- data/lib/winrm/wsmv/init_runspace_pool.rb +96 -95
- data/lib/winrm/wsmv/iso8601_duration.rb +0 -2
- data/lib/winrm/wsmv/keep_alive.rb +0 -2
- data/lib/winrm/wsmv/receive_response_reader.rb +128 -126
- data/lib/winrm/wsmv/send_data.rb +0 -2
- data/lib/winrm/wsmv/soap.rb +0 -2
- data/lib/winrm/wsmv/wql_pull.rb +54 -56
- data/lib/winrm/wsmv/wql_query.rb +98 -99
- data/lib/winrm/wsmv/write_stdin.rb +0 -2
- data/lib/winrm.rb +3 -5
- metadata +81 -135
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -26
- data/.travis.yml +0 -11
- data/Gemfile +0 -3
- data/Rakefile +0 -34
- data/Vagrantfile +0 -6
- data/WinrmAppveyor.psm1 +0 -32
- data/appveyor.yml +0 -51
- data/changelog.md +0 -128
- data/preamble +0 -17
- data/tests/integration/auth_timeout_spec.rb +0 -18
- data/tests/integration/cmd_spec.rb +0 -131
- data/tests/integration/config-example.yml +0 -16
- data/tests/integration/issue_59_spec.rb +0 -26
- data/tests/integration/powershell_spec.rb +0 -165
- data/tests/integration/spec_helper.rb +0 -65
- data/tests/integration/transport_spec.rb +0 -99
- data/tests/integration/wql_spec.rb +0 -34
- data/tests/matchers.rb +0 -60
- data/tests/spec/configuration_spec.rb +0 -184
- data/tests/spec/connection_spec.rb +0 -39
- data/tests/spec/exception_spec.rb +0 -50
- data/tests/spec/http/transport_factory_spec.rb +0 -68
- data/tests/spec/http/transport_spec.rb +0 -44
- data/tests/spec/output_spec.rb +0 -127
- data/tests/spec/psrp/fragment_spec.rb +0 -62
- data/tests/spec/psrp/message_data/base_spec.rb +0 -13
- data/tests/spec/psrp/message_data/error_record_spec.rb +0 -41
- data/tests/spec/psrp/message_data/pipeline_host_call_spec.rb +0 -25
- data/tests/spec/psrp/message_data/pipeline_output_spec.rb +0 -32
- data/tests/spec/psrp/message_data/pipeline_state_spec.rb +0 -40
- data/tests/spec/psrp/message_data/runspace_pool_host_call_spec.rb +0 -25
- data/tests/spec/psrp/message_data/runspacepool_state_spec.rb +0 -16
- data/tests/spec/psrp/message_data/session_capability_spec.rb +0 -30
- data/tests/spec/psrp/message_data_spec.rb +0 -35
- data/tests/spec/psrp/message_defragmenter_spec.rb +0 -47
- data/tests/spec/psrp/message_fragmenter_spec.rb +0 -105
- data/tests/spec/psrp/powershell_output_decoder_spec.rb +0 -100
- data/tests/spec/psrp/psrp_message_spec.rb +0 -70
- data/tests/spec/psrp/recieve_response_reader_spec.rb +0 -172
- data/tests/spec/psrp/uuid_spec.rb +0 -28
- data/tests/spec/response_handler_spec.rb +0 -61
- data/tests/spec/shells/base_spec.rb +0 -225
- data/tests/spec/shells/cmd_spec.rb +0 -75
- data/tests/spec/shells/powershell_spec.rb +0 -175
- data/tests/spec/spec_helper.rb +0 -47
- data/tests/spec/stubs/clixml/error_record.xml.erb +0 -84
- data/tests/spec/stubs/clixml/pipeline_state.xml.erb +0 -88
- data/tests/spec/stubs/responses/get_command_output_response.xml.erb +0 -13
- data/tests/spec/stubs/responses/get_command_output_response_not_done.xml.erb +0 -10
- data/tests/spec/stubs/responses/get_powershell_keepalive_response.xml.erb +0 -10
- data/tests/spec/stubs/responses/get_powershell_output_response.xml.erb +0 -12
- data/tests/spec/stubs/responses/get_powershell_output_response_not_done.xml.erb +0 -9
- data/tests/spec/stubs/responses/open_shell_v1.xml +0 -19
- data/tests/spec/stubs/responses/open_shell_v2.xml +0 -20
- data/tests/spec/stubs/responses/soap_fault_v1.xml +0 -36
- data/tests/spec/stubs/responses/soap_fault_v2.xml +0 -42
- data/tests/spec/stubs/responses/wmi_error_v2.xml +0 -41
- data/tests/spec/wsmv/cleanup_command_spec.rb +0 -22
- data/tests/spec/wsmv/close_shell_spec.rb +0 -17
- data/tests/spec/wsmv/command_output_decoder_spec.rb +0 -37
- data/tests/spec/wsmv/command_output_spec.rb +0 -45
- data/tests/spec/wsmv/command_spec.rb +0 -19
- data/tests/spec/wsmv/configuration_spec.rb +0 -17
- data/tests/spec/wsmv/create_pipeline_spec.rb +0 -31
- data/tests/spec/wsmv/create_shell_spec.rb +0 -38
- data/tests/spec/wsmv/init_runspace_pool_spec.rb +0 -36
- data/tests/spec/wsmv/keep_alive_spec.rb +0 -21
- data/tests/spec/wsmv/receive_response_reader_spec.rb +0 -123
- data/tests/spec/wsmv/send_data_spec.rb +0 -30
- data/tests/spec/wsmv/wql_query_spec.rb +0 -13
- data/tests/spec/wsmv/write_stdin_spec.rb +0 -22
- data/winrm.gemspec +0 -47
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -59,9 +57,7 @@ module WinRM
|
|
|
59
57
|
.select { |m| m.to_s.start_with?('init_') && m.to_s.end_with?('_transport') }
|
|
60
58
|
.map { |tm| tm.to_s.split('_')[1] }
|
|
61
59
|
|
|
62
|
-
unless valid.include?(transport.to_s)
|
|
63
|
-
raise WinRM::InvalidTransportError.new(transport, valid)
|
|
64
|
-
end
|
|
60
|
+
raise WinRM::InvalidTransportError.new(transport, valid) unless valid.include?(transport.to_s)
|
|
65
61
|
end
|
|
66
62
|
end
|
|
67
63
|
end
|
data/lib/winrm/output.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2014 Max Lincoln <max@devopsy.com>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -48,6 +46,7 @@ module WinRM
|
|
|
48
46
|
# Sets the exitcode
|
|
49
47
|
def exitcode=(code)
|
|
50
48
|
raise WinRM::InvalidExitCode unless code.is_a? Integer
|
|
49
|
+
|
|
51
50
|
@exitcode = code
|
|
52
51
|
end
|
|
53
52
|
|
data/lib/winrm/psrp/fragment.rb
CHANGED
data/lib/winrm/psrp/message.rb
CHANGED
|
@@ -1,130 +1,128 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
module
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
# @param
|
|
72
|
-
#
|
|
73
|
-
# @param
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
@
|
|
87
|
-
@
|
|
88
|
-
@
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
#
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
130
|
-
end
|
|
1
|
+
# Copyright 2015 Matt Wrock <matt@mattwrock.com>
|
|
2
|
+
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the 'License');
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an 'AS IS' BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
require_relative 'uuid'
|
|
17
|
+
require_relative 'message_data'
|
|
18
|
+
|
|
19
|
+
module WinRM
|
|
20
|
+
# PowerShell Remoting Protcol module
|
|
21
|
+
module PSRP
|
|
22
|
+
# PowerShell Remoting Protocol base message.
|
|
23
|
+
# http://download.microsoft.com/download/9/5/E/95EF66AF-9026-4BB0-A41D-A4F81802D92C/%5BMS-PSRP%5D.pdf
|
|
24
|
+
class Message
|
|
25
|
+
include UUID
|
|
26
|
+
|
|
27
|
+
# Value of message destination when sent to a client
|
|
28
|
+
CLIENT_DESTINATION = 1
|
|
29
|
+
|
|
30
|
+
# Value of message destination when sent to a server
|
|
31
|
+
SERVER_DESTINATION = 2
|
|
32
|
+
|
|
33
|
+
# All known PSRP message types
|
|
34
|
+
MESSAGE_TYPES = {
|
|
35
|
+
session_capability: 0x00010002,
|
|
36
|
+
init_runspacepool: 0x00010004,
|
|
37
|
+
public_key: 0x00010005,
|
|
38
|
+
encrypted_session_key: 0x00010006,
|
|
39
|
+
public_key_request: 0x00010007,
|
|
40
|
+
connect_runspacepool: 0x00010008,
|
|
41
|
+
runspace_init_data: 0x0002100b,
|
|
42
|
+
reset_runspace_state: 0x0002100c,
|
|
43
|
+
set_max_runspaces: 0x00021002,
|
|
44
|
+
set_min_runspaces: 0x00021003,
|
|
45
|
+
runspace_availability: 0x00021004,
|
|
46
|
+
runspacepool_state: 0x00021005,
|
|
47
|
+
create_pipeline: 0x00021006,
|
|
48
|
+
get_available_runspaces: 0x00021007,
|
|
49
|
+
user_event: 0x00021008,
|
|
50
|
+
application_private_data: 0x00021009,
|
|
51
|
+
get_command_metadata: 0x0002100a,
|
|
52
|
+
runspacepool_host_call: 0x00021100,
|
|
53
|
+
runspacepool_host_response: 0x00021101,
|
|
54
|
+
pipeline_input: 0x00041002,
|
|
55
|
+
end_of_pipeline_input: 0x00041003,
|
|
56
|
+
pipeline_output: 0x00041004,
|
|
57
|
+
error_record: 0x00041005,
|
|
58
|
+
pipeline_state: 0x00041006,
|
|
59
|
+
debug_record: 0x00041007,
|
|
60
|
+
verbose_record: 0x00041008,
|
|
61
|
+
warning_record: 0x00041009,
|
|
62
|
+
progress_record: 0x00041010,
|
|
63
|
+
information_record: 0x00041011,
|
|
64
|
+
pipeline_host_call: 0x00041100,
|
|
65
|
+
pipeline_host_response: 0x00041101
|
|
66
|
+
}.freeze
|
|
67
|
+
|
|
68
|
+
# Creates a new PSRP message instance
|
|
69
|
+
# @param runspace_pool_id [String] The UUID of the remote shell/runspace pool.
|
|
70
|
+
# @param pipeline_id [String] The UUID to correlate the command/pipeline response
|
|
71
|
+
# @param type [Integer] The PSRP MessageType. This is most commonly
|
|
72
|
+
# specified in hex, e.g. 0x00010002.
|
|
73
|
+
# @param data [String] The PSRP payload as serialized XML
|
|
74
|
+
# @param destination [Integer] The destination for this message - client or server
|
|
75
|
+
def initialize(
|
|
76
|
+
runspace_pool_id,
|
|
77
|
+
type,
|
|
78
|
+
data,
|
|
79
|
+
pipeline_id = nil,
|
|
80
|
+
destination = SERVER_DESTINATION
|
|
81
|
+
)
|
|
82
|
+
raise 'invalid message type' unless MESSAGE_TYPES.value?(type)
|
|
83
|
+
|
|
84
|
+
@data = data
|
|
85
|
+
@destination = destination
|
|
86
|
+
@type = type
|
|
87
|
+
@pipeline_id = pipeline_id
|
|
88
|
+
@runspace_pool_id = runspace_pool_id
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
attr_reader :destination, :type, :runspace_pool_id, :pipeline_id, :data
|
|
92
|
+
|
|
93
|
+
# Returns the raw PSRP message bytes ready for transfer to Windows inside a
|
|
94
|
+
# WinRM message.
|
|
95
|
+
# @return [Array<Byte>] Unencoded raw byte array of the PSRP message.
|
|
96
|
+
def bytes
|
|
97
|
+
[
|
|
98
|
+
int16le(destination),
|
|
99
|
+
int16le(type),
|
|
100
|
+
uuid_to_windows_guid_bytes(runspace_pool_id),
|
|
101
|
+
uuid_to_windows_guid_bytes(pipeline_id),
|
|
102
|
+
byte_order_mark,
|
|
103
|
+
data_bytes
|
|
104
|
+
].flatten
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Parses the raw data to a MessageData class
|
|
108
|
+
# @return [MessageData::Base] MessageData corresponding to this message type
|
|
109
|
+
def parsed_data
|
|
110
|
+
@parsed_data ||= MessageData.parse(self)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
def byte_order_mark
|
|
116
|
+
[239, 187, 191]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def data_bytes
|
|
120
|
+
@data_bytes ||= data.force_encoding('utf-8').bytes
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def int16le(int16)
|
|
124
|
+
[int16].pack('N').unpack('C4').reverse
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2016 Matt Wrock <matt@mattwrock.com>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -50,6 +48,8 @@ module WinRM
|
|
|
50
48
|
|
|
51
49
|
def property_hash(prop_name)
|
|
52
50
|
prop_nodes = REXML::XPath.first(doc, "//*[@N='#{prop_name}']/Props")
|
|
51
|
+
return {} if prop_nodes.nil?
|
|
52
|
+
|
|
53
53
|
prop_nodes.elements.each_with_object({}) do |node, props|
|
|
54
54
|
name = node.attributes['N']
|
|
55
55
|
props[underscore(name).to_sym] = node.text if node.text
|
|
@@ -1,54 +1,48 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
module
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
text.sub("\xEF\xBB\xBF", '')
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
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 'rexml/document' unless defined?(REXML::Document)
|
|
16
|
+
|
|
17
|
+
module WinRM
|
|
18
|
+
module PSRP
|
|
19
|
+
module MessageData
|
|
20
|
+
# Handles decoding a raw powershell output response
|
|
21
|
+
class PipelineOutput < Base
|
|
22
|
+
def output
|
|
23
|
+
extract_out_string(remove_bom(raw.force_encoding('utf-8')))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def extract_out_string(text)
|
|
29
|
+
doc = REXML::Document.new(text)
|
|
30
|
+
doc.root.get_elements('//S').map do |node|
|
|
31
|
+
text = ''
|
|
32
|
+
if node.text
|
|
33
|
+
text << node.text.gsub(/(_x\h\h\h\h_)+/) do |match|
|
|
34
|
+
match.scan(/_x(\h\h\h\h)_/).flatten.map(&:hex)
|
|
35
|
+
.pack('S*').force_encoding('utf-16le').encode('utf-8')
|
|
36
|
+
end.chomp
|
|
37
|
+
end
|
|
38
|
+
text << "\r\n"
|
|
39
|
+
end.join
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def remove_bom(text)
|
|
43
|
+
text.sub("\xEF\xBB\xBF", '')
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2016 Matt Wrock <matt@mattwrock.com>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
|
@@ -31,11 +29,13 @@ module WinRM
|
|
|
31
29
|
@messages[fragment.object_id] ||= []
|
|
32
30
|
@messages[fragment.object_id].push fragment
|
|
33
31
|
|
|
32
|
+
# rubocop:disable Style/GuardClause
|
|
34
33
|
if fragment.end_fragment
|
|
35
34
|
blob = []
|
|
36
35
|
@messages.delete(fragment.object_id).each { |frag| blob += frag.blob }
|
|
37
36
|
return message_from(blob.pack('C*'))
|
|
38
37
|
end
|
|
38
|
+
# rubocop:enable Style/GuardClause
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def fragment_from(byte_string)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -14,7 +12,7 @@
|
|
|
14
12
|
# See the License for the specific language governing permissions and
|
|
15
13
|
# limitations under the License.
|
|
16
14
|
|
|
17
|
-
require '
|
|
15
|
+
require 'erubi'
|
|
18
16
|
require_relative 'message'
|
|
19
17
|
|
|
20
18
|
module WinRM
|
|
@@ -65,9 +63,22 @@ module WinRM
|
|
|
65
63
|
# @api private
|
|
66
64
|
def render(template, context = nil)
|
|
67
65
|
template_path = File.expand_path(
|
|
68
|
-
"#{File.dirname(__FILE__)}/#{template}.xml.erb"
|
|
66
|
+
"#{File.dirname(__FILE__)}/#{template}.xml.erb"
|
|
67
|
+
)
|
|
69
68
|
template = File.read(template_path)
|
|
70
|
-
|
|
69
|
+
case context
|
|
70
|
+
when Hash
|
|
71
|
+
b = binding
|
|
72
|
+
locals = context.collect { |k, _| "#{k} = context[#{k.inspect}]; " }
|
|
73
|
+
b.eval(locals.join)
|
|
74
|
+
when Binding
|
|
75
|
+
b = context
|
|
76
|
+
when NilClass
|
|
77
|
+
b = binding
|
|
78
|
+
else
|
|
79
|
+
raise ArgumentError
|
|
80
|
+
end
|
|
81
|
+
b.eval(Erubi::Engine.new(template).src)
|
|
71
82
|
end
|
|
72
83
|
end
|
|
73
84
|
end
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
#
|
|
3
1
|
# Copyright 2016 Matt Wrock <matt@mattwrock.com>
|
|
4
2
|
#
|
|
5
3
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
|
@@ -45,7 +43,7 @@ module WinRM
|
|
|
45
43
|
object_id,
|
|
46
44
|
message.bytes[bytes_fragmented..last_byte - 1],
|
|
47
45
|
fragment_id,
|
|
48
|
-
bytes_fragmented
|
|
46
|
+
bytes_fragmented.zero?,
|
|
49
47
|
last_byte == message_bytes.length
|
|
50
48
|
)
|
|
51
49
|
fragment_id += 1
|