|
22 | 22 | control 'mysql-db-01' do
|
23 | 23 | impact 0.3
|
24 | 24 | title 'use supported mysql version in production'
|
25 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select version();' | tail -1") do |
| 25 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select version();'") do |
26 | 26 | its(:stdout) { should_not match(/Community/) }
|
27 | 27 | end
|
28 | 28 | end
|
29 | 29 |
|
30 | 30 | control 'mysql-db-02' do
|
31 | 31 | impact 0.5
|
32 | 32 | title 'use mysql version 5 or higher'
|
33 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select substring_index(version(),\".\",1);'") do |
| 33 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select substring_index(version(),\".\",1);'") do |
34 | 34 | its(:stdout) { should cmp >= 5 }
|
35 | 35 | end
|
36 | 36 | end
|
37 | 37 |
|
38 | 38 | control 'mysql-db-03' do
|
39 | 39 | impact 1.0
|
40 | 40 | title 'test database must be deleted'
|
41 |
| - describe command("mysql -u#{user} -p#{pass} -s -e 'show databases like \"test\";'") do |
| 41 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'show databases like \"test\";'") do |
42 | 42 | its(:stdout) { should_not match(/test/) }
|
43 | 43 | end
|
44 | 44 | end
|
45 | 45 |
|
46 | 46 | control 'mysql-db-04' do
|
47 | 47 | impact 1.0
|
48 | 48 | title 'deactivate annonymous user names'
|
49 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where user=\"\";' | tail -1") do |
| 49 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select count(*) from mysql.user where user=\"\";'") do |
50 | 50 | its(:stdout) { should match(/^0/) }
|
51 | 51 | end
|
52 | 52 | end
|
53 | 53 |
|
54 | 54 | control 'mysql-db-05' do
|
55 | 55 | impact 1.0
|
56 | 56 | title 'default passwords must be changed'
|
57 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where length(password)=0 or password=\"\";' | tail -1") do |
| 57 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select count(*) from mysql.user where length(password)=0 or password=\"\";'") do |
58 | 58 | its(:stdout) { should match(/^0/) }
|
59 | 59 | end
|
60 | 60 | end
|
61 | 61 |
|
62 | 62 | control 'mysql-db-06' do
|
63 | 63 | impact 0.5
|
64 | 64 | title 'the grant option must not be used'
|
65 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where grant_priv=\"y\" and User!=\"root\" and User!=\"debian-sys-maint\";' | tail -1") do |
| 65 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select count(*) from mysql.user where grant_priv=\"y\" and User!=\"root\" and User!=\"debian-sys-maint\";'") do |
66 | 66 | its(:stdout) { should match(/^0/) }
|
67 | 67 | end
|
68 | 68 | end
|
69 | 69 |
|
70 | 70 | control 'mysql-db-07' do
|
71 | 71 | impact 0.5
|
72 | 72 | title 'ensure no wildcards are used for hostnames'
|
73 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where host=\"%\"' | tail -1") do |
| 73 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select count(*) from mysql.user where host=\"%\"'") do |
74 | 74 | its(:stdout) { should match(/^0/) }
|
75 | 75 | end
|
76 | 76 | end
|
77 | 77 |
|
78 | 78 | control 'mysql-db-08' do
|
79 | 79 | impact 0.5
|
80 | 80 | title 'it must be ensured that superuser can login via localhost only'
|
81 |
| - describe command("mysql -u#{user} -p#{pass} mysql -s -e 'select count(*) from mysql.user where user=\"root\" and host not in (\"localhost\",\"127.0.0.1\",\"::1\")' | tail -1") do |
| 81 | + describe command("mysql -u#{user} -p#{pass} -sN -e 'select count(*) from mysql.user where user=\"root\" and host not in (\"localhost\",\"127.0.0.1\",\"::1\")'") do |
82 | 82 | its(:stdout) { should match(/^0/) }
|
83 | 83 | end
|
84 | 84 | end
|
0 commit comments