inspec / inspec

InSpec: Auditing and Testing Framework
http://inspec.io
Other
2.86k stars 683 forks source link

mysql configs in mysql_session resource #3166

Open mengesb opened 6 years ago

mengesb commented 6 years ago

Use .my.cnf or .mylogin.cnf files/options in mysql_session resource

🙋 feature request?

MySQL can use a dotfile (.my.cnf) for configuration information or an encrypted file (.mylogin.cnf) to support logging into a MySQL instance. In the case of the encrypted file, you must pass the profile path (e.x. mysql --login-path=client if the profile is [client])

🌍 InSpec and Platform Version

2.1.72

🤔 Replication Case

💁 Possible Solutions

Currently the only solution is to use command()

💻 Stacktrace

N/A - config loading is unsupported in the resource it appears

mengesb commented 6 years ago

This is to improve a test like:

describe command('/usr/bin/mysql --login-path=client -e "SHOW DATABASES;"') do
  its('exit_status') { should eq 0 }
  its('stdout') { should include 'mysql' }
end

to perhaps something like

sql = mysql_session(config: '/root/.mylogin.cnf', login_path: 'client')
describe sql.query('SHOW DATABASES) do
  its('stdout') { should include 'mysql' }
end