Skip to content

Commit 9ff60fe

Browse files
committed
fixing undefined values in description
1 parent c018cdf commit 9ff60fe

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/main/learnmore/CxLearnMoreDescriptions.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,22 @@ export default class CxLearnMoreDescriptions {
1010
generalRecommendations: string;
1111
samples: CxLearnMoreSamples[];
1212

13-
static parseLearnMoreDescriptionsResponse(result: any): CxLearnMoreDescriptions {
14-
const cxLearnMoreDescriptions = new CxLearnMoreDescriptions();
15-
cxLearnMoreDescriptions.queryId = result.queryId;
16-
cxLearnMoreDescriptions.queryName = result.queryName;
17-
cxLearnMoreDescriptions.queryDescriptionId = result.queryDescriptionId;
18-
cxLearnMoreDescriptions.resultDescription = result.resultDescription;
19-
cxLearnMoreDescriptions.risk = result.risk;
20-
cxLearnMoreDescriptions.cause = result.cause;
21-
cxLearnMoreDescriptions.generalRecommendations = result.generalRecommendations;
22-
cxLearnMoreDescriptions.samples = result.samples;
23-
return cxLearnMoreDescriptions;
13+
static parseLearnMoreDescriptionsResponse(resultObject: any[]): CxLearnMoreDescriptions[] {
14+
let learnMoreDescriptionsArray:CxLearnMoreDescriptions[] = []
15+
learnMoreDescriptionsArray = resultObject.map((result: any) => {
16+
const cxLearnMoreDescriptions = new CxLearnMoreDescriptions();
17+
cxLearnMoreDescriptions.queryId = result.queryId;
18+
cxLearnMoreDescriptions.queryName = result.queryName;
19+
cxLearnMoreDescriptions.queryDescriptionId = result.queryDescriptionId;
20+
cxLearnMoreDescriptions.resultDescription = result.resultDescription;
21+
cxLearnMoreDescriptions.risk = result.risk;
22+
cxLearnMoreDescriptions.cause = result.cause;
23+
cxLearnMoreDescriptions.generalRecommendations = result.generalRecommendations;
24+
cxLearnMoreDescriptions.samples = result.samples;
25+
return cxLearnMoreDescriptions;
26+
});
27+
28+
return learnMoreDescriptionsArray;
2429
}
2530

2631
}

src/main/wrapper/ExecutionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class ExecutionService {
152152
break;
153153
case CxConstants.LEARN_MORE_DESCRIPTIONS_TYPE:
154154
const learnMore = CxLearnMoreDescriptions.parseLearnMoreDescriptionsResponse(resultObject);
155-
cxCommandOutput.payload = [learnMore];
155+
cxCommandOutput.payload = learnMore;
156156
break;
157157
case CxConstants.KICS_REMEDIATION_TYPE:
158158
const kicsRemediationOutput = CxKicsRemediation.parseKicsRemediation(resultObject)

src/tests/LearnMoreDescriptions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe("LearnMoreDescriptions cases",() => {
77
it('LearnMoreDescriptions Successful case', async () => {
88
const auth = new CxWrapper(cxScanConfig);
99
const queryId = process.env.CX_TEST_QUERY_ID;
10-
const data = await auth.learnMore(queryId !== undefined? queryId : "10308959669028119927")
10+
const data = await auth.learnMore(queryId !== undefined? queryId : "16772998409937314312")
1111
const cxCommandOutput: CxCommandOutput = data;
1212
expect(cxCommandOutput.payload.length).toBeGreaterThan(0);
1313
})

0 commit comments

Comments
 (0)