为组编写了检查测试。这些组在 bash 上分配给用户 pi,但我从 inspec-test 得到一个空数组。
这里是 bash 输出:
id
uid=1000(pi) gid=1000(pi) Gruppen=1000(pi),4(adm),20(dialout),27(sudo),33(www-data),44(video),100(users),998(docker),999(gpio)
当我运行我的检查时,我得到了这个:
× users-1.0: Ensure users are known (1 failed)
✔ User pi should exist
✔ User pi group should eq "pi"
× User pi groups should eq ["pi", "sudo"]
expected: ["pi", "sudo"]
got: []
(compared using ==)
✔ User pi home should eq "/home/pi"
在我的 rb 文件中,我写了这个:
users = {
:pi => {
:uname => 'pi',
:gname => 'pi',
:groups => [
'adm',
'dialout',
'sudo',
'www-data',
'video',
'users',
'docker',
'gpio'
],
:home => '/home/pi'
}
}
...
control 'users-1.0' do
impact 1.0
title 'Ensure users are known'
users.each do |key, value|
describe user(value[:uname]) do
it { should exist }
its('group') { should eq "#{value[:gname]}" }
its('groups') { should eq [ 'pi', 'sudo' ] }
its('home') { should eq "#{value[:home]}" }
#its('shell') { should eq '/bin/bash' }
#its('mindays') { should eq 0 }
#its('maxdays') { should eq 90 }
#its('warndays') { should eq 8 }
end
end
end
我希望看到来自用户 pi 的一组组。
我不知道如何开始搜索。我是一个检查新手。
谢谢