Skip to content

Commit f50e74d

Browse files
authored
Merge pull request #142 from CheckmarxDev/feature/AST-12643-sca-panel
Feature/ast 12643 sca panel
2 parents 40add97 + 305f6ae commit f50e74d

File tree

6 files changed

+124
-2
lines changed

6 files changed

+124
-2
lines changed

src/main/java/com/checkmarx/ast/results/result/Data.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ public class Data {
2525
String expectedValue;
2626
String value;
2727
String fileName;
28+
String packageIdentifier;
29+
String recommendedVersion;
2830
int line;
2931
List<Node> nodes;
3032
List<PackageData> packageData;
33+
ScaPackageData scaPackageData;
3134

3235
public Data(@JsonProperty("queryId") String queryId,
3336
@JsonProperty("queryName") String queryName,
@@ -39,9 +42,12 @@ public Data(@JsonProperty("queryId") String queryId,
3942
@JsonProperty("expectedValue") String expectedValue,
4043
@JsonProperty("value") String value,
4144
@JsonProperty("filename") String fileName,
45+
@JsonProperty("packageIdentifier") String packageIdentifier,
46+
@JsonProperty("recommendedVersion") String recommendedVersion,
4247
@JsonProperty("line") int line,
4348
@JsonProperty("nodes") List<Node> nodes,
44-
@JsonProperty("packageData") List<PackageData> packageData) {
49+
@JsonProperty("packageData") List<PackageData> packageData,
50+
@JsonProperty("scaPackageData") ScaPackageData scaPackageData) {
4551
this.queryId = queryId;
4652
this.queryName = queryName;
4753
this.group = group;
@@ -52,8 +58,11 @@ public Data(@JsonProperty("queryId") String queryId,
5258
this.expectedValue = expectedValue;
5359
this.value = value;
5460
this.fileName = fileName;
61+
this.packageIdentifier = packageIdentifier;
62+
this.recommendedVersion = recommendedVersion;
5563
this.line = line;
5664
this.nodes = nodes;
5765
this.packageData = packageData;
66+
this.scaPackageData = scaPackageData;
5867
}
5968
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.checkmarx.ast.results.result;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
7+
import lombok.Value;
8+
9+
import java.util.List;
10+
11+
@Value
12+
@JsonDeserialize()
13+
@JsonInclude(JsonInclude.Include.NON_NULL)
14+
@JsonIgnoreProperties(ignoreUnknown = true)
15+
public class DependencyPath {
16+
17+
String Id;
18+
String name;
19+
String version;
20+
List<String> locations;
21+
boolean isResolved;
22+
boolean isDevelopment;
23+
boolean supportsQuickFix;
24+
25+
26+
public DependencyPath(@JsonProperty("Id") String id,
27+
@JsonProperty("name") String name,
28+
@JsonProperty("version") String version,
29+
@JsonProperty("locations") List<String> locations,
30+
@JsonProperty("isResolved") boolean isResolved,
31+
@JsonProperty("isDevelopment") boolean isDevelopment,
32+
@JsonProperty("supportsQuickFix") boolean supportsQuickFix) {
33+
34+
Id = id;
35+
this.name = name;
36+
this.version = version;
37+
this.locations = locations;
38+
this.isResolved = isResolved;
39+
this.isDevelopment = isDevelopment;
40+
this.supportsQuickFix = supportsQuickFix;
41+
}
42+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.checkmarx.ast.results.result;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
7+
import lombok.Value;
8+
9+
import java.util.List;
10+
11+
@Value
12+
@JsonDeserialize()
13+
@JsonInclude(JsonInclude.Include.NON_NULL)
14+
@JsonIgnoreProperties(ignoreUnknown = true)
15+
public class ScaPackageData {
16+
17+
String Id;
18+
String fixLink;
19+
List<List<DependencyPath>> dependencyPaths;
20+
boolean outdated;
21+
boolean supportsQuickFix;
22+
23+
24+
public ScaPackageData(@JsonProperty("Id") String id,
25+
@JsonProperty("fixLink") String fixLink,
26+
@JsonProperty("dependencyPaths") List<List<DependencyPath>> dependencyPaths,
27+
@JsonProperty("outdated") boolean outdated,
28+
@JsonProperty("supportsQuickFix") boolean supportsQuickFix) {
29+
30+
Id = id;
31+
this.fixLink = fixLink;
32+
this.dependencyPaths = dependencyPaths;
33+
this.outdated = outdated;
34+
this.supportsQuickFix = supportsQuickFix;
35+
}
36+
}

src/main/java/com/checkmarx/ast/results/result/VulnerabilityCVSS.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,29 @@ public class VulnerabilityCVSS {
1717
String availability;
1818
String confidentiality;
1919
String attackComplexity;
20+
String integrityImpact;
21+
String scope;
22+
String privilegesRequired;
23+
String userInteraction;
24+
2025

2126
public VulnerabilityCVSS(@JsonProperty("version") int version,
2227
@JsonProperty("attackVector") String attackVector,
2328
@JsonProperty("availability") String availability,
2429
@JsonProperty("confidentiality") String confidentiality,
25-
@JsonProperty("attackComplexity") String attackComplexity) {
30+
@JsonProperty("attackComplexity") String attackComplexity,
31+
@JsonProperty("integrityImpact") String integrityImpact,
32+
@JsonProperty("scope") String scope,
33+
@JsonProperty("privilegesRequired") String privilegesRequired,
34+
@JsonProperty("userInteraction") String userInteraction) {
2635
this.version = version;
2736
this.attackVector = attackVector;
2837
this.availability = availability;
2938
this.confidentiality = confidentiality;
3039
this.attackComplexity = attackComplexity;
40+
this.integrityImpact = integrityImpact;
41+
this.scope = scope;
42+
this.privilegesRequired = privilegesRequired;
43+
this.userInteraction = userInteraction;
3144
}
3245
}

src/main/java/com/checkmarx/ast/wrapper/CxConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,10 @@ public final class CxConstants {
5353
static final String ADDITONAL_PARAMS = "--additional-params";
5454
static final String ENGINE = "--engine";
5555
static final String SUB_CMD_KICS_REALTIME = "kics-realtime";
56+
static final String SCA_REMEDIATION_PACKAGE_FILES = "--package-files";
57+
static final String SCA_REMEDIATION_PACKAGE = "--package";
58+
static final String SCA_REMEDIATION_PACKAGE_VERSION = "--package-version";
59+
static final String CMD_UTILS = "utils";
60+
static final String CMD_REMEDIATION = "remediation";
61+
static final String SUB_CMD_REMEDIATION_SCA = "sca";
5662
}

src/main/java/com/checkmarx/ast/wrapper/CxWrapper.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.commons.lang3.StringUtils;
1818
import org.slf4j.Logger;
1919
import org.slf4j.LoggerFactory;
20+
2021
import java.io.IOException;
2122
import java.nio.file.Files;
2223
import java.util.ArrayList;
@@ -286,6 +287,21 @@ private List<String> buildResultsArgumentsArray(UUID scanId, ReportFormat report
286287
return arguments;
287288
}
288289

290+
public String scaRemediation(String packageFiles, String packages, String packageVersion) throws CxException, IOException, InterruptedException {
291+
List<String> arguments = new ArrayList<>();
292+
arguments.add(CxConstants.CMD_UTILS);
293+
arguments.add(CxConstants.CMD_REMEDIATION);
294+
arguments.add(CxConstants.SUB_CMD_REMEDIATION_SCA);
295+
arguments.add(CxConstants.SCA_REMEDIATION_PACKAGE_FILES);
296+
arguments.add(packageFiles);
297+
arguments.add(CxConstants.SCA_REMEDIATION_PACKAGE);
298+
arguments.add(packages);
299+
arguments.add(CxConstants.SCA_REMEDIATION_PACKAGE_VERSION);
300+
arguments.add(packageVersion);
301+
302+
return Execution.executeCommand(withConfigArguments(arguments), logger, line -> null);
303+
}
304+
289305
public int getResultsBfl(@NonNull UUID scanId, @NonNull String queryId, List<Node> resultNodes)
290306
throws IOException, InterruptedException, CxException {
291307
this.logger.info("Executing 'results bfl' command using the CLI.");

0 commit comments

Comments
 (0)