winrm 1.3.0 → 1.3.1

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.
data/README.md CHANGED
@@ -132,7 +132,8 @@ To run the integration tests you will need a Windows box with the WinRM service
132
132
 
133
133
  1. Create a Windows VM with WinRM configured (see above).
134
134
  2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
135
- 3. Run `bundle exec rake integration`
135
+ 3. Ensure that the box you are running the test against has a default shell profile (check ~\Documents\WindowsPowerShell). If any of your shell profiles generate stdout or stderr output, the test validators may get thrown off.
136
+ 4. Run `bundle exec rake integration`
136
137
 
137
138
  ## WinRM Author
138
139
  * Twitter: [@zentourist](https://twitter.com/zentourist)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
data/bin/rwinrm CHANGED
@@ -32,7 +32,7 @@ def parse_options
32
32
  options = {}
33
33
  fail 'Missing required options' unless ARGV.length == 1
34
34
 
35
- m = /^(?<user>\w+)@{1}(?<host>[a-zA-Z0-9\.]+)(?<port>:[0-9]+)?/.match(ARGV[0])
35
+ m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.]+)(?<port>:[0-9]+)?/i.match(ARGV[0])
36
36
  fail "#{ARGV[0]} is an invalid host" unless m
37
37
  options[:user] = m[:user]
38
38
  options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
data/changelog.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # WinRM Gem Changelog
2
2
 
3
+ # 1.3.1
4
+ - Fixed issue 129, long running commands could cause a stackoverflow exception
5
+ - Fixed use of sub! in run_command results in spurious capture/replacement of \& sequences
6
+ - Fixed issue 124 rwinrm won't take '.' characters in username
7
+
3
8
  # 1.3.0
4
9
  - Fixed multiple issues with WinRMHTTPTransportError incorrectly being raised
5
10
  - Refactored and added more unit and integration tests
@@ -164,7 +164,7 @@ module WinRM
164
164
  # Grab the command element and unescape any single quotes - issue 69
165
165
  xml = builder.target!
166
166
  escaped_cmd = /<#{NS_WIN_SHELL}:Command>(.+)<\/#{NS_WIN_SHELL}:Command>/m.match(xml)[1]
