Skip to content

Commit 9c40edf

Browse files
Merge branch 'main' into other/one-scan-action
2 parents 6272830 + e13a729 commit 9c40edf

38 files changed

+2086
-86
lines changed

.github/workflows/pr-automation.yml

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

.github/workflows/release.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,29 @@ jobs:
5151
chmod +x ./.github/scripts/update_cli.sh
5252
./.github/scripts/update_cli.sh ${{ inputs.cliTag }}
5353
54+
- name: Extract CLI version
55+
id: extract_cli_version
56+
run: |
57+
CLI_VERSION=$(./src/main/resources/cx-linux version | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+')
58+
echo "CLI version being packed is $CLI_VERSION"
59+
echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV
60+
echo "::set-output name=CLI_VERSION::$CLI_VERSION"
61+
62+
- name: Check if CLI version is latest
63+
if: ${{ github.event.inputs.dev == 'false' && !github.event.inputs.cliTag && github.ref == 'refs/heads/main' }}
64+
id: check_latest_cli_version
65+
run: |
66+
LATEST_CLI_VERSION=$(curl -s https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
67+
echo "CLI_VERSION=[$CLI_VERSION]"
68+
echo "LATEST_CLI_VERSION=[$LATEST_CLI_VERSION]"
69+
echo "Latest CLI version from GitHub: $LATEST_CLI_VERSION"
70+
if [ "$CLI_VERSION" = "$LATEST_CLI_VERSION" ]; then
71+
echo "CLI_VERSION ($CLI_VERSION) matches the latest released version ($LATEST_CLI_VERSION). Proceeding."
72+
else
73+
echo "CLI_VERSION ($CLI_VERSION) does not match the latest released version ($LATEST_CLI_VERSION). Failing workflow."
74+
exit 1
75+
fi
76+
5477
- name: Tag
5578
id: set_tag_name
5679
run: |
@@ -94,14 +117,6 @@ jobs:
94117
fi
95118
echo "AID_PROP=${prop}" >> $GITHUB_ENV
96119
97-
- name: Extract CLI version
98-
id: extract_cli_version
99-
run: |
100-
CLI_VERSION=$(./src/main/resources/cx-linux version | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+')
101-
echo "CLI version being packed is $CLI_VERSION"
102-
echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV
103-
echo "::set-output name=CLI_VERSION::$CLI_VERSION"
104-
105120
- name: Publish package
106121
run: mvn --batch-mode deploy -DskipTests ${{ env.AID_PROP }}
107122
env:
@@ -124,8 +139,8 @@ jobs:
124139
product_name: Java Wrapper
125140
release_version: ${{ needs.release.outputs.TAG_NAME }}
126141
cli_release_version: ${{ needs.release.outputs.CLI_VERSION }}
127-
release_author: "Phoenix Team"
128-
release_url: https://github.com/CheckmarxDev/ast-cli-java-wrapper/releases/tag/${{ needs.release.outputs.TAG_NAME }}
142+
release_author: "Sypher Team"
143+
release_url: https://github.com/Checkmarx/ast-cli-java-wrapper/releases/tag/${{ needs.release.outputs.TAG_NAME }}
129144
jira_product_name: JAVA_WRAPPER
130145
secrets: inherit
131146

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Each line is a file pattern followed by one or more owners
33

44
# Specify the default owners for the entire repository
5-
* @cx-anurag-dalke @cx-anand-nandeshwar @cx-atish-jadhav
5+
#* @cx-anurag-dalke @cx-anand-nandeshwar @cx-atish-jadhav

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<br />
33
<p align="center">
44
<a href="">
5-
<img src="./logo.png" alt="Logo" width="80" height="80">
5+
<img src="https://raw.githubusercontent.com/Checkmarx/ci-cd-integrations/main/.images/cx_x_icon.png" alt="Logo" width="80" height="80">
66
</a>
77

88
<h3 align="center">AST-CLI-JAVA-WRAPPER</h3>

checkmarx-ast-cli.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.28
1+
2.3.46

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<dependency>
2525
<groupId>org.apache.commons</groupId>
2626
<artifactId>commons-lang3</artifactId>
27-
<version>3.14.0</version>
27+
<version>3.18.0</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>com.googlecode.json-simple</groupId>
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>com.google.code.gson</groupId>
4646
<artifactId>gson</artifactId>
47-
<version>2.10.1</version>
47+
<version>2.12.1</version>
4848
</dependency>
4949
<dependency>
5050
<groupId>org.slf4j</groupId>
@@ -228,8 +228,8 @@
228228

229229
<developers>
230230
<developer>
231-
<name>Rahul Pidde</name>
232-
<email>rahul.pidde@checkmarx.com</email>
231+
<name>Anand Nandeshwar</name>
232+
<email>anand.nandeshwar@checkmarx.com</email>
233233
<organization>Checkmarx</organization>
234234
<organizationUrl>https://www.checkmarx.com/</organizationUrl>
235235
</developer>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.checkmarx.ast.containersrealtime;
2+
3+
import com.checkmarx.ast.realtime.RealtimeLocation;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
9+
import lombok.Value;
10+
11+
import java.util.Collections;
12+
import java.util.List;
13+
14+
@Value
15+
@JsonDeserialize
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
17+
@JsonIgnoreProperties(ignoreUnknown = true)
18+
public class ContainersRealtimeImage {
19+
@JsonProperty("ImageName") String imageName;
20+
@JsonProperty("ImageTag") String imageTag;
21+
@JsonProperty("FilePath") String filePath;
22+
@JsonProperty("Locations") List<RealtimeLocation> locations;
23+
@JsonProperty("Status") String status;
24+
@JsonProperty("Vulnerabilities") List<ContainersRealtimeVulnerability> vulnerabilities;
25+
26+
@JsonCreator
27+
public ContainersRealtimeImage(@JsonProperty("ImageName") String imageName,
28+
@JsonProperty("ImageTag") String imageTag,
29+
@JsonProperty("FilePath") String filePath,
30+
@JsonProperty("Locations") List<RealtimeLocation> locations,
31+
@JsonProperty("Status") String status,
32+
@JsonProperty("Vulnerabilities") List<ContainersRealtimeVulnerability> vulnerabilities) {
33+
this.imageName = imageName;
34+
this.imageTag = imageTag;
35+
this.filePath = filePath;
36+
this.locations = locations == null ? Collections.emptyList() : locations;
37+
this.status = status;
38+
this.vulnerabilities = vulnerabilities == null ? Collections.emptyList() : vulnerabilities;
39+
}
40+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.checkmarx.ast.containersrealtime;
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.ObjectMapper;
8+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
9+
import lombok.Value;
10+
import org.apache.commons.lang3.StringUtils;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
14+
import java.io.IOException;
15+
import java.util.List;
16+
17+
@Value
18+
@JsonDeserialize
19+
@JsonInclude(JsonInclude.Include.NON_NULL)
20+
@JsonIgnoreProperties(ignoreUnknown = true)
21+
public class ContainersRealtimeResults {
22+
private static final Logger log = LoggerFactory.getLogger(ContainersRealtimeResults.class);
23+
24+
@JsonProperty("Images") List<ContainersRealtimeImage> images;
25+
26+
@JsonCreator
27+
public ContainersRealtimeResults(@JsonProperty("Images") List<ContainersRealtimeImage> images) {
28+
this.images = images;
29+
}
30+
31+
public static ContainersRealtimeResults fromLine(String line) {
32+
if (StringUtils.isBlank(line)) {
33+
return null;
34+
}
35+
try {
36+
if (line.contains("\"Images\"") && isValidJSON(line)) {
37+
return new ObjectMapper().readValue(line, ContainersRealtimeResults.class);
38+
}
39+
} catch (IOException e) {
40+
log.debug("Failed to parse containers realtime line: {}", line, e);
41+
}
42+
return null;
43+
}
44+
45+
private static boolean isValidJSON(String json) {
46+
try {
47+
new ObjectMapper().readTree(json);
48+
return true;
49+
} catch (IOException e) {
50+
return false;
51+
}
52+
}
53+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.checkmarx.ast.containersrealtime;
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.Value;
9+
10+
@Value
11+
@JsonDeserialize
12+
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
@JsonIgnoreProperties(ignoreUnknown = true)
14+
public class ContainersRealtimeVulnerability {
15+
@JsonProperty("CVE") String cve;
16+
@JsonProperty("Severity") String severity;
17+
18+
@JsonCreator
19+
public ContainersRealtimeVulnerability(@JsonProperty("CVE") String cve,
20+
@JsonProperty("Severity") String severity) {
21+
this.cve = cve;
22+
this.severity = severity;
23+
}
24+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package com.checkmarx.ast.iacrealtime;
2+
3+
import com.checkmarx.ast.realtime.RealtimeLocation;
4+
import com.fasterxml.jackson.annotation.JsonCreator;
5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
7+
import com.fasterxml.jackson.annotation.JsonProperty;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
10+
import lombok.Value;
11+
import org.apache.commons.lang3.StringUtils;
12+
import org.slf4j.Logger;
13+
import org.slf4j.LoggerFactory;
14+
15+
import java.io.IOException;
16+
import java.util.Collections;
17+
import java.util.List;
18+
19+
@Value
20+
@JsonDeserialize
21+
@JsonInclude(JsonInclude.Include.NON_NULL)
22+
@JsonIgnoreProperties(ignoreUnknown = true)
23+
public class IacRealtimeResults {
24+
private static final Logger log = LoggerFactory.getLogger(IacRealtimeResults.class);
25+
@JsonProperty("Results") List<Issue> results; // Normalized list (array or single object)
26+
27+
@JsonCreator
28+
public IacRealtimeResults(@JsonProperty("Results") List<Issue> results) {
29+
this.results = results == null ? Collections.emptyList() : results;
30+
}
31+
32+
@Value
33+
@JsonDeserialize
34+
@JsonInclude(JsonInclude.Include.NON_NULL)
35+
@JsonIgnoreProperties(ignoreUnknown = true)
36+
public static class Issue {
37+
@JsonProperty("Title") String title;
38+
@JsonProperty("Description") String description;
39+
@JsonProperty("SimilarityID") String similarityId;
40+
@JsonProperty("FilePath") String filePath;
41+
@JsonProperty("Severity") String severity;
42+
@JsonProperty("ExpectedValue") String expectedValue;
43+
@JsonProperty("ActualValue") String actualValue;
44+
@JsonProperty("Locations") List<RealtimeLocation> locations;
45+
46+
@JsonCreator
47+
public Issue(@JsonProperty("Title") String title,
48+
@JsonProperty("Description") String description,
49+
@JsonProperty("SimilarityID") String similarityId,
50+
@JsonProperty("FilePath") String filePath,
51+
@JsonProperty("Severity") String severity,
52+
@JsonProperty("ExpectedValue") String expectedValue,
53+
@JsonProperty("ActualValue") String actualValue,
54+
@JsonProperty("Locations") List<RealtimeLocation> locations) {
55+
this.title = title;
56+
this.description = description;
57+
this.similarityId = similarityId;
58+
this.filePath = filePath;
59+
this.severity = severity;
60+
this.expectedValue = expectedValue;
61+
this.actualValue = actualValue;
62+
this.locations = locations == null ? Collections.emptyList() : locations;
63+
}
64+
}
65+
66+
public static IacRealtimeResults fromLine(String line) {
67+
if (StringUtils.isBlank(line)) {
68+
return null;
69+
}
70+
try {
71+
if (!isValidJSON(line)) {
72+
return null;
73+
}
74+
ObjectMapper mapper = new ObjectMapper();
75+
String trimmed = line.trim();
76+
if (trimmed.startsWith("[")) {
77+
List<Issue> list = mapper.readValue(trimmed, mapper.getTypeFactory().constructCollectionType(List.class, Issue.class));
78+
return new IacRealtimeResults(list == null ? Collections.emptyList() : list);
79+
}
80+
if (trimmed.startsWith("{")) {
81+
Issue single = mapper.readValue(trimmed, Issue.class);
82+
return new IacRealtimeResults(Collections.singletonList(single));
83+
}
84+
} catch (IOException e) {
85+
log.debug("Failed to parse iac realtime JSON line: {}", line, e);
86+
}
87+
return null;
88+
}
89+
90+
private static boolean isValidJSON(String json) {
91+
try {
92+
new ObjectMapper().readTree(json);
93+
return true;
94+
} catch (IOException e) {
95+
return false;
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)