Skip to content

Commit

Permalink
fix: fcli ssc appversion-artifact download: HTTP 500 error when dow…
Browse files Browse the repository at this point in the history
…nloading application file

fix: `fcli ssc appversion-artifact download`: `--no-include-sources` now available for both application file and individual FPR download (fixes #173)
  • Loading branch information
rsenden committed Dec 14, 2022
1 parent 6cc775e commit 216ac2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions fcli-ssc/src/main/java/com/fortify/cli/ssc/rest/SSCUrls.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 216ac2a

Please sign in to comment.