167
- xml.sub!(escaped_cmd, escaped_cmd.gsub(/&#39;/, "'"))
167
+ xml[escaped_cmd] = escaped_cmd.gsub(/&#39;/, "'")
168
168
 
169
169
  resp_doc = send_message(xml)
170
170
  command_id = REXML::XPath.first(resp_doc, "//#{NS_WIN_SHELL}:CommandId").text
@@ -222,41 +222,35 @@ module WinRM
222
222
  end
223
223
  end
224
224
 
225
- resp_doc = send_message(builder.target!)
225
+ resp_doc = nil
226
+ request_msg = builder.target!
227
+ done_elems = []
226
228
  output = Output.new
227
- REXML::XPath.match(resp_doc, "//#{NS_WIN_SHELL}:Stream").each do |n|
228
- next if n.text.nil? || n.text.empty?
229
- stream = { n.attributes['Name'].to_sym => Base64.decode64(n.text) }
230
- output[:data] << stream
231
- yield stream[:stdout], stream[:stderr] if block_given?
232
- end
233
229
 
234
- # We may need to get additional output if the stream has not finished.
235
- # The CommandState will change from Running to Done like so:
236
- # @example
237
- # from...
238
- # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running"/>
239
- # to...
240
- # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done">
241
- # <rsp:ExitCode>0</rsp:ExitCode>
242
- # </rsp:CommandState>
243
- #if ((resp/"//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']").empty?)
244
- done_elems = REXML::XPath.match(resp_doc, "//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']")
245
- if done_elems.empty?
246
- output.merge!(get_command_output(shell_id, command_id, &block)) do |key, old_data, new_data|
247
- old_data += new_data
230
+ while done_elems.empty?
231
+ resp_doc = send_get_output_message(request_msg)
232
+
233
+ REXML::XPath.match(resp_doc, "//#{NS_WIN_SHELL}:Stream").each do |n|
234
+ next if n.text.nil? || n.text.empty?
235
+ stream = { n.attributes['Name'].to_sym => Base64.decode64(n.text) }
236
+ output[:data] << stream
237
+ yield stream[:stdout], stream[:stderr] if block_given?
248
238
  end
249
- else
250
- output[:exitcode] = REXML::XPath.first(resp_doc, "//#{NS_WIN_SHELL}:ExitCode").text.to_i
239
+
240
+ # We may need to get additional output if the stream has not finished.
241
+ # The CommandState will change from Running to Done like so:
242
+ # @example
243
+ # from...
244
+ # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Running"/>
245
+ # to...
246
+ # <rsp:CommandState CommandId="..." State="http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done">
247
+ # <rsp:ExitCode>0</rsp:ExitCode>
248
+ # </rsp:CommandState>
249
+ done_elems = REXML::XPath.match(resp_doc, "//*[@State='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/CommandState/Done']")
251
250
  end
251
+
252
+ output[:exitcode] = REXML::XPath.first(resp_doc, "//#{NS_WIN_SHELL}:ExitCode").text.to_i
252
253
  output
253
- rescue WinRMWSManFault => e
254
- # If no output is available before the wsman:OperationTimeout expires,
255
- # the server MUST return a WSManFault with the Code attribute equal to
256
- # 2150858793. When the client receives this fault, it SHOULD issue
257
- # another Receive request.
258
- # http://msdn.microsoft.com/en-us/library/cc251676.aspx
259
- retry if e.fault_code == '2150858793'
260
254
  end
261
255
 
262
256
  # Clean-up after a command.
@@ -417,6 +411,21 @@ module WinRM
417
411
  hdr
418
412
  end
419
413
 
414
+ def send_get_output_message(message)
415
+ send_message(message)
416
+ rescue WinRMWSManFault => e
417
+ # If no output is available before the wsman:OperationTimeout expires,
418
+ # the server MUST return a WSManFault with the Code attribute equal to
419
+ # 2150858793. When the client receives this fault, it SHOULD issue
420
+ # another Receive request.
421
+ # http://msdn.microsoft.com/en-us/library/cc251676.aspx
422
+ if e.fault_code == '2150858793'
423
+ retry
424
+ else
425
+ raise
426
+ end
427
+ end
428
+
420
429
  def send_message(message)
421
430
  @xfer.send_request(message)
422
431
  end
data/spec/cmd_spec.rb CHANGED
@@ -25,6 +25,16 @@ describe 'winrm client cmd', integration: true do
25
25
  it { should have_no_stderr }
26
26
  end
27
27
 
28
+ describe 'echo "string with trailing \\" using double quotes' do
29
+ # This is a regression test for #131. " is converted to &quot; when serializing
30
+ # the command to SOAP/XML. Any naive substitution performed on such a serialized
31
+ # string can result in any \& sequence being interpreted as a back-substitution.
32
+ subject(:output) { @winrm.cmd('echo "string with trailing \\"') }
33
+ it { should have_exit_code 0 }
34
+ it { should have_stdout_match(/string with trailing \\/) }
35
+ it { should have_no_stderr }
36
+ end
37
+
28
38
  describe 'capturing output from stdout and stderr' do
29
39
  subject(:output) do
30
40
  # Note: Multiple lines doesn't work:
@@ -1,12 +1,19 @@
1
+ # Copy this file to config.yml and edit the settings below.
2
+ # This should work out of the box for vagrant provisioned boxes.
3
+
1
4
  ## Kerberos
2
- #auth_type: plaintest
5
+ #auth_type: kerberos
3
6
  #endpoint: "http://<yourserver>:5985/wsman"
4
7
  #options:
5
8
  # realm: "your.realm"
6
9
 
7
10
  ## Plain Text
8
11
  auth_type: plaintext
12
+ # If you are running this in a vagrant provisioned box using NAT,
13
+ # this will be the forwarded WinRM HTTP port to your VM.
14
+ # If you are running this on the VM, the default HTTP port is 5985.
15
+ # See README.md#Troubleshooting.
9
16
  endpoint: "http://localhost:55985/wsman"
10
17
  options:
11
18
  user: vagrant
12
- pass: vagrant
19
+ pass: vagrant
data/spec/matchers.rb CHANGED
@@ -66,7 +66,7 @@ end
66
66
  RSpec::Matchers.define :be_a_uid do
67
67
  match do |actual|
68
68
  # WinRM1.1 returns uuid's prefixed with 'uuid:' where as later versions do not
69
- !actual.nil? && actual.match(/^(uuid:)*\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/)
69
+ actual && actual.to_s.match(/^(uuid:)*\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/)
70
70
  end
71
71
  failure_message do |actual|
72
72
  "expected a uid, but got '#{actual}'"
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winrm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Dan Wanek
@@ -9,11 +10,12 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-01-20 00:00:00.000000000 Z
13
+ date: 2015-04-01 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: gssapi
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ~>
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ~>
26
29
  - !ruby/object:Gem::Version
@@ -28,26 +31,29 @@ dependencies:
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: httpclient
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
36
  - - ~>
33
37
  - !ruby/object:Gem::Version
34
38
  version: '2.2'
35
- - - '>='
39
+ - - ! '>='
36
40
  - !ruby/object:Gem::Version
37
41
  version: 2.2.0.2
38
42
  type: :runtime
39
43
  prerelease: false
40
44
  version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
41
46
  requirements:
42
47
  - - ~>
43
48
  - !ruby/object:Gem::Version
44
49
  version: '2.2'
45
- - - '>='
50
+ - - ! '>='
46
51
  - !ruby/object:Gem::Version
47
52
  version: 2.2.0.2
48
53
  - !ruby/object:Gem::Dependency
49
54
  name: rubyntlm
50
55
  requirement: !ruby/object:Gem::Requirement
56
+ none: false
51
57
  requirements:
52
58
  - - ~>
53
59
  - !ruby/object:Gem::Version
@@ -55,6 +61,7 @@ dependencies:
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
58
65
  requirements:
59
66
  - - ~>
60
67
  - !ruby/object:Gem::Version
@@ -62,6 +69,7 @@ dependencies:
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: uuidtools
64
71
  requirement: !ruby/object:Gem::Requirement
72
+ none: false
65
73
  requirements:
66
74
  - - ~>
67
75
  - !ruby/object:Gem::Version
@@ -69,6 +77,7 @@ dependencies:
69
77
  type: :runtime
70
78
  prerelease: false
71
79
  version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
72
81
  requirements:
73
82
  - - ~>
74
83
  - !ruby/object:Gem::Version
@@ -76,26 +85,29 @@ dependencies:
76
85
  - !ruby/object:Gem::Dependency
77
86
  name: logging
78
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
79
89
  requirements:
80
90
  - - ~>
81
91
  - !ruby/object:Gem::Version
82
92
  version: '1.6'
83
- - - '>='
93
+ - - ! '>='
84
94
  - !ruby/object:Gem::Version
85
95
  version: 1.6.1
86
96
  type: :runtime
87
97
  prerelease: false
88
98
  version_requirements: !ruby/object:Gem::Requirement
99
+ none: false
89
100
  requirements:
90
101
  - - ~>
91
102
  - !ruby/object:Gem::Version
92
103
  version: '1.6'
93
- - - '>='
104
+ - - ! '>='
94
105
  - !ruby/object:Gem::Version
95
106
  version: 1.6.1
96
107
  - !ruby/object:Gem::Dependency
97
108
  name: nori
98
109
  requirement: !ruby/object:Gem::Requirement
110
+ none: false
99
111
  requirements:
100
112
  - - ~>
101
113
  - !ruby/object:Gem::Version
@@ -103,6 +115,7 @@ dependencies:
103
115
  type: :runtime
104
116
  prerelease: false
105
117
  version_requirements: !ruby/object:Gem::Requirement
118
+ none: false
106
119
  requirements:
107
120
  - - ~>
108
121
  - !ruby/object:Gem::Version
@@ -110,6 +123,7 @@ dependencies:
110
123
  - !ruby/object:Gem::Dependency
111
124
  name: gyoku
112
125
  requirement: !ruby/object:Gem::Requirement
126
+ none: false
113
127
  requirements:
114
128
  - - ~>
115
129
  - !ruby/object:Gem::Version
@@ -117,6 +131,7 @@ dependencies:
117
131
  type: :runtime
118
132
  prerelease: false
119
133
  version_requirements: !ruby/object:Gem::Requirement
134
+ none: false
120
135
  requirements:
121
136
  - - ~>
122
137
  - !ruby/object:Gem::Version
@@ -124,20 +139,23 @@ dependencies:
124
139
  - !ruby/object:Gem::Dependency
125
140
  name: builder
126
141
  requirement: !ruby/object:Gem::Requirement
142
+ none: false
127
143
  requirements:
128
- - - '>='
144
+ - - ! '>='
129
145
  - !ruby/object:Gem::Version
130
146
  version: 2.1.2
131
147
  type: :runtime
132
148
  prerelease: false
133
149
  version_requirements: !ruby/object:Gem::Requirement
150
+ none: false
134
151
  requirements:
135
- - - '>='
152
+ - - ! '>='
136
153
  - !ruby/object:Gem::Version
137
154
  version: 2.1.2
138
155
  - !ruby/object:Gem::Dependency
139
156
  name: rspec
140
157
  requirement: !ruby/object:Gem::Requirement
158
+ none: false
141
159
  requirements:
142
160
  - - ~>
143
161
  - !ruby/object:Gem::Version
@@ -145,6 +163,7 @@ dependencies:
145
163
  type: :development
146
164
  prerelease: false
147
165
  version_requirements: !ruby/object:Gem::Requirement
166
+ none: false
148
167
  requirements:
149
168
  - - ~>
150
169
  - !ruby/object:Gem::Version
@@ -152,6 +171,7 @@ dependencies:
152
171
  - !ruby/object:Gem::Dependency
153
172
  name: rake
154
173
  requirement: !ruby/object:Gem::Requirement
174
+ none: false
155
175
  requirements:
156
176
  - - ~>
157
177
  - !ruby/object:Gem::Version
@@ -159,6 +179,7 @@ dependencies:
159
179
  type: :development
160
180
  prerelease: false
161
181
  version_requirements: !ruby/object:Gem::Requirement
182
+ none: false
162
183
  requirements:
163
184
  - - ~>
164
185
  - !ruby/object:Gem::Version
@@ -166,6 +187,7 @@ dependencies:
166
187
  - !ruby/object:Gem::Dependency
167
188
  name: rubocop
168
189
  requirement: !ruby/object:Gem::Requirement
190
+ none: false
169
191
  requirements:
170
192
  - - ~>
171
193
  - !ruby/object:Gem::Version
@@ -173,12 +195,14 @@ dependencies:
173
195
  type: :development
174
196
  prerelease: false
175
197
  version_requirements: !ruby/object:Gem::Requirement
198
+ none: false
176
199
  requirements:
177
200
  - - ~>
178
201
  - !ruby/object:Gem::Version
179
202
  version: 0.28.0
180
- description: |2
181
- Ruby library for Windows Remote Management
203
+ description: ! ' Ruby library for Windows Remote Management
204
+
205
+ '
182
206
  email:
183
207
  - dan.wanek@gmail.com
184
208
  - paul@themortonsonline.com
@@ -232,7 +256,6 @@ files:
232
256
  - winrm.gemspec
233
257
  homepage: http://github.com/WinRb/WinRM
234
258
  licenses: []
235
- metadata: {}
236
259
  post_install_message:
237
260
  rdoc_options:
238
261
  - -x
@@ -242,19 +265,24 @@ rdoc_options:
242
265
  require_paths:
243
266
  - lib
244
267
  required_ruby_version: !ruby/object:Gem::Requirement
268
+ none: false
245
269
  requirements:
246
- - - '>='
270
+ - - ! '>='
247
271
  - !ruby/object:Gem::Version
248
272
  version: 1.9.0
249
273
  required_rubygems_version: !ruby/object:Gem::Requirement
274
+ none: false
250
275
  requirements:
251
- - - '>='
276
+ - - ! '>='
252
277
  - !ruby/object:Gem::Version
253
278
  version: '0'
279
+ segments:
280
+ - 0
281
+ hash: -1450055644460961921
254
282
  requirements: []
255
283
  rubyforge_project:
256
- rubygems_version: 2.0.14
284
+ rubygems_version: 1.8.23.2
257
285
  signing_key:
258
- specification_version: 4
286
+ specification_version: 3
259
287
  summary: Ruby library for Windows Remote Management
260
288
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: f3608a4fcc34f3bcad9cee57c3fada4a67a4ccb0
4
- data.tar.gz: 89f128800437d974194dedafb9ef3d56300c33e5
5
- SHA512:
6
- metadata.gz: b041e877f6b11c9b11acff78c714da8d2bb6e3cd80f87a8788deb62177edb8f2e1483e9f9aa7d36966fd8cccc2d57c0f69c601498f782b96535b397ec22486c3
7
- data.tar.gz: e10dd4724ec11e483fa652ba49cf93a41f8999256ef3b5564235856b46b340dd120d7602b9da63901b356f986deecf6f54edbe0a81a8cd39ea2703b3abbcb661