Added the possibility to enable debug for site admins

- new option in server settings
- enable debug (equal to normal debug level 1) for site admins only

- regular users will be unaffected
pull/762/head
Iglocska 2015-12-03 01:45:38 +01:00
parent d433618c71
commit ab26eafd63
5 changed files with 24 additions and 11 deletions

View File

@ -229,11 +229,12 @@ class AppController extends Controller {
$this->set('isAclTemplate', false);
$this->set('isAclSharingGroup', false);
}
if (Configure::read('debug') > 0) {
$this->debugMode = 'debugOn';
} else {
$this->debugMode = 'debugOff';
if (Configure::read('site_admin_debug') && $this->_isSiteAdmin() && (Configure::read('debug') < 2)) {
Configure::write('debug', 1);
}
$this->debugMode = 'debugOff';
if (Configure::read('debug') > 1) $this->debugMode = 'debugOn';
$this->set('debugMode', $this->debugMode);
$proposalCount = $this->_getProposalCount();
$this->set('proposalCount', $proposalCount[0]);

View File

@ -946,10 +946,6 @@ class ServersController extends AppController {
return new CakeResponse(array('body'=> json_encode(array('status' => $result['status']))));
}
public function checkVersionCompatibility($id) {
debug($this->Server->checkVersionCompatibility($id, $this->Auth->user()));
}
public function startZeroMQServer() {
if (!$this->_isSiteAdmin()) throw new MethodNotAllowedException();
App::uses('PubSubTool', 'Tools');

View File

@ -760,6 +760,14 @@ class Server extends AppModel {
'type' => 'numeric',
'options' => array(0 => 'Debug off', 1 => 'Debug on', 2 => 'Debug + SQL dump'),
),
'site_admin_debug' => array(
'level' => 0,
'description' => 'The debug level of the instance for site admins. This feature allows site admins to run debug mode on a live instance without exposing it to other users. The most verbose option of debug and site_admin_debug is used for site admins.',
'value' => '',
'errorMessage' => '',
'test' => 'testDebugAdmin',
'type' => 'boolean',
),
);
public $validEventIndexFilters = array('searchall', 'searchpublished', 'searchorg', 'searchtag', 'searcheventid', 'searchdate', 'searcheventinfo', 'searchthreatlevel', 'searchdistribution', 'searchanalysis', 'searchattribute');
@ -1396,6 +1404,14 @@ class Server extends AppModel {
if ($value === 0) return true;
return 'This setting has to be set to 0 on production systems. Ignore this warning if this is not the case.';
}
public function testDebugAdmin($value) {
if ($this->testForEmpty($value) !== true) return $this->testForEmpty($value);
if ($this->testBool($value) !== true) return 'This setting has to be either true or false.';
if (!$value) return true;
return 'Enabling debug is not recommended. Turn this on temporarily if you need to see a stack trace to debug an issue, but make sure this is not left on.';
}
public function testBaseURL($value) {
if ($this->testForEmpty($value) !== true) return $this->testForEmpty($value);
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) === true ? 'HTTPS' : 'HTTP';
@ -1534,7 +1550,7 @@ class Server extends AppModel {
public function serverSettingsSaveValue($setting, $value) {
Configure::write($setting, $value);
Configure::dump('config.php', 'default', array('MISP', 'GnuPG', 'Proxy', 'SecureAuth', 'Security', 'debug', 'Plugin'));
Configure::dump('config.php', 'default', array('MISP', 'GnuPG', 'Proxy', 'SecureAuth', 'Security', 'debug', 'site_admin_debug', 'Plugin'));
}
public function checkVersion($newest) {

View File

@ -6,7 +6,7 @@
}
if ($setting['level'] == 3) $bgColour = 'background-color:gray;color:white;';
if ($setting['type'] == 'boolean') $setting['value'] = ($setting['value'] === true ? 'true' : 'false');
if (isset($setting['options'])) $setting['value'] = ($setting['options'][$setting['value']]);
if (isset($setting['options'])) $setting['value'] = $setting['options'][$setting['value']];
?>
<tr id ="<?php echo h($k); ?>_row">
<td class="short" style="<?php echo $bgColour; ?>"><?php echo h($priorities[$setting['level']]);?></td>

View File

@ -58,7 +58,7 @@
</div>
<?php
$topGap = 50;
if (Configure::read('debug') != 0) {
if (Configure::read('debug') > 1) {
$topGap = 10;
} else {
if ($has_flash) $topGap += 50;