Skip to content

Commit 5bd9e0b

Browse files
committed
Refactor verifyEngineOnMAC method to simplify engine path resolution and improve logging for fallback handling
1 parent d03675d commit 5bd9e0b

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

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

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -421,33 +421,16 @@ public String checkEngineExist(@NonNull String engineName) throws CxException, I
421421
}
422422

423423
private String verifyEngineOnMAC(String engineName,List<String>arguments) throws CxException, IOException, InterruptedException {
424-
Exception lastException = null;
425-
String enginePath;
424+
// Try to verify engine exists via shell command
426425
try{
427-
enginePath= Execution.executeCommand((arguments), logger, line->line);
428-
return enginePath;
426+
Execution.executeCommand((arguments), logger, line->line);
429427
} catch (CxException | IOException e) {
430-
lastException = e;
428+
// Log but don't fail - CLI will handle fallback path resolution
429+
// This handles the case when IDE is launched via GUI (no PATH inherited)
430+
this.logger.debug("Engine '{}' not found in PATH, CLI will try fallback paths", engineName);
431431
}
432-
Path dockerPath = Paths.get(CxConstants.DOCKER_FALLBACK_PATH);
433-
Path podmanPath = Paths.get(CxConstants.PODMAN_FALLBACK_PATH);
434-
if (CxConstants.DOCKER.equalsIgnoreCase(engineName)) {
435-
if (Files.isSymbolicLink(dockerPath)) {
436-
return Files.readSymbolicLink(dockerPath).toAbsolutePath().toString();
437-
}
438-
else { return dockerPath.toAbsolutePath().toString(); }
439-
}
440-
else if (CxConstants.PODMAN.equalsIgnoreCase(engineName)) {
441-
if (Files.exists(podmanPath)) {
442-
if (Files.isSymbolicLink(podmanPath)) {
443-
return Files.readSymbolicLink(podmanPath).toAbsolutePath().toString();
444-
}
445-
else{
446-
return podmanPath.toAbsolutePath().toString();
447-
}
448-
}
449-
}
450-
throw new CxException( 1, "Engine '" + engineName + "' is not installed or not symlinked to /usr/local/bin." );
432+
// Always return just the engine name, let CLI resolve the actual path
433+
return engineName;
451434
}
452435

453436
private String checkEngine(String engineName, String osType ) throws CxException, IOException, InterruptedException {

0 commit comments

Comments
 (0)