train-core 3.13.4 → 3.15.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d838f638d6bbc471fdd186099014d342ec80ea3d208885d709351ed1564d96d
|
|
4
|
+
data.tar.gz: 4a3c73b0faed531af7e55578a94e76754a6ce408a1a6aac706bc2a05eff7b5f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e379c906184e37a441b6c9736b95b6fd6fa724bccba8f626b964b4342305f201b4fce792bb81e4c275b8b49036aa2cad97c0682880529029354530e6d06d121
|
|
7
|
+
data.tar.gz: 72a4cfe2de2a43d359fb63c23f48264b8b316b5513693150ac256d10a867514722b5445619571b845256aeac157feaf06ea54f36288e5f192421cf6a4cf4b487
|
data/lib/train/extras/stat.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Train::Extras
|
|
|
34
34
|
|
|
35
35
|
def self.linux_stat(shell_escaped_path, backend, follow_symlink)
|
|
36
36
|
lstat = follow_symlink ? " -L" : ""
|
|
37
|
-
format = (backend.os.esx? || %w{alpine yocto ubios}.include?(backend.os[:name])) ? "-c" : "--printf"
|
|
37
|
+
format = (backend.os.esx? || %w{alpine yocto ubios}.include?(backend.os[:name]) || %w{chainguard}.include?(backend.os[:family])) ? "-c" : "--printf"
|
|
38
38
|
res = backend.run_command("stat#{lstat} #{shell_escaped_path} 2>/dev/null #{format} '%s\n%f\n%U\n%u\n%G\n%g\n%X\n%Y\n%C'")
|
|
39
39
|
# ignore the exit_code: it is != 0 if selinux labels are not supported
|
|
40
40
|
# on the system.
|
|
@@ -25,10 +25,9 @@ module Train::Platforms::Detect::Helpers
|
|
|
25
25
|
@platform[:name] = "Windows #{@platform[:release]}"
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
read_wmic
|
|
28
|
+
# Prefer retrieving the OS details via `wmic` if available on the system to retain existing behavior.
|
|
29
|
+
# If `wmic` is not available, fall back to using cmd-only commands as an alternative method.
|
|
30
|
+
wmic_available? ? read_wmic : read_cmd_os
|
|
32
31
|
true
|
|
33
32
|
end
|
|
34
33
|
|
|
@@ -243,6 +242,62 @@ module Train::Platforms::Detect::Helpers
|
|
|
243
242
|
arch_map[res.stdout.strip.to_i]
|
|
244
243
|
end
|
|
245
244
|
|
|
245
|
+
# Fallback method for reading OS info using cmd-only commands when wmic is not available
|
|
246
|
+
def read_cmd_os
|
|
247
|
+
# Try to get architecture from PROCESSOR_ARCHITECTURE environment variable
|
|
248
|
+
# This covers the same architectures as wmic CPU detection but uses environment variables
|
|
249
|
+
# which are available on all Windows versions since NT
|
|
250
|
+
arch_res = @backend.run_command("echo %PROCESSOR_ARCHITECTURE%")
|
|
251
|
+
if arch_res.exit_status == 0
|
|
252
|
+
arch_string = arch_res.stdout.strip.downcase
|
|
253
|
+
# Only set architecture if we got actual output
|
|
254
|
+
unless arch_string.empty?
|
|
255
|
+
@platform[:arch] = case arch_string
|
|
256
|
+
when "x86"
|
|
257
|
+
"i386"
|
|
258
|
+
when "amd64", "x64"
|
|
259
|
+
"x86_64"
|
|
260
|
+
when "ppc", "powerpc"
|
|
261
|
+
"powerpc"
|
|
262
|
+
else
|
|
263
|
+
# For any unknown architecture, preserve the original value
|
|
264
|
+
# This handles: arm64, ia64, arm, mips, alpha, and future architectures
|
|
265
|
+
arch_string
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
# If PROCESSOR_ARCHITECTURE fails, architecture remains unset (consistent with other methods)
|
|
270
|
+
|
|
271
|
+
# Try to get more detailed OS info from systeminfo command as fallback
|
|
272
|
+
# This is slower than wmic but works without PowerShell
|
|
273
|
+
# Only override the basic info from check_cmd if systeminfo provides better data
|
|
274
|
+
sysinfo_res = @backend.run_command("systeminfo")
|
|
275
|
+
if sysinfo_res.exit_status == 0
|
|
276
|
+
sysinfo_res.stdout.lines.each do |line|
|
|
277
|
+
line = line.strip
|
|
278
|
+
if line =~ /^OS Name:\s*(.+)$/i
|
|
279
|
+
os_name = $1.strip
|
|
280
|
+
# Only override if we get a more detailed name than the basic "Windows X.X.X" from check_cmd
|
|
281
|
+
detailed_name = os_name.gsub("Microsoft", "").strip
|
|
282
|
+
@platform[:name] = detailed_name unless detailed_name.empty?
|
|
283
|
+
elsif line =~ /^OS Version:\s*(.+)$/i
|
|
284
|
+
version_info = $1.strip
|
|
285
|
+
# Extract version number from format like "10.0.19044 N/A Build 19044"
|
|
286
|
+
if version_info =~ /^(\d+\.\d+\.\d+)/
|
|
287
|
+
# Only override release if systeminfo provides the same or more detailed version
|
|
288
|
+
systeminfo_release = $1
|
|
289
|
+
@platform[:release] = systeminfo_release if systeminfo_release
|
|
290
|
+
end
|
|
291
|
+
# Extract build number (this is additional info not available from check_cmd)
|
|
292
|
+
if version_info =~ /Build (\d+)/
|
|
293
|
+
@platform[:build] = $1
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
# If systeminfo fails, we keep the basic info from check_cmd method
|
|
299
|
+
end
|
|
300
|
+
|
|
246
301
|
def windows_uuid_from_cim
|
|
247
302
|
cmd = 'powershell -Command "(Get-CimInstance -Class Win32_ComputerSystemProduct).UUID"'
|
|
248
303
|
res = @backend.run_command(cmd)
|
|
@@ -232,6 +232,27 @@ module Train::Platforms::Detect::Specifications
|
|
|
232
232
|
end
|
|
233
233
|
end
|
|
234
234
|
|
|
235
|
+
declare_category("chainguard", "linux") do
|
|
236
|
+
rel = linux_os_release
|
|
237
|
+
rel && rel["ID"] =~ /(wolfi|chainguard)/
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
declare_instance("wolfi", "Wolfi Linux", "chainguard") do
|
|
241
|
+
rel = linux_os_release
|
|
242
|
+
if rel && rel["ID"] =~ /wolfi/
|
|
243
|
+
@platform[:release] = rel["VERSION_ID"]
|
|
244
|
+
true
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
declare_instance("chainguard", "Chainguard Linux", "chainguard") do
|
|
249
|
+
rel = linux_os_release
|
|
250
|
+
if rel && rel["ID"] =~ /chainguard/
|
|
251
|
+
@platform[:release] = rel["VERSION_ID"]
|
|
252
|
+
true
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
235
256
|
# brocade family detected here if device responds to 'uname' command,
|
|
236
257
|
# happens when logging in as root
|
|
237
258
|
plat.family("brocade").title("Brocade Family").in_family("linux")
|
|
@@ -230,6 +230,12 @@ module Train::Transports
|
|
|
230
230
|
|
|
231
231
|
pipe = nil
|
|
232
232
|
|
|
233
|
+
# Verify ownership before connecting
|
|
234
|
+
owner, current_user, is_owner = pipe_owned_by_current_user?(pipe_name)
|
|
235
|
+
unless is_owner
|
|
236
|
+
raise PipeError, "Unauthorized user '#{current_user}' tried to connect to pipe '#{pipe_name}'. Pipe is owned by '#{owner}'."
|
|
237
|
+
end
|
|
238
|
+
|
|
233
239
|
# PowerShell needs time to create pipe.
|
|
234
240
|
100.times do
|
|
235
241
|
pipe = open("//./pipe/#{pipe_name}", "r+")
|
|
@@ -246,8 +252,11 @@ module Train::Transports
|
|
|
246
252
|
|
|
247
253
|
script = <<-EOF
|
|
248
254
|
$ErrorActionPreference = 'Stop'
|
|
249
|
-
|
|
250
|
-
$
|
|
255
|
+
$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
|
256
|
+
$pipeSecurity = New-Object System.IO.Pipes.PipeSecurity
|
|
257
|
+
$rule = New-Object System.IO.Pipes.PipeAccessRule($user, "FullControl", "Allow")
|
|
258
|
+
$pipeSecurity.AddAccessRule($rule)
|
|
259
|
+
$pipeServer = New-Object System.IO.Pipes.NamedPipeServerStream('#{pipe_name}', [System.IO.Pipes.PipeDirection]::InOut, 1, [System.IO.Pipes.PipeTransmissionMode]::Byte, [System.IO.Pipes.PipeOptions]::None, 4096, 4096, $pipeSecurity)
|
|
251
260
|
$pipeReader = New-Object System.IO.StreamReader($pipeServer)
|
|
252
261
|
$pipeWriter = New-Object System.IO.StreamWriter($pipeServer)
|
|
253
262
|
|
|
@@ -288,6 +297,29 @@ module Train::Transports
|
|
|
288
297
|
cmd = "#{@powershell_cmd} -NoProfile -ExecutionPolicy bypass -NonInteractive -EncodedCommand #{base64_script}"
|
|
289
298
|
Process.create(command_line: cmd).process_id
|
|
290
299
|
end
|
|
300
|
+
|
|
301
|
+
def current_windows_user
|
|
302
|
+
user = `powershell -Command "[System.Security.Principal.WindowsIdentity]::GetCurrent().Name"`.strip
|
|
303
|
+
if user.nil? || user.empty?
|
|
304
|
+
user = `whoami`.strip
|
|
305
|
+
end
|
|
306
|
+
if user.nil? || user.empty?
|
|
307
|
+
raise "Unable to determine current Windows user"
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
user
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Verify pipe ownership before connecting
|
|
314
|
+
def pipe_owned_by_current_user?(pipe_name)
|
|
315
|
+
exists = `powershell -Command "Test-Path \\\\.\\pipe\\#{pipe_name}"`.strip.downcase == "true"
|
|
316
|
+
current_user = current_windows_user
|
|
317
|
+
return [nil, current_user, false] unless exists
|
|
318
|
+
|
|
319
|
+
owner = `powershell -Command "(Get-Acl \\\\.\\pipe\\#{pipe_name}).Owner" 2>&1`.strip
|
|
320
|
+
is_owner = !owner.nil? && !current_user.nil? && owner.casecmp(current_user) == 0
|
|
321
|
+
[owner, current_user, is_owner]
|
|
322
|
+
end
|
|
291
323
|
end
|
|
292
324
|
end
|
|
293
325
|
end
|
data/lib/train/version.rb
CHANGED
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
|
+
version: 3.15.0
|
|
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: 2025-
|
|
11
|
+
date: 2025-12-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -28,16 +28,22 @@ dependencies:
|
|
|
28
28
|
name: ffi
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: 1.16.0
|
|
34
|
+
- - "<"
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '1.18'
|
|
34
37
|
type: :runtime
|
|
35
38
|
prerelease: false
|
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
40
|
requirements:
|
|
38
|
-
- - "
|
|
41
|
+
- - ">="
|
|
39
42
|
- !ruby/object:Gem::Version
|
|
40
43
|
version: 1.16.0
|
|
44
|
+
- - "<"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '1.18'
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: json
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|