chef-powershell 2.18.6 → 3.0.31
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 -35
- 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: 1b3d7d0cfcea3798ced68ae7efb8bbf974bedca98336133a44aa48f1f429a83f
|
4
|
+
data.tar.gz: 15354f61587a5fa79873f22a59c33396cbf4b0aca1790666df6a21b428d9614b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b0985a8a3e12d49310634e7bf72cbac989cf8608bdb33149117821fba20b929e8dc49bc184deadfda68cbd7a5deb1972d07d24377119965bec782fcd5fe735
|
7
|
+
data.tar.gz: 4705dbe0a51917b216a6acfe844389f5bc03b4d11d2840ecaa866ec53e7519c86346aec6bcfc8254f4264ef849f1026834d8ad85c39a77b600a12d613dfa81b9
|
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", "~> 2.4"
|
21
|
+
spec.add_runtime_dependency "ffi-yajl", "~> 2.2.4"
|
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,30 +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
|
-
@retry_count += 1
|
91
|
-
# capture exception so that it can be raised later, since otherwise
|
92
|
-
# we will be raising back to C++.
|
93
|
-
@exception = e
|
94
|
-
return true if @retry_count > 3
|
95
|
-
puts "Retrying PowerShell command execution #{@retry_count}"
|
96
|
-
sleep 1
|
97
|
-
false
|
98
|
-
rescue => e
|
99
|
-
# no retry for other exceptions
|
100
|
-
@exception = e
|
101
|
-
true
|
102
|
-
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
|
103
86
|
end
|
104
87
|
|
105
88
|
def self.set_ps_dll(value)
|
@@ -115,12 +98,10 @@ class ChefPowerShell
|
|
115
98
|
end
|
116
99
|
|
117
100
|
def self.do_work
|
118
|
-
@exception = nil
|
119
|
-
@retry_count = 0
|
120
101
|
ffi_lib @@powershell_dll
|
121
102
|
attach_function :execute_powershell, :ExecuteScript, %i{string int pointer}, :pointer
|
122
103
|
|
123
|
-
execute_powershell(@@ps_command, @@ps_timeout,
|
104
|
+
execute_powershell(@@ps_command, @@ps_timeout, AllocateCallback)
|
124
105
|
end
|
125
106
|
end
|
126
107
|
|
@@ -136,10 +117,13 @@ class ChefPowerShell
|
|
136
117
|
|
137
118
|
PowerMod.set_ps_command(script)
|
138
119
|
execution = PowerMod.do_work
|
139
|
-
|
140
|
-
|
141
|
-
@
|
142
|
-
@
|
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
|
143
127
|
end
|
144
128
|
end
|
145
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.31
|
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-14 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: 2.2.4
|
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: 2.2.4
|
41
41
|
description:
|
42
42
|
email:
|
43
43
|
- oss@chef.io
|