mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
package resource: Fix Windows package detection (#2624)
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
parent
925c5bca8e
commit
7f0a39a76a
1 changed files with 6 additions and 0 deletions
|
@ -267,6 +267,12 @@ module Inspec::Resources
|
||||||
Select-Object -Property DisplayName,DisplayVersion | ConvertTo-Json
|
Select-Object -Property DisplayName,DisplayVersion | ConvertTo-Json
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# We cannot rely on `exit_status` since PowerShell always exits 0 from the
|
||||||
|
# above command. Instead, if no package is found the output of the command
|
||||||
|
# will be `''` so we can use that to return `{}` to match the behavior of
|
||||||
|
# other package managers.
|
||||||
|
return {} if cmd.stdout == ''
|
||||||
|
|
||||||
begin
|
begin
|
||||||
package = JSON.parse(cmd.stdout)
|
package = JSON.parse(cmd.stdout)
|
||||||
rescue JSON::ParserError => e
|
rescue JSON::ParserError => e
|
||||||
|
|
Loading…
Reference in a new issue