diff --git a/www/src/app/pages/admin/organizations/components/analyzers/analyzer-config-form.controller.js b/www/src/app/pages/admin/organizations/components/analyzers/analyzer-config-form.controller.js index 6e2a9988f..3765388be 100644 --- a/www/src/app/pages/admin/organizations/components/analyzers/analyzer-config-form.controller.js +++ b/www/src/app/pages/admin/organizations/components/analyzers/analyzer-config-form.controller.js @@ -1,9 +1,10 @@ 'use strict'; import _ from 'lodash/core'; +import omit from 'lodash/omit'; export default class AnalyzerConfigFormController { - constructor($log, Tlps, AnalyzerService) { + constructor($Tlps, AnalyzerService) { 'ngInject'; this.AnalyzerService = AnalyzerService; @@ -24,10 +25,15 @@ export default class AnalyzerConfigFormController { } applyGlobalConfig() { - this.applyConfig(this.globalConfig.config); + const props = ['jobCache', 'jobTimeout']; + + this.applyConfig(omit(this.globalConfig.config, props)); + _.each(props, prop => { + this.analyzer[prop] = this.globalConfig.config[prop]; + }); } applyBaseConfig() { this.applyConfig(this.baseConfig.config); } -} +} \ No newline at end of file diff --git a/www/src/app/pages/admin/organizations/components/analyzers/analyzers-list.controller.js b/www/src/app/pages/admin/organizations/components/analyzers/analyzers-list.controller.js index cf801c118..5d262e895 100644 --- a/www/src/app/pages/admin/organizations/components/analyzers/analyzers-list.controller.js +++ b/www/src/app/pages/admin/organizations/components/analyzers/analyzers-list.controller.js @@ -140,8 +140,7 @@ export default class OrganizationAnalyzersController { disable(analyzerId) { let modalInstance = this.ModalService.confirm( 'Disable analyzer', - 'Are you sure you want to disable this analyzer? The corresponding configuration will be lost.', - { + 'Are you sure you want to disable this analyzer? The corresponding configuration will be lost.', { flavor: 'danger', okText: 'Yes, disable it' } @@ -181,4 +180,4 @@ export default class OrganizationAnalyzersController { ) ); } -} +} \ No newline at end of file diff --git a/www/src/app/pages/admin/organizations/components/responders/responder-config-form.controller.js b/www/src/app/pages/admin/organizations/components/responders/responder-config-form.controller.js index e1d8b04b2..a73d7a691 100644 --- a/www/src/app/pages/admin/organizations/components/responders/responder-config-form.controller.js +++ b/www/src/app/pages/admin/organizations/components/responders/responder-config-form.controller.js @@ -1,9 +1,10 @@ 'use strict'; import _ from 'lodash/core'; +import omit from 'lodash/omit'; export default class ResponderConfigFormController { - constructor($log, Tlps, ResponderService) { + constructor(Tlps, ResponderService) { 'ngInject'; this.ResponderService = ResponderService; @@ -19,7 +20,12 @@ export default class ResponderConfigFormController { } applyGlobalConfig() { - this.applyConfig(this.globalConfig.config); + const props = ['jobTimeout']; + + this.applyConfig(omit(this.globalConfig.config, props)); + _.each(props, prop => { + this.responder[prop] = this.globalConfig.config[prop]; + }); } applyBaseConfig() { diff --git a/www/src/app/pages/admin/organizations/components/responders/responder-config-form.html b/www/src/app/pages/admin/organizations/components/responders/responder-config-form.html index 16d81aee6..0972d6cfd 100644 --- a/www/src/app/pages/admin/organizations/components/responders/responder-config-form.html +++ b/www/src/app/pages/admin/organizations/components/responders/responder-config-form.html @@ -1,6 +1,6 @@

Base details

- +
@@ -18,8 +18,9 @@

Apply defaults

- - + + +
@@ -30,47 +31,53 @@

Apply defaults - +

- - + +
-
+ ng-options="tlp.value as tlp.key for tlp in $ctrl.Tlps" + ng-required="$ctrl.responder.configuration.check_tlp"> +
- +
- - + +
+ ng-options="tlp.value as tlp.key for tlp in $ctrl.Tlps" + ng-required="$ctrl.responder.configuration.check_pap">
-
+
-
+
-
+
@@ -78,18 +85,24 @@

+
+ +
+ +
+
-
+
-
+

Define the maximum number of requests and the associated unit if applicable.

-
-
+ +
\ No newline at end of file diff --git a/www/src/app/pages/admin/organizations/components/responders/responder.edit.controller.js b/www/src/app/pages/admin/organizations/components/responders/responder.edit.controller.js index 9d21e0772..d0510a64c 100644 --- a/www/src/app/pages/admin/organizations/components/responders/responder.edit.controller.js +++ b/www/src/app/pages/admin/organizations/components/responders/responder.edit.controller.js @@ -31,7 +31,8 @@ export default class ResponderEditController { name: this.definition.id, configuration: {}, rate: undefined, - rateUnit: undefined + rateUnit: undefined, + jobTimeout: undefined }; _.forEach(this.definition.configurationItems, item => { @@ -49,7 +50,6 @@ export default class ResponderEditController { 'proxy_http', 'proxy_https', 'cacerts', - 'jobCache', 'jobTimeout' ]; _.forEach(globalConfig, cnf => { @@ -74,6 +74,10 @@ export default class ResponderEditController { responder.configuration.max_pap = 2; } + if (responder.jobTimeout === undefined) { + responder.jobTimeout = this.globalConfig.config.jobTimeout; + } + this.responder = responder; } } @@ -84,4 +88,4 @@ export default class ResponderEditController { cancel() { this.$uibModalInstance.dismiss('cancel'); } -} +} \ No newline at end of file diff --git a/www/src/app/pages/admin/organizations/components/responders/responders-list.controller.js b/www/src/app/pages/admin/organizations/components/responders/responders-list.controller.js index 01b62188b..b9c794909 100644 --- a/www/src/app/pages/admin/organizations/components/responders/responders-list.controller.js +++ b/www/src/app/pages/admin/organizations/components/responders/responders-list.controller.js @@ -101,7 +101,8 @@ export default class OrganizationRespondersController { 'configuration', 'rate', 'rateUnit', - 'name' + 'name', + 'jobTimeout' ) ); } diff --git a/www/src/app/pages/analyzers/analyzers.service.js b/www/src/app/pages/analyzers/analyzers.service.js index b1061a4fe..54c9a61d0 100644 --- a/www/src/app/pages/analyzers/analyzers.service.js +++ b/www/src/app/pages/analyzers/analyzers.service.js @@ -111,7 +111,23 @@ export default class AnalyzerService { this.$http .get(`./api/analyzerconfig/${name}`) - .then(response => defer.resolve(response.data), err => defer.reject(err)); + .then(response => { + let cfg = response.data; + + if (name === 'global') { + // Prepare the default values of the global config + let globalWithDefaults = {}; + _.each(cfg.configurationItems, item => { + globalWithDefaults[item.name] = item.defaultValue; + }); + + // Set the default value of the global config that are not set + _.defaults(cfg.config, globalWithDefaults); + } + + defer.resolve(cfg); + }) + .catch(err => defer.reject(err)); return defer.promise; } diff --git a/www/src/app/pages/responders/responders.service.js b/www/src/app/pages/responders/responders.service.js index ee69e28fc..6c24db94b 100644 --- a/www/src/app/pages/responders/responders.service.js +++ b/www/src/app/pages/responders/responders.service.js @@ -98,7 +98,23 @@ export default class ResponderService { getConfiguration(name) { return this.$http .get(`./api/responderconfig/${name}`) - .then(response => this.$q.resolve(response.data), err => this.$q.reject(err)); + .then(response => { + let cfg = response.data; + + if (name === 'global') { + // Prepare the default values of the global config + let globalWithDefaults = {}; + _.each(cfg.configurationItems, item => { + globalWithDefaults[item.name] = item.defaultValue; + }); + + // Set the default value of the global config that are not set + _.defaults(cfg.config, globalWithDefaults); + } + + return this.$q.resolve(cfg); + }) + .catch(err => this.$q.reject(err)); } saveConfiguration(name, values) {