From 134f857612f615654670df5670da5d889869b38b Mon Sep 17 00:00:00 2001 From: RahulP Date: Thu, 28 Nov 2024 16:23:47 +0530 Subject: [PATCH] Q4 2024 integration branch (#117) --- package.json | 2 +- src/dto/scanConfig.ts | 1 + src/services/clients/cxClient.ts | 15 ++++++++++----- src/services/clients/scaClient.ts | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index f05a2bc..469a171 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@checkmarx/cx-common-js-client", - "version": "0.1.87", + "version": "0.1.88", "description": "Client for interaction with Checkmarx products.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/dto/scanConfig.ts b/src/dto/scanConfig.ts index 8a1ba33..18f59ab 100644 --- a/src/dto/scanConfig.ts +++ b/src/dto/scanConfig.ts @@ -16,4 +16,5 @@ export interface ScanConfig { scaConfig?: ScaConfig; proxyConfig?: ProxyConfig; version?: string; + originName?: string; } \ No newline at end of file diff --git a/src/services/clients/cxClient.ts b/src/services/clients/cxClient.ts index c7c36f2..26366b2 100644 --- a/src/services/clients/cxClient.ts +++ b/src/services/clients/cxClient.ts @@ -143,11 +143,11 @@ export class CxClient { sastProxyConfig.proxyUrl = this.proxyConfig.sastProxyUrl != '' ? this.proxyConfig.sastProxyUrl : this.proxyConfig.proxyUrl; sastProxyConfig.sastProxyUrl = ''; sastProxyConfig.scaProxyUrl = ''; - this.httpClient = new HttpClient(baseUrl, this.config.cxOrigin, this.config.cxOriginUrl, this.log, sastProxyConfig, this.sastConfig.cacert_chainFilePath,this.config.version); + this.httpClient = new HttpClient(baseUrl,this.config.originName ? this.config.originName : this.config.cxOrigin, this.config.cxOriginUrl, this.log, sastProxyConfig, this.sastConfig.cacert_chainFilePath,this.config.version); } else { - this.httpClient = new HttpClient(baseUrl, this.config.cxOrigin, this.config.cxOriginUrl, this.log, undefined, this.sastConfig.cacert_chainFilePath,this.config.version); + this.httpClient = new HttpClient(baseUrl, this.config.originName ? this.config.originName : this.config.cxOrigin, this.config.cxOriginUrl, this.log, undefined, this.sastConfig.cacert_chainFilePath,this.config.version); } await this.httpClient.getPacProxyResolve(); await this.httpClient.login(this.sastConfig.username, this.sastConfig.password); @@ -174,11 +174,11 @@ export class CxClient { scaProxyConfig.sastProxyUrl = ''; scaProxyConfig.scaProxyUrl = ''; this.log.info("Overriten URL "+this.config.proxyConfig.sastProxyUrl); - scaHttpClient = new HttpClient(this.scaConfig.apiUrl, this.config.cxOrigin, this.config.cxOriginUrl,this.log, scaProxyConfig, this.scaConfig.cacert_chainFilePath,this.config.version); + scaHttpClient = new HttpClient(this.scaConfig.apiUrl, this.config.originName ? this.config.originName : this.config.cxOrigin, this.config.cxOriginUrl,this.log, scaProxyConfig, this.scaConfig.cacert_chainFilePath,this.config.version); } else { - scaHttpClient = new HttpClient(this.scaConfig.apiUrl, this.config.cxOrigin, this.config.cxOriginUrl,this.log, undefined, this.scaConfig.cacert_chainFilePath,this.config.version); + scaHttpClient = new HttpClient(this.scaConfig.apiUrl, this.config.originName ? this.config.originName : this.config.cxOrigin, this.config.cxOriginUrl,this.log, undefined, this.scaConfig.cacert_chainFilePath,this.config.version); } await scaHttpClient.getPacProxyResolve(); this.scaClient = new ScaClient(this.scaConfig, this.config.sourceLocation, scaHttpClient, this.log,scaProxyConfig, this.config); @@ -682,11 +682,16 @@ Scan results location: ${result.sastScanResultsLink} JSON.stringify({ name: query.$.name, severity: query.$.Severity, - resultLength: query.Result.length + resultLength: this.getQueryResultCount(query.Result) }) ).join(SEPARATOR); } + private static getQueryResultCount(Result: any[]) + { + return Result.length > 0 ? Result.filter( (queryResult ) => queryResult.$['state'] !== '1').length : 0; + } + private static getNewVulnerabilityCounts(scanResult: ScanResults, queries: any[]) { var results, severity; if(queries == undefined || queries.length == 0) diff --git a/src/services/clients/scaClient.ts b/src/services/clients/scaClient.ts index 118718f..9bb48e7 100644 --- a/src/services/clients/scaClient.ts +++ b/src/services/clients/scaClient.ts @@ -850,8 +850,8 @@ The Build Failed for the Following Reasons: projectCustomTagObj = this.normalizeTags(this.config.projectCustomTags); let projectId = this.projectId; let path = ScaClient.PROJECTS + `/${projectId}`; - const teamName = this.config.scaSastTeam; - let teamNameArray: Array = [teamName]; + let teamName = this.config.scaSastTeam.trim(); + let teamNameArray: Array = (teamName != null && teamName != "" && teamName != '/') ? [teamName] : []; const request = { name: this.scanConfig.projectName, AssignedTeams: teamNameArray,