From 2ef6b2134fe69b2706a4c0742bb9008feb16b68b Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:22:02 +0100 Subject: [PATCH] fix: Fix NoSuchFileExceptions if FCLI_HOME or FORTIFY_HOME set to relative directory (fixes #227) --- .../java/com/fortify/cli/common/util/FcliHomeHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fcli-common/src/main/java/com/fortify/cli/common/util/FcliHomeHelper.java b/fcli-common/src/main/java/com/fortify/cli/common/util/FcliHomeHelper.java index 274b54eb4a..ec5f289dc5 100644 --- a/fcli-common/src/main/java/com/fortify/cli/common/util/FcliHomeHelper.java +++ b/fcli-common/src/main/java/com/fortify/cli/common/util/FcliHomeHelper.java @@ -29,15 +29,15 @@ public class FcliHomeHelper { public static final Path getFortifyHomePath() { String fortifyHome = System.getenv(ENVNAME_FORTIFY_HOME); return StringUtils.isNotBlank(fortifyHome) - ? Path.of(fortifyHome) - : Path.of(System.getProperty("user.home"), DEFAULT_FORTIFY_DIR_NAME); + ? Path.of(fortifyHome).toAbsolutePath() + : Path.of(System.getProperty("user.home"), DEFAULT_FORTIFY_DIR_NAME).toAbsolutePath(); } public static final Path getFcliHomePath() { String fcliHome = System.getenv(ENVNAME_FCLI_HOME); return StringUtils.isNotBlank(fcliHome) - ? Path.of(fcliHome) - : getFortifyHomePath().resolve(DEFAULT_FCLI_DIR_NAME); + ? Path.of(fcliHome).toAbsolutePath() + : getFortifyHomePath().resolve(DEFAULT_FCLI_DIR_NAME).toAbsolutePath(); } public static final void saveSecuredFile(Path relativePath, Object contents, boolean failOnError) {