mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
auditd_rules resource: fix get_keys error on lines that have no keys (#2103)
* Added line to fix bug when no key in file rule and updated test to validate bug fix Signed-off-by: Jennifer Burns <jburns@mitre.org> * Updated to consider corner case Signed-off-by: Jennifer Burns <jburns@mitre.org>
This commit is contained in:
parent
7a41cec73f
commit
3b2bf52b1d
3 changed files with 12 additions and 1 deletions
|
@ -177,7 +177,7 @@ module Inspec::Resources
|
|||
|
||||
# NB only in file lines
|
||||
def get_key(line)
|
||||
line.match(/-k ([^ ]+)/)[1]
|
||||
line.match(/-k ([^ ]+)/)[1] if line.include?('-k ')
|
||||
end
|
||||
|
||||
# NOTE there are NO precautions wrt. filenames containing spaces in auditctl
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
-a always,exit -F arch=b64 -S open,openat -F exit=-EACCES -F key=access
|
||||
-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=500 f24!=0 -F key=perm_mod
|
||||
-w /etc/ssh/sshd_config -p rwxa -k CFG_sshd_config
|
||||
-w /etc/sudoers -p wa
|
||||
-w /etc/private-keys -p x
|
||||
|
|
|
@ -12,6 +12,8 @@ describe 'Inspec::Resources::AuditDaemonRules' do
|
|||
'-a always,exit -F arch=b64 -S open,openat -F exit=-EACCES -F key=access',
|
||||
'-a always,exit -F arch=b32 -S chmod,fchmod,fchmodat -F auid>=500 f24!=0 -F key=perm_mod',
|
||||
'-w /etc/ssh/sshd_config -p rwxa -k CFG_sshd_config',
|
||||
'-w /etc/sudoers -p wa',
|
||||
'-w /etc/private-keys -p x',
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -56,6 +58,13 @@ describe 'Inspec::Resources::AuditDaemonRules' do
|
|||
]
|
||||
end
|
||||
|
||||
it 'check auditd_rules file interface with no keys' do
|
||||
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
||||
_(resource.send('file', '/etc/private-keys').send('rules')).must_equal [
|
||||
{ file: '/etc/private-keys', key: nil, permissions: 'x'},
|
||||
]
|
||||
end
|
||||
|
||||
it 'check auditd_rules status interface' do
|
||||
resource = MockLoader.new(:centos7).load_resource('auditd_rules')
|
||||
_(resource.send('status')).must_equal({
|
||||
|
|
Loading…
Reference in a new issue