Skip to content

Commit 809f5a3

Browse files
fix issue in tenant (#5)
* fix issue in tenant * update cli version and fix scan show
1 parent d03d7bd commit 809f5a3

File tree

11 files changed

+46
-32
lines changed

11 files changed

+46
-32
lines changed

src/main/java/com/checkmarx/ast/CxAuth.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.fasterxml.jackson.core.type.TypeReference;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import com.google.gson.Gson;
7+
import org.apache.commons.lang3.StringUtils;
78
import org.slf4j.Logger;
89
import org.slf4j.LoggerFactory;
910

@@ -25,22 +26,25 @@
2526
public class CxAuth {
2627
private Logger log = LoggerFactory.getLogger(CxAuth.class.getName());
2728
private String baseuri;
29+
private String baseAuthUri;
30+
private String tenant;
2831
private String key;
2932
private String secret;
3033
private String apikey;
3134
private URI executable = null;
3235
private static final Gson gson = new Gson();
3336

3437
public CxAuth(CxScanConfig scanConfig, Logger log)
35-
throws InterruptedException, IOException, URISyntaxException, CxExeception {
36-
if (scanConfig == null) throw new CxExeception("CxScanConfig object returned as null!");
38+
throws IOException, URISyntaxException, CxException {
39+
if (scanConfig == null) throw new CxException("CxScanConfig object returned as null!");
40+
3741
this.baseuri = scanConfig.getBaseUri();
38-
if (scanConfig.getClientId() != null && scanConfig.getClientSecret() != null) {
39-
this.key = scanConfig.getClientId();
40-
this.secret = scanConfig.getClientSecret();
41-
} else if (scanConfig.getApiKey() != null) {
42-
this.apikey = scanConfig.getApiKey();
43-
}
42+
this.baseAuthUri = scanConfig.getBaseAuthUri();
43+
this.tenant = scanConfig.getTenant();
44+
this.key = scanConfig.getClientId();
45+
this.secret = scanConfig.getClientSecret();
46+
this.apikey = scanConfig.getApiKey();
47+
4448
if (scanConfig.getPathToExecutable() != null && !scanConfig.getPathToExecutable().isEmpty()) {
4549
File file = new File(scanConfig.getPathToExecutable());
4650
this.executable = file.toURI();
@@ -157,6 +161,7 @@ public CxScan cxScanShow(String id) throws IOException, InterruptedException {
157161
List<String> commands = initialCommands();
158162
commands.add("scan");
159163
commands.add("show");
164+
commands.add("--scan-id");
160165
commands.add(id);
161166
CxScan scanObject = runExecutionCommands(commands);
162167
if (scanObject != null)
@@ -197,10 +202,23 @@ public List<String> initialCommands() {
197202
List<String> commands = new ArrayList<String>();
198203
commands.add(executable.getPath());
199204
addAuthCredentials(commands);
205+
206+
if (!StringUtils.isEmpty(this.tenant)) {
207+
commands.add("--tenant");
208+
commands.add(this.tenant);
209+
}
210+
200211
commands.add("--base-uri");
201212
commands.add(baseuri);
213+
214+
if (!StringUtils.isEmpty(this.baseAuthUri)) {
215+
commands.add("--base-auth-uri");
216+
commands.add(this.baseAuthUri);
217+
}
218+
202219
commands.add("--format");
203220
commands.add("json");
221+
204222
return commands;
205223
}
206224

src/main/java/com/checkmarx/ast/CxAuthType.java

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.checkmarx.ast;
2+
3+
public class CxException extends RuntimeException{
4+
public CxException(String errorMessage) {
5+
super(errorMessage);
6+
}
7+
}

src/main/java/com/checkmarx/ast/CxExeception.java

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.checkmarx.ast;
22

33
public enum CxParamType {
4-
S, V, G, PROJECT_NAME, SCAN_TYPES, SAST_PRESET_NAME, FILTER, DIRECTORY, ADDITIONAL_PARAMETERS, AGENT, SOURCES, TENANT
4+
S, V, G, PROJECT_NAME, SCAN_TYPES, SAST_PRESET_NAME, FILTER, DIRECTORY, ADDITIONAL_PARAMETERS, AGENT, SOURCES
55
}

src/main/java/com/checkmarx/ast/CxScanConfig.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88
@Getter
99
@Setter
10-
1110
public class CxScanConfig implements Serializable {
1211

1312
private String baseUri;
14-
private String pathToExecutable;
15-
private CxAuthType authType;
13+
private String baseAuthUri;
14+
private String tenant;
1615
private String clientId;
1716
private String clientSecret;
1817
private String apiKey;
19-
18+
private String pathToExecutable;
2019
}

src/main/java/com/checkmarx/ast/ExecutionService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ public BufferedReader executeCommand(List<String> commands) throws IOException {
1515
InputStreamReader isr = new InputStreamReader(is);
1616
BufferedReader br = new BufferedReader(isr);
1717
return br;
18-
1918
}
20-
2119
}

src/main/resources/cx-linux

-87 KB
Binary file not shown.

src/main/resources/cx-mac

-77.3 KB
Binary file not shown.

src/main/resources/cx.exe

-82 KB
Binary file not shown.

0 commit comments

Comments
 (0)