From 216ac2a61ea1b6722462d279923ea6f4bc744d5d Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:15:40 +0100 Subject: [PATCH] fix: `fcli ssc appversion-artifact download`: HTTP 500 error when downloading application file fix: `fcli ssc appversion-artifact download`: `--no-include-sources` now available for both application file and individual FPR download (fixes #173) --- .../SSCAppVersionArtifactDownloadCommand.java | 16 +++++----------- .../java/com/fortify/cli/ssc/rest/SSCUrls.java | 4 ++-- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/SSCAppVersionArtifactDownloadCommand.java b/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/SSCAppVersionArtifactDownloadCommand.java index 473550787e..5e2b516bcd 100644 --- a/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/SSCAppVersionArtifactDownloadCommand.java +++ b/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/SSCAppVersionArtifactDownloadCommand.java @@ -55,29 +55,23 @@ public class SSCAppVersionArtifactDownloadCommand extends AbstractSSCOutputComma @CommandLine.Option(names = {"-f", "--dest"}, descriptionKey = "download.destination") private String destination; @Mixin private SSCAppVersionResolverMixin.RequiredOption parentResolver; - - @ArgGroup(exclusive=true) private SSCAppVersionArtifactDownloadOptions options = new SSCAppVersionArtifactDownloadOptions(); - - private static final class SSCAppVersionArtifactDownloadOptions { - // When downloading an artifact by id, the --no-include-sources option is not applicable, and vice versa - @Option(names = "--no-include-sources", negatable = true) private boolean includeSources = true; - @Option(names="--id") private String artifactId; //TODO Should this be an option or optional positional parameter? - } + @Option(names = "--no-include-sources", negatable = true) private boolean includeSources = true; + @Option(names="--id") private String artifactId; @Override public JsonNode getJsonNode(UnirestInstance unirest) { SSCAppVersionDescriptor av = parentResolver.getAppVersionDescriptor(unirest); destination = destination != null ? destination : String.format("./%s_%s.fpr", av.getApplicationName(), av.getVersionName()); - if ( StringUtils.isNotBlank(options.artifactId) ) { + if ( StringUtils.isBlank(artifactId) ) { SSCFileTransferHelper.download( unirest, - SSCUrls.DOWNLOAD_CURRENT_FPR(av.getVersionId(), options.includeSources), + SSCUrls.DOWNLOAD_CURRENT_FPR(av.getVersionId(), includeSources), destination, ISSCAddDownloadTokenFunction.ROUTEPARAM_DOWNLOADTOKEN); } else { SSCFileTransferHelper.download( unirest, - SSCUrls.DOWNLOAD_ARTIFACT(options.artifactId), + SSCUrls.DOWNLOAD_ARTIFACT(artifactId, includeSources), destination, ISSCAddDownloadTokenFunction.ROUTEPARAM_DOWNLOADTOKEN); } diff --git a/fcli-ssc/src/main/java/com/fortify/cli/ssc/rest/SSCUrls.java b/fcli-ssc/src/main/java/com/fortify/cli/ssc/rest/SSCUrls.java index 6dcafd0270..195f953012 100644 --- a/fcli-ssc/src/main/java/com/fortify/cli/ssc/rest/SSCUrls.java +++ b/fcli-ssc/src/main/java/com/fortify/cli/ssc/rest/SSCUrls.java @@ -468,8 +468,8 @@ public static String WEBHOOK_HISTORY(String webHookId, String historyId) { } // FOR DOWNLOAD & UPLOAD - public static String DOWNLOAD_ARTIFACT(String artifactId) { - return String.format("/download/artifactDownload.html?mat={downloadToken}&id=%s", artifactId); + public static String DOWNLOAD_ARTIFACT(String artifactId, boolean includeSource) { + return String.format("/download/artifactDownload.html?mat={downloadToken}&id=%s&includeSource=%b", artifactId, includeSource); } public static String DOWNLOAD_REPORT_LIBRARY(String reportLibraryId) {