Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail disabled kernel module checks if the modules aren't installed #149

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 73 additions & 28 deletions controls/1_1_filesystem_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
cis_level = input('cis_level')

title '1.1 Filesystem Configuration'

kernel_module
bendres97 marked this conversation as resolved.
Show resolved Hide resolved
control 'cis-dil-benchmark-1.1.1.1' do
title 'Ensure mounting of cramfs filesystems is disabled'
desc "The cramfs filesystem type is a compressed read-only Linux filesystem embedded in small footprint systems. A cramfs image can be used without having to first decompress the image.\n\nRationale: Removing support for unneeded filesystem types reduces the local attack surface of the server. If this filesystem type is not needed, disable it."
Expand All @@ -29,9 +29,14 @@
tag cis: 'distribution-independent-linux:1.1.1.1'
tag level: 1

describe kernel_module('cramfs') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^cramfs\s/) }
end
describe kernel_module('cramfs') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -43,9 +48,14 @@
tag cis: 'distribution-independent-linux:1.1.1.2'
tag level: 1

describe kernel_module('freevxfs') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^freevxfs\s/) }
end
describe kernel_module('freevxfs') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -57,9 +67,14 @@
tag cis: 'distribution-independent-linux:1.1.1.3'
tag level: 1

describe kernel_module('jffs2') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^jffs2\s/) }
end
describe kernel_module('jffs2') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -71,9 +86,14 @@
tag cis: 'distribution-independent-linux:1.1.1.4'
tag level: 1

describe kernel_module('hfs') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^hfs\s/) }
end
describe kernel_module('hfs') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -85,9 +105,14 @@
tag cis: 'distribution-independent-linux:1.1.1.5'
tag level: 1

describe kernel_module('hfsplus') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^hfsplus\s/) }
end
describe kernel_module('hfsplus') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -99,9 +124,14 @@
tag cis: 'distribution-independent-linux:1.1.1.6'
tag level: 1

describe kernel_module('squashfs') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^squashfs\s/) }
end
describe kernel_module('squashfs') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -113,9 +143,14 @@
tag cis: 'distribution-independent-linux:1.1.1.7'
tag level: 1

describe kernel_module('udf') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^udf\s/) }
end
describe kernel_module('udf') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -127,9 +162,14 @@
tag cis: 'distribution-independent-linux:1.1.1.8'
tag level: 2

describe kernel_module('vfat') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^vfat\s/) }
end
describe kernel_module('vfat') do
it { should_not be_loaded }
it { should be_disabled }
end
end

only_if { cis_level == 2 }
Expand Down Expand Up @@ -465,8 +505,13 @@

# kernel modules need to use underscores
# ref: https://github.com/inspec/inspec/issues/5190
describe kernel_module('usb_storage') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^usb_storage\s/) }
end
describe kernel_module('usb_storage') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end
44 changes: 32 additions & 12 deletions controls/3_4_uncommon_network_protocols.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@

only_if { cis_level == 2 }

describe kernel_module('dccp') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^dccp\s/) }
end
describe kernel_module('dccp') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -47,9 +52,14 @@

only_if { cis_level == 2 }

describe kernel_module('sctp') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^sctp\s/) }
end
describe kernel_module('sctp') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -63,9 +73,14 @@

only_if { cis_level == 2 }

describe kernel_module('rds') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^rds\s/) }
end
describe kernel_module('rds') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end

Expand All @@ -79,8 +94,13 @@

only_if { cis_level == 2 }

describe kernel_module('tipc') do
it { should_not be_loaded }
it { should be_disabled }
describe.one do
describe file('/proc/modules') do
its('content') { should_not match(/^tipc\s/) }
end
describe kernel_module('tipc') do
it { should_not be_loaded }
it { should be_disabled }
end
end
end