Skip to content

Commit

Permalink
Merge branch 'psmf22-develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Oct 13, 2023
2 parents b822412 + 69fa495 commit aac4027
Show file tree
Hide file tree
Showing 18 changed files with 456 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ public final Stream<ToolVersionDownloadDescriptor> getVersionsStream() {
}

public final ToolVersionDownloadDescriptor getVersion(String version) {
var lookupVersion = version.replaceFirst("^v", "")+".";
return getVersionsStream()
.filter(v->v.getVersion().equals(version))
.filter(v->(v.getVersion()+".").startsWith(lookupVersion))
.findFirst().orElseThrow(()->new IllegalArgumentException("Version "+version+" not defined"));
}

public final ToolVersionDownloadDescriptor getVersionOrDefault(String versionName) {
if ( StringUtils.isBlank(versionName) || "default".equals(versionName) ) {
if ( StringUtils.isBlank(versionName) || "default".equals(versionName) || "latest".equals(versionName) ) {
versionName = defaultVersion;
}
return getVersion(versionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static final ToolVersionInstallDescriptor loadToolVersionInstallDescripto
}

public static final ToolVersionCombinedDescriptor loadToolVersionCombinedDescriptor(String toolName, String version) {
version = getToolDownloadDescriptor(toolName).getVersionOrDefault(version).getVersion();
ToolVersionInstallDescriptor installDescriptor = loadToolVersionInstallDescriptor(toolName, version);
return installDescriptor==null ? null : new ToolVersionCombinedDescriptor(toolName, getToolDownloadDescriptor(toolName).getVersion(version), installDescriptor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.fortify.cli.tool._main.cli.cmd;

import com.fortify.cli.common.cli.cmd.AbstractContainerCommand;
import com.fortify.cli.tool.bugtracker_utility.cli.cmd.ToolBugTrackerUtilityCommands;
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;
Expand All @@ -23,6 +24,7 @@
name = "tool",
resourceBundle = "com.fortify.cli.tool.i18n.ToolMessages",
subcommands = {
ToolBugTrackerUtilityCommands.class,
ToolFoDUploaderCommands.class,
ToolSCClientCommands.class,
ToolVulnExporterCommands.class
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* 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.bugtracker_utility.cli.cmd;

import com.fortify.cli.common.cli.cmd.AbstractContainerCommand;

import picocli.CommandLine.Command;

@Command(
name = ToolBugTrackerUtilityCommands.TOOL_NAME,
aliases = {"bugtrackerutility"},
subcommands = {
ToolBugTrackerUtilityInstallCommand.class,
ToolBugTrackerUtilityListCommand.class,
ToolBugTrackerUtilityUninstallCommand.class
}

)
public class ToolBugTrackerUtilityCommands extends AbstractContainerCommand {
static final String TOOL_NAME = "bugtracker-utility";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*******************************************************************************
* 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.bugtracker_utility.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.ToolHelper;
import com.fortify.cli.tool._common.helper.ToolVersionInstallDescriptor;
import com.fortify.cli.tool._common.util.FileUtils;

import lombok.Getter;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;

@Command(name = OutputHelperMixins.Install.CMD_NAME)
public class ToolBugTrackerUtilityInstallCommand extends AbstractToolInstallCommand {
@Getter @Mixin private OutputHelperMixins.Install outputHelper;
@Getter private String toolName = ToolBugTrackerUtilityCommands.TOOL_NAME;

@Override
protected InstallType getInstallType() {
return InstallType.EXTRACT_ZIP;
}

@Override
protected void postInstall(ToolVersionInstallDescriptor descriptor) throws IOException {
Path binPath = descriptor.getBinPath();
Files.createDirectories(binPath);
FileUtils.copyResourceToDir(ToolHelper.getResourceFile(getToolName(), "extra-files/bin/FortifyBugTrackerUtility"), binPath);
FileUtils.copyResourceToDir(ToolHelper.getResourceFile(getToolName(), "extra-files/bin/FortifyBugTrackerUtility.bat"), binPath);

String version = descriptor.getOriginalDownloadDescriptor().getVersion();
String jarName = String.format("FortifyBugTrackerUtility-%s.jar", version);

//we are renaming the jar to remove the version reference
//this allows us to use pre-written bat/bash wrappers rather than having to dynamically generate those
descriptor.getInstallPath().resolve(jarName).toFile().renameTo(
descriptor.getInstallPath().resolve("FortifyBugTrackerUtility.jar").toFile());

}
}
Original file line number Diff line number Diff line change
@@ -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.bugtracker_utility.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 ToolBugTrackerUtilityListCommand extends AbstractToolListCommand {
@Getter @Mixin private OutputHelperMixins.List outputHelper;
@Getter private String toolName = ToolBugTrackerUtilityCommands.TOOL_NAME;
}
Original file line number Diff line number Diff line change
@@ -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.bugtracker_utility.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;

@Command(name = OutputHelperMixins.Uninstall.CMD_NAME)
public class ToolBugTrackerUtilityUninstallCommand extends AbstractToolUninstallCommand {
@Getter @Mixin private OutputHelperMixins.Uninstall outputHelper;
@Getter private String toolName = ToolBugTrackerUtilityCommands.TOOL_NAME;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Versions must be listed in descending order to guarantee proper version selection when users provide a partial version number
defaultDownloadUrl: https://github.com/fortify-ps/FortifyBugTrackerUtility/releases/download/{toolVersion}/FortifyBugTrackerUtility-{toolVersion}-dist.zip
defaultVersion: 4.12
versions:
- version: 4.12
digest: SHA-256:3c5142c63be6a6338f827e26ee79fdb70566dffd5a31680dce05544452c8a56a
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
java -jar ${SCRIPT_DIR}/../FortifyBugTrackerUtility.jar "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@rem ***************************************************************************
@rem Copyright 2021, 2022 Open Text.
@rem
@rem The only warranties for products and services of Open Text
@rem and its affiliates and licensors ("Open Text") are as may
@rem be set forth in the express warranty statements accompanying
@rem such products and services. Nothing herein should be construed
@rem as constituting an additional warranty. Open Text shall not be
@rem liable for technical or editorial errors or omissions contained
@rem herein. The information contained herein is subject to change
@rem without notice.
@rem ***************************************************************************
java -jar %~dp0\..\FortifyBugTrackerUtility.jar %*
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Versions must be listed in descending order to guarantee proper version selection when users provide a partial version number
defaultDownloadUrl: https://github.com/fod-dev/fod-uploader-java/releases/download/v{toolVersion}/FodUpload.jar
defaultVersion: 5.4.0
versions:
- version: latest
downloadUrl: https://github.com/fod-dev/fod-uploader-java/releases/latest/download/FodUpload.jar
digest: SHA-256:7d3fc9ada2df3cd5ed6159685d36656d04cef6ddda69bff2110702c052e64fce
- version: 5.4.0
digest: SHA-256:7d3fc9ada2df3cd5ed6159685d36656d04cef6ddda69bff2110702c052e64fce
- version: 5.3.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ fcli.tool.install.on-digest-mismatch = Action to take if there is a digest misma
fcli.tool.uninstall.version = Tool version to uninstall.
fcli.tool.output.header.isDefaultVersion = Default

# fcli tool bugtracker-utility
fcli.tool.bugtracker-utility.usage.header = Manage Fortify on Demand (FoD) Uploader installations. (https://github.com/fod-dev/fod-uploader-java)
fcli.tool.bugtracker-utility.install.usage.header = Download and install FortifyBugTrackerUtility.
fcli.tool.bugtracker-utility.install.confirm.0 = Confirm replacing existing FortifyBugTrackerUtility installation.
fcli.tool.bugtracker-utility.install.confirm.1 = If a non-empty destination directory exists, the installation will fail unless this option is specified.
fcli.tool.bugtracker-utility.list.usage.header = List FortifyBugTrackerUtility 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.bugtracker-utility.uninstall.usage.header = Uninstall FortifyBugTrackerUtility.
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 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Versions must be listed in descending order to guarantee proper version selection when users provide a partial version number
defaultDownloadUrl: https://tools.fortify.com/scancentral/Fortify_ScanCentral_Client_{toolVersion}_x64.zip
defaultVersion: 23.1.0
versions:
- version: latest
downloadUrl: https://tools.fortify.com/scancentral/Fortify_ScanCentral_Client_Latest_x64.zip
digest: SHA-256:012e00fab914495ad235e8658207702869e02fffbd4d2adfcc3c2baf50fe8de9
- version: 23.1.0
digest: SHA-256:012e00fab914495ad235e8658207702869e02fffbd4d2adfcc3c2baf50fe8de9
- version: 22.2.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Versions must be listed in descending order to guarantee proper version selection when users provide a partial version number
defaultDownloadUrl: https://github.com/fortify/FortifyVulnerabilityExporter/releases/download/v{toolVersion}/FortifyVulnerabilityExporter.zip
defaultVersion: 2.0.4
versions:
- version: latest
downloadUrl: https://github.com/fortify/FortifyVulnerabilityExporter/releases/latest/download/FortifyVulnerabilityExporter.zip
digest: SHA-256:e4793235e2d1152a98975b5aa3baee4ab440ae08ba03e320ec0c4882cd325a2b
- version: 2.0.4
digest: SHA-256:e4793235e2d1152a98975b5aa3baee4ab440ae08ba03e320ec0c4882cd325a2b
- version: 2.0.3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* 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.bugtracker-utility") @Stepwise
class ToolBugTrackerUtilitySpec extends FcliBaseSpec {

def "install"() {
def args = "tool bugtracker-utility install -y latest"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>0
it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindirAction")
it[1].replace(" ", "").contains("YesYes")
it[1].contains("INSTALLED")
}
}

def "listVersions"() {
def args = "tool bugtracker-utility list"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>0
it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindir")
it[1].replace(" ", "").startsWith("bugtracker-utility")
it[1].replace(" ", "").contains("YesYes")
}
}

def "uninstall"() {
def args = "tool bugtracker-utility uninstall -y default"
when:
def result = Fcli.run(args)
then:
verifyAll(result.stdout) {
size()>0
it[0].replace(' ', '').equals("NameVersionDefaultInstalledInstalldirBindirAction")
it[1].replace(" ", "").contains("YesNoN/AN/AUNINSTALLED")
}
}


}
Loading

0 comments on commit aac4027

Please sign in to comment.