mirror of https://github.com/MISP/MISP
Merge branch '2.4' of github.com:MISP/MISP into 2.4
commit
ba1a4811a9
|
@ -1 +1 @@
|
|||
{"major":2, "minor":4, "hotfix":97}
|
||||
{"major":2, "minor":4, "hotfix":98}
|
||||
|
|
|
@ -1266,45 +1266,54 @@ class ServersController extends AppController
|
|||
}
|
||||
} else {
|
||||
$oldValue = Configure::read($setting);
|
||||
$this->Server->serverSettingsSaveValue($setting, $this->request->data['Server']['value']);
|
||||
$settingSaveResult = $this->Server->serverSettingsSaveValue($setting, $this->request->data['Server']['value']);
|
||||
$this->Log->create();
|
||||
$result = $this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Server',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'serverSettingsEdit',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => 'Server setting changed',
|
||||
'change' => $setting . ' (' . $oldValue . ') => (' . $this->request->data['Server']['value'] . ')',
|
||||
));
|
||||
// execute after hook
|
||||
if (isset($found['afterHook'])) {
|
||||
$afterResult = call_user_func_array(array($this->Server, $found['afterHook']), array($setting, $this->request->data['Server']['value']));
|
||||
if ($afterResult !== true) {
|
||||
$this->Log->create();
|
||||
$result = $this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Server',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'serverSettingsEdit',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => 'Server setting issue',
|
||||
'change' => 'There was an issue after setting a new setting. The error message returned is: ' . $afterResult,
|
||||
));
|
||||
if ($this->_isRest) {
|
||||
return $this->RestResponse->saveFailResponse('Servers', 'serverSettingsEdit', false, $afterResult, $this->response->type());
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => $afterResult)), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_isRest) {
|
||||
return $this->RestResponse->saveSuccessResponse('Servers', 'serverSettingsEdit', false, $this->response->type(), 'Field updated');
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Field updated.')), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
if ($settingSaveResult) {
|
||||
$result = $this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Server',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'serverSettingsEdit',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => 'Server setting changed',
|
||||
'change' => $setting . ' (' . $oldValue . ') => (' . $this->request->data['Server']['value'] . ')',
|
||||
));
|
||||
// execute after hook
|
||||
if (isset($found['afterHook'])) {
|
||||
$afterResult = call_user_func_array(array($this->Server, $found['afterHook']), array($setting, $this->request->data['Server']['value']));
|
||||
if ($afterResult !== true) {
|
||||
$this->Log->create();
|
||||
$result = $this->Log->save(array(
|
||||
'org' => $this->Auth->user('Organisation')['name'],
|
||||
'model' => 'Server',
|
||||
'model_id' => 0,
|
||||
'email' => $this->Auth->user('email'),
|
||||
'action' => 'serverSettingsEdit',
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'title' => 'Server setting issue',
|
||||
'change' => 'There was an issue after setting a new setting. The error message returned is: ' . $afterResult,
|
||||
));
|
||||
if ($this->_isRest) {
|
||||
return $this->RestResponse->saveFailResponse('Servers', 'serverSettingsEdit', false, $afterResult, $this->response->type());
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => $afterResult)), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->saveSuccessResponse('Servers', 'serverSettingsEdit', false, $this->response->type(), 'Field updated');
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => true, 'success' => 'Field updated.')), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
} else {
|
||||
if ($this->_isRest()) {
|
||||
$message = __('Something went wrong. MISP tried to save a malformed config file. Setting change reverted.');
|
||||
return $this->RestResponse->saveFailResponse('Servers', 'serverSettingsEdit', false, $message, $this->response->type());
|
||||
} else {
|
||||
return new CakeResponse(array('body'=> json_encode(array('saved' => false, 'errors' => $message)), 'status'=>200, 'type' => 'json'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,22 @@ class BroExport
|
|||
|
||||
private $whitelist = null;
|
||||
|
||||
public function export($items, $orgs, $valueField, $whitelist, $instanceString)
|
||||
public function handler($data, $options = array())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function footer()
|
||||
{
|
||||
return "\n";
|
||||
}
|
||||
|
||||
public function separator()
|
||||
{
|
||||
return "\n";
|
||||
}
|
||||
|
||||
public function export($items, $orgs, $valueField, $whitelist = array(), $instanceString)
|
||||
{
|
||||
$intel = array();
|
||||
//For bro format organisation
|
||||
|
@ -155,10 +170,10 @@ class BroExport
|
|||
return $intel;
|
||||
}
|
||||
|
||||
private function __generateRule($attribute, $ruleFormat, $valueField, $whitelist)
|
||||
private function __generateRule($attribute, $ruleFormat, $valueField, $whitelist = array())
|
||||
{
|
||||
if (isset($this->mapping[$attribute['type']])) {
|
||||
if (! $this->checkWhitelist($attribute['value'], $whitelist)) {
|
||||
if (empty($whitelist) || !$this->checkWhitelist($attribute['value'], $whitelist)) {
|
||||
$brotype = $this->mapping[$attribute['type']]['brotype'];
|
||||
if (isset($this->mapping[$attribute['type']]['alternate'])) {
|
||||
if (preg_match($this->mapping[$attribute['type']]['alternate'][0], $attribute['value'])) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
App::uses('Model', 'Model');
|
||||
App::uses('LogableBehavior', 'Assets.models/behaviors');
|
||||
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
|
||||
App::uses('RandomTool', 'Tools');
|
||||
class AppModel extends Model
|
||||
{
|
||||
public $name;
|
||||
|
@ -1894,4 +1895,9 @@ class AppModel extends Model
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function generateRandomFileName()
|
||||
{
|
||||
return (new RandomTool())->random_str(false, 12);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3096,11 +3096,6 @@ class Attribute extends AppModel
|
|||
return false;
|
||||
}
|
||||
|
||||
public function generateRandomFileName()
|
||||
{
|
||||
return (new RandomTool())->random_str(false, 12);
|
||||
}
|
||||
|
||||
public function resolveHashType($hash)
|
||||
{
|
||||
$hashTypes = $this->hashTypes;
|
||||
|
|
|
@ -2242,7 +2242,7 @@ class Server extends AppModel
|
|||
}
|
||||
$sgs = $this->Event->SharingGroup->find('all', array(
|
||||
'recursive' => -1,
|
||||
'contain' => array('Organisation', 'SharingGroupOrg', 'SharingGroupServer')
|
||||
'contain' => array('Organisation', 'SharingGroupOrg' => array('Organisation'), 'SharingGroupServer')
|
||||
));
|
||||
$sgIds = array();
|
||||
foreach ($sgs as $k => $sg) {
|
||||
|
@ -3158,6 +3158,7 @@ class Server extends AppModel
|
|||
|
||||
public function serverSettingsSaveValue($setting, $value)
|
||||
{
|
||||
copy(APP . 'Config' . DS . 'config.php', APP . 'Config' . DS . 'config.php.bk');
|
||||
$settingObject = $this->getCurrentServerSettings();
|
||||
foreach ($settingObject as $branchName => $branch) {
|
||||
if (!isset($branch['level'])) {
|
||||
|
@ -3203,7 +3204,17 @@ class Server extends AppModel
|
|||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
file_put_contents(APP . 'Config' . DS . 'config.php', $settingsString);
|
||||
$randomFilename = $this->generateRandomFileName();
|
||||
// To protect us from 2 admin users having a concurent file write to the config file, solar flares and the bogeyman
|
||||
file_put_contents(APP . 'Config' . DS . $randomFilename, $settingsString);
|
||||
rename(APP . 'Config' . DS . $randomFilename, APP . 'Config' . DS . 'config.php');
|
||||
$config_saved = file_get_contents(APP . 'Config' . DS . 'config.php');
|
||||
// if the saved config file is empty, restore the backup.
|
||||
if (strlen($config_saved) < 20) {
|
||||
copy(APP . 'Config' . DS . 'config.php.bk', APP . 'Config' . DS . 'config.php');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkVersion($newest)
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
<th style="padding-left:0px;padding-right:0px;"> </th>
|
||||
<?php endif;?>
|
||||
<th><?php echo $this->Paginator->sort('id');?></th>
|
||||
<th><?php echo $this->Paginator->sort('enabled');?></th>
|
||||
<th><?php echo $this->Paginator->sort('caching_enabled');?></th>
|
||||
<th title="<?php echo __('Enable pulling the feed into your MISP as events/attributes.'); ?>"><?php echo $this->Paginator->sort('enabled');?></th>
|
||||
<th title="<?php echo __('Enable caching the feed into Redis - allowing for correlations to the feed to be shown.'); ?>"><?php echo $this->Paginator->sort('caching_enabled');?></th>
|
||||
<th><?php echo $this->Paginator->sort('name');?></th>
|
||||
<th><?php echo $this->Paginator->sort('source_format', __('Feed Format'));?></th>
|
||||
<th><?php echo $this->Paginator->sort('provider');?></th>
|
||||
|
|
Loading…
Reference in New Issue