winrm-transport 1.0.2 → 1.0.3
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 +4 -4
- data/.cane +2 -2
- data/.gitignore +15 -15
- data/.travis.yml +26 -26
- data/CHANGELOG.md +44 -38
- data/Gemfile +13 -13
- data/Guardfile +27 -27
- data/LICENSE.txt +15 -15
- data/README.md +80 -80
- data/Rakefile +49 -49
- data/bin/console +7 -7
- data/bin/setup +7 -7
- data/lib/winrm/transport.rb +28 -28
- data/lib/winrm/transport/command_executor.rb +217 -217
- data/lib/winrm/transport/file_transporter.rb +498 -498
- data/lib/winrm/transport/logging.rb +47 -47
- data/lib/winrm/transport/shell_closer.rb +71 -71
- data/lib/winrm/transport/tmp_zip.rb +184 -184
- data/lib/winrm/transport/version.rb +25 -25
- data/support/check_files.ps1 +47 -46
- data/support/decode_files.ps1 +52 -52
- data/winrm-transport.gemspec +51 -51
- metadata +3 -3
@@ -1,25 +1,25 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2015, Fletcher Nichol
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
module WinRM
|
20
|
-
|
21
|
-
module Transport
|
22
|
-
|
23
|
-
VERSION = "1.0.
|
24
|
-
end
|
25
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2015, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
module WinRM
|
20
|
+
|
21
|
+
module Transport
|
22
|
+
|
23
|
+
VERSION = "1.0.3"
|
24
|
+
end
|
25
|
+
end
|
data/support/check_files.ps1
CHANGED
@@ -1,46 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
$
|
7
|
-
$
|
8
|
-
$
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
1
|
+
$progresspreference = 'silentlycontinue'
|
2
|
+
Function Cleanup($o) { if (($o -ne $null) -and ($o.GetType().GetMethod("Dispose") -ne $null)) { $o.Dispose() } }
|
3
|
+
|
4
|
+
Function Decode-Base64File($src, $dst) {
|
5
|
+
Try {
|
6
|
+
$in = (Get-Item $src).OpenRead()
|
7
|
+
$b64 = New-Object -TypeName System.Security.Cryptography.FromBase64Transform
|
8
|
+
$m = [System.Security.Cryptography.CryptoStreamMode]::Read
|
9
|
+
$d = New-Object -TypeName System.Security.Cryptography.CryptoStream $in,$b64,$m
|
10
|
+
Copy-Stream $d ($out = [System.IO.File]::OpenWrite($dst))
|
11
|
+
} Finally { Cleanup $in; Cleanup $out; Cleanup $d }
|
12
|
+
}
|
13
|
+
|
14
|
+
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) } }
|
15
|
+
|
16
|
+
Function Check-Files($h) {
|
17
|
+
return $h.GetEnumerator() | ForEach-Object {
|
18
|
+
$dst = Unresolve-Path $_.Key
|
19
|
+
New-Object psobject -Property @{
|
20
|
+
chk_exists = ($exists = Test-Path $dst -PathType Leaf)
|
21
|
+
src_md5 = ($sMd5 = $_.Value)
|
22
|
+
dst_md5 = ($dMd5 = if ($exists) { Get-MD5Sum $dst } else { $null })
|
23
|
+
chk_dirty = ($dirty = if ($sMd5 -ne $dMd5) { $true } else { $false })
|
24
|
+
verifies = if ($dirty -eq $false) { $true } else { $false }
|
25
|
+
}
|
26
|
+
} | Select-Object -Property chk_exists,src_md5,dst_md5,chk_dirty,verifies
|
27
|
+
}
|
28
|
+
|
29
|
+
Function Get-MD5Sum($src) {
|
30
|
+
Try {
|
31
|
+
$c = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider
|
32
|
+
$bytes = $c.ComputeHash(($in = (Get-Item $src).OpenRead()))
|
33
|
+
return ([System.BitConverter]::ToString($bytes)).Replace("-", "").ToLower()
|
34
|
+
} Finally { Cleanup $c; Cleanup $in }
|
35
|
+
}
|
36
|
+
|
37
|
+
Function Invoke-Input($in) {
|
38
|
+
$in = Unresolve-Path $in
|
39
|
+
Decode-Base64File $in ($decoded = "$($in).ps1")
|
40
|
+
$expr = Get-Content $decoded | Out-String
|
41
|
+
Remove-Item $in,$decoded -Force
|
42
|
+
return Invoke-Expression "$expr"
|
43
|
+
}
|
44
|
+
|
45
|
+
Function Unresolve-Path($p) { if ($p -eq $null) { return $null } else { return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($p) } }
|
46
|
+
|
47
|
+
Check-Files (Invoke-Input $hash_file) | ConvertTo-Csv -NoTypeInformation
|
data/support/decode_files.ps1
CHANGED
@@ -1,52 +1,52 @@
|
|
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) } }
|
5
|
-
function Resolve-ProviderPath{ $input | % {if ($_){(Resolve-Path $_).ProviderPath} else{$null}} }
|
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 }
|
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()}} }
|
12
|
-
set-alias RPP -Value Resolve-ProviderPath
|
13
|
-
|
14
|
-
Function Decode-Files($hash) {
|
15
|
-
foreach ($key in $hash.keys) {
|
16
|
-
$value = $hash[$key]
|
17
|
-
$tmp, $tzip, $dst = $Key, $Value["tmpzip"], $Value["dst"]
|
18
|
-
$sMd5 = (gi $tmp).BaseName.Replace("b64-", "")
|
19
|
-
$decoded = if ($tzip -ne $null) { $tzip } else { $dst }
|
20
|
-
Decode-Base64File $tmp $decoded
|
21
|
-
rm $tmp -Force
|
22
|
-
$dMd5 = Get-MD5Sum $decoded
|
23
|
-
$verifies = $sMd5 -like $dMd5
|
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}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
Function Get-MD5Sum($src) {
|
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
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
Function Invoke-Input($in) {
|
37
|
-
$in = $in | rpp
|
38
|
-
$d = "$($in).ps1"
|
39
|
-
Decode-Base64File $in $d
|
40
|
-
$expr = gc $d | Out-String
|
41
|
-
rm $in,$d -Force
|
42
|
-
iex "$expr"
|
43
|
-
}
|
44
|
-
|
45
|
-
Function Unzip-File($src, $dst) {
|
46
|
-
$unpack = $src -replace '\.zip'
|
47
|
-
folder $unpack, $dst
|
48
|
-
if (Test-IOCompression) {Add-Type -AN System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory($src, $unpack)}
|
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)}}
|
50
|
-
dir $unpack | cp -dest "$dst/" -force -recurse
|
51
|
-
rm $unpack -recurse -force
|
52
|
-
}
|
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) } }
|
5
|
+
function Resolve-ProviderPath{ $input | % {if ($_){(Resolve-Path $_).ProviderPath} else{$null}} }
|
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 }
|
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()}} }
|
12
|
+
set-alias RPP -Value Resolve-ProviderPath
|
13
|
+
|
14
|
+
Function Decode-Files($hash) {
|
15
|
+
foreach ($key in $hash.keys) {
|
16
|
+
$value = $hash[$key]
|
17
|
+
$tmp, $tzip, $dst = $Key, $Value["tmpzip"], $Value["dst"]
|
18
|
+
$sMd5 = (gi $tmp).BaseName.Replace("b64-", "")
|
19
|
+
$decoded = if ($tzip -ne $null) { $tzip } else { $dst }
|
20
|
+
Decode-Base64File $tmp $decoded
|
21
|
+
rm $tmp -Force
|
22
|
+
$dMd5 = Get-MD5Sum $decoded
|
23
|
+
$verifies = $sMd5 -like $dMd5
|
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}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
Function Get-MD5Sum($src) {
|
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
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
Function Invoke-Input($in) {
|
37
|
+
$in = $in | rpp
|
38
|
+
$d = "$($in).ps1"
|
39
|
+
Decode-Base64File $in $d
|
40
|
+
$expr = gc $d | Out-String
|
41
|
+
rm $in,$d -Force
|
42
|
+
iex "$expr"
|
43
|
+
}
|
44
|
+
|
45
|
+
Function Unzip-File($src, $dst) {
|
46
|
+
$unpack = $src -replace '\.zip'
|
47
|
+
folder $unpack, $dst
|
48
|
+
if (Test-IOCompression) {Add-Type -AN System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::ExtractToDirectory($src, $unpack)}
|
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)}}
|
50
|
+
dir $unpack | cp -dest "$dst/" -force -recurse
|
51
|
+
rm $unpack -recurse -force
|
52
|
+
}
|
data/winrm-transport.gemspec
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "winrm/transport/version"
|
5
|
-
require "English"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "winrm-transport"
|
9
|
-
spec.version = WinRM::Transport::VERSION
|
10
|
-
spec.authors = ["Fletcher Nichol"]
|
11
|
-
spec.email = ["fnichol@nichol.ca"]
|
12
|
-
|
13
|
-
spec.summary = "WinRM transport logic for re-using remote shells " \
|
14
|
-
"and uploading files. The original code was extracted " \
|
15
|
-
"from the Test Kitchen project and remains the " \
|
16
|
-
"primary reference use case."
|
17
|
-
|
18
|
-
spec.description = spec.summary
|
19
|
-
spec.homepage = "https://github.com/test-kitchen/winrm-transport"
|
20
|
-
spec.license = "Apache 2.0"
|
21
|
-
|
22
|
-
spec.files = `git ls-files -z`.split("\x0").
|
23
|
-
reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
-
|
25
|
-
spec.bindir = "exe"
|
26
|
-
spec.executables = []
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
-
|
29
|
-
spec.required_ruby_version = ">= 1.9.1"
|
30
|
-
|
31
|
-
spec.add_dependency "winrm", "~> 1.3"
|
32
|
-
spec.add_dependency "rubyzip", ">= 1.1.7", "~> 1.1"
|
33
|
-
|
34
|
-
spec.add_development_dependency "pry"
|
35
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
36
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
-
|
38
|
-
spec.add_development_dependency "minitest"
|
39
|
-
spec.add_development_dependency "mocha", "~> 1.1"
|
40
|
-
|
41
|
-
spec.add_development_dependency "countloc", "~> 0.4"
|
42
|
-
spec.add_development_dependency "maruku", "~> 0.6"
|
43
|
-
spec.add_development_dependency "simplecov", "~> 0.7"
|
44
|
-
spec.add_development_dependency "yard", "~> 0.8"
|
45
|
-
|
46
|
-
# style and complexity libraries are tightly version pinned as newer releases
|
47
|
-
# may introduce new and undesireable style choices which would be immediately
|
48
|
-
# enforced in CI
|
49
|
-
spec.add_development_dependency "finstyle", "1.4.0"
|
50
|
-
spec.add_development_dependency "cane", "2.6.2"
|
51
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "winrm/transport/version"
|
5
|
+
require "English"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "winrm-transport"
|
9
|
+
spec.version = WinRM::Transport::VERSION
|
10
|
+
spec.authors = ["Fletcher Nichol"]
|
11
|
+
spec.email = ["fnichol@nichol.ca"]
|
12
|
+
|
13
|
+
spec.summary = "WinRM transport logic for re-using remote shells " \
|
14
|
+
"and uploading files. The original code was extracted " \
|
15
|
+
"from the Test Kitchen project and remains the " \
|
16
|
+
"primary reference use case."
|
17
|
+
|
18
|
+
spec.description = spec.summary
|
19
|
+
spec.homepage = "https://github.com/test-kitchen/winrm-transport"
|
20
|
+
spec.license = "Apache 2.0"
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").
|
23
|
+
reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = []
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.required_ruby_version = ">= 1.9.1"
|
30
|
+
|
31
|
+
spec.add_dependency "winrm", "~> 1.3"
|
32
|
+
spec.add_dependency "rubyzip", ">= 1.1.7", "~> 1.1"
|
33
|
+
|
34
|
+
spec.add_development_dependency "pry"
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
|
38
|
+
spec.add_development_dependency "minitest"
|
39
|
+
spec.add_development_dependency "mocha", "~> 1.1"
|
40
|
+
|
41
|
+
spec.add_development_dependency "countloc", "~> 0.4"
|
42
|
+
spec.add_development_dependency "maruku", "~> 0.6"
|
43
|
+
spec.add_development_dependency "simplecov", "~> 0.7"
|
44
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
45
|
+
|
46
|
+
# style and complexity libraries are tightly version pinned as newer releases
|
47
|
+
# may introduce new and undesireable style choices which would be immediately
|
48
|
+
# enforced in CI
|
49
|
+
spec.add_development_dependency "finstyle", "1.4.0"
|
50
|
+
spec.add_development_dependency "cane", "2.6.2"
|
51
|
+
end
|
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.3
|
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-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: winrm
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
version: '0'
|
249
249
|
requirements: []
|
250
250
|
rubyforge_project:
|
251
|
-
rubygems_version: 2.4.
|
251
|
+
rubygems_version: 2.4.8
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: WinRM transport logic for re-using remote shells and uploading files. The
|