Skip to content

Commit 0a281c8

Browse files
committed
Merge pull request #9 from ehaselwanter/hardening-fixes
update tests for all supported plattform
2 parents 5499d5b + abb8392 commit 0a281c8

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

default/roles/mysql.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"default_attributes" : {
99
"mysql": {
1010
"server_root_password": "iloverandompasswordsbutthiswilldo",
11-
"server_repl_password": "iloverandompasswordsbutthiswilldo",
1211
"server_debian_password": "iloverandompasswordsbutthiswilldo"
1312
}
1413
},

default/serverspec/mysql_spec.rb

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@
1414
end
1515
end
1616

17+
mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf'
18+
1719
# set OS-dependent filenames and paths
1820
case backend.check_os[:family]
19-
when 'Ubuntu'
21+
when 'Ubuntu', 'Debian'
2022
mysql_config_file = '/etc/mysql/my.cnf'
21-
mysql_hardening_file = '/etc/mysql/conf.d/hardening.cnf'
2223
mysql_config_path = '/etc/mysql/'
2324
mysql_data_path = '/var/lib/mysql/'
2425
mysql_log_path = '/var/log/'
26+
mysql_log_file = 'mysql.log'
27+
mysql_log_group = 'adm'
28+
os[:release] == '14.04' ? mysql_log_dir_group = 'syslog' : mysql_log_dir_group = 'root'
2529
service_name = 'mysql'
2630
when 'RedHat', 'Fedora'
2731
mysql_config_file = '/etc/my.cnf'
28-
mysql_hardening_file = '/etc/hardening.cnf'
2932
mysql_config_path = '/etc/'
3033
mysql_data_path = '/var/lib/mysql/'
3134
mysql_log_path = '/var/log/'
35+
mysql_log_file = 'mysqld.log'
36+
mysql_log_group = 'mysql'
37+
mysql_log_dir_group = 'root'
3238
service_name = 'mysqld'
3339
end
3440

@@ -92,7 +98,7 @@
9298

9399
# Req. 299 (nur eine instanz pro server)
94100
describe 'Req. 299: check for multiple instances' do
95-
describe command('ps aux | grep mysqld | grep -v grep | wc -l') do
101+
describe command('ps aux | grep mysqld | egrep -v "grep|mysqld_safe|logger" | wc -l') do
96102
its(:stdout) { should match(/^1$/) }
97103
end
98104
end
@@ -136,7 +142,7 @@
136142

137143
# Req. 316 (skip-grant-tables)
138144
describe file(tmp_config_file) do
139-
its(:content) { should match(/^\s*?skip-grant-tables/) }
145+
its(:content) { should_not match(/^\s*?skip-grant-tables/) }
140146
end
141147

142148
# Req. 320 (kein "allow-suspicious-udfs")
@@ -151,27 +157,26 @@
151157

152158
describe file(mysql_data_path) do
153159
it { should be_directory }
154-
end
155-
156-
describe file(mysql_data_path) do
157160
it { should be_owned_by 'mysql' }
158161
it { should be_grouped_into 'mysql' }
159162
end
160163

161164
describe file("#{mysql_data_path}/ibdata1") do
162165
it { should be_owned_by 'mysql' }
163166
it { should be_grouped_into 'mysql' }
167+
it { should_not be_readable.by('others') }
164168
end
165169

166170
describe file(mysql_log_path) do
167171
it { should be_directory }
168172
it { should be_owned_by 'root' }
169-
it { should be_grouped_into 'root' }
173+
it { should be_grouped_into mysql_log_dir_group }
170174
end
171175

172-
describe file("#{mysql_log_path}/mysql.log") do
176+
describe file("#{mysql_log_path}/#{mysql_log_file}") do
173177
it { should be_owned_by 'mysql' }
174-
it { should be_grouped_into 'adm' }
178+
it { should be_grouped_into mysql_log_group }
179+
it { should_not be_readable.by('others') }
175180
end
176181

177182
end
@@ -190,6 +195,13 @@
190195
describe file(mysql_config_file) do
191196
it { should be_owned_by 'mysql' }
192197
it { should be_grouped_into 'mysql' }
198+
it { should_not be_readable.by('others') }
199+
end
200+
201+
describe file(mysql_hardening_file) do
202+
it { should be_owned_by 'mysql' }
203+
it { should be_grouped_into 'root' }
204+
it { should_not be_readable.by('others') }
193205
end
194206

195207
end

0 commit comments

Comments
 (0)