Skip to content

Commit db56f3b

Browse files
AST-37667 adding ability to send the agent to results command (#633)
1 parent 001f8da commit db56f3b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ export class CxWrapper {
205205
return exec.executeResultsCommandsFile(scanId, CxConstants.FORMAT_HTML, CxConstants.FORMAT_HTML_FILE, commands, this.config.pathToExecutable, fileName);
206206
}
207207

208-
async getResults(scanId: string, resultType: string, outputFileName: string, outputFilePath: string) {
209-
const commands = this.resultsShow(scanId, resultType, outputFileName, outputFilePath)
208+
async getResults(scanId: string, resultType: string, outputFileName: string, outputFilePath: string, agent?: string | null) {
209+
const commands = this.resultsShow(scanId, resultType, outputFileName, outputFilePath, agent)
210210
const exec = new ExecutionService();
211211
return await exec.executeCommands(this.config.pathToExecutable, commands);
212212
}
@@ -218,7 +218,7 @@ export class CxWrapper {
218218
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.CODE_BASHING_TYPE);
219219
}
220220

221-
resultsShow(scanId: string, reportFormat: string, outputFileName: string, outputPath: string): string[] {
221+
resultsShow(scanId: string, reportFormat: string, outputFileName: string, outputPath: string, agent?: string | null): string[] {
222222
const commands: string[] = [CxConstants.CMD_RESULT, CxConstants.SUB_CMD_SHOW, CxConstants.SCAN_ID, scanId, CxConstants.REPORT_FORMAT, reportFormat];
223223
if (outputFileName) {
224224
commands.push(CxConstants.OUTPUT_NAME);
@@ -228,6 +228,10 @@ export class CxWrapper {
228228
commands.push(CxConstants.OUTPUT_PATH);
229229
commands.push(outputPath);
230230
}
231+
if (agent) {
232+
commands.push(CxConstants.AGENT);
233+
commands.push(agent);
234+
}
231235
commands.push(...this.initializeCommands(false));
232236
return commands;
233237
}

src/tests/ResultTest.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ describe("Results cases",() => {
1515
});
1616
});
1717

18+
it('Result Test With Agent Flug Successful case', async () => {
19+
const auth = new CxWrapper(cxScanConfig);
20+
const cxCommandOutput: CxCommandOutput = await auth.scanList("statuses=Completed");
21+
const sampleId = cxCommandOutput.payload.pop().id;
22+
23+
auth.getResults(sampleId,"json","jsonList", ".", "jswrapper").then(() => {
24+
fileExists("./jsonList.json").then(file => expect(file).toBe(true));
25+
});
26+
});
27+
1828
it('Result List Successful case', async () => {
1929
const auth = new CxWrapper(cxScanConfig);
2030
const scanList: CxCommandOutput = await auth.scanList("statuses=Completed");

0 commit comments

Comments
 (0)