chef-powershell 2.18.5 → 3.0.30
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/bin/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/bin/ruby_bin_folder/AMD64/Chef.Powershell.Wrapper.dll +0 -0
- data/bin/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/chef-powershell.gemspec +1 -1
- data/lib/chef-powershell/powershell.rb +19 -31
- data/lib/chef-powershell/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d93049c98f0e42d1cf2760cf353eb4fb16d0259ff0fec3790e0d1763a835bc4
|
|
4
|
+
data.tar.gz: 2a162dc437e62342bf1fd54fdbf5d0aa82b77047320135c27c40b1672e6d97b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e13dad4b1a55c8af3bcdffdc0728ccd4bea6eeaa1d75cd17d3d3f1cffb2bb5393c42fa3f8138c2c4258f54d7ef7d66187d6a5433d77f46042db880b2577f4ce4
|
|
7
|
+
data.tar.gz: 4008e7bf79b9df4de1cc06facb61a9938cdddff1903880df37b3af3ba81cf01e2a99d00d13e11e1e1f84e49231bd2bab34d3dc8c2947ae81f43592c678499268
|
|
Binary file
|
|
Binary file
|
data/bin/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll
CHANGED
|
Binary file
|
data/chef-powershell.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.required_ruby_version = ">= 2.6"
|
|
19
19
|
|
|
20
20
|
spec.add_runtime_dependency "ffi", "~> 1.15"
|
|
21
|
-
spec.add_runtime_dependency "ffi-yajl", "~>
|
|
21
|
+
spec.add_runtime_dependency "ffi-yajl", "~> 3.0"
|
|
22
22
|
|
|
23
23
|
spec.metadata = {
|
|
24
24
|
"bug_tracker_uri" => "https://github.com/chef/chef/issues",
|
|
@@ -64,10 +64,6 @@ class ChefPowerShell
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
module PowerMod
|
|
67
|
-
class << self
|
|
68
|
-
attr_accessor :result_string, :retry_count, :exception, :result, :errors, :verbose, :hashed_outcome
|
|
69
|
-
end
|
|
70
|
-
|
|
71
67
|
extend FFI::Library
|
|
72
68
|
# FFI requires attaching to modules, not classes, so we need to
|
|
73
69
|
# have a module here. The module level variables *could* be refactored
|
|
@@ -76,26 +72,17 @@ class ChefPowerShell
|
|
|
76
72
|
@@ps_command = ""
|
|
77
73
|
@@ps_timeout = -1
|
|
78
74
|
|
|
79
|
-
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
rescue => e
|
|
91
|
-
@retry_count += 1
|
|
92
|
-
puts "#{e.inspect}"
|
|
93
|
-
@exception = e
|
|
94
|
-
return true if @retry_count > 3
|
|
95
|
-
puts "Retrying PowerShell command execution #{@retry_count}"
|
|
96
|
-
sleep 1
|
|
97
|
-
false
|
|
98
|
-
end
|
|
75
|
+
AllocateCallback = FFI::Function.new(:pointer, [:size_t]) do |size|
|
|
76
|
+
# Capture the pointer here so that Ruby knows that it is an
|
|
77
|
+
# FFI::MemoryPointer that can receive &.free. If you try to
|
|
78
|
+
# free the pointer from execute_powershell, Ruby will not have
|
|
79
|
+
# access to the type information and will core dump spectacularly.
|
|
80
|
+
@@pointer = FFI::MemoryPointer.new(:uchar, size)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.free_pointer
|
|
84
|
+
@@pointer&.free
|
|
85
|
+
@@pointer = nil
|
|
99
86
|
end
|
|
100
87
|
|
|
101
88
|
def self.set_ps_dll(value)
|
|
@@ -111,12 +98,10 @@ class ChefPowerShell
|
|
|
111
98
|
end
|
|
112
99
|
|
|
113
100
|
def self.do_work
|
|
114
|
-
@exception = nil
|
|
115
|
-
@retry_count = 0
|
|
116
101
|
ffi_lib @@powershell_dll
|
|
117
102
|
attach_function :execute_powershell, :ExecuteScript, %i{string int pointer}, :pointer
|
|
118
103
|
|
|
119
|
-
execute_powershell(@@ps_command, @@ps_timeout,
|
|
104
|
+
execute_powershell(@@ps_command, @@ps_timeout, AllocateCallback)
|
|
120
105
|
end
|
|
121
106
|
end
|
|
122
107
|
|
|
@@ -132,10 +117,13 @@ class ChefPowerShell
|
|
|
132
117
|
|
|
133
118
|
PowerMod.set_ps_command(script)
|
|
134
119
|
execution = PowerMod.do_work
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
@
|
|
138
|
-
@
|
|
120
|
+
output = execution.read_utf16string
|
|
121
|
+
hashed_outcome = FFI_Yajl::Parser.parse(output)
|
|
122
|
+
@result = FFI_Yajl::Parser.parse(hashed_outcome["result"])
|
|
123
|
+
@errors = hashed_outcome["errors"]
|
|
124
|
+
@verbose = hashed_outcome["verbose"]
|
|
125
|
+
ensure
|
|
126
|
+
PowerMod.free_pointer
|
|
139
127
|
end
|
|
140
128
|
end
|
|
141
129
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chef-powershell
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.30
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chef Software, Inc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-07-
|
|
11
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '3.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '3.0'
|
|
41
41
|
description:
|
|
42
42
|
email:
|
|
43
43
|
- oss@chef.io
|