Skip to content

Commit 7ac92c6

Browse files
author
Sebastian Gumprich
committed
only run password-checks when the appropriate columns exist
Signed-off-by: Sebastian Gumprich <github@gumpri.ch>
1 parent e74bd4f commit 7ac92c6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

controls/mysql_db.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,25 @@
5454
control 'mysql-db-05' do
5555
impact 1.0
5656
title 'default passwords must be changed'
57+
only_if('mysql user table has a password column') do
58+
command("mysql -u#{user} -p#{pass} mysql -sN -e 'SELECT count(COLUMN_NAME) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \"mysql\" AND TABLE_NAME = \"user\" AND COLUMN_NAME = \"password\";'").stdout.strip == '1'
59+
end
5760
describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where length(password)=0 or password=\"\";' | tail -1") do
5861
its(:stdout) { should match(/^0/) }
5962
end
6063
end
6164

65+
control 'mysql-db-05b' do
66+
impact 1.0
67+
title 'default passwords must be changed'
68+
only_if('mysql user table has an authentication_string column') do
69+
command("mysql -u#{user} -p#{pass} mysql -sN -e 'SELECT count(COLUMN_NAME) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = \"mysql\" AND TABLE_NAME = \"user\" AND COLUMN_NAME = \"authentication_string\";'").stdout.strip == '1'
70+
end
71+
describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where length(authentication_string)=0 or authentication_string=\"\";' | tail -1") do
72+
its(:stdout) { should match(/^0/) }
73+
end
74+
end
75+
6276
control 'mysql-db-06' do
6377
impact 0.5
6478
title 'the grant option must not be used'

0 commit comments

Comments
 (0)