diff --git a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/util/FileUtils.java b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/util/FileUtils.java index 4402a32089..6ffe9d48c6 100644 --- a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/util/FileUtils.java +++ b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/util/FileUtils.java @@ -24,10 +24,13 @@ import java.security.NoSuchAlgorithmException; import java.util.Comparator; import java.util.stream.Stream; +import java.util.zip.GZIPInputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; // TODO For now, methods provided in this class are only used by the tools module, // but potentially some methods or the full class could be moved to the common module. @@ -95,6 +98,23 @@ public static final void extractZip(File zipFile, Path targetDir) throws IOExcep } } + public static final void extractTarGZ(File tgzFile, Path targetDir) throws IOException { + try (InputStream source = Files.newInputStream(tgzFile.toPath()); + GZIPInputStream gzip = new GZIPInputStream(source); + TarArchiveInputStream tar = new TarArchiveInputStream(gzip)) { + + TarArchiveEntry entry; + while ((entry = tar.getNextEntry()) != null) { + Path extractTo = targetDir.resolve(entry.getName()); + if(entry.isDirectory()) { + Files.createDirectories(extractTo); + } else { + Files.copy(tar, extractTo); + } + } + } + } + public static final void deleteRecursive(Path installPath) throws IOException { try (Stream walk = Files.walk(installPath)) { walk.sorted(Comparator.reverseOrder()) diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolInstallCommand.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolInstallCommand.java index 9d99cd74ac..5eca6f9275 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolInstallCommand.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolInstallCommand.java @@ -66,7 +66,7 @@ private static enum DigestMismatchAction { @Override public final JsonNode getJsonNode() { String toolName = getToolName(); - ToolVersionDownloadDescriptor descriptor = ToolHelper.getToolDownloadDescriptor(toolName).getVersionOrDefault(version); + ToolVersionDownloadDescriptor descriptor = ToolHelper.getToolDownloadDescriptor(toolName).getVersionOrDefault(version, getCpuArchitecture()); return downloadAndInstall(toolName, descriptor); } @@ -118,6 +118,7 @@ protected void install(ToolVersionInstallDescriptor descriptor, File downloadedF // TODO Clean this up case COPY: Files.copy(downloadedFile.toPath(), installPath.resolve(StringUtils.substringAfterLast(descriptor.getOriginalDownloadDescriptor().getDownloadUrl(), "/")), StandardCopyOption.REPLACE_EXISTING); break; case EXTRACT_ZIP: FileUtils.extractZip(downloadedFile, installPath); break; + case EXTRACT_TGZ: FileUtils.extractTarGZ(downloadedFile, installPath); break; default: throw new RuntimeException("Unknown install type: "+installType.name()); } downloadedFile.delete(); @@ -140,6 +141,9 @@ protected Path getBinPath(ToolVersionDownloadDescriptor descriptor) { protected abstract String getToolName(); protected abstract InstallType getInstallType(); protected abstract void postInstall(ToolVersionInstallDescriptor installDescriptor) throws IOException; + protected String getCpuArchitecture() { + return ""; + } private final void emptyExistingInstallPath(Path installPath) throws IOException { if ( Files.exists(installPath) && Files.list(installPath).findFirst().isPresent() ) { @@ -178,6 +182,6 @@ private static final void updateFilePermissions(Path p) { } protected static enum InstallType { - EXTRACT_ZIP, COPY + EXTRACT_ZIP, EXTRACT_TGZ, COPY } } diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolUninstallCommand.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolUninstallCommand.java index 4b2cff9341..dda6bae4cb 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolUninstallCommand.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/cli/cmd/AbstractToolUninstallCommand.java @@ -37,7 +37,7 @@ public abstract class AbstractToolUninstallCommand extends AbstractOutputCommand @Override public final JsonNode getJsonNode() { String toolName = getToolName(); - ToolVersionCombinedDescriptor descriptor = ToolHelper.loadToolVersionCombinedDescriptor(toolName, version); + ToolVersionCombinedDescriptor descriptor = ToolHelper.loadToolVersionCombinedDescriptor(toolName, version, getCpuArchitecture()); if ( descriptor==null ) { throw new IllegalArgumentException("Tool installation not found"); } @@ -67,4 +67,7 @@ public boolean isSingular() { } protected abstract String getToolName(); + protected String getCpuArchitecture() { + return ""; + } } diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolDownloadDescriptor.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolDownloadDescriptor.java index 1fc8346afe..9aa0c61201 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolDownloadDescriptor.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolDownloadDescriptor.java @@ -25,6 +25,8 @@ public class ToolDownloadDescriptor { private String defaultDownloadUrl; private String defaultVersion; + private String defaultOperatingSystem; + private String defaultCpuArchitecture; private ToolVersionDownloadDescriptor[] versions; public final ToolVersionDownloadDescriptor[] getVersions() { @@ -37,18 +39,30 @@ public final Stream getVersionsStream() { .map(this::addIsDefaultVersion); } - public final ToolVersionDownloadDescriptor getVersion(String version) { + public final ToolVersionDownloadDescriptor getVersion(String version, String cpuArchitecture) { var lookupVersion = (version.replaceFirst("^v", "")+".").replaceFirst("\\.\\.$", "."); - return getVersionsStream() - .filter(v->(v.getVersion()+".").startsWith(lookupVersion)) - .findFirst().orElseThrow(()->new IllegalArgumentException("Version "+version+" not defined")); + var osString = getOSString(); + var versionResult = getVersionsStream() + .filter(v->(v.getVersion()+".").startsWith(lookupVersion) && + (v.getCpuArchitecture()==null || v.getCpuArchitecture().equals(cpuArchitecture)) && + (v.getOperatingSystem()==null || v.getOperatingSystem().equals(osString))) + .findFirst(); + if (versionResult.isPresent()) { + return versionResult.get(); + } else { + if(cpuArchitecture==null) { + throw new IllegalArgumentException("Version "+version+" not defined"); + } else { + throw new IllegalArgumentException("Version "+version+" not defined for architecture "+cpuArchitecture); + } + } } - public final ToolVersionDownloadDescriptor getVersionOrDefault(String versionName) { + public final ToolVersionDownloadDescriptor getVersionOrDefault(String versionName, String cpuArchitecture) { if ( StringUtils.isBlank(versionName) || "default".equals(versionName) || "latest".equals(versionName) ) { versionName = defaultVersion; } - return getVersion(versionName); + return getVersion(versionName, cpuArchitecture); } private final ToolVersionDownloadDescriptor updateDownloadUrl(ToolVersionDownloadDescriptor versionDescriptor) { @@ -56,13 +70,31 @@ private final ToolVersionDownloadDescriptor updateDownloadUrl(ToolVersionDownloa versionDescriptor.setDownloadUrl(defaultDownloadUrl); } versionDescriptor.setDownloadUrl(versionDescriptor.getDownloadUrl().replaceAll("\\{toolVersion\\}", versionDescriptor.getVersion())); + versionDescriptor.setDownloadUrl(versionDescriptor.getDownloadUrl().replaceAll("\\{operatingSystem\\}", versionDescriptor.getOperatingSystem())); + versionDescriptor.setDownloadUrl(versionDescriptor.getDownloadUrl().replaceAll("\\{cpuArchitecture\\}", versionDescriptor.getCpuArchitecture())); return versionDescriptor; } private final ToolVersionDownloadDescriptor addIsDefaultVersion(ToolVersionDownloadDescriptor versionDescriptor) { - if ( versionDescriptor.getVersion().equals(defaultVersion) ) { + if ( versionDescriptor.getVersion().equals(defaultVersion) && + (versionDescriptor.getOperatingSystem()==null || versionDescriptor.getOperatingSystem().equals(defaultOperatingSystem)) && + (versionDescriptor.getCpuArchitecture()==null || versionDescriptor.getCpuArchitecture().equals(defaultCpuArchitecture))) { versionDescriptor.setIsDefaultVersion("Yes"); } return versionDescriptor; } + + private final String getOSString() { + String OS = System.getProperty("os.name", "generic").toLowerCase(); + if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) { + return "macOS"; + } else if (OS.indexOf("win") >= 0) { + return "windows"; + } else if (OS.indexOf("nux") >= 0) { + return "linux"; + } else { + throw new RuntimeException("Unexpected OS detected: '" + OS + "'"); + } + } + } \ No newline at end of file diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolHelper.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolHelper.java index 6c2d44ecd2..9dcd226089 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolHelper.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolHelper.java @@ -44,10 +44,10 @@ public static final ToolVersionInstallDescriptor loadToolVersionInstallDescripto return FcliDataHelper.readFile(getInstallDescriptorPath(toolName, version), ToolVersionInstallDescriptor.class, false); } - public static final ToolVersionCombinedDescriptor loadToolVersionCombinedDescriptor(String toolName, String version) { - version = getToolDownloadDescriptor(toolName).getVersionOrDefault(version).getVersion(); + public static final ToolVersionCombinedDescriptor loadToolVersionCombinedDescriptor(String toolName, String version, String cpuArchitecture) { + version = getToolDownloadDescriptor(toolName).getVersionOrDefault(version, cpuArchitecture).getVersion(); ToolVersionInstallDescriptor installDescriptor = loadToolVersionInstallDescriptor(toolName, version); - return installDescriptor==null ? null : new ToolVersionCombinedDescriptor(toolName, getToolDownloadDescriptor(toolName).getVersion(version), installDescriptor); + return installDescriptor==null ? null : new ToolVersionCombinedDescriptor(toolName, getToolDownloadDescriptor(toolName).getVersion(version, cpuArchitecture), installDescriptor); } public static final void deleteToolVersionInstallDescriptor(String toolName, String version) { diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionCombinedDescriptor.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionCombinedDescriptor.java index 2bb1d23500..fb2a55c281 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionCombinedDescriptor.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionCombinedDescriptor.java @@ -69,6 +69,14 @@ public Path getBinPath() { return getPath(ToolVersionInstallDescriptor::getBinPath); } + public String getOperatingSystem() { + return getDownloadDescriptor().getOperatingSystem(); + } + + public String getCpuArchitecture() { + return getDownloadDescriptor().getCpuArchitecture(); + } + private String getDir(Function f) { if ( installDescriptor!=null ) { String dir = f.apply(installDescriptor); diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionDownloadDescriptor.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionDownloadDescriptor.java index fd1a2a087a..bf1594f55c 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionDownloadDescriptor.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_common/helper/ToolVersionDownloadDescriptor.java @@ -26,6 +26,8 @@ public final class ToolVersionDownloadDescriptor { private String downloadUrl; private String digest; private String isDefaultVersion = "No"; + private String operatingSystem; + private String cpuArchitecture; @JsonIgnore public final String getDigestAlgorithm() { diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_main/cli/cmd/ToolCommands.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_main/cli/cmd/ToolCommands.java index 2c7b003b87..ef4ed6affe 100644 --- a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_main/cli/cmd/ToolCommands.java +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/_main/cli/cmd/ToolCommands.java @@ -14,6 +14,7 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.tool.bugtracker_utility.cli.cmd.ToolBugTrackerUtilityCommands; +import com.fortify.cli.tool.debricked.cli.cmd.ToolDebrickedCommands; import com.fortify.cli.tool.fod_uploader.cli.cmd.ToolFoDUploaderCommands; import com.fortify.cli.tool.sc_client.cli.cmd.ToolSCClientCommands; import com.fortify.cli.tool.vuln_exporter.cli.cmd.ToolVulnExporterCommands; @@ -25,6 +26,7 @@ resourceBundle = "com.fortify.cli.tool.i18n.ToolMessages", subcommands = { ToolBugTrackerUtilityCommands.class, + ToolDebrickedCommands.class, ToolFoDUploaderCommands.class, ToolSCClientCommands.class, ToolVulnExporterCommands.class diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedCommands.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedCommands.java new file mode 100644 index 0000000000..1e07d1c2e3 --- /dev/null +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedCommands.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 2021, 2022 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ +package com.fortify.cli.tool.debricked.cli.cmd; + +import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; + +import picocli.CommandLine.Command; + +@Command( + name = ToolDebrickedCommands.TOOL_NAME, + subcommands = { + ToolDebrickedInstallCommand.class, + ToolDebrickedListCommand.class, + ToolDebrickedUninstallCommand.class + } + +) +public class ToolDebrickedCommands extends AbstractContainerCommand { + static final String TOOL_NAME = "debricked"; +} diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedInstallCommand.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedInstallCommand.java new file mode 100644 index 0000000000..4d78f31f33 --- /dev/null +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedInstallCommand.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ +package com.fortify.cli.tool.debricked.cli.cmd; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.tool._common.cli.cmd.AbstractToolInstallCommand; +import com.fortify.cli.tool._common.helper.ToolVersionInstallDescriptor; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; +import picocli.CommandLine.Option; + +@Command(name = OutputHelperMixins.Install.CMD_NAME) +public class ToolDebrickedInstallCommand extends AbstractToolInstallCommand { + @Getter @Mixin private OutputHelperMixins.Install outputHelper; + @Getter private String toolName = ToolDebrickedCommands.TOOL_NAME; + @Getter @Option(names={"-a", "--cpuArchitecture"}, required = true, descriptionKey="fcli.tool.debricked.install.cpuArchitecture", defaultValue = "x86_64") + private String _cpuArchitecture; + + @Override + protected InstallType getInstallType() { + return InstallType.EXTRACT_TGZ; + } + + @Override + protected void postInstall(ToolVersionInstallDescriptor descriptor) throws IOException { + Path binPath = descriptor.getBinPath(); + Files.createDirectories(binPath); + } + + @Override + protected String getCpuArchitecture() { + return _cpuArchitecture; + } +} diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedListCommand.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedListCommand.java new file mode 100644 index 0000000000..db7984011d --- /dev/null +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedListCommand.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ +package com.fortify.cli.tool.debricked.cli.cmd; + +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.tool._common.cli.cmd.AbstractToolListCommand; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = OutputHelperMixins.List.CMD_NAME) +public class ToolDebrickedListCommand extends AbstractToolListCommand { + @Getter @Mixin private OutputHelperMixins.List outputHelper; + @Getter private String toolName = ToolDebrickedCommands.TOOL_NAME; +} diff --git a/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedUninstallCommand.java b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedUninstallCommand.java new file mode 100644 index 0000000000..5c3296f4ca --- /dev/null +++ b/fcli-core/fcli-tool/src/main/java/com/fortify/cli/tool/debricked/cli/cmd/ToolDebrickedUninstallCommand.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ +package com.fortify.cli.tool.debricked.cli.cmd; + +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.tool._common.cli.cmd.AbstractToolUninstallCommand; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; +import picocli.CommandLine.Option; + +@Command(name = OutputHelperMixins.Uninstall.CMD_NAME) +public class ToolDebrickedUninstallCommand extends AbstractToolUninstallCommand { + @Getter @Mixin private OutputHelperMixins.Uninstall outputHelper; + @Getter private String toolName = ToolDebrickedCommands.TOOL_NAME; + @Getter @Option(names={"-a", "--cpuArchitecture"}, required = true, descriptionKey="fcli.tool.debricked.uninstall.cpuArchitecture", defaultValue = "x86_64") + private String _cpuArchitecture; + + @Override + protected String getCpuArchitecture() { + return _cpuArchitecture; + } +} diff --git a/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/debricked/debricked.yaml b/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/debricked/debricked.yaml new file mode 100644 index 0000000000..13db4422d1 --- /dev/null +++ b/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/debricked/debricked.yaml @@ -0,0 +1,41 @@ +#Versions must be listed in descending order to guarantee proper version selection when users provide a partial version number +defaultDownloadUrl: https://github.com/debricked/cli/releases/download/v{toolVersion}/cli_{operatingSystem}_{cpuArchitecture}.tar.gz +defaultVersion: 1.5.1 +defaultOperatingSystem: windows +defaultCpuArchitecture: x86_64 +versions: + - version: 1.5.1 + operatingSystem: linux + cpuArchitecture: x86_64 + digest: SHA-256:2d7614d4161a6259c287ec92317bb39a793af82be053926b43e36428c60a3d94 + - version: 1.5.1 + operatingSystem: linux + cpuArchitecture: arm64 + digest: SHA-256:87c686d709b62078e1bf4b4e7f21f6c7cf6737e5dc7ff30f1b04017f86928a31 + - version: 1.5.1 + operatingSystem: linux + cpuArchitecture: i386 + digest: SHA-256:cd1e076ff4f42dff3145b87f928b17610353f162cb79b250851550b60cf313cb + - version: 1.5.1 + operatingSystem: macOS + cpuArchitecture: x86_64 + digest: SHA-256:4fb928d02c87c922ff0bc63dd2d0592a1e567cf0c86b6b1e681388017d29f968 + - version: 1.5.1 + operatingSystem: macOS + cpuArchitecture: arm64 + digest: SHA-256:61b6215780687a38af82873f48962d868b23fd13c8863910c56e60d51d2bffed + - version: 1.5.1 + operatingSystem: windows + cpuArchitecture: x86_64 + digest: SHA-256:d7cf92f12a66bdcd26d1a12b33555348c1d50a4dd57640680b1986cf66e75a73 + - version: 1.5.1 + operatingSystem: windows + cpuArchitecture: arm64 + digest: SHA-256:2dc8379db38b6f9c250e3fb31fbb035e6d05d034df5b3bdf3e172617b3289d93 + - version: 1.5.1 + operatingSystem: windows + cpuArchitecture: i386 + digest: SHA-256:cf7dc59d01b9bbb3d830a56cba2cc1e8cb4bae7744805e30703b62f600902e97 + + + diff --git a/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/i18n/ToolMessages.properties b/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/i18n/ToolMessages.properties index 78d6aeafca..6b4e57f3d9 100644 --- a/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/i18n/ToolMessages.properties +++ b/fcli-core/fcli-tool/src/main/resources/com/fortify/cli/tool/i18n/ToolMessages.properties @@ -25,6 +25,18 @@ fcli.tool.bugtracker-utility.uninstall.usage.header = Uninstall FortifyBugTracke fcli.tool.bugtracker-utility.uninstall.usage.description = This command removes a FortifyBugTrackerUtility installation that was previously installed using the 'fcli tool bugtracker-utility install' command. fcli.tool.bugtracker-utility.uninstall.confirm = Confirm removal of FortifyBugTrackerUtility. +# fcli tool debricked +fcli.tool.debricked.usage.header = Manage Debricked CLI installations. (https://github.com/debricked/cli) +fcli.tool.debricked.install.usage.header = Download and install the Debricked CLI. +fcli.tool.debricked.install.confirm.0 = Confirm replacing existing Debricked CLI installation. +fcli.tool.debricked.install.confirm.1 = If a non-empty destination directory exists, the installation will fail unless this option is specified. +fcli.tool.debricked.install.cpuArchitecture = CPU architecture for which to install Debricked CLI. Valid values are "x86_64", "i386" and "arm64". Defaults to "x86_64". +fcli.tool.debricked.list.usage.header = List Debricked CLI available and installed versions. If you don't see the latest version(s) listed, please submit an issue on the fcli issue tracker to request adding support for the missing versions. +fcli.tool.debricked.uninstall.usage.header = Uninstall Debricked CLI. +fcli.tool.debricked.uninstall.usage.description = This command removes a Debricked CLI installation that was previously installed using the 'fcli tool debricked install' command. +fcli.tool.debricked.uninstall.confirm = Confirm removal of Debricked CLI. +fcli.tool.debricked.uninstall.cpuArchitecture = CPU architecture of the Debricked CLI version to uninstall. Valid values are "x86_64", "i386" and "arm64". Defaults to "x86_64". + # fcli tool fod-uploader fcli.tool.fod-uploader.usage.header = Manage Fortify on Demand (FoD) Uploader installations. (https://github.com/fod-dev/fod-uploader-java) fcli.tool.fod-uploader.install.usage.header = Download and install Fortify on Demand Uploader. @@ -59,4 +71,5 @@ fcli.tool.vuln-exporter.uninstall.confirm = Confirm removal of Fortify Vulnerabi ################################################################################################################# # The following are technical properties that shouldn't be internationalized #################################### ################################################################################################################# -fcli.tool.output.table.options = name,version,isDefaultVersion,installed,installDir,binDir \ No newline at end of file +fcli.tool.output.table.options = name,version,isDefaultVersion,installed,installDir,binDir +fcli.tool.debricked.output.table.options = name,version,isDefaultVersion,installed,installDir,binDir,operatingSystem,cpuArchitecture \ No newline at end of file diff --git a/fcli-other/fcli-bom/build.gradle b/fcli-other/fcli-bom/build.gradle index 2d02f1cb07..236a6cc0ed 100644 --- a/fcli-other/fcli-bom/build.gradle +++ b/fcli-other/fcli-bom/build.gradle @@ -52,5 +52,8 @@ dependencies { api 'org.junit.jupiter:junit-jupiter-api:5.9.3' api 'org.junit.jupiter:junit-jupiter-params:5.9.3' api 'org.junit.jupiter:junit-jupiter-engine:5.9.3' + + //required for unpacking tar.gz (debricked cli) + api('org.apache.commons:commons-compress:1.25.0') } } \ No newline at end of file diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolBugTrackerUtilitySpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolBugTrackerUtilitySpec.groovy index 9ba3f8372a..88510fbc1b 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolBugTrackerUtilitySpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolBugTrackerUtilitySpec.groovy @@ -29,7 +29,7 @@ import spock.lang.Stepwise class ToolBugTrackerUtilitySpec extends FcliBaseSpec { def "install"() { - def args = "tool bugtracker-utility install -y latest" + def args = "tool bugtracker-utility install -y -v=latest" when: def result = Fcli.run(args) then: @@ -55,7 +55,7 @@ class ToolBugTrackerUtilitySpec extends FcliBaseSpec { } def "uninstall"() { - def args = "tool bugtracker-utility uninstall -y default" + def args = "tool bugtracker-utility uninstall -y -v=default" when: def result = Fcli.run(args) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDebrickedSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDebrickedSpec.groovy new file mode 100644 index 0000000000..d7ef32f07e --- /dev/null +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolDebrickedSpec.groovy @@ -0,0 +1,69 @@ +/** + * Copyright 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + */ +package com.fortify.cli.ftest.tool + +import static com.fortify.cli.ftest._common.spec.FcliSessionType.SSC + +import com.fortify.cli.ftest._common.Fcli +import com.fortify.cli.ftest._common.spec.FcliBaseSpec +import com.fortify.cli.ftest._common.spec.FcliSession +import com.fortify.cli.ftest._common.spec.Prefix +import com.fortify.cli.ftest.ssc._common.SSCRoleSupplier +import com.fortify.cli.ftest.ssc._common.SSCRoleSupplier.SSCRole +import spock.lang.AutoCleanup +import spock.lang.Requires +import spock.lang.Shared +import spock.lang.Stepwise + +@Prefix("tool.debricked") @Stepwise +class ToolDebrickedSpec extends FcliBaseSpec { + + def "install"() { + def args = "tool debricked install -y -v=latest" + when: + def result = Fcli.run(args) + then: + verifyAll(result.stdout) { + size()>0 + it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindirOperatingsystemCpuarchitectureAction") + it[1].replace(" ", "").contains("YesYes") + it[1].contains("INSTALLED") + } + } + + def "listVersions"() { + def args = "tool debricked list" + when: + def result = Fcli.run(args) + then: + verifyAll(result.stdout) { + size()>0 + it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindirOperatingsystemCpuarchitecture") + it[11].replace(" ", "").startsWith("debricked") + it[11].replace(" ", "").contains("YesYes") + } + } + + def "uninstall"() { + def args = "tool debricked uninstall -y -v=default -a=x86_64" + when: + def result = Fcli.run(args) + then: + verifyAll(result.stdout) { + size()>0 + it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindirOperatingsystemCpuarchitectureAction") + it[1].replace(" ", "").contains("YesNoN/AN/Awindowsx86_64UNINSTALLED") + } + } + +} diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolFoDUploaderSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolFoDUploaderSpec.groovy index 287cb1422d..78227c3231 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolFoDUploaderSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolFoDUploaderSpec.groovy @@ -29,7 +29,7 @@ import spock.lang.Stepwise class ToolFoDUploaderSpec extends FcliBaseSpec { def "install"() { - def args = "tool fod-uploader install -y latest" + def args = "tool fod-uploader install -y -v=latest" when: def result = Fcli.run(args) then: @@ -55,7 +55,7 @@ class ToolFoDUploaderSpec extends FcliBaseSpec { } def "uninstall"() { - def args = "tool fod-uploader uninstall -y default" + def args = "tool fod-uploader uninstall -y -v=default" when: def result = Fcli.run(args) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolScClientSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolScClientSpec.groovy index 6938ae059c..24970a6085 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolScClientSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolScClientSpec.groovy @@ -29,7 +29,7 @@ import spock.lang.Stepwise class ToolScClientSpec extends FcliBaseSpec { def "install"() { - def args = "tool sc-client install -y latest" + def args = "tool sc-client install -y -v=latest" when: def result = Fcli.run(args) then: @@ -55,7 +55,7 @@ class ToolScClientSpec extends FcliBaseSpec { } def "uninstall"() { - def args = "tool sc-client uninstall -y default" + def args = "tool sc-client uninstall -y -v=default" when: def result = Fcli.run(args) then: diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVulnExporterSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVulnExporterSpec.groovy index 37340336a8..ee03f6abb4 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVulnExporterSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/tool/ToolVulnExporterSpec.groovy @@ -29,7 +29,7 @@ import spock.lang.Stepwise class ToolVulnExporterSpec extends FcliBaseSpec { def "install"() { - def args = "tool vuln-exporter install -y latest" + def args = "tool vuln-exporter install -y -v=latest" when: def result = Fcli.run(args) then: @@ -55,7 +55,7 @@ class ToolVulnExporterSpec extends FcliBaseSpec { } def "uninstall"() { - def args = "tool vuln-exporter uninstall -y default" + def args = "tool vuln-exporter uninstall -y -v=default" when: def result = Fcli.run(args) then: diff --git a/fcli-other/fcli-gradle/fcli-java.gradle b/fcli-other/fcli-gradle/fcli-java.gradle index 47ac2735c3..ee1eb57ca8 100644 --- a/fcli-other/fcli-gradle/fcli-java.gradle +++ b/fcli-other/fcli-gradle/fcli-java.gradle @@ -59,6 +59,9 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-params' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + //required for unpacking tar.gz (debricked cli) + implementation('org.apache.commons:commons-compress') } compileJava {