mirror of https://github.com/MISP/MISP
Changes to logs and some minor changes
- Regexp, blacklist, roles, whitelists now logged - adminCRUD now sets ID (for the logging) on edit - some minor UI changes (removal of empty action menues on the left menu bar)pull/63/head
parent
13f2a274e8
commit
83294820bf
|
@ -47,7 +47,7 @@ class BlacklistsController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
public function admin_add() {
|
||||
if($this->_isSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_isSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminAdd();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class BlacklistsController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
public function admin_index() {
|
||||
if($this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminIndex();
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ class BlacklistsController extends AppController {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
public function admin_edit($id = null) {
|
||||
if($this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminEdit($id);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class BlacklistsController extends AppController {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
public function admin_delete($id = null) {
|
||||
if($this->Auth->User('org') != 'ADMIN') $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->Auth->User('org') != 'ADMIN') $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminDelete($id);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class WhitelistsController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
public function admin_index() {
|
||||
if($this->_IsSiteAdmin()) $this->redirect(array('controller' => 'whitelists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_IsSiteAdmin()) $this->redirect(array('controller' => 'whitelists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminIndex();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class WhitelistsController extends AppController {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
public function admin_edit($id = null) {
|
||||
if($this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminEdit($id);
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class WhitelistsController extends AppController {
|
|||
* @throws NotFoundException
|
||||
*/
|
||||
public function admin_delete($id = null) {
|
||||
if($this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
if(!$this->_IsSiteAdmin()) $this->redirect(array('controller' => 'blacklists', 'action' => 'index', 'admin' => false));
|
||||
$this->AdminCrud->adminDelete($id);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,14 @@ class Blacklist extends AppModel {
|
|||
*/
|
||||
public $displayField = 'name';
|
||||
|
||||
public $actsAs = array('Trim');
|
||||
public $actsAs = array(
|
||||
'Trim',
|
||||
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
||||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppModel', 'Model');
|
||||
|
||||
/**
|
||||
* Regexp Model
|
||||
*
|
||||
*/
|
||||
class Regexp extends AppModel {
|
||||
|
||||
/**
|
||||
* Use table
|
||||
*
|
||||
* @var mixed False or table name
|
||||
*/
|
||||
public $useTable = 'regexp';
|
||||
<?php
|
||||
|
||||
App::uses('AppModel', 'Model');
|
||||
|
||||
/**
|
||||
* Regexp Model
|
||||
*
|
||||
*/
|
||||
class Regexp extends AppModel {
|
||||
|
||||
public $actsAs = array(
|
||||
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
||||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
),
|
||||
);
|
||||
/**
|
||||
* Use table
|
||||
*
|
||||
* @var mixed False or table name
|
||||
*/
|
||||
public $useTable = 'regexp';
|
||||
}
|
|
@ -1,103 +1,112 @@
|
|||
<?php
|
||||
App::uses('AppModel', 'Model');
|
||||
/**
|
||||
* Role Model
|
||||
*
|
||||
* @property User $User
|
||||
*/
|
||||
class Role extends AppModel {
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $validate = array(
|
||||
'name' => array(
|
||||
'notempty' => array(
|
||||
'rule' => array('notempty'),
|
||||
//'message' => 'Your custom message here',
|
||||
//'allowEmpty' => false,
|
||||
//'required' => false,
|
||||
//'last' => false, // Stop validation after this rule
|
||||
//'on' => 'create', // Limit validation to 'create' or 'update' operations
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* hasMany associations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $hasMany = array(
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'role_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO ACL: 1: be requester to CakePHP ACL system
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $actsAs = array('Acl' => array('type' => 'requester'), 'MagicTools.OrphansProtectable', 'Trim');
|
||||
|
||||
/**
|
||||
* TODO ACL: 2: hook Role into CakePHP ACL system (so link to aros)
|
||||
*/
|
||||
public function parentNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual field
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $virtualFields = array(
|
||||
'permission' => "IF (Role.perm_add && Role.perm_modify && Role.perm_publish, '3', IF (Role.perm_add && Role.perm_modify_org, '2', IF (Role.perm_add, '1', '0')))",
|
||||
);
|
||||
|
||||
public function beforeSave($options = array()) {
|
||||
switch ($this->data['Role']['permission']) {
|
||||
case '0':
|
||||
$this->data['Role']['perm_add'] = false;
|
||||
$this->data['Role']['perm_modify'] = false;
|
||||
$this->data['Role']['perm_modify_org'] = false;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '1':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true; // SHOULD BE true
|
||||
$this->data['Role']['perm_modify_org'] = false;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '2':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true;
|
||||
$this->data['Role']['perm_modify_org'] = true;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '3':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true; // ?
|
||||
$this->data['Role']['perm_modify_org'] = true; // ?
|
||||
$this->data['Role']['perm_publish'] = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
<?php
|
||||
App::uses('AppModel', 'Model');
|
||||
/**
|
||||
* Role Model
|
||||
*
|
||||
* @property User $User
|
||||
*/
|
||||
class Role extends AppModel {
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $validate = array(
|
||||
'name' => array(
|
||||
'notempty' => array(
|
||||
'rule' => array('notempty'),
|
||||
//'message' => 'Your custom message here',
|
||||
//'allowEmpty' => false,
|
||||
//'required' => false,
|
||||
//'last' => false, // Stop validation after this rule
|
||||
//'on' => 'create', // Limit validation to 'create' or 'update' operations
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* hasMany associations
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $hasMany = array(
|
||||
'User' => array(
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'role_id',
|
||||
'dependent' => false,
|
||||
'conditions' => '',
|
||||
'fields' => '',
|
||||
'order' => '',
|
||||
'limit' => '',
|
||||
'offset' => '',
|
||||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO ACL: 1: be requester to CakePHP ACL system
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
public $actsAs = array(
|
||||
'Acl' => array('type' => 'requester'),
|
||||
'MagicTools.OrphansProtectable',
|
||||
'Trim',
|
||||
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
||||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* TODO ACL: 2: hook Role into CakePHP ACL system (so link to aros)
|
||||
*/
|
||||
public function parentNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual field
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $virtualFields = array(
|
||||
'permission' => "IF (Role.perm_add && Role.perm_modify && Role.perm_publish, '3', IF (Role.perm_add && Role.perm_modify_org, '2', IF (Role.perm_add, '1', '0')))",
|
||||
);
|
||||
|
||||
public function beforeSave($options = array()) {
|
||||
switch ($this->data['Role']['permission']) {
|
||||
case '0':
|
||||
$this->data['Role']['perm_add'] = false;
|
||||
$this->data['Role']['perm_modify'] = false;
|
||||
$this->data['Role']['perm_modify_org'] = false;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '1':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true; // SHOULD BE true
|
||||
$this->data['Role']['perm_modify_org'] = false;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '2':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true;
|
||||
$this->data['Role']['perm_modify_org'] = true;
|
||||
$this->data['Role']['perm_publish'] = false;
|
||||
break;
|
||||
case '3':
|
||||
$this->data['Role']['perm_add'] = true;
|
||||
$this->data['Role']['perm_modify'] = true; // ?
|
||||
$this->data['Role']['perm_modify_org'] = true; // ?
|
||||
$this->data['Role']['perm_publish'] = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,14 @@ class Whitelist extends AppModel {
|
|||
*/
|
||||
public $displayField = 'name';
|
||||
|
||||
public $actsAs = array('Trim');
|
||||
public $actsAs = array(
|
||||
'Trim',
|
||||
'SysLogLogable.SysLogLogable' => array( // TODO Audit, logable
|
||||
'roleModel' => 'Role',
|
||||
'roleKey' => 'role_id',
|
||||
'change' => 'full'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Validation rules
|
||||
|
|
|
@ -204,6 +204,30 @@ class SysLogLogableBehavior extends LogableBehavior {
|
|||
$title = 'Server ('. $Model->data[$Model->alias]['id'].'): '. $this->Servers->getName($Model->data[$Model->alias]['id']);
|
||||
$logData['Log']['title'] = $title;
|
||||
break;
|
||||
case "Role":
|
||||
$this->Roles = new RolesController();
|
||||
$this->Roles->constructClasses();
|
||||
$title = 'Role ('. $Model->data[$Model->alias]['id'] .'): '. $Model->data[$Model->alias]['name'];
|
||||
$logData['Log']['title'] = $title;
|
||||
break;
|
||||
case "Whitelist":
|
||||
$this->Whitelists = new WhitelistsController();
|
||||
$this->Whitelists->constructClasses();
|
||||
$title = 'Whitelist ('. $Model->data[$Model->alias]['id'] .'): '. $Model->data[$Model->alias]['name'];
|
||||
$logData['Log']['title'] = $title;
|
||||
break;
|
||||
case "Blacklist":
|
||||
$this->Blacklists = new BlacklistsController();
|
||||
$this->Blacklists->constructClasses();
|
||||
$title = 'Blacklists ('. $Model->data[$Model->alias]['id'] .'): '. $Model->data[$Model->alias]['name'];
|
||||
$logData['Log']['title'] = $title;
|
||||
break;
|
||||
case "Regexp":
|
||||
$this->Regexp = new RegexpController();
|
||||
$this->Regexp->constructClasses();
|
||||
$title = 'Regexp ('. $Model->data[$Model->alias]['id'] .'): '. $Model->data[$Model->alias]['regexp'];
|
||||
$logData['Log']['title'] = $title;
|
||||
break;
|
||||
default:
|
||||
if (isset($Model->combinedKeys)) {
|
||||
if (is_array($Model->combinedKeys)) {
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<h3><?php echo __('Actions');?></h3>
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu');?>
|
||||
</ul>
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<h3><?php echo __('Actions');?></h3>
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu');?>
|
||||
</ul>
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<legend><?php echo __('Add Role'); ?></legend>
|
||||
<?php
|
||||
echo $this->Form->input('name');?>
|
||||
<?php echo $this->Form->radio('permission', $options, array('value' => '3', 'style' => 'vertical-align: middle'));?>
|
||||
<?php echo $this->Form->input('perm_sync', array('type' => 'checkbox', 'checked' => false, 'label' => 'Sync Actions', 'style' => 'vertical-align: middle'));?>
|
||||
<?php echo $this->Form->input('perm_admin', array('type' => 'checkbox', 'checked' => false, 'label' => 'Administration Actions', 'style' => 'vertical-align: middle'));?>
|
||||
<?php echo $this->Form->input('perm_audit', array('type' => 'checkbox', 'checked' => false, 'label' => 'Audit Actions', 'style' => 'vertical-align: middle'));?>
|
||||
<?php echo $this->Form->input('perm_auth', array('type' => 'checkbox', 'checked' => false, 'label' => 'Auth Key Access', 'style' => 'vertical-align: middle'));?>
|
||||
<?php echo $this->Form->radio('permission', $options, array('value' => '3'));?>
|
||||
<?php echo $this->Form->input('perm_sync', array('type' => 'checkbox', 'checked' => false));?>
|
||||
<?php echo $this->Form->input('perm_admin', array('type' => 'checkbox', 'checked' => false));?>
|
||||
<?php echo $this->Form->input('perm_audit', array('type' => 'checkbox', 'checked' => false));?>
|
||||
<?php echo $this->Form->input('perm_auth', array('type' => 'checkbox', 'checked' => false));?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<?php echo $this->Form->end(__('Submit'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<h3><?php echo __('Actions');?></h3>
|
||||
<ul>
|
||||
<?php echo $this->element('actions_menu');?>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue