Skip to content

Commit f2fad54

Browse files
authored
Merge pull request #138 from imjoseangel/ISSUE114
feat(osbaseline): support validation for cpu vulnerabilities
2 parents 8ee448e + f0873c7 commit f2fad54

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

controls/os_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
description: 'blacklist of suid/sgid program on system'
3838
)
3939

40+
cpuvulndir = '/sys/devices/system/cpu/vulnerabilities/'
41+
4042
control 'os-01' do
4143
impact 1.0
4244
title 'Trusted hosts login'
@@ -236,3 +238,24 @@
236238
its(:group) { should match(/^root|syslog$/) }
237239
end
238240
end
241+
242+
control 'os-12' do
243+
impact 1.0
244+
title 'Detect vulnerabilities in the cpu-vulnerability-directory'
245+
desc 'Check for known cpu vulnerabilities described here: https://www.kernel.org/doc/html/v5.6/admin-guide/hw-vuln/index.html'
246+
247+
if file(cpuvulndir).exist?
248+
describe file(cpuvulndir) do
249+
it { should be_directory }
250+
end
251+
252+
loaded_files = command('find ' + cpuvulndir + ' -type f -maxdepth 1').stdout.split(/\n/).map(&:strip).find_all { |vulnfiles| !vulnfiles.empty? }
253+
254+
loaded_files.each do |vulnfile|
255+
describe file(vulnfile) do
256+
its(:content) { should_not match 'vulnerable' }
257+
its(:content) { should_not match 'Vulnerable' }
258+
end
259+
end
260+
end
261+
end

0 commit comments

Comments
 (0)