mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Hide db credentials
To protect users who have publically accessible installs with debug turned on - *** out db login credentials
This commit is contained in:
parent
f641da89fa
commit
e4fee14a5b
2 changed files with 46 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue