mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
bugfix: handle empty processes result
This commit is contained in:
parent
ec6d1e680a
commit
414bf6b1fa
2 changed files with 6 additions and 0 deletions
|
@ -31,6 +31,7 @@ class Processes < Inspec.resource(1)
|
|||
# get all running processes
|
||||
cmd = inspec.command('ps aux')
|
||||
all = cmd.stdout.split("\n")[1..-1]
|
||||
return [] if all.nil?
|
||||
|
||||
lines = all.map do |line|
|
||||
# user 32296 0.0 0.0 42592 7972 pts/15 Ss+ Apr06 0:00 zsh
|
||||
|
|
|
@ -6,6 +6,11 @@ require 'helper'
|
|||
require 'inspec/resource'
|
||||
|
||||
describe 'Inspec::Resources::Processes' do
|
||||
it 'handles empty process results' do
|
||||
resource = load_resource('processes', 'nothing')
|
||||
_(resource.list).must_equal []
|
||||
end
|
||||
|
||||
it 'verify processes resource' do
|
||||
resource = load_resource('processes', '/bin/bash')
|
||||
_(resource.list).must_equal [{
|
||||
|
|
Loading…
Reference in a new issue