winrm-elevated 1.1.0 → 1.2.2
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/LICENSE +202 -202
- data/README.md +99 -99
- data/lib/winrm-elevated.rb +17 -18
- data/lib/winrm-elevated/scripts/elevated_shell.ps1 +136 -116
- data/lib/winrm/shells/elevated.rb +101 -104
- metadata +37 -36
- data/.gitignore +0 -9
- data/.rspec +0 -3
- data/.rubocop.yml +0 -17
- data/.travis.yml +0 -10
- data/Gemfile +0 -9
- data/Rakefile +0 -28
- data/VERSION +0 -1
- data/appveyor.yml +0 -39
- data/changelog.md +0 -31
- data/spec/config-example.yml +0 -3
- data/spec/matchers.rb +0 -50
- data/spec/powershell_elevated_spec.rb +0 -87
- data/spec/spec_helper.rb +0 -58
- data/winrm-elevated.gemspec +0 -33
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: winrm-elevated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shawn Neal
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: erubi
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.8'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.8'
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: winrm
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,49 +53,55 @@ dependencies:
|
|
|
39
53
|
- !ruby/object:Gem::Version
|
|
40
54
|
version: '1.0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
56
|
+
name: rake
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
44
58
|
requirements:
|
|
45
|
-
- - "
|
|
59
|
+
- - ">="
|
|
46
60
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3
|
|
61
|
+
version: '10.3'
|
|
62
|
+
- - "<"
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '13'
|
|
48
65
|
type: :development
|
|
49
66
|
prerelease: false
|
|
50
67
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
68
|
requirements:
|
|
52
|
-
- - "
|
|
69
|
+
- - ">="
|
|
53
70
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3
|
|
71
|
+
version: '10.3'
|
|
72
|
+
- - "<"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '13'
|
|
55
75
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
76
|
+
name: rspec
|
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
|
58
78
|
requirements:
|
|
59
79
|
- - "~>"
|
|
60
80
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
81
|
+
version: '3.2'
|
|
62
82
|
type: :development
|
|
63
83
|
prerelease: false
|
|
64
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
85
|
requirements:
|
|
66
86
|
- - "~>"
|
|
67
87
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
88
|
+
version: '3.2'
|
|
69
89
|
- !ruby/object:Gem::Dependency
|
|
70
90
|
name: rubocop
|
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
|
72
92
|
requirements:
|
|
73
93
|
- - "~>"
|
|
74
94
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
95
|
+
version: 0.51.0
|
|
76
96
|
type: :development
|
|
77
97
|
prerelease: false
|
|
78
98
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
99
|
requirements:
|
|
80
100
|
- - "~>"
|
|
81
101
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
83
|
-
description:
|
|
84
|
-
|
|
102
|
+
version: 0.51.0
|
|
103
|
+
description: Ruby library for running commands via WinRM as elevated through a scheduled
|
|
104
|
+
task
|
|
85
105
|
email:
|
|
86
106
|
- sneal@sneal.net
|
|
87
107
|
executables: []
|
|
@@ -90,50 +110,31 @@ extra_rdoc_files:
|
|
|
90
110
|
- README.md
|
|
91
111
|
- LICENSE
|
|
92
112
|
files:
|
|
93
|
-
- ".gitignore"
|
|
94
|
-
- ".rspec"
|
|
95
|
-
- ".rubocop.yml"
|
|
96
|
-
- ".travis.yml"
|
|
97
|
-
- Gemfile
|
|
98
113
|
- LICENSE
|
|
99
114
|
- README.md
|
|
100
|
-
- Rakefile
|
|
101
|
-
- VERSION
|
|
102
|
-
- appveyor.yml
|
|
103
|
-
- changelog.md
|
|
104
115
|
- lib/winrm-elevated.rb
|
|
105
116
|
- lib/winrm-elevated/scripts/elevated_shell.ps1
|
|
106
117
|
- lib/winrm/shells/elevated.rb
|
|
107
|
-
- spec/config-example.yml
|
|
108
|
-
- spec/matchers.rb
|
|
109
|
-
- spec/powershell_elevated_spec.rb
|
|
110
|
-
- spec/spec_helper.rb
|
|
111
|
-
- winrm-elevated.gemspec
|
|
112
118
|
homepage: https://github.com/WinRb/winrm-elevated
|
|
113
119
|
licenses:
|
|
114
120
|
- Apache-2.0
|
|
115
121
|
metadata: {}
|
|
116
122
|
post_install_message:
|
|
117
|
-
rdoc_options:
|
|
118
|
-
- "-x"
|
|
119
|
-
- test/
|
|
120
|
-
- "-x"
|
|
121
|
-
- examples/
|
|
123
|
+
rdoc_options: []
|
|
122
124
|
require_paths:
|
|
123
125
|
- lib
|
|
124
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
127
|
requirements:
|
|
126
128
|
- - ">="
|
|
127
129
|
- !ruby/object:Gem::Version
|
|
128
|
-
version:
|
|
130
|
+
version: 2.3.0
|
|
129
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
132
|
requirements:
|
|
131
133
|
- - ">="
|
|
132
134
|
- !ruby/object:Gem::Version
|
|
133
135
|
version: '0'
|
|
134
136
|
requirements: []
|
|
135
|
-
|
|
136
|
-
rubygems_version: 2.6.6
|
|
137
|
+
rubygems_version: 3.1.2
|
|
137
138
|
signing_key:
|
|
138
139
|
specification_version: 4
|
|
139
140
|
summary: Ruby library for running commands as elevated
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
require 'rubygems'
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
require 'rspec/core/rake_task'
|
|
5
|
-
require 'rubocop/rake_task'
|
|
6
|
-
require 'bundler/gem_tasks'
|
|
7
|
-
|
|
8
|
-
# Change to the directory of this file.
|
|
9
|
-
Dir.chdir(File.expand_path('../', __FILE__))
|
|
10
|
-
|
|
11
|
-
RSpec::Core::RakeTask.new(:spec) do |task|
|
|
12
|
-
task.pattern = 'spec/*_spec.rb'
|
|
13
|
-
task.rspec_opts = ['--color', '-f documentation']
|
|
14
|
-
task.rspec_opts << '-tunit'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Run the integration test suite
|
|
18
|
-
RSpec::Core::RakeTask.new(:integration) do |task|
|
|
19
|
-
task.pattern = 'spec/*_spec.rb'
|
|
20
|
-
task.rspec_opts = ['--color', '-f documentation']
|
|
21
|
-
task.rspec_opts << '-tintegration'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
RuboCop::RakeTask.new
|
|
25
|
-
|
|
26
|
-
task default: [:spec, :rubocop]
|
|
27
|
-
|
|
28
|
-
task all: [:default, :integration]
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.1.0
|
data/appveyor.yml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
version: "master-{build}"
|
|
2
|
-
|
|
3
|
-
os: Windows Server 2012 R2
|
|
4
|
-
platform:
|
|
5
|
-
- x64
|
|
6
|
-
|
|
7
|
-
environment:
|
|
8
|
-
winrm_user: test_user
|
|
9
|
-
winrm_password: Pa$$word1
|
|
10
|
-
|
|
11
|
-
matrix:
|
|
12
|
-
- ruby_version: "21"
|
|
13
|
-
winrm_endpoint: http://localhost:5985/wsman
|
|
14
|
-
|
|
15
|
-
clone_folder: c:\projects\winrm-elevated
|
|
16
|
-
clone_depth: 1
|
|
17
|
-
branches:
|
|
18
|
-
only:
|
|
19
|
-
- master
|
|
20
|
-
|
|
21
|
-
install:
|
|
22
|
-
- ps: net user /add $env:winrm_user $env:winrm_password
|
|
23
|
-
- ps: net localgroup administrators $env:winrm_user /add
|
|
24
|
-
- ps: winrm set winrm/config/client/auth '@{Basic="true"}'
|
|
25
|
-
- ps: winrm set winrm/config/service/auth '@{Basic="true"}'
|
|
26
|
-
- ps: winrm set winrm/config/service '@{AllowUnencrypted="true"}'
|
|
27
|
-
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
|
|
28
|
-
- ps: Write-Host $env:PATH
|
|
29
|
-
- ps: ruby --version
|
|
30
|
-
- ps: gem --version
|
|
31
|
-
- ps: gem install bundler --quiet --no-ri --no-rdoc
|
|
32
|
-
- ps: bundler --version
|
|
33
|
-
|
|
34
|
-
build_script:
|
|
35
|
-
- bundle install || bundle install || bundle install
|
|
36
|
-
|
|
37
|
-
test_script:
|
|
38
|
-
- SET SPEC_OPTS=--format progress
|
|
39
|
-
- bundle exec rake integration
|
data/changelog.md
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# WinRM-Elevated Gem Changelog
|
|
2
|
-
|
|
3
|
-
# 1.1.0
|
|
4
|
-
- Allow tasks to be configured for interactive logon
|
|
5
|
-
- Fix broken credentials when they contain dollar signs
|
|
6
|
-
- Do not fail when temporary files cannot be deleted
|
|
7
|
-
|
|
8
|
-
# 1.0.1
|
|
9
|
-
- Fix to avoid profile conflicts
|
|
10
|
-
- Fix inadequate Execution Policy errors
|
|
11
|
-
|
|
12
|
-
# 1.0.0
|
|
13
|
-
- Adjust to comply with winrm v2 APIs
|
|
14
|
-
- Expose implementation as a class of `WinRM::Shells`
|
|
15
|
-
|
|
16
|
-
# 0.4.0
|
|
17
|
-
- Initialize `Elevated::Runner` with a `CommandExecutor` instead of a `WinrmService` client
|
|
18
|
-
- Run commands from newer winrm executor
|
|
19
|
-
- Use latest winrm-fs 0.4.2
|
|
20
|
-
- Allow task to run as a service account
|
|
21
|
-
- Provide an artificially long timeout to the task to keep the task from dying after 60 seconds
|
|
22
|
-
|
|
23
|
-
# 0.3.0
|
|
24
|
-
- [Name Powershell Script and Log Files Uniquely](https://github.com/WinRb/winrm-elevated/pull/6)
|
|
25
|
-
|
|
26
|
-
# 0.2.0
|
|
27
|
-
- [Only upload the elevated runner script once per winrm session](https://github.com/WinRb/winrm-elevated/pull/3)
|
|
28
|
-
- Bump WinRM (1.5) and WinRM-fs (0.3.0) gem constraints
|
|
29
|
-
|
|
30
|
-
# 0.1.0
|
|
31
|
-
- Initial Release
|
data/spec/config-example.yml
DELETED
data/spec/matchers.rb
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
require 'rspec/expectations'
|
|
3
|
-
|
|
4
|
-
# rspec matchers
|
|
5
|
-
RSpec::Matchers.define :have_stdout_match do |expected_stdout|
|
|
6
|
-
match do |actual_output|
|
|
7
|
-
!expected_stdout.match(actual_output.stdout).nil?
|
|
8
|
-
end
|
|
9
|
-
failure_message do |actual_output|
|
|
10
|
-
"expected that '#{actual_output.stdout}' would match #{expected_stdout}"
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
RSpec::Matchers.define :have_stderr_match do |expected_stderr|
|
|
15
|
-
match do |actual_output|
|
|
16
|
-
!expected_stderr.match(actual_output.stderr).nil?
|
|
17
|
-
end
|
|
18
|
-
failure_message do |actual_output|
|
|
19
|
-
"expected that '#{actual_output.stderr}' would match #{expected_stderr}"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
RSpec::Matchers.define :have_no_stdout do
|
|
24
|
-
match do |actual_output|
|
|
25
|
-
stdout = actual_output.stdout
|
|
26
|
-
stdout == '\r\n' || stdout == ''
|
|
27
|
-
end
|
|
28
|
-
failure_message do |actual_output|
|
|
29
|
-
"expected that '#{actual_output.stdout}' would have no stdout"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
RSpec::Matchers.define :have_no_stderr do
|
|
34
|
-
match do |actual_output|
|
|
35
|
-
stderr = actual_output.stderr
|
|
36
|
-
stderr == '\r\n' || stderr == ''
|
|
37
|
-
end
|
|
38
|
-
failure_message do |actual_output|
|
|
39
|
-
"expected that '#{actual_output.stderr}' would have no stderr"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
RSpec::Matchers.define :have_exit_code do |expected_exit_code|
|
|
44
|
-
match do |actual_output|
|
|
45
|
-
expected_exit_code == actual_output.exitcode
|
|
46
|
-
end
|
|
47
|
-
failure_message do |actual_output|
|
|
48
|
-
"expected exit code #{expected_exit_code}, but got #{actual_output.exitcode}"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
describe 'powershell elevated runner', integration: true do
|
|
3
|
-
describe 'ipconfig' do
|
|
4
|
-
subject(:output) { elevated_shell.run('ipconfig') }
|
|
5
|
-
it { should have_exit_code 0 }
|
|
6
|
-
it { should have_stdout_match(/Windows IP Configuration/) }
|
|
7
|
-
it { should have_no_stderr }
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe 'ipconfig as Service' do
|
|
11
|
-
subject(:output) do
|
|
12
|
-
elevated_shell.username = 'System'
|
|
13
|
-
elevated_shell.password = nil
|
|
14
|
-
elevated_shell.run('ipconfig')
|
|
15
|
-
end
|
|
16
|
-
it { should have_exit_code 0 }
|
|
17
|
-
it { should have_stdout_match(/Windows IP Configuration/) }
|
|
18
|
-
it { should have_no_stderr }
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe 'echo \'hello world\' using apostrophes' do
|
|
22
|
-
subject(:output) { elevated_shell.run("echo 'hello world'") }
|
|
23
|
-
it { should have_exit_code 0 }
|
|
24
|
-
it { should have_stdout_match(/hello world/) }
|
|
25
|
-
it { should have_no_stderr }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe 'ipconfig with incorrect argument -z' do
|
|
29
|
-
subject(:output) { elevated_shell.run('ipconfig 127.0.0.1 -z') }
|
|
30
|
-
it { should have_exit_code 1 }
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe 'Math area calculation' do
|
|
34
|
-
subject(:output) do
|
|
35
|
-
cmd = <<-EOH
|
|
36
|
-
$diameter = 4.5
|
|
37
|
-
$area = [Math]::pow([Math]::PI * ($diameter/2), 2)
|
|
38
|
-
Write-Host $area
|
|
39
|
-
EOH
|
|
40
|
-
elevated_shell.run(cmd)
|
|
41
|
-
end
|
|
42
|
-
it { should have_exit_code 0 }
|
|
43
|
-
it { should have_stdout_match(/49.9648722805149/) }
|
|
44
|
-
it { should have_no_stderr }
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe 'ipconfig with a block' do
|
|
48
|
-
subject(:stdout) do
|
|
49
|
-
outvar = ''
|
|
50
|
-
elevated_shell.run('ipconfig') do |stdout, _stderr|
|
|
51
|
-
outvar << stdout
|
|
52
|
-
end
|
|
53
|
-
outvar
|
|
54
|
-
end
|
|
55
|
-
it { should match(/Windows IP Configuration/) }
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
describe 'capturing output from Write-Host and Write-Error' do
|
|
59
|
-
subject(:output) do
|
|
60
|
-
script = <<-eos
|
|
61
|
-
Write-Host 'Hello'
|
|
62
|
-
$host.ui.WriteErrorLine(', world!')
|
|
63
|
-
eos
|
|
64
|
-
|
|
65
|
-
@captured_stdout = ''
|
|
66
|
-
@captured_stderr = ''
|
|
67
|
-
elevated_shell.run(script) do |stdout, stderr|
|
|
68
|
-
@captured_stdout << stdout if stdout
|
|
69
|
-
@captured_stderr << stderr if stderr
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'should have stdout' do
|
|
74
|
-
expect(output.stdout).to eq("Hello\r\n")
|
|
75
|
-
expect(output.stdout).to eq(@captured_stdout)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it 'should have stderr' do
|
|
79
|
-
expect(output.stderr).to eq(", world!\r\n")
|
|
80
|
-
expect(output.stderr).to eq(@captured_stderr)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'should have output' do
|
|
84
|
-
expect(output.output).to eq("Hello\r\n, world!\r\n")
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|