Skip to content

Commit

Permalink
#309 Fix the analyzer/responder/config modals to correctly evaluate f…
Browse files Browse the repository at this point in the history
…alse default values
  • Loading branch information
nadouani committed Oct 28, 2020
1 parent bf5e922 commit 9d2be97
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ export default class AnalyzerEditController {
const property = item.name,
configValue = (this.configuration.config || {})[property];

analyzer.configuration[property] =
configValue ||
item.defaultValue ||
(item.multi ? [undefined] : undefined);
if(configValue !== undefined) {
analyzer.configuration[property] = configValue;
} else if (item.defaultValue !== undefined) {
analyzer.configuration[property] = item.defaultValue;
} else {
analyzer.configuration[property] = item.multi ? [undefined] : undefined;
}
});

// Handle TLP default config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ export default class OrganizationConfigsController {
size: 'lg',
resolve: {
configuration: () => {
// let defaultValues = {
// string: null,
// number: 0,
// boolean: true
// };
let conf = angular.copy(config);

_.forEach(conf.configurationItems, item => {
conf.config[item.name] =
conf.config[item.name] !== undefined ?
conf.config[item.name] :
item.defaultValue || (item.multi ? [undefined] : undefined);
if(conf.config[item.name] === undefined) {
if (item.defaultValue !== undefined) {
conf.config[item.name] = item.defaultValue;
} else {
conf.config[item.name] = item.multi ? [undefined] : undefined;
}
});

return conf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ export default class ResponderEditController {
const property = item.name,
configValue = (this.configuration.config || {})[property];

responder.configuration[property] =
configValue ||
item.defaultValue ||
(item.multi ? [undefined] : undefined);
if(configValue !== undefined) {
responder.configuration[property] = configValue;
} else if (item.defaultValue !== undefined) {
responder.configuration[property] = item.defaultValue;
} else {
responder.configuration[property] = item.multi ? [undefined] : undefined;
}
});

// Handle TLP default config
Expand Down

0 comments on commit 9d2be97

Please sign in to comment.