From ee0955b30b4f0cd5f94c2bc74dd0c26b8fe49527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 17 Jun 2016 11:04:28 +0200 Subject: [PATCH 1/2] Use same condition for link start as for link end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- templates/list/item.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/list/item.phtml b/templates/list/item.phtml index 6cdfabb27a..099a211d86 100644 --- a/templates/list/item.phtml +++ b/templates/list/item.phtml @@ -32,10 +32,10 @@ ?>> - + - \ No newline at end of file + From f5e8953356465d079cbb6b6f3445aca90c98d801 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 17 Jun 2016 11:18:39 +0200 Subject: [PATCH 2/2] Share backtrace processing for debugging and error reporting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to achieve same thing in both cases - backtrace which is stripped from sensitive information, has reasonable size and can be read. Sharing the code will make it easier to fix possible problems and also will make both cases behave consistent. Signed-off-by: Michal Čihař --- libraries/DatabaseInterface.php | 27 ++------------- libraries/Error.php | 60 +++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 46 deletions(-) diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index c36f9399dc..114132ee9c 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -206,30 +206,9 @@ class DatabaseInterface // Get and slightly format backtrace, this is used // in the javascript console. // Strip call to _dbgQuery - $dbgInfo['trace'] = array_slice(debug_backtrace(), 1); - foreach ($dbgInfo['trace'] as $key => $step) { - if (isset($step['file'])) { - $dbgInfo['trace'][$key]['file'] = Error::relPath($step['file']); - } - // We don't need object value in console and it's too big - if (isset($step['object'])) { - unset($dbgInfo['trace'][$key]['object']); - } - // Convert args to string as that's what the client would do anyway - if (isset($step['args'])) { - $simplified = array(); - foreach ($step['args'] as $akey => $aval) { - if (is_object($aval)) { - $simplified[$akey] = ''; - } elseif (is_array($aval)) { - $simplified[$akey] = var_export($aval, true); - } else { - $simplified[$akey] = $aval; - } - } - $dbgInfo['trace'][$key]['args'] = $simplified; - } - } + $dbgInfo['trace'] = Error::processBacktrace( + array_slice(debug_backtrace(), 1) + ); $dbgInfo['hash'] = md5($query); $_SESSION['debug']['queries'][] = $dbgInfo; diff --git a/libraries/Error.php b/libraries/Error.php index 947bf998bc..5caec03852 100644 --- a/libraries/Error.php +++ b/libraries/Error.php @@ -106,6 +106,41 @@ class Error extends Message $this->setBacktrace($backtrace); } + /** + * Process backtrace to avoid path disclossures, objects and so on + * + * @param array $backtrace backtrace + * + * @return array + */ + public static function processBacktrace($backtrace) + { + $result = array(); + + $members = array('file', 'line', 'function', 'class', 'type'); + + foreach ($backtrace as $idx => $step) { + /* Create new backtrace entry */ + $result[$idx] = array(); + + /* Store members we want */ + foreach ($members as $name) { + if (isset($step[$name])) { + $result[$idx][$name] = $step[$name]; + } + } + + /* Store simplified args */ + if (isset($step['args'])) { + foreach ($step['args'] as $key => $arg) { + $result[$idx]['args'][$key] = Error::getArg($arg, $step['function']); + } + } + } + + return $result; + } + /** * sets PMA\libraries\Error::$_backtrace * @@ -117,28 +152,7 @@ class Error extends Message */ public function setBacktrace($backtrace) { - $this->backtrace = array(); - - $members = array('file', 'line', 'function', 'class', 'type'); - - foreach ($backtrace as $idx => $step) { - /* Create new backtrace entry */ - $this->backtrace[$idx] = array(); - - /* Store members we want */ - foreach ($members as $name) { - if (isset($step[$name])) { - $this->backtrace[$idx][$name] = $step[$name]; - } - } - - /* Store simplified args */ - if (isset($step['args'])) { - foreach ($step['args'] as $key => $arg) { - $this->backtrace[$idx]['args'][$key] = Error::getArg($arg, $step['function']); - } - } - } + $this->backtrace = Error::processBacktrace($backtrace); } /** @@ -379,6 +393,8 @@ class Error extends Message } elseif (is_scalar($arg)) { $retval .= getType($arg) . ' ' . htmlspecialchars(var_export($arg, true)); + } elseif (is_object($arg)) { + $retval .= ''; } else { $retval .= getType($arg); }