diff --git a/app/Model/Server.php b/app/Model/Server.php index 17eef9841..a4ea06913 100644 --- a/app/Model/Server.php +++ b/app/Model/Server.php @@ -4,6 +4,10 @@ App::uses('GpgTool', 'Tools'); class Server extends AppModel { + const SETTING_CRITICAL = 0, + SETTING_RECOMMENDED = 1, + SETTING_OPTIONAL = 2; + public $name = 'Server'; public $actsAs = array('SysLogLogable.SysLogLogable' => array( @@ -1100,7 +1104,33 @@ class Server extends AppModel 'test' => 'testBool', 'type' => 'boolean', 'null' => true - ) + ), + 'attachment_scan_module' => [ + 'level' => self::SETTING_OPTIONAL, + 'description' => __('Name of enrichment module that will be used for attachment malware scanning. This module must return av-signature or sb-signature object.'), + 'value' => '', + 'errorMessage' => '', + 'type' => 'string', + 'null' => true, + ], + 'attachment_scan_hash_only' => [ + 'level' => self::SETTING_OPTIONAL, + 'description' => __('Send to attachment scan module just file hash. This can be useful if module sends attachment to remote service and you don\'t want to leak real data.'), + 'value' => false, + 'errorMessage' => '', + 'test' => 'testBool', + 'type' => 'boolean', + 'null' => true, + ], + 'attachment_scan_timeout' => [ + 'level' => self::SETTING_OPTIONAL, + 'description' => __('How long to wait for scan results in seconds.'), + 'value' => 30, + 'errorMessage' => '', + 'test' => 'testForPositiveInteger', + 'type' => 'numeric', + 'null' => true, + ] ), 'GnuPG' => array( 'branch' => 1, @@ -3426,6 +3456,14 @@ class Server extends AppModel return true; } + public function testForPositiveInteger($value) + { + if ((is_int($value) && $value >= 0) || ctype_digit($value)) { + return true; + } + return __('The value has to be a whole number greater or equal 0.'); + } + public function testForCookieTimeout($value) { $numeric = $this->testForNumeric($value); diff --git a/app/webroot/js/misp.js b/app/webroot/js/misp.js index 23e4e90c4..e07f3aa2e 100644 --- a/app/webroot/js/misp.js +++ b/app/webroot/js/misp.js @@ -2523,33 +2523,42 @@ function serverSettingsPostActivationScripts(name, setting, id) { } function serverSettingSubmitForm(name, setting, id) { - subGroup = getSubGroupFromSetting(setting); + var subGroup = getSubGroupFromSetting(setting); var formData = $(name + '_field').closest("form").serialize(); $.ajax({ data: formData, cache: false, - beforeSend: function (XMLHttpRequest) { + beforeSend: function () { $(".loading").show(); }, - success:function (data, textStatus) { + success: function (data) { + if (!data.saved) { + $(".loading").hide(); + showMessage('fail', data.errors); + resetForms(); + $('.inline-field-placeholder').hide(); + return; + } + $.ajax({ - type:"get", + type: "get", url: baseurl + "/servers/serverSettingsReloadSetting/" + setting + "/" + id, - success:function (data2, textStatus2) { + success: function (data2) { $('#' + subGroup + "_" + id + '_row').replaceWith(data2); $(".loading").hide(); }, - error:function() { + error: function() { showMessage('fail', 'Could not refresh the table.'); } }); }, - error:function() { + error: function() { + $(".loading").hide(); showMessage('fail', 'Request failed for an unknown reason.'); resetForms(); $('.inline-field-placeholder').hide(); }, - type:"post", + type: "post", url: baseurl + "/servers/serverSettingsEdit/" + setting + "/" + id + "/" + 1 }); $(name + '_field').unbind("keyup");