Skip to content

Commit

Permalink
Merge pull request #15 from crashdummymch/1_1_redhat
Browse files Browse the repository at this point in the history
1 1 redhat
  • Loading branch information
crashdummymch authored Apr 11, 2018
2 parents 5581595 + 31daeff commit 7acf3e7
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

gem 'inspec', '~> 2'
gem 'inspec', '2.1.0'
gem 'rake'
gem 'rubocop'

Expand Down
37 changes: 30 additions & 7 deletions controls/1_1_filesystem_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@
tag cis: 'distribution-independent-linux:1.1.1.3'
tag level: 1

describe linux_module('jffs2') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/true$}) }
if os.redhat? && os.release.to_i < 7 then
describe linux_module('jffs2') do
it { should_not be_loaded }
its(:command) { should match(%r{^insmod.*zlib_deflate.koinstall /bin/true$}) }
end
else
describe linux_module('jffs2') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/true$}) }
end
end
end

Expand Down Expand Up @@ -111,9 +118,21 @@
tag cis: 'distribution-independent-linux:1.1.1.7'
tag level: 1

describe linux_module('udf') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/true$}) }
if os.redhat? && os.release.to_i < 7 then
describe linux_module('udf') do
it { should_not be_loaded }
its(:command) { should match(%r{^insmod.*crc-itu-t.koinstall /bin/true$}) }
end
elsif os.family? == 'redhat' then
describe linux_module('udf') do
it { should_not be_loaded }
its(:command) { should match(%r{^insmod.*crc-itu-t.ko.xzinstall /bin/true$}) }
end
else
describe linux_module('udf') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/true$}) }
end
end
end

Expand All @@ -127,7 +146,11 @@

describe linux_module('vfat') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/true$}) }
its(:command) { should match(%r{^install /bin/trueinstall /bin/true$}) }
end
describe linux_module('msdos') do
it { should_not be_loaded }
its(:command) { should match(%r{^install /bin/trueinstall /bin/true$}) }
end
end

Expand Down
3 changes: 2 additions & 1 deletion controls/1_3_filesystem_integrity_checking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# limitations under the License.
#
# author: Kristian Vlaardingerbroek
#

title '1.3 Filesystem Integrity Checking'

Expand Down Expand Up @@ -45,7 +46,7 @@
tag level: 1

describe.one do
%w(/var/spool/cron/crontabs/root /etc/crontab).each do |f|
%w(/var/spool/cron/crontabs/root /var/spool/cron/root /etc/crontab).each do |f|
describe file(f) do
its(:content) { should match(/aide --check/) }
end
Expand Down
4 changes: 2 additions & 2 deletions controls/1_4_secure_boot_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
tag level: 1

describe.one do
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst).each do |f|
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst /boot/grub2/grub.cfg).each do |f|
describe file(f) do
it { should exist }
it { should_not be_readable.by 'group' }
Expand All @@ -51,7 +51,7 @@
tag level: 1

describe.one do
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst).each do |f|
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst /boot/grub/grub.cfg).each do |f|
describe file(f) do
its(:content) { should match(/^set superusers/) }
its(:content) { should match(/^password/) }
Expand Down
12 changes: 10 additions & 2 deletions controls/2_2_special_purpose_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
its(:content) { should match(/^RUNASUSER=ntp\s*(?:#.*)?$/) }
end

describe file('/etc/init.d/ntpd') do
its(:content) { should match(/daemon\s+(\S+\s+)-u ntp:ntp(?:\s+|\s?")/) }
end

describe file('/etc/sysconfig/ntpd') do
its(:content) { should match(/^OPTIONS="(?:.)?-u ntp:ntp\s*(?:.)?"\s*(?:#.*)?$/) }
end
Expand All @@ -95,8 +99,12 @@
package('chrony').installed? || command('chronyd').exist?
end

describe file('/etc/chrony/chrony.conf') do
its(:content) { should match(/^server\s+\S+/) }
describe.one do
%w(/etc/chrony/chrony.conf /etc/chrony.conf).each do |f|
describe file(f) do
its(:content) { should match(/^server\s+\S+/) }
end
end
end

describe processes('chronyd') do
Expand Down
8 changes: 6 additions & 2 deletions controls/3_4_tcp_wrappers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
tag cis: 'distribution-independent-linux:3.4.1'
tag level: 1

describe package('tcpd') do
it { should be_installed }
describe.one do
%w(tcpd tcp_wrappers).each do |p|
describe package(p) do
it { should be_installed }
end
end
end
end

Expand Down
6 changes: 3 additions & 3 deletions controls/4_1_configure_system_accounting_auditd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
tag level: 2

describe.one do
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst).each do |f|
%w(/boot/grub/grub.conf /boot/grub/grub.cfg /boot/grub/menu.lst /boot/boot/grub/grub.conf /boot/boot/grub/grub.cfg /boot/boot/grub/menu.lst /boot/grub2/grub.cfg).each do |f|
describe file(f) do
its(:content) { should match(/audit=1/) }
end
Expand Down Expand Up @@ -353,11 +353,11 @@

if command('uname -m').stdout.strip == 'x86_64'
describe file('/etc/audit/audit.rules') do
its(:content) { should match(/^-a (always,exit|exit,always) arch=b64 -S init_module -S delete_module -k modules$/) }
its(:content) { should match(/^-a (always,exit|exit,always) -F arch=b64 -S init_module -S delete_module -k modules$/) }
end
else
describe file('/etc/audit/audit.rules') do
its(:content) { should match(/^-a (always,exit|exit,always) arch=b32 -S init_module -S delete_module -k modules$/) }
its(:content) { should match(/^-a (always,exit|exit,always) -F arch=b32 -S init_module -S delete_module -k modules$/) }
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions controls/5_1_configure_cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
tag cis: 'distribution-independent-linux:5.1.1'
tag level: 1

%w(cron crond).each do |s|
describe service(s) do
it { should be_enabled }
it { should be_running }
describe.one do
%w(cron crond).each do |s|
describe service(s) do
it { should be_enabled }
it { should be_running }
end
end
end
end
Expand Down

0 comments on commit 7acf3e7

Please sign in to comment.