Skip to content

Commit bb8584a

Browse files
authored
Feature/ast 4445/enrich wrapper results (#15)
* AST-4445 match results output structure to the CLI; bump release number * AST-4445 add method to auto parse json and return a built CxResultOutput object * AST-4445 change queryId and cweId to String; add vulnerability details to CxResult * AST-4445 remove no longer existing argument * AST-4445 increment version
1 parent e72469f commit bb8584a

File tree

14 files changed

+338
-140
lines changed

14 files changed

+338
-140
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.checkmarx.ast</groupId>
66
<artifactId>ast-cli-java-wrapper</artifactId>
7-
<version>1.0.11</version>
7+
<version>1.0.12</version>
88
<packaging>jar</packaging>
99

1010
<dependencies>

src/main/java/com/checkmarx/ast/results/CxCommandOutput.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33

44
import com.checkmarx.ast.scans.CxScan;
5-
import lombok.*;
6-
5+
import lombok.Getter;
6+
import lombok.Setter;
77

88
import java.util.List;
99

1010
@Getter
1111
@Setter
12-
public class CxCommandOutput extends CxOutput{
12+
public class CxCommandOutput {
1313
private int exitCode;
1414
private List<CxScan> scanObjectList;
15-
1615
}

src/main/java/com/checkmarx/ast/results/CxOutput.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/com/checkmarx/ast/results/CxResult.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/main/java/com/checkmarx/ast/results/CxResultOutput.java

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.checkmarx.ast.results.structure;
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.*;
8+
9+
@Data
10+
@Builder
11+
@Value
12+
@EqualsAndHashCode
13+
@ToString
14+
@JsonDeserialize()
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
@JsonIgnoreProperties(ignoreUnknown = true)
17+
public class CxResult {
18+
19+
String type;
20+
String id;
21+
String similarityId;
22+
String status;
23+
String state;
24+
String severity;
25+
String created;
26+
String firstFoundAt;
27+
String foundAt;
28+
String firstScan;
29+
String firstScanId;
30+
String publishedAt;
31+
String recommendations;
32+
CxResultData data;
33+
CxResultComments comments;
34+
CxResultVulnerabilityDetails vulnerabilityDetails;
35+
36+
public CxResult(@JsonProperty("type") String type,
37+
@JsonProperty("id") String id,
38+
@JsonProperty("similarityId") String similarityId,
39+
@JsonProperty("status") String status,
40+
@JsonProperty("state") String state,
41+
@JsonProperty("severity") String severity,
42+
@JsonProperty("created") String created,
43+
@JsonProperty("firstFoundAt") String firstFoundAt,
44+
@JsonProperty("foundAt") String foundAt,
45+
@JsonProperty("firstScan") String firstScan,
46+
@JsonProperty("firstScanId") String firstScanId,
47+
@JsonProperty("publishedAt") String publishedAt,
48+
@JsonProperty("recommendations") String recommendations,
49+
@JsonProperty("data") CxResultData data,
50+
@JsonProperty("comments") CxResultComments comments,
51+
@JsonProperty("vulnerabilityDetails") CxResultVulnerabilityDetails vulnerabilityDetails) {
52+
this.type = type;
53+
this.id = id;
54+
this.similarityId = similarityId;
55+
this.status = status;
56+
this.state = state;
57+
this.severity = severity;
58+
this.created = created;
59+
this.firstFoundAt = firstFoundAt;
60+
this.foundAt = foundAt;
61+
this.firstScan = firstScan;
62+
this.firstScanId = firstScanId;
63+
this.publishedAt = publishedAt;
64+
this.recommendations = recommendations;
65+
this.data = data;
66+
this.comments = comments;
67+
this.vulnerabilityDetails = vulnerabilityDetails;
68+
}
69+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.checkmarx.ast.results.structure;
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.*;
8+
9+
@Data
10+
@Builder
11+
@Value
12+
@EqualsAndHashCode
13+
@ToString
14+
@JsonDeserialize()
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
@JsonIgnoreProperties(ignoreUnknown = true)
17+
public class CxResultComments {
18+
String comments;
19+
20+
public CxResultComments(@JsonProperty("comments") String comments) {
21+
this.comments = comments;
22+
}
23+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.checkmarx.ast.results.structure;
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.*;
8+
9+
import java.math.BigInteger;
10+
import java.util.List;
11+
12+
@Data
13+
@Builder
14+
@Value
15+
@EqualsAndHashCode
16+
@ToString
17+
@JsonDeserialize()
18+
@JsonInclude(JsonInclude.Include.NON_NULL)
19+
@JsonIgnoreProperties(ignoreUnknown = true)
20+
public class CxResultData {
21+
22+
String queryId;
23+
String queryName;
24+
String group;
25+
String resultHash;
26+
String languageName;
27+
String description;
28+
List<CxResultDataNode> nodes;
29+
30+
public CxResultData(@JsonProperty("queryId") String queryId,
31+
@JsonProperty("queryName") String queryName,
32+
@JsonProperty("group") String group,
33+
@JsonProperty("resultHash") String resultHash,
34+
@JsonProperty("languageName") String languageName,
35+
@JsonProperty("description") String description,
36+
@JsonProperty("nodes") List<CxResultDataNode> nodes) {
37+
this.queryId = queryId;
38+
this.queryName = queryName;
39+
this.group = group;
40+
this.resultHash = resultHash;
41+
this.languageName = languageName;
42+
this.description = description;
43+
this.nodes = nodes;
44+
}
45+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.checkmarx.ast.results.structure;
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.*;
8+
9+
@Data
10+
@Builder
11+
@Value
12+
@EqualsAndHashCode
13+
@ToString
14+
@JsonDeserialize()
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
@JsonIgnoreProperties(ignoreUnknown = true)
17+
public class CxResultDataNode {
18+
19+
String id;
20+
int line;
21+
String name;
22+
int column;
23+
int length;
24+
String method;
25+
int nodeId;
26+
String domType;
27+
String fileName;
28+
String fullName;
29+
String typeName;
30+
String methodLine;
31+
String definitions;
32+
33+
public CxResultDataNode(@JsonProperty("id") String id,
34+
@JsonProperty("line") int line,
35+
@JsonProperty("name") String name,
36+
@JsonProperty("column") int column,
37+
@JsonProperty("length") int length,
38+
@JsonProperty("method") String method,
39+
@JsonProperty("nodeID") int nodeId,
40+
@JsonProperty("domType") String domType,
41+
@JsonProperty("fileName") String fileName,
42+
@JsonProperty("fullName") String fullName,
43+
@JsonProperty("typeName") String typeName,
44+
@JsonProperty("methodLine") String methodLine,
45+
@JsonProperty("definitions") String definitions) {
46+
this.id = id;
47+
this.line = line;
48+
this.name = name;
49+
this.column = column;
50+
this.length = length;
51+
this.method = method;
52+
this.nodeId = nodeId;
53+
this.domType = domType;
54+
this.fileName = fileName;
55+
this.fullName = fullName;
56+
this.typeName = typeName;
57+
this.methodLine = methodLine;
58+
this.definitions = definitions;
59+
}
60+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.checkmarx.ast.results.structure;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
8+
import lombok.*;
9+
10+
import java.util.List;
11+
12+
@Data
13+
@Builder
14+
@Value
15+
@EqualsAndHashCode
16+
@ToString
17+
@JsonDeserialize()
18+
@JsonInclude(JsonInclude.Include.NON_NULL)
19+
@JsonIgnoreProperties(ignoreUnknown = true)
20+
public class CxResultOutput {
21+
22+
int totalCount;
23+
List<CxResult> results;
24+
25+
@JsonCreator
26+
public CxResultOutput(@JsonProperty("totalCount") int totalCount, @JsonProperty("results") List<CxResult> results) {
27+
this.totalCount = totalCount;
28+
this.results = results;
29+
}
30+
}

0 commit comments

Comments
 (0)