Skip to content

Commit

Permalink
Fix: Also use edit_config_family_all for policies
Browse files Browse the repository at this point in the history
The config dialog now also uses edit_config_family_all alongside
edit_config_family.

This fixes the dialog for editing a family in a compliance policy
not loading correctly.
  • Loading branch information
timopollmeier authored and a-h-abdelsalam committed Dec 14, 2023
1 parent 2d4c73f commit 237adde
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
40 changes: 22 additions & 18 deletions src/gmp/commands/__tests__/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
createActionResultResponse,
createEntityResponse,
createHttp,
createHttpMany,
createResponse,
} from '../testing';

Expand Down Expand Up @@ -215,27 +216,30 @@ describe('PolicyCommand tests', () => {
},
],
},
all: {
get_nvts_response: {
nvt: [
{
_oid: 1,
cvss_base: 1.1,
},
{
_oid: 2,
cvss_base: 2.2,
},
{
_oid: 3,
cvss_base: 3.3,
},
],
},
},
});
const responseAll = createResponse({
get_config_family_response: {
get_nvts_response: {
nvt: [
{
_oid: 1,
cvss_base: 1.1,
},
{
_oid: 2,
cvss_base: 2.2,
},
{
_oid: 3,
cvss_base: 3.3,
},
],
},
},
});
const fakeHttp = createHttp(response);
const responses = [response, responseAll];
const fakeHttp = createHttpMany(responses);

expect.hasAssertions();

Expand Down
14 changes: 11 additions & 3 deletions src/gmp/commands/policies.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,21 @@ export class PolicyCommand extends EntityCommand {
}

editPolicyFamilySettings({id, familyName}) {
return this.httpGet({
const get = this.httpGet({
cmd: 'edit_config_family',
id,
family: familyName,
}).then(response => {
});
const all = this.httpGet({
cmd: 'edit_config_family_all',
id,
family: familyName,
});
return Promise.all([get, all]).then(([response, response_all]) => {
const {data} = response;
const data_all = response_all.data;
const policy_resp = data.get_config_family_response;
const policy_resp_all = data_all.get_config_family_response;
const settings = {};

const nvts = {};
Expand All @@ -108,7 +116,7 @@ export class PolicyCommand extends EntityCommand {
nvts[oid] = true;
});

settings.nvts = map(policy_resp.all.get_nvts_response.nvt, nvt => {
settings.nvts = map(policy_resp_all.get_nvts_response.nvt, nvt => {
nvt.oid = nvt._oid;
delete nvt._oid;

Expand Down

0 comments on commit 237adde

Please sign in to comment.