winrm-transport 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +1 -1
- data/lib/winrm/transport/file_transporter.rb +32 -4
- data/lib/winrm/transport/version.rb +1 -1
- data/support/decode_files.ps1 +24 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66b0b892802274668ed50e030ce87b881beb8ed5
|
4
|
+
data.tar.gz: 8d8706354672deab32c49a2df17d9e8f3b9b2d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5bf53cacd7076b98987a99521a8882a57cade93b7433bb429ddecf5f49143cff19f559d90d10698a430a4e5e131c3e007eb233e73f168f38727dc52dfc5ab8d
|
7
|
+
data.tar.gz: 4d31347e809699128cc47348c59c901fcd07b4b1f7def0150bf46fff499030e4e97048ef3955b9bd2fd9ad5e0cf509840327f10c7cef0eb5436007220e709ba7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
## 1.0.2 / 2015-06-24
|
2
|
+
|
3
|
+
### Bug fixes
|
4
|
+
|
5
|
+
* Pull request [#8][]: Fix unzipping from COM, fix failed single file copies (when parent directory was not present), adding more tests around decode_files.ps1, cleaner error output. ([@smurawski][], [@xmik][])
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Pull request [#10][]: Fix winrm-transport/issues link in README.md. ([@hh][])
|
10
|
+
|
11
|
+
|
1
12
|
## 1.0.1 / 2015-05-20
|
2
13
|
|
3
14
|
### Bug fixes
|
@@ -18,6 +29,10 @@ The initial release.
|
|
18
29
|
[#4]: https://github.com/test-kitchen/winrm-transport/issues/4
|
19
30
|
[#5]: https://github.com/test-kitchen/winrm-transport/issues/5
|
20
31
|
[#6]: https://github.com/test-kitchen/winrm-transport/issues/6
|
32
|
+
[#8]: https://github.com/test-kitchen/winrm-transport/issues/8
|
33
|
+
[#10]: https://github.com/test-kitchen/winrm-transport/issues/10
|
21
34
|
[@fnichol]: https://github.com/fnichol
|
35
|
+
[@hh]: https://github.com/hh
|
22
36
|
[@jmccann]: https://github.com/jmccann
|
23
37
|
[@smurawski]: https://github.com/smurawski
|
38
|
+
[@xmik]: https://github.com/xmik
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ Apache License, Version 2.0 (see [LICENSE.txt][license])
|
|
73
73
|
[contributors]: https://github.com/test-kitchen/winrm-transport/graphs/contributors
|
74
74
|
[file_transporter]: https://github.com/test-kitchen/winrm-transport/blob/master/lib/winrm/transport/file_transporter.rb
|
75
75
|
[fnichol]: https://github.com/fnichol
|
76
|
-
[issues]: https://github.com/test-kitchen/winrm-
|
76
|
+
[issues]: https://github.com/test-kitchen/winrm-transport/issues
|
77
77
|
[license]: https://github.com/test-kitchen/winrm-transport/blob/master/LICENSE.txt
|
78
78
|
[repo]: https://github.com/test-kitchen/winrm-transport
|
79
79
|
[semver]: http://semver.org/
|
@@ -252,8 +252,8 @@ module WinRM
|
|
252
252
|
vars = %{$hash_file = "#{hash_file}"\n}
|
253
253
|
|
254
254
|
output = service.run_powershell_script(
|
255
|
-
[
|
256
|
-
|
255
|
+
["#{decode_files_script}",
|
256
|
+
vars,
|
257
257
|
"Decode-Files (Invoke-Input $hash_file) | ConvertTo-Csv -NoTypeInformation"
|
258
258
|
].join("\n")
|
259
259
|
)
|
@@ -348,6 +348,20 @@ module WinRM
|
|
348
348
|
" " * depth
|
349
349
|
end
|
350
350
|
|
351
|
+
# Parses CLIXML String into regular String (without any XML syntax).
|
352
|
+
# Inspired by https://github.com/WinRb/WinRM/issues/106.
|
353
|
+
#
|
354
|
+
# @param clixml [String] clixml text
|
355
|
+
# @return [String] parsed clixml into String
|
356
|
+
def clixml_to_s(clixml)
|
357
|
+
doc = REXML::Document.new(clixml)
|
358
|
+
text = doc.get_elements("//S").map(&:text).join
|
359
|
+
text.gsub(/_x(\h\h\h\h)_/) do
|
360
|
+
code = Regexp.last_match[1]
|
361
|
+
code.hex.chr
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
351
365
|
# Parses response of a PowerShell script or CMD command which contains
|
352
366
|
# a CSV-formatted document in the standard output stream.
|
353
367
|
#
|
@@ -356,10 +370,24 @@ module WinRM
|
|
356
370
|
# @return [Hash] report hash, keyed by the local MD5 digest
|
357
371
|
# @api private
|
358
372
|
def parse_response(output)
|
359
|
-
|
373
|
+
exitcode = output[:exitcode]
|
374
|
+
stderr = output.stderr
|
375
|
+
if stderr.include?("The command line is too long")
|
376
|
+
# The powershell script which should result in `output` parameter
|
377
|
+
# is too long, remove some newlines, comments, etc from it.
|
378
|
+
raise StandardError, "The command line is too long" \
|
379
|
+
" (powershell script is too long)"
|
380
|
+
end
|
381
|
+
pretty_stderr = clixml_to_s(stderr)
|
382
|
+
|
383
|
+
if exitcode != 0
|
360
384
|
raise FileTransporterFailed, "[#{self.class}] Upload failed " \
|
361
|
-
"(exitcode: #{
|
385
|
+
"(exitcode: #{exitcode})\n#{pretty_stderr}"
|
386
|
+
elsif stderr != '\r\n' && stderr != ""
|
387
|
+
raise FileTransporterFailed, "[#{self.class}] Upload failed " \
|
388
|
+
"(exitcode: 0), but stderr present\n#{pretty_stderr}"
|
362
389
|
end
|
390
|
+
|
363
391
|
array = CSV.parse(output.stdout, :headers => true).map(&:to_hash)
|
364
392
|
array.each { |h| h.each { |key, value| h[key] = nil if value == "" } }
|
365
393
|
Hash[array.map { |entry| [entry.fetch("src_md5"), entry] }]
|
data/support/decode_files.ps1
CHANGED
@@ -1,50 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
trap {$e = $_.Exception; $e.InvocationInfo.ScriptName; do {$e.Message; $e = $e.InnerException} while ($e); break;}
|
2
|
+
$progresspreference = 'SilentlyContinue'
|
3
|
+
function Decode-Base64File($src, $dst) {folder (split-path $dst);sc -force -Encoding Byte -Path $dst -Value ([Convert]::FromBase64String([IO.File]::ReadAllLines($src)))}
|
4
|
+
function Copy-Stream($src, $dst) {$b = New-Object Byte[] 4096; while (($i = $src.Read($b, 0, $b.Length)) -ne 0) { $dst.Write($b, 0, $i) } }
|
4
5
|
function Resolve-ProviderPath{ $input | % {if ($_){(Resolve-Path $_).ProviderPath} else{$null}} }
|
5
|
-
|
6
|
-
function Test-NETStack($Version
|
6
|
+
function Get-FrameworkVersion { "Full", "Client" | % {([version](gp "HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\$_").Version)} | select -first 1}
|
7
|
+
function Test-NETStack($Version){ Get-FrameworkVersion -ge $Version }
|
7
8
|
function Test-IOCompression {($PSVersionTable.PSVersion.Major -ge 3) -and (Test-NETStack '4.5')}
|
9
|
+
function folder($path){ $path | ? {-not (test-path $_)} | % {$null = mkdir $_}}
|
10
|
+
function disposable($o){($o -is [IDisposable]) -and (($o | gm | %{$_.name}) -contains 'Dispose')}
|
11
|
+
function use($obj, [scriptblock]$sb){try {& $sb} catch [exception]{throw $_} finally {if (disposable $obj) {$obj.Dispose()}} }
|
8
12
|
set-alias RPP -Value Resolve-ProviderPath
|
9
13
|
|
10
14
|
Function Decode-Files($hash) {
|
11
15
|
foreach ($key in $hash.keys) {
|
12
16
|
$value = $hash[$key]
|
13
17
|
$tmp, $tzip, $dst = $Key, $Value["tmpzip"], $Value["dst"]
|
14
|
-
$sMd5 = (
|
18
|
+
$sMd5 = (gi $tmp).BaseName.Replace("b64-", "")
|
15
19
|
$decoded = if ($tzip -ne $null) { $tzip } else { $dst }
|
16
20
|
Decode-Base64File $tmp $decoded
|
17
|
-
|
21
|
+
rm $tmp -Force
|
18
22
|
$dMd5 = Get-MD5Sum $decoded
|
19
23
|
$verifies = $sMd5 -like $dMd5
|
20
|
-
if ($tzip) {Unzip-File $tzip $dst;
|
21
|
-
New-Object psobject -Property @{
|
24
|
+
if ($tzip) {Unzip-File $tzip $dst;rm $tzip -Force}
|
25
|
+
New-Object psobject -Property @{dst=$dst;verifies=$verifies;src_md5=$sMd5;dst_md5=$dMd5;tmpfile=$tmp;tmpzip=$tzip}
|
22
26
|
}
|
23
27
|
}
|
24
28
|
|
25
29
|
Function Get-MD5Sum($src) {
|
26
|
-
|
27
|
-
|
28
|
-
$
|
29
|
-
|
30
|
-
} catch [exception]{throw $_} finally { Cleanup $c; Cleanup $in }
|
30
|
+
if ($src -and (test-path $src)) {
|
31
|
+
use ($c = New-Object -TypeName Security.Cryptography.MD5CryptoServiceProvider) {
|
32
|
+
use ($in = (gi $src).OpenRead()) {([BitConverter]::ToString($c.ComputeHash($in))).Replace("-", "").ToLower()}}
|
33
|
+
}
|
31
34
|
}
|
32
35
|
|
33
36
|
Function Invoke-Input($in) {
|
34
37
|
$in = $in | rpp
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
$d = "$($in).ps1"
|
39
|
+
Decode-Base64File $in $d
|
40
|
+
$expr = gc $d | Out-String
|
41
|
+
rm $in,$d -Force
|
42
|
+
iex "$expr"
|
39
43
|
}
|
40
44
|
|
41
45
|
Function Unzip-File($src, $dst) {
|
42
46
|
$unpack = $src -replace '\.zip'
|
47
|
+
folder $unpack, $dst
|
43
48
|
if (Test-IOCompression) {Add-Type -AN System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory($src, $unpack)}
|
44
|
-
else {
|
45
|
-
Try {$s = New-Object -ComObject Shell.Application; ($dp = $s.NameSpace($unpack)).CopyHere(($z = $s.NameSpace($src)).Items(), 0x610)} Finally {Release-Com $s; Release-Com $z; Release-COM $dp}
|
46
|
-
}
|
47
|
-
if (-not (test-path $dst)) {$null = mkdir $dst }
|
49
|
+
else {Try {$s = New-Object -ComObject Shell.Application; ($s.NameSpace($unpack)).CopyHere(($s.NameSpace($src)).Items(), 0x610)} Finally {[void][Runtime.Interopservices.Marshal]::ReleaseComObject($s)}}
|
48
50
|
dir $unpack | cp -dest "$dst/" -force -recurse
|
49
51
|
rm $unpack -recurse -force
|
50
52
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winrm-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fletcher Nichol
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|