From 0b7986100bd87a6c93e9341ad9d296de3f3801db Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Wed, 9 Jul 2014 10:22:48 +0200 Subject: [PATCH 1/6] added additional test (find rhosts-files, check /etc/shadow owner and rights, check PATH variable, check umask) Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index bc75d8d..2701423 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -207,3 +207,43 @@ its(:value) { should eq 2 } end end + +# GIS: Req 3.21-4 +describe command('find / -name \'.rhosts\' | wc -l ') do + its(:stdout) { should match /0/ } +end + +# GIS: Req 3.21-4 +describe command('find / -name \'hosts.equiv\' | wc -l ') do + its(:stdout) { should match /0/ } +end + +# GIS: Req 3.21-7 +describe file('/etc/shadow') do + it { should be_owned_by 'root' } +end + +# GIS: Req 3.21-7 +describe file('/etc/shadow') do + it { should be_mode 600 } +end + +# GIS: Req 3.21-8 +describe command('echo $PATH | grep -ci \'\.\'') do + its(:stdout) { should match /0/ } +end + +# GIS: Req 3.21-8 +describe file('/etc/login.defs') do + its(:content) { should match /^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:/ } +end + +# GIS: Req 3.21-8 +describe file('/etc/login.defs') do + its(:content) { should match /^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin:/ } +end + +# GIS: Req 3.21-10 +describe file('/etc/login.defs') do + its(:content) { should match /^UMASK +027/ } +end From fb8e4a7d182c747c0ef4636405a85e8cd8b88f04 Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Thu, 10 Jul 2014 10:31:13 +0200 Subject: [PATCH 2/6] Fixed rubocop issues, Travis run failed Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 2701423..0ed951e 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -210,12 +210,12 @@ # GIS: Req 3.21-4 describe command('find / -name \'.rhosts\' | wc -l ') do - its(:stdout) { should match /0/ } + its(:stdout) { should match (/^0/) } end # GIS: Req 3.21-4 describe command('find / -name \'hosts.equiv\' | wc -l ') do - its(:stdout) { should match /0/ } + its(:stdout) { should match (/^0/) } end # GIS: Req 3.21-7 @@ -230,20 +230,20 @@ # GIS: Req 3.21-8 describe command('echo $PATH | grep -ci \'\.\'') do - its(:stdout) { should match /0/ } + its(:stdout) { should match (/^0/) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match /^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:/ } + its(:content) { should match (/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:/) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match /^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin:/ } + its(:content) { should match (/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin:/) } end # GIS: Req 3.21-10 describe file('/etc/login.defs') do - its(:content) { should match /^UMASK +027/ } + its(:content) { should match (/^UMASK +027/) } end From ef40878dcf30ee0ea7228d0862ac43e660b9c699 Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Thu, 10 Jul 2014 10:35:46 +0200 Subject: [PATCH 3/6] Fix: ENV_PATH in login.defs test not correct Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 0ed951e..5ae50b2 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -235,12 +235,12 @@ # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match (/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin:/) } + its(:content) { should match (/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin/) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match (/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin:/) } + its(:content) { should match (/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin/) } end # GIS: Req 3.21-10 From 8a6c0eb52db94379bdf715015ae51c70efdfa607 Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Thu, 10 Jul 2014 10:41:18 +0200 Subject: [PATCH 4/6] Fix: Syntax warrings Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 5ae50b2..5e02dde 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -210,12 +210,12 @@ # GIS: Req 3.21-4 describe command('find / -name \'.rhosts\' | wc -l ') do - its(:stdout) { should match (/^0/) } + its(:stdout) { should match(/^0/) } end # GIS: Req 3.21-4 describe command('find / -name \'hosts.equiv\' | wc -l ') do - its(:stdout) { should match (/^0/) } + its(:stdout) { should match(/^0/) } end # GIS: Req 3.21-7 @@ -230,20 +230,20 @@ # GIS: Req 3.21-8 describe command('echo $PATH | grep -ci \'\.\'') do - its(:stdout) { should match (/^0/) } + its(:stdout) { should match(/^0/) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match (/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin/) } + its(:content) { should match(/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin/) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match (/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin/) } + its(:content) { should match(/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin/) } end # GIS: Req 3.21-10 describe file('/etc/login.defs') do - its(:content) { should match (/^UMASK +027/) } + its(:content) { should match(/^UMASK +027/) } end From 998370b205aa050a9b474ebbf1f9a7d06a0dcdcb Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Thu, 10 Jul 2014 10:55:04 +0200 Subject: [PATCH 5/6] FIX: Use %r for regular expressions matching Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 5e02dde..418735c 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -235,12 +235,12 @@ # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match(/^ENV_SUPATH\s+PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin/) } + its(:content) { should match(%r{/^ENV_SUPATH\s+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin/}) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match(/^ENV_PATH\s+PATH=\/usr\/local\/bin:\/usr\/bin:\/bin/) } + its(:content) { should match(%r{/^ENV_PATH\s+PATH=/usr/local/bin:/usr/bin:/bin/}) } end # GIS: Req 3.21-10 From 2de4db352a70dd71ddb427bc5daa78fa9a31081b Mon Sep 17 00:00:00 2001 From: Patrick Meier Date: Thu, 10 Jul 2014 12:25:50 +0200 Subject: [PATCH 6/6] FIX: reqular expression in PATH variable Signed-off-by: Patrick Meier --- default/serverspec/sysctl_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default/serverspec/sysctl_spec.rb b/default/serverspec/sysctl_spec.rb index 418735c..5cb6226 100644 --- a/default/serverspec/sysctl_spec.rb +++ b/default/serverspec/sysctl_spec.rb @@ -235,12 +235,12 @@ # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match(%r{/^ENV_SUPATH\s+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin/}) } + its(:content) { should match(%r{^ENV_SUPATH\s+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}) } end # GIS: Req 3.21-8 describe file('/etc/login.defs') do - its(:content) { should match(%r{/^ENV_PATH\s+PATH=/usr/local/bin:/usr/bin:/bin/}) } + its(:content) { should match(%r{^ENV_PATH\s+PATH=/usr/local/bin:/usr/bin:/bin}) } end # GIS: Req 3.21-10