winrm-elevated 1.1.0 → 1.1.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.
- 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 +116 -116
- data/lib/winrm/shells/elevated.rb +103 -104
- metadata +23 -35
- 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,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: winrm-elevated
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
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: 2018-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: winrm
|
|
@@ -39,49 +39,55 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '1.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3
|
|
47
|
+
version: '10.3'
|
|
48
|
+
- - "<"
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '13'
|
|
48
51
|
type: :development
|
|
49
52
|
prerelease: false
|
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
54
|
requirements:
|
|
52
|
-
- - "
|
|
55
|
+
- - ">="
|
|
53
56
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3
|
|
57
|
+
version: '10.3'
|
|
58
|
+
- - "<"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '13'
|
|
55
61
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
62
|
+
name: rspec
|
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
|
58
64
|
requirements:
|
|
59
65
|
- - "~>"
|
|
60
66
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
67
|
+
version: '3.2'
|
|
62
68
|
type: :development
|
|
63
69
|
prerelease: false
|
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
71
|
requirements:
|
|
66
72
|
- - "~>"
|
|
67
73
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
74
|
+
version: '3.2'
|
|
69
75
|
- !ruby/object:Gem::Dependency
|
|
70
76
|
name: rubocop
|
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
|
72
78
|
requirements:
|
|
73
79
|
- - "~>"
|
|
74
80
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
81
|
+
version: 0.51.0
|
|
76
82
|
type: :development
|
|
77
83
|
prerelease: false
|
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
85
|
requirements:
|
|
80
86
|
- - "~>"
|
|
81
87
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
83
|
-
description:
|
|
84
|
-
|
|
88
|
+
version: 0.51.0
|
|
89
|
+
description: Ruby library for running commands via WinRM as elevated through a scheduled
|
|
90
|
+
task
|
|
85
91
|
email:
|
|
86
92
|
- sneal@sneal.net
|
|
87
93
|
executables: []
|
|
@@ -90,42 +96,24 @@ extra_rdoc_files:
|
|
|
90
96
|
- README.md
|
|
91
97
|
- LICENSE
|
|
92
98
|
files:
|
|
93
|
-
- ".gitignore"
|
|
94
|
-
- ".rspec"
|
|
95
|
-
- ".rubocop.yml"
|
|
96
|
-
- ".travis.yml"
|
|
97
|
-
- Gemfile
|
|
98
99
|
- LICENSE
|
|
99
100
|
- README.md
|
|
100
|
-
- Rakefile
|
|
101
|
-
- VERSION
|
|
102
|
-
- appveyor.yml
|
|
103
|
-
- changelog.md
|
|
104
101
|
- lib/winrm-elevated.rb
|
|
105
102
|
- lib/winrm-elevated/scripts/elevated_shell.ps1
|
|
106
103
|
- 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
104
|
homepage: https://github.com/WinRb/winrm-elevated
|
|
113
105
|
licenses:
|
|
114
106
|
- Apache-2.0
|
|
115
107
|
metadata: {}
|
|
116
108
|
post_install_message:
|
|
117
|
-
rdoc_options:
|
|
118
|
-
- "-x"
|
|
119
|
-
- test/
|
|
120
|
-
- "-x"
|
|
121
|
-
- examples/
|
|
109
|
+
rdoc_options: []
|
|
122
110
|
require_paths:
|
|
123
111
|
- lib
|
|
124
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
113
|
requirements:
|
|
126
114
|
- - ">="
|
|
127
115
|
- !ruby/object:Gem::Version
|
|
128
|
-
version:
|
|
116
|
+
version: 2.2.0
|
|
129
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
118
|
requirements:
|
|
131
119
|
- - ">="
|
|
@@ -133,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
121
|
version: '0'
|
|
134
122
|
requirements: []
|
|
135
123
|
rubyforge_project:
|
|
136
|
-
rubygems_version: 2.
|
|
124
|
+
rubygems_version: 2.7.6
|
|
137
125
|
signing_key:
|
|
138
126
|
specification_version: 4
|
|
139
127
|
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
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
require 'winrm'
|
|
3
|
-
require 'winrm-elevated'
|
|
4
|
-
require_relative 'matchers'
|
|
5
|
-
|
|
6
|
-
# Creates a WinRM connection for integration tests
|
|
7
|
-
module ConnectionHelper
|
|
8
|
-
def winrm_connection
|
|
9
|
-
WinRM::Connection.new(winrm_config)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def elevated_shell
|
|
13
|
-
@elevated_shell ||= winrm_connection.shell(:elevated)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def winrm_config
|
|
17
|
-
unless @winrm_config
|
|
18
|
-
path = File.expand_path("#{File.dirname(__FILE__)}/config.yml")
|
|
19
|
-
unless File.exist?(path)
|
|
20
|
-
path = File.expand_path("#{File.dirname(__FILE__)}/config-example.yml")
|
|
21
|
-
end
|
|
22
|
-
@winrm_config = symbolize_keys(YAML.load(File.read(path)))
|
|
23
|
-
@winrm_config[:endpoint] = ENV['winrm_endpoint'] if ENV['winrm_endpoint']
|
|
24
|
-
@winrm_config[:user] = ENV['winrm_user'] if ENV['winrm_user']
|
|
25
|
-
@winrm_config[:password] = ENV['winrm_password'] if ENV['winrm_password']
|
|
26
|
-
end
|
|
27
|
-
@winrm_config
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def username
|
|
31
|
-
winrm_config[:user]
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def password
|
|
35
|
-
winrm_config[:password]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# rubocop:disable Metrics/MethodLength
|
|
39
|
-
def symbolize_keys(hash)
|
|
40
|
-
hash.each_with_object({}) do |(key, value), result|
|
|
41
|
-
new_key = case key
|
|
42
|
-
when String then key.to_sym
|
|
43
|
-
else key
|
|
44
|
-
end
|
|
45
|
-
new_value = case value
|
|
46
|
-
when Hash then symbolize_keys(value)
|
|
47
|
-
else value
|
|
48
|
-
end
|
|
49
|
-
result[new_key] = new_value
|
|
50
|
-
result
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
# rubocop:enable Metrics/MethodLength
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
RSpec.configure do |config|
|
|
57
|
-
config.include(ConnectionHelper)
|
|
58
|
-
end
|