chef-powershell 3.0.19 → 3.0.21

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chef-powershell might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796f6e2c68755a378d7cb48342ecaa453eb956e8128de2d37fa8a871bd18952b
4
- data.tar.gz: d164064ae694c3851becb226d7f5f778477ba54dd8cf0e25b66a497f050a79dc
3
+ metadata.gz: 34a8f11c745dcc80ae9c958bb64ee978274627e916db91b9f175ffa7a5584dc8
4
+ data.tar.gz: a80ed1e45f558e0fd742ab055f8cc91417881bf83f727ea1403d055d4e94f898
5
5
  SHA512:
6
- metadata.gz: a64d1b650bfae1e2590903620a186fe29f58756f7b627f595a88f0d729d570181b41abd54d542fd7dad18ee98261666df2fdd9beceeb455b5a759d8c37f9dabc
7
- data.tar.gz: 73c0a22ba95ade251b30f16edd836f7bdb35b3bfa7f406610d974028908f33cb624802a3f9dd43d66bd4b3b00a3e71745e80a49fd44c432ec865731ec7cf41e2
6
+ metadata.gz: 4c83d7d8ea23fa9eb2d00c7f8ec090a4b2e13c5bc451a03da5fcb43cb70179f9d8bf291f588977196bdec05765e6745a473c0966a5e5fe2131b9a1a2cff15cf5
7
+ data.tar.gz: 2e9a08ab539a0d68fece5e76f4f4ca291d6671ad17a4f525b0c5867fb240d05324e1293de12be87f1b8cc3452e8e793784a3a9a9260bd06f04fceb10002e7bf5
@@ -47,6 +47,9 @@ class ChefPowerShell
47
47
  exec(script, timeout: timeout)
48
48
  end
49
49
 
50
+ def power_mod
51
+ ChefPowerShell::PowerShell::PowerShellMod
52
+ end
50
53
  #
51
54
  # Was there an error running the command
52
55
  #
@@ -63,7 +66,7 @@ class ChefPowerShell
63
66
  raise ChefPowerShell::PowerShellExceptions::PowerShellCommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
64
67
  end
65
68
 
66
- module PowerMod
69
+ module PowerShellMod
67
70
  extend FFI::Library
68
71
 
69
72
  def self.load_powershell_dll(powershell_dll)
@@ -82,13 +85,22 @@ class ChefPowerShell
82
85
  private
83
86
 
84
87
  def exec(script, timeout: -1)
85
- PowerMod.load_powershell_dll(@powershell_dll)
86
- execution = PowerMod.do_work(script, timeout)
87
- output = execution.read_utf16string
88
- hashed_outcome = FFI_Yajl::Parser.parse(output)
89
- @result = FFI_Yajl::Parser.parse(hashed_outcome["result"])
90
- @errors = hashed_outcome["errors"]
91
- @verbose = hashed_outcome["verbose"]
88
+ power_mod.load_powershell_dll(@powershell_dll)
89
+ begin
90
+ execution = power_mod.do_work(script, timeout)
91
+ output = execution.read_utf16string
92
+ hashed_outcome = FFI_Yajl::Parser.parse(output)
93
+ @result = FFI_Yajl::Parser.parse(hashed_outcome["result"])
94
+ @errors = hashed_outcome["errors"]
95
+ @verbose = hashed_outcome["verbose"]
96
+ rescue => e
97
+ if File.exist?("C:\\chef-powershell-output.txt")
98
+ message=[e.inspect, File.read("C:\\chef-powershell-output.txt")].join("\n")
99
+ raise message
100
+ else
101
+ raise
102
+ end
103
+ end
92
104
  end
93
105
  end
94
106
  end
@@ -30,7 +30,25 @@ class ChefPowerShell
30
30
  super
31
31
  end
32
32
 
33
- protected
33
+ def power_mod
34
+ ChefPowerShell::Pwsh::PwshMod
35
+ end
36
+
37
+ module PwshMod
38
+ extend FFI::Library
39
+
40
+ def self.load_powershell_dll(powershell_dll)
41
+ @dlls ||= []
42
+ return if @dlls.include?(powershell_dll)
43
+ ffi_lib powershell_dll
44
+ @dlls << powershell_dll
45
+ end
46
+
47
+ def self.do_work(ps_command, timeout = -1)
48
+ attach_function(:execute_powershell, :ExecuteScript, %i{string int}, :pointer) unless method_defined?(:execute_powershell)
49
+ execute_powershell(ps_command, timeout)
50
+ end
51
+ end
34
52
 
35
53
  def exec(script, timeout: -1)
36
54
  # Note that we need to override the location of the shared dotnet core library
@@ -16,5 +16,5 @@
16
16
 
17
17
  module ChefPowerShellModule
18
18
  CHEFPOWERSHELL_ROOT = File.expand_path("..", __dir__)
19
- VERSION = "3.0.19".freeze
19
+ VERSION = "3.0.21".freeze
20
20
  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: 3.0.19
4
+ version: 3.0.21
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-03-22 00:00:00.000000000 Z
11
+ date: 2023-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi