Skip to content

Commit a01974d

Browse files
authored
Merge pull request #156 from CheckmarxDev/feature/AST-12644-updating-sca-results-details
adding full results structure + support for new sca results
2 parents a4f6040 + 1ea2118 commit a01974d

File tree

13 files changed

+1003
-11
lines changed

13 files changed

+1003
-11
lines changed

src/main/results/CxCvss.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default class CxCvss {
2+
version:string;
3+
attackVector:string;
4+
availability:string;
5+
confidentiality:string;
6+
attackComplexity:string;
7+
integrityImpact:string;
8+
scope:string;
9+
privilegesRequired:string;
10+
userInteraction:string;
11+
12+
constructor(version: string,attackVector: string,availability: string,confidentiality: string,attackComplexity:string,integrityImpact:string,scope:string,privilegesRequired:string,userInteraction:string) {
13+
this.version = version;
14+
this.attackVector = attackVector;
15+
this.availability = availability;
16+
this.confidentiality = confidentiality;
17+
this.attackComplexity = attackComplexity;
18+
this.integrityImpact = integrityImpact;
19+
this.scope = scope;
20+
this.privilegesRequired = privilegesRequired;
21+
this.userInteraction = userInteraction;
22+
}
23+
}

src/main/results/CxData.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import CxPackageData from "./CxPackageData";
2+
import CxScaPackageData from "./CxScaPackageData";
3+
import CxNode from "./CxNode";
4+
5+
export default class CxData {
6+
packageData: CxPackageData[];
7+
packageIdentifier: string;
8+
scaPackageData: CxScaPackageData;
9+
queryId: string;
10+
queryName: string;
11+
group: string;
12+
resultHash: string;
13+
languageName: string;
14+
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+
}
29+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default class CxDependencyPaths {
2+
id: string;
3+
name: string;
4+
version: string;
5+
isDevelopment: boolean;
6+
}

src/main/results/CxNode.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export default class CxNode {
2+
id: string;
3+
line: number;
4+
name: string;
5+
column: number;
6+
length: number;
7+
method: string;
8+
nodeID: number;
9+
domType: string;
10+
fileName: string;
11+
fullName: string;
12+
typeName: string;
13+
methodLine: number;
14+
definitions: string;
15+
16+
constructor(id: string,line: number,name: string,column: number,length: number,method: string,nodeID: number,domType: string,fileName: string,fullName:string,typeName: string,methodLine: number,definitions: string) {
17+
this.id = id;
18+
this.line = line;
19+
this.name = name;
20+
this.column = column;
21+
this.length = length;
22+
this.method = method;
23+
this.nodeID = nodeID;
24+
this.domType = domType;
25+
this.fileName = fileName;
26+
this.fullName = fullName;
27+
this.typeName = typeName;
28+
this.methodLine = methodLine;
29+
this.definitions = definitions;
30+
}
31+
}

src/main/results/CxPackageData.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default class CxPackageData {
2+
comment: string;
3+
type: string;
4+
url: string;
5+
6+
constructor(comment: string,type: string,url: string) {
7+
this.comment = comment;
8+
this.type = type;
9+
this.url = url;
10+
}
11+
}

src/main/results/CxResult.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import CxData from "./CxData";
2+
import CxVulnerabilityDetails from "./CxVulnerabilityDetails";
3+
14
export default class CxResult {
25
type: string;
36
id: string;
@@ -10,7 +13,25 @@ export default class CxResult {
1013
foundAt: string;
1114
firstScanId: string;
1215
description: string;
13-
data: any = {};
16+
data: CxData;
1417
comments: any = {};
15-
vulnerabilityDetails:object = {};
16-
}
18+
vulnerabilityDetails:CxVulnerabilityDetails;
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+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import CxDependencyPaths from "./CxDependencyPaths";
2+
3+
export default class CxScaPackageData {
4+
id: string;
5+
locations: string [];
6+
dependencyPaths: CxDependencyPaths [];
7+
outdated: boolean;
8+
fixLink:string
9+
10+
constructor(id: string,locations: string [],dependencyPaths: CxDependencyPaths [],outdated: boolean,fixLink:string) {
11+
this.id = id;
12+
this.locations = locations;
13+
this.dependencyPaths = dependencyPaths;
14+
this.outdated = outdated;
15+
this.fixLink = fixLink;
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import CxCvss from "./CxCvss";
2+
3+
export default class CxVulnerabilityDetails {
4+
cweId: number;
5+
cvss: CxCvss;
6+
compliances: string[];
7+
cvssScore:number;
8+
cveName:string;
9+
10+
constructor(cweId: number,cvss: CxCvss,compliances: string[],cvssScore: number,cveName:string) {
11+
this.cweId = cweId;
12+
this.cvss = cvss;
13+
this.compliances = compliances;
14+
this.cvssScore = cvssScore;
15+
this.cveName = cveName;
16+
}
17+
}

src/main/wrapper/CxConstants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ export enum CxConstants {
1818
CMD_UTILS = "utils",
1919
CMD_REMEDIATION = "remediation",
2020
SUB_CMD_REMEDIATION_KICS = "kics",
21+
SUB_CMD_REMEDIATION_SCA = "sca",
2122
KICS_REMEDIATION_RESULTS_FILE = "--results-file",
2223
KICS_REMEDIATION_KICS_FILE = "--kics-files",
2324
KICS_REMEDIATION_SIMILARITY_IDS = "--similarity-ids",
25+
SCA_REMEDIATION_PACKAGE_FILE = "--package-file",
26+
SCA_REMEDIATION_PACKAGE = "--package",
27+
SCA_REMEDIATION_PACKAGE_VERSION = "--package-version",
2428
CMD_AUTH = "auth",
2529
SUB_CMD_VALIDATE = "validate",
2630
CMD_PROJECT = "project",

src/main/wrapper/CxWrapper.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { CxConfig } from "./CxConfig";
2-
import { CxParamType } from "./CxParamType";
3-
import { CxConstants } from "./CxConstants";
4-
import { ExecutionService } from "./ExecutionService";
5-
import { CxCommandOutput } from "./CxCommandOutput";
6-
import path = require('path');
7-
import { getLoggerWithFilePath, logger } from "./loggerConfig";
1+
import {CxConfig} from "./CxConfig";
2+
import {CxParamType} from "./CxParamType";
3+
import {CxConstants} from "./CxConstants";
4+
import {ExecutionService} from "./ExecutionService";
5+
import {CxCommandOutput} from "./CxCommandOutput";
6+
import {getLoggerWithFilePath, logger} from "./loggerConfig";
87
import * as fs from "fs"
98
import * as os from "os";
109
import CxBFL from "../bfl/CxBFL";
10+
import path = require('path');
1111

1212
type ParamTypeMap = Map<CxParamType, string>;
1313

@@ -260,6 +260,13 @@ export class CxWrapper {
260260
return exec.executeKicsCommands(this.config.pathToExecutable, commands, CxConstants.KICS_REMEDIATION_TYPE);
261261
}
262262

263+
async scaRemediation(packageFile: string, packages:string, packageVersion:string): Promise<CxCommandOutput> {
264+
const commands: string[] = [CxConstants.CMD_UTILS, CxConstants.CMD_REMEDIATION,CxConstants.SUB_CMD_REMEDIATION_SCA,CxConstants.SCA_REMEDIATION_PACKAGE_FILE, packageFile,CxConstants.SCA_REMEDIATION_PACKAGE, packages,CxConstants.SCA_REMEDIATION_PACKAGE_VERSION,packageVersion];
265+
commands.push(...this.initializeCommands(false));
266+
const exec = new ExecutionService();
267+
return exec.executeCommands(this.config.pathToExecutable, commands);
268+
}
269+
263270
getIndexOfBflNode(bflNodes: CxBFL[], resultNodes: any[]): number {
264271

265272
const bflNodeNotFound = -1;

0 commit comments

Comments
 (0)