mirror of https://github.com/MISP/MISP
commit
d5d8906670
|
@ -2414,9 +2414,9 @@ class AttributesController extends AppController
|
|||
$options = array();
|
||||
$found = false;
|
||||
foreach ($modules['modules'] as $temp) {
|
||||
if ($temp['name'] == $type) {
|
||||
if ($temp['name'] === $type) {
|
||||
$found = true;
|
||||
$format = (isset($temp['mispattributes']['format']) ? $temp['mispattributes']['format'] : 'simplified');
|
||||
$format = isset($temp['mispattributes']['format']) ? $temp['mispattributes']['format'] : 'simplified';
|
||||
if (isset($temp['meta']['config'])) {
|
||||
foreach ($temp['meta']['config'] as $conf) {
|
||||
$options[$conf] = Configure::read('Plugin.Enrichment_' . $type . '_' . $conf);
|
||||
|
@ -2456,7 +2456,7 @@ class AttributesController extends AppController
|
|||
if (isset($result['results']['Object'])) {
|
||||
if (!empty($result['results']['Object'])) {
|
||||
$objects = array();
|
||||
foreach($result['results']['Object'] as $object) {
|
||||
foreach ($result['results']['Object'] as $object) {
|
||||
if (isset($object['Attribute']) && !empty($object['Attribute'])) {
|
||||
$object_attributes = array();
|
||||
foreach($object['Attribute'] as $object_attribute) {
|
||||
|
@ -2469,9 +2469,7 @@ class AttributesController extends AppController
|
|||
$objects[] = array('name' => $object['name'], 'Attribute' => $object_attributes);
|
||||
}
|
||||
}
|
||||
if (!empty($objects)) {
|
||||
$current_result['Object'] = $objects;
|
||||
}
|
||||
$current_result['Object'] = $objects;
|
||||
}
|
||||
unset($result['results']['Object']);
|
||||
}
|
||||
|
|
|
@ -4948,25 +4948,27 @@ class EventsController extends AppController
|
|||
$this->request->data['Event']['config']['special_delimiter'] = ' ';
|
||||
}
|
||||
}
|
||||
foreach ($module['mispattributes']['userConfig'] as $configName => $config) {
|
||||
if (!$fail) {
|
||||
if (isset($config['validation'])) {
|
||||
if ($config['validation'] === '0' && $config['type'] == 'String') {
|
||||
$validation = true;
|
||||
}
|
||||
} else {
|
||||
$validation = call_user_func_array(array($this->Module, $this->Module->configTypes[$config['type']]['validation']), array($this->request->data['Event']['config'][$configName]));
|
||||
}
|
||||
if ($validation !== true) {
|
||||
$fail = ucfirst($configName) . ': ' . $validation;
|
||||
} else {
|
||||
if (isset($config['regex']) && !empty($config['regex'])) {
|
||||
$fail = preg_match($config['regex'], $this->request->data['Event']['config'][$configName]) ? false : ucfirst($configName) . ': ' . 'Invalid setting' . ($config['errorMessage'] ? ' - ' . $config['errorMessage'] : '');
|
||||
if (!empty($fail)) {
|
||||
$modulePayload['config'][$configName] = $this->request->data['Event']['config'][$configName];
|
||||
if (isset($module['mispattributes']['userConfig'])) {
|
||||
foreach ($module['mispattributes']['userConfig'] as $configName => $config) {
|
||||
if (!$fail) {
|
||||
if (isset($config['validation'])) {
|
||||
if ($config['validation'] === '0' && $config['type'] == 'String') {
|
||||
$validation = true;
|
||||
}
|
||||
} else {
|
||||
$modulePayload['config'][$configName] = $this->request->data['Event']['config'][$configName];
|
||||
$validation = call_user_func_array(array($this->Module, $this->Module->configTypes[$config['type']]['validation']), array($this->request->data['Event']['config'][$configName]));
|
||||
}
|
||||
if ($validation !== true) {
|
||||
$fail = ucfirst($configName) . ': ' . $validation;
|
||||
} else {
|
||||
if (isset($config['regex']) && !empty($config['regex'])) {
|
||||
$fail = preg_match($config['regex'], $this->request->data['Event']['config'][$configName]) ? false : ucfirst($configName) . ': ' . 'Invalid setting' . ($config['errorMessage'] ? ' - ' . $config['errorMessage'] : '');
|
||||
if (!empty($fail)) {
|
||||
$modulePayload['config'][$configName] = $this->request->data['Event']['config'][$configName];
|
||||
}
|
||||
} else {
|
||||
$modulePayload['config'][$configName] = $this->request->data['Event']['config'][$configName];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5078,7 +5080,8 @@ class EventsController extends AppController
|
|||
$this->set('importComment', $importComment);
|
||||
$this->render($render_name);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if ($fail) {
|
||||
$this->Flash->error($fail);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,12 +145,18 @@ class Module extends AppModel
|
|||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @return array|string
|
||||
*/
|
||||
public function getEnabledModule($name, $type)
|
||||
{
|
||||
if (!isset($this->__typeToFamily[$type])) {
|
||||
throw new InvalidArgumentException("Invalid type '$type'.");
|
||||
}
|
||||
$moduleFamily = $this->__typeToFamily[$type];
|
||||
$url = $this->__getModuleServer($moduleFamily);
|
||||
$modules = $this->getModules($type, $moduleFamily);
|
||||
$module = false;
|
||||
if (!Configure::read('Plugin.' . $moduleFamily . '_' . $name . '_enabled')) {
|
||||
return 'The requested module is not enabled.';
|
||||
}
|
||||
|
@ -175,10 +181,22 @@ class Module extends AppModel
|
|||
if (!Configure::read('Plugin.' . $moduleFamily . '_services_enable')) {
|
||||
return false;
|
||||
}
|
||||
$this->Server = ClassRegistry::init('Server');
|
||||
$url = Configure::read('Plugin.' . $moduleFamily . '_services_url') ? Configure::read('Plugin.' . $moduleFamily . '_services_url') : $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_url']['value'];
|
||||
$port = Configure::read('Plugin.' . $moduleFamily . '_services_port') ? Configure::read('Plugin.' . $moduleFamily . '_services_port') : $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_port']['value'];
|
||||
return $url . ':' . $port;
|
||||
|
||||
$url = Configure::read('Plugin.' . $moduleFamily . '_services_url');
|
||||
$port = Configure::read('Plugin.' . $moduleFamily . '_services_port');
|
||||
|
||||
if (empty($url) || empty($port)) {
|
||||
// Load default values
|
||||
$this->Server = ClassRegistry::init('Server');
|
||||
if (empty($url)) {
|
||||
$url = $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_url']['value'];
|
||||
}
|
||||
if (empty($port)) {
|
||||
$port = $this->Server->serverSettings['Plugin'][$moduleFamily . '_services_port']['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return "$url:$port";
|
||||
}
|
||||
|
||||
public function queryModuleServer($uri, $post = false, $hover = false, $moduleFamily = 'Enrichment', &$exception = false)
|
||||
|
@ -190,11 +208,11 @@ class Module extends AppModel
|
|||
App::uses('HttpSocket', 'Network/Http');
|
||||
if ($hover) {
|
||||
$settings = array(
|
||||
'timeout' => Configure::read('Plugin.' . $moduleFamily . '_hover_timeout') ? Configure::read('Plugin.' . $moduleFamily . '_hover_timeout') : 5
|
||||
'timeout' => Configure::read('Plugin.' . $moduleFamily . '_hover_timeout') ?: 5
|
||||
);
|
||||
} else {
|
||||
$settings = array(
|
||||
'timeout' => Configure::read('Plugin.' . $moduleFamily . '_timeout') ? Configure::read('Plugin.' . $moduleFamily . '_timeout') : 10
|
||||
'timeout' => Configure::read('Plugin.' . $moduleFamily . '_timeout') ?: 10
|
||||
);
|
||||
}
|
||||
$sslSettings = array('ssl_verify_peer', 'ssl_verify_host', 'ssl_allow_self_signed', 'ssl_verify_peer', 'ssl_cafile');
|
||||
|
|
Loading…
Reference in New Issue