Skip to content

Commit ec5e69d

Browse files
committed
adding test coverage
1 parent 3fdeb07 commit ec5e69d

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

src/main/results/CxData.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@ export default class CxData {
1212
resultHash: string;
1313
languageName: string;
1414
nodes: CxNode[];
15+
recommendedVersion: string;
16+
17+
constructor(packageData: CxPackageData[],packageIdentifier: string,scaPackageData: CxScaPackageData,queryId: string,queryName: string,group: string,resultHash: string,languageName: string,nodes: CxNode[],recommendedVersion:string) {
18+
this.packageData = packageData;
19+
this.packageIdentifier = packageIdentifier;
20+
this.scaPackageData = scaPackageData;
21+
this.queryId = queryId;
22+
this.queryName = queryName;
23+
this.group = group;
24+
this.resultHash = resultHash;
25+
this.languageName = languageName;
26+
this.nodes = nodes;
27+
this.recommendedVersion=recommendedVersion;
28+
}
1529
}

src/main/results/CxResult.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,22 @@ export default class CxResult {
1616
data: CxData;
1717
comments: any = {};
1818
vulnerabilityDetails:CxVulnerabilityDetails;
19-
}
19+
20+
constructor(type: string,id: string,status: string,similarityId: string,state: string,severity: string,created: string,firstFoundAt: string,foundAt: string,firstScanId:string,description: string,data: CxData,comments: any,vulnerabilityDetails: CxVulnerabilityDetails) {
21+
this.type = type;
22+
this.id = id;
23+
this.status = status;
24+
this.similarityId = similarityId;
25+
this.state = state;
26+
this.severity = severity;
27+
this.created = created;
28+
this.firstFoundAt = firstFoundAt;
29+
this.foundAt = foundAt;
30+
this.firstScanId = firstScanId;
31+
this.description = description;
32+
this.data = data;
33+
this.comments = comments;
34+
this.vulnerabilityDetails = vulnerabilityDetails;
35+
}
36+
}
37+

src/main/results/CxScaPackageData.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@ export default class CxScaPackageData {
55
locations: string [];
66
dependencyPaths: CxDependencyPaths [];
77
outdated: boolean;
8+
9+
constructor(id: string,locations: string [],dependencyPaths: CxDependencyPaths [],outdated: boolean) {
10+
this.id = id;
11+
this.locations = locations;
12+
this.dependencyPaths = dependencyPaths;
13+
this.outdated = outdated;
14+
}
815
}

src/main/wrapper/ExecutionService.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import CxCodeBashing from "../codebashing/CxCodeBashing";
1010
import CxBFL from "../bfl/CxBFL";
1111
import spawner = require('child_process');
1212
import CxKicsRealTime from "../kicsRealtime/CxKicsRealTime";
13+
import CxData from "../results/CxData";
14+
import CxScaPackageData from "../results/CxScaPackageData";
1315

1416

1517

@@ -180,7 +182,11 @@ export class ExecutionService {
180182
if(fileExtension.includes("json")){
181183
const read_json = JSON.parse(read.replace(/:([0-9]{15,}),/g, ':"$1",'));
182184
if (read_json.results){
183-
const r : CxResult[] = read_json.results.map((member:any)=>{return Object.assign( new CxResult(),member);});
185+
const r : CxResult[] = read_json.results.map((member:any)=>{
186+
const cxScaPackageData = new CxScaPackageData(member.data.scaPackageData?.id,member.data.scaPackageData?.locations,member.data.scaPackageData?.dependencyPaths,member.data.scaPackageData?.outdated)
187+
const data = new CxData(member.data.packageData,member.data.packageIdentifier,cxScaPackageData,member.data.queryId,member.data.queryName,member.data.group,member.data.resultHash,member.data.languageName,member.data.nodes,member.data.recommendedVersion)
188+
return new CxResult(member.type,member.id,member.status,member.similarityId,member.state,member.severity,member.created,member.firstFoundAt,member.foundAt,member.firstScanId,member.description,data,member.comments,member.vulnerabilityDetails)
189+
});
184190
cxCommandOutput.payload = r;
185191
}
186192
else{

0 commit comments

Comments
 (0)