Hide db credentials

To protect users who have publically accessible installs with debug
turned on - *** out db login credentials
This commit is contained in:
AD7six 2011-06-24 10:12:08 +02:00
parent f641da89fa
commit e4fee14a5b
2 changed files with 46 additions and 0 deletions

View file

@ -499,6 +499,16 @@ class Debugger extends Object {
case 'object':
return get_class($var) . "\n" . $_this->__object($var);
case 'array':
$var = array_merge($var, array_intersect_key(array(
'password' => '*****',
'login' => '*****',
'host' => '*****',
'database' => '*****',
'port' => '*****',
'prefix' => '*****',
'schema' => '*****'
), $var));
$out = "array(";
$vars = array();
foreach ($var as $key => $val) {

View file

@ -333,4 +333,40 @@ class DebuggerTest extends CakeTestCase {
$result =& Debugger::getInstance('Debugger');
$this->assertIsA($result, 'Debugger');
}
/**
* testNoDbCredentials
*
* If a connection error occurs, the config variable is passed through exportVar
* *** our database login credentials such that they are never visible
*
* @access public
* @return void
*/
function testNoDbCredentials() {
$config = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'void.cakephp.org',
'login' => 'cakephp-user',
'password' => 'cakephp-password',
'database' => 'cakephp-database',
'prefix' => ''
);
$output = Debugger::exportVar($config);
$expectedArray = array(
'driver' => 'mysql',
'persistent' => false,
'host' => '*****',
'login' => '*****',
'password' => '*****',
'database' => '*****',
'prefix' => ''
);
$expected = Debugger::exportVar($expectedArray);
$this->assertEqual($expected, $output);
}
}