train-core 3.4.8 → 3.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54dee42a0ad37ef8b4308a184f5bd63f869565db241c1c1fa910626d6c9a323f
4
- data.tar.gz: afbeb697f1d0613f9d86af612e5ce6745b27b4ac597221b5e07db0e11b9d90d8
3
+ metadata.gz: 6272024b67e2dac1df86499e4687dc44d5df58b328146d52cb864433d7c6e6a7
4
+ data.tar.gz: a4133877056cc7feed58ac9dab964ecfc435d28cc30a09d6dd104577a8a30374
5
5
  SHA512:
6
- metadata.gz: d2029c737655fc5f2eea92e290d73bbd0b6b7eac73ecc7e2e5526870e5318f6beceba8bc64c555ac451007cd1083870bba35985fa8353560a6040a5c6b997186
7
- data.tar.gz: c57536c1bdddbde99d4955276d5fe14c20dbe84b7f109059bb8d8ee56a02f49f484811784aacf8384b1d6e5229f92f46f03fe005008677531eaef2abea55fe62
6
+ metadata.gz: 53bcc25af9bade96ee63aa1f0940927cb4e4183220737269bb4882c800df94c1bf6cb924abf5cb6b354b18ae000b6fba3d7a35787a3764d9402cd63f7b90bdd2
7
+ data.tar.gz: 775d8a24be41a87f8427f3850b829b1acbc78d2a9ef8e299e1e4c9f9dbd352838d7bd9ef906723832171d0f822a10dac39827ab8a1b92c7ebec220bf37e337dd
@@ -31,6 +31,10 @@ module Train::Transports
31
31
  nil # none, open your shell
32
32
  end
33
33
 
34
+ def close
35
+ @runner.close
36
+ end
37
+
34
38
  def uri
35
39
  "local://"
36
40
  end
@@ -108,6 +112,10 @@ module Train::Transports
108
112
  res.run_command
109
113
  Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
110
114
  end
115
+
116
+ def close
117
+ # nothing to do at the moment
118
+ end
111
119
  end
112
120
 
113
121
  class WindowsShellRunner
@@ -132,6 +140,10 @@ module Train::Transports
132
140
  res.run_command
133
141
  Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
134
142
  end
143
+
144
+ def close
145
+ # nothing to do at the moment
146
+ end
135
147
  end
136
148
 
137
149
  class WindowsPipeRunner
@@ -141,6 +153,7 @@ module Train::Transports
141
153
 
142
154
  def initialize(powershell_cmd = "powershell")
143
155
  @powershell_cmd = powershell_cmd
156
+ @server_pid = nil
144
157
  @pipe = acquire_pipe
145
158
  raise PipeError if @pipe.nil?
146
159
  end
@@ -160,12 +173,21 @@ module Train::Transports
160
173
  Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
161
174
  end
162
175
 
176
+ def close
177
+ Process.kill("KILL", @server_pid) unless @server_pid.nil?
178
+ @server_pid = nil
179
+ end
180
+
163
181
  private
164
182
 
165
183
  def acquire_pipe
184
+ require "win32/process"
166
185
  pipe_name = "inspec_#{SecureRandom.hex}"
167
186
 
168
- start_pipe_server(pipe_name)
187
+ @server_pid = start_pipe_server(pipe_name)
188
+
189
+ # Ensure process is killed when the Train process exits
190
+ at_exit { close }
169
191
 
170
192
  pipe = nil
171
193
 
@@ -227,13 +249,9 @@ module Train::Transports
227
249
  utf8_script = script.encode("UTF-16LE", "UTF-8")
228
250
  base64_script = Base64.strict_encode64(utf8_script)
229
251
  cmd = "#{@powershell_cmd} -NoProfile -ExecutionPolicy bypass -NonInteractive -EncodedCommand #{base64_script}"
230
-
231
- server_pid = Process.create(command_line: cmd).process_id
232
-
233
- # Ensure process is killed when the Train process exits
234
- at_exit { Process.kill("KILL", server_pid) }
252
+ Process.create(command_line: cmd).process_id
235
253
  end
236
254
  end
237
255
  end
238
256
  end
239
- end
257
+ end
@@ -2,5 +2,5 @@
2
2
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
3
3
 
4
4
  module Train
5
- VERSION = "3.4.8".freeze
5
+ VERSION = "3.4.9".freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: train-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.8
4
+ version: 3.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-26 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable