Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/scaRealtime/CxScaRealTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default class CxScaRealTime {
totalCount: string;
results: any = [];

static parseScaRealTimeResponse(resultObject: any): CxScaRealTime {
const scaRealTime: CxScaRealTime = new CxScaRealTime();
scaRealTime.totalCount = resultObject.totalCount;
scaRealTime.results = resultObject.results || [];

return scaRealTime;
}
}
3 changes: 3 additions & 0 deletions src/main/wrapper/CxConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export enum CxConstants {
SUB_CMD_BFL = "bfl",
CMD_CODE_BASHING = "codebashing",
CMD_KICS_REALTIME = "kics-realtime",
CMD_SCA_REALTIME = "sca-realtime",
CMD_SCA_REALTIME_PROJECT_DIR = "--project-dir",
SCAN_INFO_FORMAT = "--scan-info-format",
FORMAT = "--format",
FORMAT_JSON = "json",
Expand All @@ -67,6 +69,7 @@ export enum CxConstants {
PREDICATE_TYPE = "CxPredicate",
CODE_BASHING_TYPE = "CxCodeBashing",
KICS_REALTIME_TYPE = "CxKicsRealTime",
SCA_REALTIME_TYPE = "CxScaRealTime",
LEARN_MORE_DESCRIPTIONS_TYPE = "CxLearnMoreDescriptions",
KICS_REMEDIATION_TYPE = "CxKicsRemediation",
BFL_TYPE = "CxBFL",
Expand Down
11 changes: 11 additions & 0 deletions src/main/wrapper/CxWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@ export class CxWrapper {
return exec.executeKicsCommands(this.config.pathToExecutable, commands, CxConstants.KICS_REALTIME_TYPE);
}

/**
* Run SCA Realtime for a specific directory
*
* @param projectDirPath
*/
async runScaRealtimeScan(projectDirPath: string): Promise<CxCommandOutput> {
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_SCA_REALTIME, CxConstants.CMD_SCA_REALTIME_PROJECT_DIR, projectDirPath];
commands.push(...this.initializeCommands(false));
return new ExecutionService().executeCommands(this.config.pathToExecutable, commands, CxConstants.SCA_REALTIME_TYPE);
}


async learnMore(queryId: string){
const commands: string[] = [CxConstants.CMD_UTILS,CxConstants.CMD_LEARN_MORE,CxConstants.QUERY_ID,queryId]
Expand Down
5 changes: 5 additions & 0 deletions src/main/wrapper/ExecutionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import CxCvss from "../results/CxCvss";
import CxNode from "../results/CxNode";
import CxPackageData from "../results/CxPackageData";
import CxKicsRemediation from "../remediation/CxKicsRemediation";
import CxScaRealTime from "../scaRealtime/CxScaRealTime";


function isJsonString(s: string) {
Expand Down Expand Up @@ -196,6 +197,10 @@ export class ExecutionService {
const kicsResults = CxKicsRealTime.parseKicsRealTimeResponse(resultObject);
cxCommandOutput.payload = [kicsResults];
break;
case CxConstants.SCA_REALTIME_TYPE:
const scaRealtimeResponse = CxScaRealTime.parseScaRealTimeResponse(resultObject);
cxCommandOutput.payload = [scaRealtimeResponse];
break;
case CxConstants.LEARN_MORE_DESCRIPTIONS_TYPE:
const learnMore = CxLearnMoreDescriptions.parseLearnMoreDescriptionsResponse(resultObject);
cxCommandOutput.payload = learnMore;
Expand Down
11 changes: 11 additions & 0 deletions src/tests/ScanTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ describe("ScanCreate cases", () => {
expect(pid).toBeDefined();
})

it('ScaRealtime Successful case', async () => {
const wrapper = new CxWrapper(cxScanConfig);
const cxCommandOutput: CxCommandOutput = await wrapper.runScaRealtimeScan(process.cwd());
if(cxCommandOutput.exitCode == 1) {
expect(cxCommandOutput.payload).toBeUndefined();
} else {
const scanObject = cxCommandOutput.payload.pop();
expect(scanObject.results).toBeDefined();
}
})

it("Should check if scan create is possible", async() => {
const auth = new CxWrapper(cxScanConfig);
const tenantSettings: boolean = await auth.ideScansEnabled();
Expand Down