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

added checks to ensure some kernel modules are properly configured to be blacklisted #44

Closed
wants to merge 4 commits into from
Closed
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
13 changes: 13 additions & 0 deletions controls/SV-257804.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the kernel_module resource not do this for you already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears so. I was under the impression that kernel_module was testing the results of the configuration being loaded (maybe using something lsmod or modprobe command itself) rather than directly looking at how it was configured. In this case, this means that this whole PR is redundant, right?

blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('atm')
end

describe 'atm' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-257805.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one a slightly different pattern compared to the rest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I wrote it that way. It should be fixed now.

blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('can')
end

describe 'can' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-257806.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('firewire-core')
end

describe 'firewire_core' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-257807.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('sctp')
end

describe 'sctp' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-257808.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('tipc')
end

describe 'tipc' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-257880.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,17 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('cramfs')
end

describe 'cramfs' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
20 changes: 20 additions & 0 deletions controls/SV-258034.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,35 @@
only_if('This control is Not Applicable to containers', impact: 0.0) {
!virtualization.system.eql?('docker')
}

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('usb-storage')
end

if input('usb_storage_required') == true
describe kernel_module('usb_storage') do
it { should_not be_disabled }
it { should_not be_blacklisted }
end

describe 'usb_storage' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(false)
end
end
else
describe kernel_module('usb_storage') do
it { should be_disabled }
it { should be_blacklisted }
end

describe 'usb_storage' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
end
end
13 changes: 13 additions & 0 deletions controls/SV-258039.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
it { should be_disabled }
it { should be_blacklisted }
end

config_files = command('find /etc/modprobe.conf /etc/modprobe.d/* -print0').stdout.split("\0")
blacklisted = config_files.any? do |c|
params = parse_config_file(c, comment_char: '#', multiple_values: true,
assignment_regex: /^(\S+)\s+(\S+)$/).params
params.include?('blacklist') and params['blacklist'].include?('bluetooth')
end

describe 'bluetooth' do
it 'is configured to be blacklisted' do
expect(blacklisted).to eq(true)
end
end
else
impact 0.0
describe 'Device or operating system does not have a Bluetooth adapter installed' do
Expand Down
Loading