winrm-fs 1.3.4 → 1.3.7
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/README.md +15 -9
- data/bin/rwinrmcp +0 -0
- data/lib/winrm-fs/core/file_transporter.rb +11 -5
- data/lib/winrm-fs/core/tmp_zip.rb +8 -13
- data/lib/winrm-fs/file_manager.rb +21 -8
- data/lib/winrm-fs/scripts/scripts.rb +2 -2
- data/lib/winrm-fs.rb +2 -3
- metadata +31 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85111e8743dcffa4aafcf63f815eff675bda56e951ff83c0f7e63d7b97e4b25c
|
|
4
|
+
data.tar.gz: 29c072897a7d7372391d64446e1f7256d60e02a9846914f0b6decb497343b7c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 658a0ee64bfb237dc03e31e6e2b25db8d90cf692452d82fe3c25fe09d41ab568611d588c6830b9a6496d582181b5221e9689994a5b4ce51af024188bdfa6c4ea
|
|
7
|
+
data.tar.gz: 4adf7ef9cd6ae186f402b0f8b8e29b09d37e5f325e0b9aa648a2ca4f2eb0c399793fab4e13c6866ba087fb464db09108bffef8fa0d7ebc0b368b57f7ce0727a6
|
data/README.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# File system operations over Windows Remote Management (WinRM) for Ruby
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
[](https://github.com/WinRb/winrm-fs/actions/workflows/ci.yml)
|
|
3
4
|
[](http://badge.fury.io/rb/winrm-fs)
|
|
4
|
-
[](https://ci.appveyor.com/project/winrb/winrm-fs)
|
|
5
5
|
|
|
6
6
|
## Uploading files
|
|
7
|
+
|
|
7
8
|
Files may be copied from the local machine to the winrm endpoint. Individual files or directories, as well as arrays of files and directories may be specified. Data from a `StringIO` object may also be uploaded to a remote file.
|
|
9
|
+
|
|
8
10
|
```ruby
|
|
9
11
|
require 'winrm-fs'
|
|
10
12
|
|
|
11
|
-
connection = WinRM::Connection.new(...
|
|
13
|
+
connection = WinRM::Connection.new(...)
|
|
12
14
|
file_manager = WinRM::FS::FileManager.new(connection)
|
|
13
15
|
|
|
14
16
|
# upload file.txt from the current working directory
|
|
@@ -29,11 +31,14 @@ file_manager.upload([
|
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
### Optimizing WinRM settings
|
|
34
|
+
|
|
32
35
|
Since winrm-fs 1.0/winrm 2.0, files are uploaded using the PSRP protocol and transfer speeds are dramatically improved from previous versions. This is largely due to the fact that the size of chunks that can be transferred at one time are now governed by the `MaxEnvelopeSizekb` winrm configuration setting on the endpoint. This default to 500 on Windows 2012 R2 and 150 on Windows 2008 R2. You may experience much faster transfer rates on 2008 R2 by increasing this setting.
|
|
33
36
|
|
|
34
37
|
### Handling progress events
|
|
38
|
+
|
|
35
39
|
If you want to implement your own custom progress handling, you can pass a code
|
|
36
|
-
block and use the
|
|
40
|
+
block and use the progress data that `upload` yields to this block:
|
|
41
|
+
|
|
37
42
|
```ruby
|
|
38
43
|
file_manager.upload('c:/dev/my_dir', '$env:AppData') do |bytes_copied, total_bytes, local_path, remote_path|
|
|
39
44
|
puts "#{bytes_copied}bytes of #{total_bytes}bytes copied"
|
|
@@ -53,20 +58,20 @@ first.
|
|
|
53
58
|
3. Run the unit and integration tests (bundle exec rake integration)
|
|
54
59
|
4. Commit your changes (git commit -am "Added a sweet feature")
|
|
55
60
|
5. Push to the branch (git push origin my_feature_branch)
|
|
56
|
-
6. Create a pull
|
|
61
|
+
6. Create a pull request from your branch into main (Please be sure to provide enough detail for us to cipher what this change is doing)
|
|
57
62
|
|
|
58
63
|
### Running the tests
|
|
59
64
|
|
|
60
65
|
We use Bundler to manage dependencies during development.
|
|
61
66
|
|
|
62
|
-
```
|
|
63
|
-
|
|
67
|
+
```bash
|
|
68
|
+
bundle install
|
|
64
69
|
```
|
|
65
70
|
|
|
66
71
|
Once you have the dependencies, you can run the unit tests with `rake`:
|
|
67
72
|
|
|
68
|
-
```
|
|
69
|
-
|
|
73
|
+
```bash
|
|
74
|
+
bundle exec rake spec
|
|
70
75
|
```
|
|
71
76
|
|
|
72
77
|
To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use the Vagrant Windows box in the Vagrantilfe of this repo.
|
|
@@ -76,6 +81,7 @@ To run the integration tests you will need a Windows box with the WinRM service
|
|
|
76
81
|
3. Run `bundle exec rake integration`
|
|
77
82
|
|
|
78
83
|
## WinRM-fs Authors
|
|
84
|
+
|
|
79
85
|
* Shawn Neal (https://github.com/sneal)
|
|
80
86
|
* Matt Wrock (https://github.com/mwrock)
|
|
81
87
|
|
data/bin/rwinrmcp
CHANGED
|
File without changes
|
|
@@ -17,11 +17,10 @@
|
|
|
17
17
|
# See the License for the specific language governing permissions and
|
|
18
18
|
# limitations under the License.
|
|
19
19
|
|
|
20
|
-
require 'benchmark'
|
|
21
|
-
require '
|
|
22
|
-
require '
|
|
23
|
-
require '
|
|
24
|
-
require 'stringio'
|
|
20
|
+
require 'benchmark' unless defined?(Benchmark)
|
|
21
|
+
require 'digest' unless defined?(Digest)
|
|
22
|
+
require 'securerandom' unless defined?(SecureRandom)
|
|
23
|
+
require 'stringio' unless defined?(StringIO)
|
|
25
24
|
|
|
26
25
|
require 'winrm/exceptions'
|
|
27
26
|
require 'winrm-fs/core/tmp_zip'
|
|
@@ -67,6 +66,7 @@ module WinRM
|
|
|
67
66
|
@shell = shell
|
|
68
67
|
@logger = shell.logger
|
|
69
68
|
@id_generator = opts.fetch(:id_generator) { -> { SecureRandom.uuid } }
|
|
69
|
+
require 'zip'
|
|
70
70
|
Zip.unicode_names = true
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -117,6 +117,10 @@ module WinRM
|
|
|
117
117
|
[total_size, files]
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
def close
|
|
121
|
+
shell.close
|
|
122
|
+
end
|
|
123
|
+
|
|
120
124
|
private
|
|
121
125
|
|
|
122
126
|
# @return [String] the Array pack template for Base64 encoding a stream
|
|
@@ -405,6 +409,8 @@ module WinRM
|
|
|
405
409
|
"(exitcode: 0), but stderr present\n#{stderr}"
|
|
406
410
|
end
|
|
407
411
|
|
|
412
|
+
require 'csv'
|
|
413
|
+
|
|
408
414
|
logger.debug 'Parsing CSV Response'
|
|
409
415
|
logger.debug output.stdout
|
|
410
416
|
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
# limitations under the License.
|
|
19
19
|
|
|
20
20
|
require 'delegate'
|
|
21
|
-
require '
|
|
22
|
-
require '
|
|
23
|
-
require '
|
|
21
|
+
require 'logger' unless defined?(Logger)
|
|
22
|
+
require 'pathname' unless defined?(Pathname)
|
|
23
|
+
require 'tempfile' unless defined?(Tempfile)
|
|
24
24
|
|
|
25
25
|
module WinRM
|
|
26
26
|
module FS
|
|
@@ -68,7 +68,8 @@ module WinRM
|
|
|
68
68
|
# @param logger [#debug,#debug?] an optional logger/ui object that
|
|
69
69
|
# responds to `#debug` and `#debug?` (default `nil`)
|
|
70
70
|
def initialize(dir, logger = nil)
|
|
71
|
-
|
|
71
|
+
require 'zip'
|
|
72
|
+
@logger = logger || Logger.new(nil)
|
|
72
73
|
@dir = clean_dirname(dir)
|
|
73
74
|
@zip_io = Tempfile.open(['tmpzip-', '.zip'], binmode: true)
|
|
74
75
|
write_zip
|
|
@@ -113,13 +114,7 @@ module WinRM
|
|
|
113
114
|
# directory, excluding directories
|
|
114
115
|
# @api private
|
|
115
116
|
def entries
|
|
116
|
-
Pathname.glob(dir.join('**/*')).delete_if(&:directory?).sort
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# (see Logging.log_subject)
|
|
120
|
-
# @api private
|
|
121
|
-
def log_subject
|
|
122
|
-
@log_subject ||= [self.class.to_s.split('::').last, path].join('::')
|
|
117
|
+
Pathname.glob(dir.join('**/.*')).push(*Pathname.glob(dir.join('**/*'))).delete_if(&:directory?).sort
|
|
123
118
|
end
|
|
124
119
|
|
|
125
120
|
# Adds all file entries to the Zip output stream.
|
|
@@ -149,12 +144,12 @@ module WinRM
|
|
|
149
144
|
end
|
|
150
145
|
end
|
|
151
146
|
|
|
147
|
+
# rubyzip 3.x takes optional Entry arguments as keywords
|
|
152
148
|
def zip_entry(entry_path)
|
|
153
149
|
Zip::Entry.new(
|
|
154
150
|
zip_io.path,
|
|
155
151
|
entry_path.to_s,
|
|
156
|
-
|
|
157
|
-
::Zip::DOSTime.new(2000)
|
|
152
|
+
time: ::Zip::DOSTime.new(2000)
|
|
158
153
|
)
|
|
159
154
|
end
|
|
160
155
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
|
-
require 'winrm'
|
|
18
|
+
require 'winrm' unless defined?(WinRM::Connection)
|
|
19
19
|
require_relative 'scripts/scripts'
|
|
20
20
|
require_relative 'core/file_transporter'
|
|
21
21
|
|
|
@@ -37,7 +37,7 @@ module WinRM
|
|
|
37
37
|
def checksum(path, digest = 'SHA1')
|
|
38
38
|
@logger.debug("checksum with #{digest}: #{path}")
|
|
39
39
|
script = WinRM::FS::Scripts.render('checksum', path: path, digest: digest)
|
|
40
|
-
|
|
40
|
+
ps_run(script).exitcode == 0
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# Create the specifed directory recursively
|
|
@@ -46,7 +46,7 @@ module WinRM
|
|
|
46
46
|
def create_dir(path)
|
|
47
47
|
@logger.debug("create_dir: #{path}")
|
|
48
48
|
script = WinRM::FS::Scripts.render('create_dir', path: path)
|
|
49
|
-
|
|
49
|
+
ps_run(script).exitcode == 0
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# Deletes the file or directory at the specified path
|
|
@@ -55,7 +55,7 @@ module WinRM
|
|
|
55
55
|
def delete(path)
|
|
56
56
|
@logger.debug("deleting: #{path}")
|
|
57
57
|
script = WinRM::FS::Scripts.render('delete', path: path)
|
|
58
|
-
|
|
58
|
+
ps_run(script).exitcode == 0
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# Downloads the specified remote file to the specified local path
|
|
@@ -87,7 +87,7 @@ module WinRM
|
|
|
87
87
|
|
|
88
88
|
def _output_from_file(remote_path, chunk_size, index)
|
|
89
89
|
script = WinRM::FS::Scripts.render('download', path: remote_path, chunk_size: chunk_size, index: index)
|
|
90
|
-
|
|
90
|
+
ps_run(script)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def _write_file(tofd, output)
|
|
@@ -106,7 +106,7 @@ module WinRM
|
|
|
106
106
|
def exists?(path)
|
|
107
107
|
@logger.debug("exists?: #{path}")
|
|
108
108
|
script = WinRM::FS::Scripts.render('exists', path: path)
|
|
109
|
-
|
|
109
|
+
ps_run(script).exitcode == 0
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
# Gets the current user's TEMP directory on the remote system, for example
|
|
@@ -114,7 +114,7 @@ module WinRM
|
|
|
114
114
|
# @return [String] Full path to the temp directory
|
|
115
115
|
def temp_dir
|
|
116
116
|
@temp_dir ||= begin
|
|
117
|
-
(
|
|
117
|
+
ps_run('$env:TEMP').stdout.chomp.tr('\\', '/')
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -139,12 +139,25 @@ module WinRM
|
|
|
139
139
|
def upload(local_path, remote_path, &block)
|
|
140
140
|
@connection.shell(:powershell) do |shell|
|
|
141
141
|
file_transporter ||= WinRM::FS::Core::FileTransporter.new(shell)
|
|
142
|
-
|
|
142
|
+
begin
|
|
143
|
+
file_transporter.upload(local_path, remote_path, &block)[0]
|
|
144
|
+
ensure
|
|
145
|
+
file_transporter.close
|
|
146
|
+
end
|
|
143
147
|
end
|
|
144
148
|
end
|
|
145
149
|
|
|
146
150
|
private
|
|
147
151
|
|
|
152
|
+
def ps_run(cmd)
|
|
153
|
+
shell = @connection.shell(:powershell)
|
|
154
|
+
begin
|
|
155
|
+
shell.run(cmd)
|
|
156
|
+
ensure
|
|
157
|
+
shell.close
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
148
161
|
def download_dir(remote_path, local_path, chunk_size, first)
|
|
149
162
|
local_path = File.join(local_path, File.basename(remote_path.to_s)) if first
|
|
150
163
|
FileUtils.mkdir_p(local_path) unless File.directory?(local_path)
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
|
-
require '
|
|
18
|
+
require 'erb'
|
|
19
19
|
|
|
20
20
|
module WinRM
|
|
21
21
|
module FS
|
|
@@ -40,7 +40,7 @@ module WinRM
|
|
|
40
40
|
else
|
|
41
41
|
raise ArgumentError
|
|
42
42
|
end
|
|
43
|
-
|
|
43
|
+
ERB.new(template).result(b)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
data/lib/winrm-fs.rb
CHANGED
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
# See the License for the specific language governing permissions and
|
|
16
16
|
# limitations under the License.
|
|
17
17
|
|
|
18
|
-
require 'winrm'
|
|
19
|
-
require '
|
|
20
|
-
require 'pathname'
|
|
18
|
+
require 'winrm' unless defined?(WinRM::Connection)
|
|
19
|
+
require 'pathname' unless defined?(Pathname)
|
|
21
20
|
require_relative 'winrm-fs/exceptions'
|
|
22
21
|
require_relative 'winrm-fs/file_manager'
|
|
23
22
|
|
metadata
CHANGED
|
@@ -1,64 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: winrm-fs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shawn Neal
|
|
8
8
|
- Matt Wrock
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2026-09-14 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
14
|
+
name: benchmark
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: csv
|
|
16
29
|
requirement: !ruby/object:Gem::Requirement
|
|
17
30
|
requirements:
|
|
18
31
|
- - "~>"
|
|
19
32
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
33
|
+
version: '3.3'
|
|
21
34
|
type: :runtime
|
|
22
35
|
prerelease: false
|
|
23
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
37
|
requirements:
|
|
25
38
|
- - "~>"
|
|
26
39
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
40
|
+
version: '3.3'
|
|
28
41
|
- !ruby/object:Gem::Dependency
|
|
29
|
-
name:
|
|
42
|
+
name: logger
|
|
30
43
|
requirement: !ruby/object:Gem::Requirement
|
|
31
44
|
requirements:
|
|
32
45
|
- - ">="
|
|
33
46
|
- !ruby/object:Gem::Version
|
|
34
|
-
version:
|
|
35
|
-
- - "<"
|
|
36
|
-
- !ruby/object:Gem::Version
|
|
37
|
-
version: '3.0'
|
|
47
|
+
version: '0'
|
|
38
48
|
type: :runtime
|
|
39
49
|
prerelease: false
|
|
40
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
51
|
requirements:
|
|
42
52
|
- - ">="
|
|
43
53
|
- !ruby/object:Gem::Version
|
|
44
|
-
version:
|
|
45
|
-
- - "<"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
54
|
+
version: '0'
|
|
48
55
|
- !ruby/object:Gem::Dependency
|
|
49
56
|
name: rubyzip
|
|
50
57
|
requirement: !ruby/object:Gem::Requirement
|
|
51
58
|
requirements:
|
|
52
59
|
- - "~>"
|
|
53
60
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
61
|
+
version: '3.4'
|
|
55
62
|
type: :runtime
|
|
56
63
|
prerelease: false
|
|
57
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
65
|
requirements:
|
|
59
66
|
- - "~>"
|
|
60
67
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
68
|
+
version: '3.4'
|
|
62
69
|
- !ruby/object:Gem::Dependency
|
|
63
70
|
name: winrm
|
|
64
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,7 +103,7 @@ dependencies:
|
|
|
96
103
|
version: '10.3'
|
|
97
104
|
- - "<"
|
|
98
105
|
- !ruby/object:Gem::Version
|
|
99
|
-
version: '
|
|
106
|
+
version: '14'
|
|
100
107
|
type: :development
|
|
101
108
|
prerelease: false
|
|
102
109
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -106,7 +113,7 @@ dependencies:
|
|
|
106
113
|
version: '10.3'
|
|
107
114
|
- - "<"
|
|
108
115
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '
|
|
116
|
+
version: '14'
|
|
110
117
|
- !ruby/object:Gem::Dependency
|
|
111
118
|
name: rspec
|
|
112
119
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -127,14 +134,14 @@ dependencies:
|
|
|
127
134
|
requirements:
|
|
128
135
|
- - "~>"
|
|
129
136
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
137
|
+
version: 1.26.0
|
|
131
138
|
type: :development
|
|
132
139
|
prerelease: false
|
|
133
140
|
version_requirements: !ruby/object:Gem::Requirement
|
|
134
141
|
requirements:
|
|
135
142
|
- - "~>"
|
|
136
143
|
- !ruby/object:Gem::Version
|
|
137
|
-
version:
|
|
144
|
+
version: 1.26.0
|
|
138
145
|
description: " Ruby library for file system operations via Windows Remote Management\n"
|
|
139
146
|
email:
|
|
140
147
|
- sneal@sneal.net
|
|
@@ -143,8 +150,8 @@ executables:
|
|
|
143
150
|
- rwinrmcp
|
|
144
151
|
extensions: []
|
|
145
152
|
extra_rdoc_files:
|
|
146
|
-
- README.md
|
|
147
153
|
- LICENSE
|
|
154
|
+
- README.md
|
|
148
155
|
files:
|
|
149
156
|
- LICENSE
|
|
150
157
|
- README.md
|
|
@@ -166,7 +173,6 @@ homepage: http://github.com/WinRb/winrm-fs
|
|
|
166
173
|
licenses:
|
|
167
174
|
- Apache-2.0
|
|
168
175
|
metadata: {}
|
|
169
|
-
post_install_message:
|
|
170
176
|
rdoc_options:
|
|
171
177
|
- "-x"
|
|
172
178
|
- test/
|
|
@@ -178,16 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
178
184
|
requirements:
|
|
179
185
|
- - ">="
|
|
180
186
|
- !ruby/object:Gem::Version
|
|
181
|
-
version: 2.
|
|
187
|
+
version: 2.5.0
|
|
182
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
189
|
requirements:
|
|
184
190
|
- - ">="
|
|
185
191
|
- !ruby/object:Gem::Version
|
|
186
192
|
version: '0'
|
|
187
193
|
requirements: []
|
|
188
|
-
|
|
189
|
-
rubygems_version: 2.7.8
|
|
190
|
-
signing_key:
|
|
194
|
+
rubygems_version: 3.6.9
|
|
191
195
|
specification_version: 4
|
|
192
196
|
summary: WinRM File System
|
|
193
197
|
test_files: []
|