Skip to content

Commit bfaa9d3

Browse files
aimcp server changes
1 parent 40cc485 commit bfaa9d3

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public final class CxConstants {
6161
static final String ADDITONAL_PARAMS = "--additional-params";
6262
static final String ENGINE = "--engine";
6363
static final String SUB_CMD_KICS_REALTIME = "kics-realtime";
64+
static final String SUB_CMD_OSS_REALTIME = "oss-realtime";
65+
static final String IGNORED_FILE_PATH = "--ignored-file-path";
6466
static final String SCA_REMEDIATION_PACKAGE_FILES = "--package-files";
6567
static final String SCA_REMEDIATION_PACKAGE = "--package";
6668
static final String SCA_REMEDIATION_PACKAGE_VERSION = "--package-version";
@@ -74,4 +76,5 @@ public final class CxConstants {
7476
static final String SUB_CMD_LEARN_MORE = "learn-more";
7577
static final String SUB_CMD_TENANT = "tenant";
7678
static final String IDE_SCANS_KEY = "scan.config.plugins.ideScans";
79+
static final String AI_MCP_SERVER_KEY = "scan.config.plugins.aiMcpServer";
7780
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,26 @@ public KicsRealtimeResults kicsRealtimeScan(@NonNull String fileSources, String
404404
return Execution.executeCommand(withConfigArguments(arguments), logger, KicsRealtimeResults::fromLine);
405405
}
406406

407+
public String ossRealtimeScan(@NonNull String sourcePath, String ignoredFilePath)
408+
throws IOException, InterruptedException, CxException {
409+
this.logger.info("Executing 'scan oss-realtime' command using the CLI.");
410+
this.logger.info("Source: {} IgnoredFilePath: {}", sourcePath, ignoredFilePath);
411+
List<String> arguments = new ArrayList<>();
412+
arguments.add(CxConstants.CMD_SCAN);
413+
arguments.add(CxConstants.SUB_CMD_OSS_REALTIME);
414+
arguments.add(CxConstants.SOURCE);
415+
arguments.add(sourcePath);
416+
if (StringUtils.isNotBlank(ignoredFilePath)) {
417+
arguments.add(CxConstants.IGNORED_FILE_PATH);
418+
arguments.add(ignoredFilePath);
419+
}
420+
return Execution.executeCommand(withConfigArguments(arguments), logger, line -> line);
421+
}
422+
423+
public String ossRealtimeScan(@NonNull String sourcePath)
424+
throws IOException, InterruptedException, CxException {
425+
return ossRealtimeScan(sourcePath, null);
426+
}
407427
public KicsRemediation kicsRemediate(@NonNull String resultsFile, String kicsFile, String engine,String similarityIds)
408428
throws IOException, InterruptedException, CxException {
409429
this.logger.info("Executing 'remediation kics' command using the CLI.");
@@ -455,6 +475,18 @@ public boolean ideScansEnabled() throws CxException, IOException, InterruptedExc
455475
.orElse(false);
456476
}
457477

478+
public boolean aiMcpServerEnabled() throws CxException, IOException, InterruptedException {
479+
List<TenantSetting> tenantSettings = tenantSettings();
480+
if (tenantSettings == null) {
481+
throw new CxException(1, "Unable to parse tenant settings");
482+
}
483+
return tenantSettings.stream()
484+
.filter(t -> t.getKey().equals(CxConstants.AI_MCP_SERVER_KEY))
485+
.findFirst()
486+
.map(t -> Boolean.parseBoolean(t.getValue()))
487+
.orElse(false);
488+
}
489+
458490
public List<TenantSetting> tenantSettings() throws CxException, IOException, InterruptedException {
459491
List<String> arguments = jsonArguments();
460492

0 commit comments

Comments
 (0)