diff --git a/fcli-core/fcli-app/src/main/java/com/fortify/cli/app/runner/util/FortifyCLIStaticInitializer.java b/fcli-core/fcli-app/src/main/java/com/fortify/cli/app/runner/util/FortifyCLIStaticInitializer.java index 82730c4769..1158f83fdc 100644 --- a/fcli-core/fcli-app/src/main/java/com/fortify/cli/app/runner/util/FortifyCLIStaticInitializer.java +++ b/fcli-core/fcli-app/src/main/java/com/fortify/cli/app/runner/util/FortifyCLIStaticInitializer.java @@ -25,7 +25,7 @@ import com.fortify.cli.common.http.ssl.truststore.helper.TrustStoreConfigHelper; import com.fortify.cli.common.i18n.helper.LanguageHelper; import com.fortify.cli.common.util.StringUtils; -import com.fortify.cli.fod.scan.helper.FoDScanStatus; +import com.fortify.cli.fod._common.scan.helper.FoDScanStatus; import com.fortify.cli.sc_dast.scan.helper.SCDastScanStatus; import com.fortify.cli.sc_sast.scan.helper.SCSastControllerScanJobArtifactState; import com.fortify.cli.sc_sast.scan.helper.SCSastControllerScanJobState; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/output/mixin/FoDOutputHelperMixins.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/output/mixin/FoDOutputHelperMixins.java index 0cbd043c31..6aac3996e1 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/output/mixin/FoDOutputHelperMixins.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/output/mixin/FoDOutputHelperMixins.java @@ -23,6 +23,9 @@ * @author rsenden */ public class FoDOutputHelperMixins { + public static class DownloadLatest extends OutputHelperMixins.TableNoQuery { + public static final String CMD_NAME = "download-latest"; + } public static class SetupSast extends OutputHelperMixins.DetailsNoQuery { public static final String CMD_NAME = "setup-sast"; } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCancelCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java similarity index 66% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCancelCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java index b723235969..89d7076e7b 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCancelCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java @@ -11,50 +11,46 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; import com.fortify.cli.common.output.transform.IRecordTransformer; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; import com.fortify.cli.fod._common.rest.FoDUrls; -import com.fortify.cli.fod.scan.cli.mixin.FoDScanResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDScanResolverMixin; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import kong.unirest.UnirestInstance; -import lombok.Getter; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -@Command(name = OutputHelperMixins.Cancel.CMD_NAME, hidden = false) -public class FoDScanCancelCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { - @Getter @Mixin private OutputHelperMixins.Cancel outputHelper; - +public abstract class AbstractFoDScanCancelCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; - @Override - public JsonNode getJsonNode(UnirestInstance unirest) { - FoDScanDescriptor descriptor = scanResolver.getScanDescriptor(unirest); + public final JsonNode getJsonNode(UnirestInstance unirest) { + FoDScanDescriptor descriptor = scanResolver.getScanDescriptor(unirest, getScanType()); unirest.post(FoDUrls.RELEASE + "/scans/{scanId}/cancel-scan") .routeParam("relId", String.valueOf(descriptor.getReleaseId())) .routeParam("scanId", String.valueOf(descriptor.getScanId())); return descriptor.asJsonNode(); } + + protected abstract FoDScanType getScanType(); - public JsonNode transformRecord(JsonNode record) { + public final JsonNode transformRecord(JsonNode record) { return FoDScanHelper.renameFields(record); } @Override - public String getActionCommandResult() { + public final String getActionCommandResult() { return "CANCELLED"; } @Override - public boolean isSingular() { + public final boolean isSingular() { return true; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java index d4c97cd81d..fd660cf146 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOSSScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java similarity index 51% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOSSScanDownloadCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java index 5c185962a4..fbf517f41c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOSSScanDownloadCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java @@ -10,57 +10,57 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.fod.oss_scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; + +import java.nio.file.StandardCopyOption; import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.common.cli.mixin.CommonOptionMixins; import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; -import com.fortify.cli.fod.scan.cli.mixin.FoDScanResolverMixin; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDScanResolverMixin; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import kong.unirest.GetRequest; import kong.unirest.UnirestInstance; -import lombok.Getter; import lombok.SneakyThrows; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; - -import java.io.File; -import java.nio.file.StandardCopyOption; -@Command(name = OutputHelperMixins.Download.CMD_NAME) -public class FoDOSSScanDownloadCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { - @Getter @Mixin private OutputHelperMixins.Download outputHelper; +public abstract class AbstractFoDScanDownloadCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; - - @Option(names = {"-f", "--sbom"}, required = true) - private File outputFile; + @Mixin private CommonOptionMixins.RequiredFile outputFileMixin; @Override @SneakyThrows - public JsonNode getJsonNode(UnirestInstance unirest) { - var scanDescriptor = scanResolver.getScanDescriptor(unirest); + public final JsonNode getJsonNode(UnirestInstance unirest) { + FoDScanDescriptor scanDescriptor = scanResolver.getScanDescriptor(unirest, getScanType()); + FoDScanHelper.validateScanDate(scanDescriptor, FoDScanHelper.MAX_RETENTION_PERIOD); + var file = outputFileMixin.getFile().getAbsolutePath(); + GetRequest request = getDownloadRequest(unirest, scanDescriptor); + int status = 202; while ( status==202 ) { - status = unirest.get("/api/v3/open-source-scans/{scanId}/sbom") - .routeParam("scanId", String.valueOf(scanDescriptor.getScanId())) - .accept("application/octet-stream") - .asFile(outputFile.getAbsolutePath(), StandardCopyOption.REPLACE_EXISTING) + status = request + .asFile(file, StandardCopyOption.REPLACE_EXISTING) .getStatus(); if ( status==202 ) { Thread.sleep(30000L); } } - return scanDescriptor.asObjectNode() - .put("scanType", "OpenSource") - .put("file", outputFile.getName()); + return scanDescriptor.asObjectNode().put("file", file); } + protected abstract GetRequest getDownloadRequest(UnirestInstance unirest, FoDScanDescriptor scanDescriptor); + protected abstract FoDScanType getScanType(); + @Override - public String getActionCommandResult() { - return "SBOM_DOWNLOADED"; + public final String getActionCommandResult() { + return "SCAN_DOWNLOADED"; } @Override - public boolean isSingular() { + public final boolean isSingular() { return true; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java similarity index 50% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeCommands.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java index a1ab9a4678..085550e114 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java @@ -10,17 +10,19 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ +package com.fortify.cli.fod._common.scan.cli.cmd; -package com.fortify.cli.fod.assessment_type.cli.cmd; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; -import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; +import kong.unirest.GetRequest; +import kong.unirest.UnirestInstance; -import picocli.CommandLine; - -@CommandLine.Command(name = "assessment-type", - subcommands = { - FoDAssessmentTypeListCommand.class, - } -) -public class FoDAssessmentTypeCommands extends AbstractContainerCommand { +public abstract class AbstractFoDScanDownloadFprCommand extends AbstractFoDScanDownloadCommand { + @Override + protected GetRequest getDownloadRequest(UnirestInstance unirest, FoDScanDescriptor scanDescriptor) { + return unirest.get("GET /api/v3/scans/{scanId}/fpr") + .routeParam("scanId", scanDescriptor.getScanId()) + .accept("application/octet-stream") + .queryString("scanType", scanDescriptor.getScanType()); + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseDownloadResultsCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java similarity index 52% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseDownloadResultsCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java index 7c458be1fa..7538a76d0a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseDownloadResultsCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java @@ -10,61 +10,61 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.fod.release.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; -import java.io.File; import java.nio.file.StandardCopyOption; import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.mixin.CommonOptionMixins; import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; -import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanType; +import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; +import kong.unirest.GetRequest; import kong.unirest.UnirestInstance; -import lombok.Getter; import lombok.SneakyThrows; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; -@Command(name = FoDOutputHelperMixins.DownloadResults.CMD_NAME) -public class FoDReleaseDownloadResultsCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { - @Mixin @Getter private FoDOutputHelperMixins.DownloadResults outputHelper; +public abstract class AbstractFoDScanDownloadLatestCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; - - @Option(names = {"-f", "--fpr"}, required = true) - private File outputFile; - - @Option(names = {"-s", "--scan-type"}, required = true) - private FoDScanType scanType; + @Mixin private CommonOptionMixins.RequiredFile outputFileMixin; @Override @SneakyThrows - public JsonNode getJsonNode(UnirestInstance unirest) { + public final JsonNode getJsonNode(UnirestInstance unirest) { var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); + + FoDScanDescriptor scanDescriptor = FoDScanHelper.getLatestScanDescriptor(unirest, releaseDescriptor.getReleaseId(), + getScanType(), false); + FoDScanHelper.validateScanDate(scanDescriptor, FoDScanHelper.MAX_RETENTION_PERIOD); + var file = outputFileMixin.getFile().getAbsolutePath(); + GetRequest request = getDownloadRequest(unirest, releaseDescriptor, scanDescriptor); + int status = 202; while ( status==202 ) { - status = unirest.get("/api/v3/releases/{releaseId}/fpr") - .routeParam("releaseId", releaseDescriptor.getReleaseId()) - .accept("application/octet-stream") - .queryString("scanType", scanType.name()) - .asFile(outputFile.getAbsolutePath(), StandardCopyOption.REPLACE_EXISTING) + status = request + .asFile(file, StandardCopyOption.REPLACE_EXISTING) .getStatus(); if ( status==202 ) { Thread.sleep(30000L); } } - return releaseDescriptor.asJsonNode(); + return scanDescriptor.asObjectNode().put("file", file); } + protected abstract GetRequest getDownloadRequest(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanDescriptor scanDescriptor); + protected abstract FoDScanType getScanType(); + @Override - public String getActionCommandResult() { - return "FPR_DOWNLOADED"; + public final String getActionCommandResult() { + return "SCAN_DOWNLOADED"; } @Override - public boolean isSingular() { + public final boolean isSingular() { return true; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestFprCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestFprCommand.java new file mode 100644 index 0000000000..06b2b493ca --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestFprCommand.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.fod._common.scan.cli.cmd; + +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; + +import kong.unirest.GetRequest; +import kong.unirest.UnirestInstance; + +public abstract class AbstractFoDScanDownloadLatestFprCommand extends AbstractFoDScanDownloadLatestCommand { + @Override + protected GetRequest getDownloadRequest(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanDescriptor scanDescriptor) { + return unirest.get("/api/v3/releases/{releaseId}/fpr") + .routeParam("releaseId", releaseDescriptor.getReleaseId()) + .accept("application/octet-stream") + .queryString("scanType", scanDescriptor.getScanType()); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java similarity index 68% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanGetCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java index 07e3d64409..81ee2beb6e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java @@ -11,30 +11,27 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; -import com.fortify.cli.fod.scan.cli.mixin.FoDScanResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDScanResolverMixin; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import kong.unirest.UnirestInstance; -import lombok.Getter; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -@Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = false) -public class FoDScanGetCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer { - @Getter @Mixin private OutputHelperMixins.Get outputHelper; - +public abstract class AbstractFoDScanGetCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer { @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; @Override public JsonNode getJsonNode(UnirestInstance unirest) { - return scanResolver.getScanDescriptor(unirest).asJsonNode(); + return scanResolver.getScanDescriptor(unirest, getScanType()).asJsonNode(); } + + protected abstract FoDScanType getScanType(); @Override public JsonNode transformRecord(JsonNode record) { diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java similarity index 93% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanImportCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java index 90175f0634..1d98d093f0 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -21,6 +21,7 @@ import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; import kong.unirest.HttpRequest; @@ -44,12 +45,12 @@ public final JsonNode getJsonNode(UnirestInstance unirest) { FoDFileTransferHelper.uploadChunked(unirest, baseRequest, scanFileMixin.getFile()); return releaseDescriptor.asObjectNode() .put("importScanSessionId", importScanSessionId) - .put("scanType", getImportScanType()); + .put("scanType", getScanType().name()); } protected abstract HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId); - protected abstract String getImportScanType(); + protected abstract FoDScanType getScanType(); @Override public final String getActionCommandResult() { diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java similarity index 55% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanListCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java index ef7fabd1dc..6193554c7e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java @@ -10,41 +10,29 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; - -import java.util.function.Predicate; +package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDBaseRequestOutputCommand; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import com.fortify.cli.fod.app.cli.mixin.FoDAppResolverMixin; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDAnalysisStatusType; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; -import lombok.Getter; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; - -@Command(name = OutputHelperMixins.List.CMD_NAME, hidden = false) -public class FoDScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { - @Getter @Mixin private OutputHelperMixins.List outputHelper; +public abstract class AbstractFoDScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDAppResolverMixin.OptionalOption appResolver; @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.OptionalOption releaseResolver; - @Getter @Option(names = {"--type"}, required = false, descriptionKey = "fcli.fod.scan.list.type") FoDScanType type; - @Getter @Option(names = {"--status"}, required = false, descriptionKey = "fcli.fod.scan.list.status") FoDAnalysisStatusType status; - + @Override - public HttpRequest getBaseRequest(UnirestInstance unirest) { + public final HttpRequest getBaseRequest(UnirestInstance unirest) { var appId = appResolver.getAppId(unirest); var releaseId = releaseResolver.getReleaseId(unirest); HttpRequest baseRequest; @@ -60,36 +48,21 @@ public HttpRequest getBaseRequest(UnirestInstance unirest) { } else { baseRequest = unirest.get(FoDUrls.SCANS); } - return updateRequest(baseRequest); - } - - private HttpRequest updateRequest(HttpRequest request) { - request.queryString("orderBy", "startedDateTime"); - request.queryString("orderByDirection", "DESC"); - return request; + return FoDScanHelper.addDefaultScanListParams(baseRequest); } @Override - public JsonNode transformRecord(JsonNode record) { - return getFilterPredicate().test(record) - ? FoDScanHelper.renameFields(record) - : null; + public final JsonNode transformRecord(JsonNode record) { + var scanType = getScanType(); + return scanType!=null && !scanType.equals(record.get("scanType")) + ? null + : FoDScanHelper.renameFields(record); } + + protected abstract FoDScanType getScanType(); @Override - public boolean isSingular() { + public final boolean isSingular() { return false; } - - protected Predicate getFilterPredicate() { - Predicate result = o->true; - result = and(result, "scanType", type); - result = and(result, "analysisStatusType", status); - return result; - } - - protected final Predicate and(Predicate p, String name, Enum value) { - return value==null ? p : p.and(o->o.get(name).asText().equals(value.name())); - } - } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java similarity index 71% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanWaitForCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java index 549ed7ae63..c3611a65d3 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java @@ -11,34 +11,32 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd; +package com.fortify.cli.fod._common.scan.cli.cmd; import java.util.Set; -import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.rest.cli.cmd.AbstractWaitForCommand; import com.fortify.cli.common.rest.wait.WaitHelper.WaitHelperBuilder; import com.fortify.cli.fod._common.output.mixin.FoDProductHelperStandardMixin; -import com.fortify.cli.fod.scan.cli.mixin.FoDScanResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanStatus; -import com.fortify.cli.fod.scan.helper.FoDScanStatus.FoDScanStatusIterable; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDScanResolverMixin; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanStatus; +import com.fortify.cli.fod._common.scan.helper.FoDScanStatus.FoDScanStatusIterable; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import kong.unirest.UnirestInstance; import lombok.Getter; -import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; -@Command(name = OutputHelperMixins.WaitFor.CMD_NAME, hidden = false) -public class FoDScanWaitForCommand extends AbstractWaitForCommand { +public abstract class AbstractFoDScanWaitForCommand extends AbstractWaitForCommand { @Getter @Mixin FoDProductHelperStandardMixin productHelper; @Mixin private FoDScanResolverMixin.PositionalParameterMulti scansResolver; @Option(names={"-s", "--any-state"}, required=true, split=",", defaultValue="Completed", completionCandidates = FoDScanStatusIterable.class) private Set states; @Override - protected WaitHelperBuilder configure(UnirestInstance unirest, WaitHelperBuilder builder) { + protected final WaitHelperBuilder configure(UnirestInstance unirest, WaitHelperBuilder builder) { return builder .recordsSupplier(scansResolver::getScanDescriptorJsonNodes) .recordTransformer(FoDScanHelper::renameFields) @@ -47,5 +45,8 @@ protected WaitHelperBuilder configure(UnirestInstance unirest, WaitHelperBuilder .failureStates(FoDScanStatus.getFailureStateNames()) .matchStates(states); } + + // TODO Verify that all given scan id's are of given scan type + protected abstract FoDScanType getScanType(); } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java similarity index 96% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java index c9b265c239..379598ab42 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementFrequencyTypeMixins.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.mixin; +package com.fortify.cli.fod._common.scan.cli.mixin; import com.fortify.cli.fod._common.util.FoDEnums; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java index a6a3135ff7..f3c42d3921 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDEntitlementPreferenceTypeMixins.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.mixin; +package com.fortify.cli.fod._common.scan.cli.mixin; import com.fortify.cli.fod._common.util.FoDEnums; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java index 0c876e084f..295d32a731 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDInProgressScanActionTypeMixins.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.mixin; +package com.fortify.cli.fod._common.scan.cli.mixin; import com.fortify.cli.fod._common.util.FoDEnums; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java index b0fa44ca23..07673dd128 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDRemediationScanPreferenceTypeMixins.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.mixin; +package com.fortify.cli.fod._common.scan.cli.mixin; import com.fortify.cli.fod._common.util.FoDEnums; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDScanResolverMixin.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDScanResolverMixin.java similarity index 80% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDScanResolverMixin.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDScanResolverMixin.java index e6ffdca5f5..c0c4f04c18 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/mixin/FoDScanResolverMixin.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/mixin/FoDScanResolverMixin.java @@ -10,7 +10,7 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.mixin; +package com.fortify.cli.fod._common.scan.cli.mixin; import java.util.Collection; import java.util.stream.Collectors; @@ -18,8 +18,9 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.cli.util.EnvSuffix; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -34,8 +35,16 @@ public static abstract class AbstractFoDScanResolverMixin { public FoDScanDescriptor getScanDescriptor(UnirestInstance unirest) { return FoDScanHelper.getScanDescriptor(unirest, getScanId()); } + + public FoDScanDescriptor getScanDescriptor(UnirestInstance unirest, FoDScanType scanType) { + var result = getScanDescriptor(unirest); + if ( scanType!=null && !scanType.name().equals(result.getScanType()) ) { + throw new IllegalArgumentException(String.format("Scan id %s (%s) doesn't match expected scan type %s", result.getScanId(), result.getScanType(), scanType.name())); + } + return result; + } - public Integer getScanId(UnirestInstance unirest) { + public String getScanId(UnirestInstance unirest) { return getScanDescriptor(unirest).getScanId(); } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAnalysisStatusType.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAnalysisStatusType.java similarity index 92% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAnalysisStatusType.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAnalysisStatusType.java index 75375d10ab..38b9651d3f 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAnalysisStatusType.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAnalysisStatusType.java @@ -10,6 +10,6 @@ * herein. The information contained herein is subject to change * without notice. */ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; public enum FoDAnalysisStatusType {Not_Started, In_Progress, Completed, Canceled, Waiting, Scheduled, Queued} \ No newline at end of file diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentType.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAssessmentType.java similarity index 96% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentType.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAssessmentType.java index 09167b84e3..c260404d81 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentType.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDAssessmentType.java @@ -10,7 +10,7 @@ * herein. The information contained herein is subject to change * without notice. */ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; public enum FoDAssessmentType { Static(1, 4), diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanAssessmentTypeDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanAssessmentTypeDescriptor.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanAssessmentTypeDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanAssessmentTypeDescriptor.java index 3bbd2cbbe1..c44274d29d 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanAssessmentTypeDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanAssessmentTypeDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.fod.dast_scan.helper.FoDScanConfigDastDescriptor; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanDescriptor.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanDescriptor.java index 63e83f3e87..fd5df1e003 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; import java.util.Date; @@ -26,12 +26,12 @@ @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper = true) public class FoDScanDescriptor extends JsonNodeHolder { - private Integer scanId; + private String scanId; private String scanType; private String applicationName; private String releaseName; - private Integer applicationId; - private Integer releaseId; + private String applicationId; + private String releaseId; private String microserviceName; private String status; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyy-MM-dd'T'hh:mm:ss") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java similarity index 94% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java index db2b1ed0d3..d5458f9375 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; import static java.util.function.Predicate.not; @@ -30,6 +30,7 @@ import com.fortify.cli.fod.rest.lookup.helper.FoDLookupHelper; import com.fortify.cli.fod.rest.lookup.helper.FoDLookupType; +import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -104,5 +105,10 @@ private static final FoDScanDescriptor getEmptyDescriptor() { return JsonHelper.treeToValue(getObjectMapper().createObjectNode(), FoDScanDescriptor.class); } + public static final HttpRequest addDefaultScanListParams(HttpRequest request) { + return request.queryString("orderBy", "startedDateTime") + .queryString("orderByDirection", "DESC"); + } + } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanStatus.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanStatus.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanStatus.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanStatus.java index 2bf6832090..7ae0de3ea1 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanStatus.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanStatus.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; import java.util.ArrayList; import java.util.stream.Stream; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanType.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanType.java similarity index 92% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanType.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanType.java index fe18156719..fe636e3f8e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanType.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanType.java @@ -10,6 +10,6 @@ * herein. The information contained herein is subject to change * without notice. */ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; public enum FoDScanType {Static, Dynamic, Mobile, Monitoring, Network, OpenSource, Container} \ No newline at end of file diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDStartScanResponse.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDStartScanResponse.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDStartScanResponse.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDStartScanResponse.java index 83cbc0b9cf..d352453e51 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDStartScanResponse.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDStartScanResponse.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod._common.scan.helper; import java.util.ArrayList; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastDescriptor.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastDescriptor.java index 8bc41df21f..5eb44470e4 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.dast; +package com.fortify.cli.fod._common.scan.helper.dast; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastHelper.java similarity index 90% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastHelper.java index 2fd5a7cb89..07e1fe8a3a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastHelper.java @@ -11,18 +11,18 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.dast; +package com.fortify.cli.fod._common.scan.helper.dast; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fortify.cli.common.json.JsonHelper; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.FoDStartScanResponse; import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.FoDStartScanResponse; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastStartRequest.java similarity index 96% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastStartRequest.java index c2a94068f0..4b77746c4a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/dast/FoDScanDastStartRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.dast; +package com.fortify.cli.fod._common.scan.helper.dast; import com.fasterxml.jackson.annotation.JsonFormat; import com.formkiq.graalvm.annotations.Reflectable; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileHelper.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileHelper.java index 7897465505..bf3b59b1d6 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileHelper.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.mobile; +package com.fortify.cli.fod._common.scan.helper.mobile; import java.io.File; @@ -21,11 +21,11 @@ import com.fortify.cli.common.progress.helper.IProgressWriterI18n; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.FoDStartScanResponse; import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.FoDStartScanResponse; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileStartRequest.java similarity index 96% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileStartRequest.java index c34f4cc110..f827cce0eb 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/mobile/FoDScanMobileStartRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.mobile; +package com.fortify.cli.fod._common.scan.helper.mobile; import com.fasterxml.jackson.annotation.JsonFormat; import com.formkiq.graalvm.annotations.Reflectable; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java index fe1158bc4e..ca67a2f428 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.oss; +package com.fortify.cli.fod._common.scan.helper.oss; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java similarity index 92% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java index 377cd13514..170bb857bf 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.oss; +package com.fortify.cli.fod._common.scan.helper.oss; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -19,12 +19,13 @@ import com.fortify.cli.common.json.JsonHelper; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.FoDStartScanResponse; import com.fortify.cli.fod.oss_scan.helper.FoDScanConfigOssDescriptor; import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.FoDStartScanResponse; + import kong.unirest.GetRequest; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssStartRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java similarity index 94% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssStartRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java index b7ff9b2873..2cb7980428 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDScanOssStartRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.oss; +package com.fortify.cli.fod._common.scan.helper.oss; import com.formkiq.graalvm.annotations.Reflectable; import lombok.AllArgsConstructor; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastDescriptor.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastDescriptor.java index ca7cbbaea3..b79f89dcb8 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.sast; +package com.fortify.cli.fod._common.scan.helper.sast; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastHelper.java similarity index 95% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastHelper.java index 07ac7a37bd..7c483a3f17 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastHelper.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.sast; +package com.fortify.cli.fod._common.scan.helper.sast; import java.io.File; @@ -22,13 +22,13 @@ import com.fortify.cli.common.util.StringUtils; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.FoDStartScanResponse; import com.fortify.cli.fod._common.util.FoDConstants; import com.fortify.cli.fod._common.util.FoDEnums; import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.FoDStartScanResponse; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastDescriptor; import kong.unirest.GetRequest; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastStartRequest.java similarity index 96% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastStartRequest.java index 061c53aaa6..0741dc082d 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/sast/FoDScanSastStartRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.sast; +package com.fortify.cli.fod._common.scan.helper.sast; import com.formkiq.graalvm.annotations.Reflectable; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_main/cli/cmd/FoDCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_main/cli/cmd/FoDCommands.java index 0f9e8443ca..17385c6fd3 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_main/cli/cmd/FoDCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_main/cli/cmd/FoDCommands.java @@ -15,7 +15,6 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.fod._common.session.cli.cmd.FoDSessionCommands; import com.fortify.cli.fod.app.cli.cmd.FoDAppCommands; -import com.fortify.cli.fod.assessment_type.cli.cmd.FoDAssessmentTypeCommands; import com.fortify.cli.fod.dast_scan.cli.cmd.FoDDastScanCommands; import com.fortify.cli.fod.mast_scan.cli.cmd.FoDMastScanCommands; import com.fortify.cli.fod.microservice.cli.cmd.FoDMicroserviceCommands; @@ -23,7 +22,6 @@ import com.fortify.cli.fod.release.cli.cmd.FoDReleaseCommands; import com.fortify.cli.fod.rest.cli.cmd.FoDRestCommands; import com.fortify.cli.fod.sast_scan.cli.cmd.FoDSastScanCommands; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanCommands; import com.fortify.cli.fod.user.cli.cmd.FoDUserCommands; import com.fortify.cli.fod.user_group.cli.cmd.FoDUserGroupCommands; @@ -45,10 +43,8 @@ // and release FoDSessionCommands.class, FoDAppCommands.class, - FoDAssessmentTypeCommands.class, FoDMicroserviceCommands.class, FoDReleaseCommands.class, - FoDScanCommands.class, FoDSastScanCommands.class, FoDDastScanCommands.class, FoDMastScanCommands.class, diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppCommands.java index 45bcd5f516..fe6b03ba67 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppCommands.java @@ -23,7 +23,8 @@ FoDAppGetCommand.class, FoDAppCreateCommand.class, FoDAppUpdateCommand.class, - FoDAppDeleteCommand.class + FoDAppDeleteCommand.class, + FoDAppScanListCommand.class } ) @DefaultVariablePropertyName("applicationId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppScanListCommand.java new file mode 100644 index 0000000000..1a198dbdca --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/app/cli/cmd/FoDAppScanListCommand.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.fod.app.cli.cmd; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.common.output.transform.IRecordTransformer; +import com.fortify.cli.fod._common.output.cli.AbstractFoDBaseRequestOutputCommand; +import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod.app.cli.mixin.FoDAppResolverMixin; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = "list-scans", aliases = "lss") +public class FoDAppScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; + @Mixin private FoDAppResolverMixin.RequiredOption appResolver; + + @Override + public HttpRequest getBaseRequest(UnirestInstance unirest) { + return FoDScanHelper.addDefaultScanListParams(unirest.get(FoDUrls.APP_SCANS) + .routeParam("appId", appResolver.getAppId(unirest))); + } + + @Override + public JsonNode transformRecord(JsonNode record) { + return FoDScanHelper.renameFields(record); + } + + @Override + public boolean isSingular() { + return false; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCancelCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCancelCommand.java index 3da1a482f0..0b00dd3afc 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCancelCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCancelCommand.java @@ -14,12 +14,19 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanCancelCommand; -import picocli.CommandLine.Command; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanCancelCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -@Command(name = OutputHelperMixins.Cancel.CMD_NAME, hidden = true) -public class FoDDastScanCancelCommand extends FoDScanCancelCommand implements IRecordTransformer, IActionCommandResultSupplier { +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; +@Command(name = OutputHelperMixins.Cancel.CMD_NAME) +public class FoDDastScanCancelCommand extends AbstractFoDScanCancelCommand { + @Getter @Mixin private OutputHelperMixins.Cancel outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCommands.java index 105475b9af..0ea2f22d52 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCommands.java @@ -17,7 +17,7 @@ import com.fortify.cli.common.variable.DefaultVariablePropertyName; import picocli.CommandLine; -@CommandLine.Command(name = "dast-scan", hidden = false, +@CommandLine.Command(name = "dast-scan", aliases = "dast", subcommands = { FoDDastScanListCommand.class, FoDDastScanGetCommand.class, @@ -27,7 +27,8 @@ FoDDastScanCancelCommand.class, FoDDastScanWaitForCommand.class, FoDDastScanImportCommand.class, - FoDDastScanDownloadCommand.class + FoDDastScanDownloadCommand.class, + FoDDastScanDownloadLatestCommand.class } ) @DefaultVariablePropertyName("scanId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadCommand.java index cf4132c431..569c7e8265 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadCommand.java @@ -14,17 +14,19 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDDownloadScanCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import lombok.Getter; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Download.CMD_NAME) -public class FoDDastScanDownloadCommand extends AbstractFoDDownloadScanCommand { +public class FoDDastScanDownloadCommand extends AbstractFoDScanDownloadFprCommand { @Getter @Mixin private OutputHelperMixins.Download outputHelper; @Override - protected String getDownloadScanType() { - return "Dynamic"; + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadLatestCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadLatestCommand.java new file mode 100644 index 0000000000..12abf12c5d --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanDownloadLatestCommand.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.fod.dast_scan.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadLatestFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.DownloadLatest.CMD_NAME) +public class FoDDastScanDownloadLatestCommand extends AbstractFoDScanDownloadLatestFprCommand { + @Getter @Mixin private FoDOutputHelperMixins.DownloadLatest outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetCommand.java index eaaeddcc78..e679d53532 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetCommand.java @@ -15,10 +15,19 @@ import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanGetCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanGetCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = true) -public class FoDDastScanGetCommand extends FoDScanGetCommand implements IRecordTransformer { - +public class FoDDastScanGetCommand extends AbstractFoDScanGetCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.Get outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetConfigLegacyCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetConfigLegacyCommand.java index 025609bb15..279736e3b2 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetConfigLegacyCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetConfigLegacyCommand.java @@ -13,9 +13,9 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import com.fortify.cli.fod.dast_scan.helper.FoDScanConfigDastDescriptor; import com.fortify.cli.fod.dast_scan.helper.FoDScanConfigDastHelper; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanImportCommand.java index 068bd5042c..a71c0fbaf7 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanImportCommand.java @@ -13,10 +13,10 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanImportCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanImportCommand; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -33,7 +33,7 @@ protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseI } @Override - protected String getImportScanType() { - return "Dynamic"; + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanListCommand.java index d9914000fd..55f2dfb168 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanListCommand.java @@ -12,23 +12,20 @@ *******************************************************************************/ package com.fortify.cli.fod.dast_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanListCommand; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import picocli.CommandLine.Command; - -import java.util.function.Predicate; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanListCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -@Command(name = OutputHelperMixins.List.CMD_NAME, hidden = false) -public class FoDDastScanListCommand extends FoDScanListCommand implements IRecordTransformer { +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; +@Command(name = OutputHelperMixins.List.CMD_NAME) +public class FoDDastScanListCommand extends AbstractFoDScanListCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.List outputHelper; @Override - protected Predicate getFilterPredicate() { - Predicate result = o->true; - result = and(result, "scanType", FoDScanType.Dynamic); - result = and(result, "analysisStatusType", super.getStatus()); - return result; + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanStartLegacyCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanStartLegacyCommand.java index b0e695efa3..0d9f242c8e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanStartLegacyCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanStartLegacyCommand.java @@ -22,19 +22,20 @@ import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDInProgressScanActionTypeMixins; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.dast.FoDScanDastHelper; +import com.fortify.cli.fod._common.scan.helper.dast.FoDScanDastStartRequest; import com.fortify.cli.fod._common.util.FoDEnums; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeDescriptor; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeHelper; import com.fortify.cli.fod.dast_scan.helper.FoDScanConfigDastDescriptor; import com.fortify.cli.fod.dast_scan.helper.FoDScanConfigDastHelper; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; -import com.fortify.cli.fod.scan.cli.mixin.FoDInProgressScanActionTypeMixins; -import com.fortify.cli.fod.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.dast.FoDScanDastHelper; -import com.fortify.cli.fod.scan.helper.dast.FoDScanDastStartRequest; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeDescriptor; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeHelper; + import kong.unirest.UnirestInstance; import lombok.Getter; import org.apache.commons.logging.Log; @@ -107,8 +108,8 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Finding appropriate entitlement to use."); // find an appropriate assessment type to use - Optional atd = Arrays.stream( - FoDAssessmentTypeHelper.getAssessmentTypes(unirest, + Optional atd = Arrays.stream( + FoDReleaseAssessmentTypeHelper.getAssessmentTypes(unirest, relId, FoDScanType.Dynamic, entitlementFrequencyTypeMixin.getEntitlementFrequencyType(), isRemediation, true) @@ -137,7 +138,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Configuring release to use entitlement " + entitlementIdToUse); // check if the entitlement is still valid - FoDAssessmentTypeHelper.validateEntitlement(relId, atd.get()); + FoDReleaseAssessmentTypeHelper.validateEntitlement(relId, atd.get()); LOG.info("The entitlement " + entitlementIdToUse + " is valid."); String startDateStr = (startDate == null || startDate.isEmpty()) diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanWaitForCommand.java index 33507a7d81..bd63f0756a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanWaitForCommand.java @@ -14,10 +14,15 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import picocli.CommandLine.Command; @Command(name = OutputHelperMixins.WaitFor.CMD_NAME, hidden = true) -public class FoDDastScanWaitForCommand extends FoDScanWaitForCommand { - +public class FoDDastScanWaitForCommand extends AbstractFoDScanWaitForCommand { + @Override + protected FoDScanType getScanType() { + return FoDScanType.Dynamic; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCancelCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCancelCommand.java index ff67eb0e58..d4a00fdd82 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCancelCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCancelCommand.java @@ -14,12 +14,20 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanCancelCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanCancelCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Cancel.CMD_NAME, hidden = false) -public class FoDMastScanCancelCommand extends FoDScanCancelCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDMastScanCancelCommand extends AbstractFoDScanCancelCommand { + @Getter @Mixin private OutputHelperMixins.Cancel outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Mobile; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCommands.java index 9d19fdf159..16341a9396 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanCommands.java @@ -15,10 +15,10 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.common.variable.DefaultVariablePropertyName; -import com.fortify.cli.fod.dast_scan.cli.cmd.*; + import picocli.CommandLine; -@CommandLine.Command(name = "mast-scan", hidden = false, +@CommandLine.Command(name = "mast-scan", aliases = "mast", subcommands = { FoDMastScanListCommand.class, FoDMastScanGetCommand.class, @@ -28,7 +28,8 @@ FoDMastScanCancelCommand.class, FoDMastScanWaitForCommand.class, FoDMastScanImportCommand.class, - FoDMastScanDownloadCommand.class + FoDMastScanDownloadCommand.class, + FoDMastScanDownloadLatestCommand.class } ) @DefaultVariablePropertyName("scanId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadCommand.java index 8a0378a9a8..3a5873a551 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadCommand.java @@ -14,17 +14,19 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDDownloadScanCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import lombok.Getter; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Download.CMD_NAME) -public class FoDMastScanDownloadCommand extends AbstractFoDDownloadScanCommand { +public class FoDMastScanDownloadCommand extends AbstractFoDScanDownloadFprCommand { @Getter @Mixin private OutputHelperMixins.Download outputHelper; @Override - protected String getDownloadScanType() { - return "Mobile"; + protected FoDScanType getScanType() { + return FoDScanType.Mobile; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadLatestCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadLatestCommand.java new file mode 100644 index 0000000000..c1f26fa3a2 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanDownloadLatestCommand.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.fod.mast_scan.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadLatestFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.DownloadLatest.CMD_NAME) +public class FoDMastScanDownloadLatestCommand extends AbstractFoDScanDownloadLatestFprCommand { + @Getter @Mixin private FoDOutputHelperMixins.DownloadLatest outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Mobile; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetCommand.java index 9ef57d80d4..f68f6d5674 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetCommand.java @@ -14,11 +14,19 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanGetCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanGetCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = false) -public class FoDMastScanGetCommand extends FoDScanGetCommand implements IRecordTransformer { - +public class FoDMastScanGetCommand extends AbstractFoDScanGetCommand { + @Getter @Mixin private OutputHelperMixins.Get outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Mobile; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetConfigCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetConfigCommand.java index e154267842..5808a1267a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetConfigCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanGetConfigCommand.java @@ -13,9 +13,9 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import com.fortify.cli.fod.mast_scan.helper.FoDScanConfigMobileDescriptor; import com.fortify.cli.fod.mast_scan.helper.FoDScanConfigMobileHelper; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanImportCommand.java index a4e533a50f..d307397d63 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanImportCommand.java @@ -13,10 +13,10 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanImportCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanImportCommand; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -33,7 +33,7 @@ protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseI } @Override - protected String getImportScanType() { - return "Mobile"; + protected FoDScanType getScanType() { + return FoDScanType.Mobile; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanListCommand.java index b9bba2c48d..5ceea61b36 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanListCommand.java @@ -12,23 +12,20 @@ *******************************************************************************/ package com.fortify.cli.fod.mast_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanListCommand; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import picocli.CommandLine.Command; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanListCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import java.util.function.Predicate; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.List.CMD_NAME, hidden = false) -public class FoDMastScanListCommand extends FoDScanListCommand implements IRecordTransformer { - +public class FoDMastScanListCommand extends AbstractFoDScanListCommand { + @Getter @Mixin private OutputHelperMixins.List outputHelper; + @Override - protected Predicate getFilterPredicate() { - Predicate result = o->true; - result = and(result, "scanType", FoDScanType.Mobile); - result = and(result, "analysisStatusType", super.getStatus()); - return result; + protected FoDScanType getScanType() { + return FoDScanType.Mobile; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanStartCommand.java index 9f37c7d409..b78e57101e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanStartCommand.java @@ -22,16 +22,17 @@ import com.fortify.cli.common.util.FcliBuildPropertiesHelper; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.mobile.FoDScanMobileHelper; +import com.fortify.cli.fod._common.scan.helper.mobile.FoDScanMobileStartRequest; import com.fortify.cli.fod._common.util.FoDEnums; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeDescriptor; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeHelper; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; -import com.fortify.cli.fod.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileHelper; -import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileStartRequest; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeDescriptor; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeHelper; + import kong.unirest.UnirestInstance; import lombok.Getter; import org.apache.commons.logging.Log; @@ -101,8 +102,8 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Finding appropriate entitlement to use."); // find an appropriate assessment type to use - Optional atd = Arrays.stream( - FoDAssessmentTypeHelper.getAssessmentTypes(unirest, + Optional atd = Arrays.stream( + FoDReleaseAssessmentTypeHelper.getAssessmentTypes(unirest, relId, FoDScanType.Mobile, entitlementFrequencyTypeMixin.getEntitlementFrequencyType(), isRemediation, true) @@ -132,7 +133,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Configuring release to use entitlement " + entitlementIdToUse); // check if the entitlement is still valid - FoDAssessmentTypeHelper.validateEntitlement(relId, atd.get()); + FoDReleaseAssessmentTypeHelper.validateEntitlement(relId, atd.get()); LOG.info("The entitlement " + entitlementIdToUse + " is valid"); // validate timezone (if specified) diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanWaitForCommand.java index 8bdb69200a..78341a3ff4 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanWaitForCommand.java @@ -14,10 +14,15 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import picocli.CommandLine.Command; @Command(name = OutputHelperMixins.WaitFor.CMD_NAME, hidden = false) -public class FoDMastScanWaitForCommand extends FoDScanWaitForCommand { - +public class FoDMastScanWaitForCommand extends AbstractFoDScanWaitForCommand { + @Override + protected FoDScanType getScanType() { + return FoDScanType.Mobile; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/cmd/FoDMicroserviceCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/cmd/FoDMicroserviceCommands.java index be6c106d9d..61a1dc688b 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/cmd/FoDMicroserviceCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/cmd/FoDMicroserviceCommands.java @@ -19,6 +19,7 @@ import picocli.CommandLine; @CommandLine.Command(name = "microservice", + aliases = "ms", subcommands = { FoDMicroserviceListCommand.class, //FoDAppMicroserviceGetCommand.class, diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/mixin/FoDMicroserviceByQualifiedNameResolverMixin.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/mixin/FoDMicroserviceByQualifiedNameResolverMixin.java index 2ee3019241..48c5fed5ae 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/mixin/FoDMicroserviceByQualifiedNameResolverMixin.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/microservice/cli/mixin/FoDMicroserviceByQualifiedNameResolverMixin.java @@ -61,7 +61,7 @@ public FoDMicroserviceDescriptor getMicroserviceDescriptor(UnirestInstance unire } public static class RequiredOption extends AbstractFoDAppAndMicroserviceNameResolverMixin { - @Option(names = {"--microservice"}, required = true, paramLabel="app:ms", descriptionKey = "fcli.fod.microservice.resolver.name") + @Option(names = {"--microservice", "--ms"}, required = true, paramLabel="app:ms", descriptionKey = "fcli.fod.microservice.resolver.name") @Getter private String qualifiedMicroserviceName; } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanCommands.java index 75fa307aa3..0bd3d59c83 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanCommands.java @@ -15,9 +15,10 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.common.variable.DefaultVariablePropertyName; + import picocli.CommandLine; -@CommandLine.Command(name = "oss-scan", hidden = false, +@CommandLine.Command(name = "oss-scan", aliases = "oss", subcommands = { FoDOssScanListCommand.class, FoDOssScanGetCommand.class, @@ -27,7 +28,8 @@ //FoDOssScanCancelCommand.class, FoDOssScanWaitForCommand.class, FoDOssScanImportCommand.class, - FoDOSSScanDownloadCommand.class + FoDOssScanDownloadCommand.class, + FoDOssScanDownloadLatestCommand.class } ) @DefaultVariablePropertyName("scanId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadCommand.java new file mode 100644 index 0000000000..0aa9ba8c35 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadCommand.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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.fod.oss_scan.cli.cmd; + +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import kong.unirest.GetRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = OutputHelperMixins.Download.CMD_NAME) +public class FoDOssScanDownloadCommand extends AbstractFoDScanDownloadCommand { + @Getter @Mixin private OutputHelperMixins.Download outputHelper; + + @Override + protected GetRequest getDownloadRequest(UnirestInstance unirest, FoDScanDescriptor scanDescriptor) { + return unirest.get("/api/v3/open-source-scans/{scanId}/sbom") + .routeParam("scanId", scanDescriptor.getScanId()) + .accept("application/octet-stream"); + } + + @Override + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadLatestCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadLatestCommand.java new file mode 100644 index 0000000000..9a395dfaa3 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanDownloadLatestCommand.java @@ -0,0 +1,42 @@ +/** + * 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.fod.oss_scan.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadLatestCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; + +import kong.unirest.GetRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.DownloadLatest.CMD_NAME) +public class FoDOssScanDownloadLatestCommand extends AbstractFoDScanDownloadLatestCommand { + @Getter @Mixin private FoDOutputHelperMixins.DownloadLatest outputHelper; + + @Override + protected GetRequest getDownloadRequest(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanDescriptor scanDescriptor) { + return unirest.get("/api/v3/open-source-scans/{scanId}/sbom") + .routeParam("scanId", scanDescriptor.getScanId()); + } + + @Override + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; + } + +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanGetCommand.java index e5b03dbed2..b0998697ba 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanGetCommand.java @@ -14,11 +14,20 @@ package com.fortify.cli.fod.oss_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanGetCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanGetCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = false) -public class FoDOssScanGetCommand extends FoDScanGetCommand implements IRecordTransformer { +public class FoDOssScanGetCommand extends AbstractFoDScanGetCommand { + @Getter @Mixin private OutputHelperMixins.Get outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanImportCommand.java index 4ab4377b66..b6448b45ab 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanImportCommand.java @@ -16,8 +16,9 @@ import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanImportCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanImportCommand; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -39,8 +40,8 @@ protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseI } @Override - protected String getImportScanType() { - return "OpenSource"; + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; } @RequiredArgsConstructor diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanListCommand.java index b737706087..3afab1941c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanListCommand.java @@ -12,23 +12,20 @@ *******************************************************************************/ package com.fortify.cli.fod.oss_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanListCommand; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import picocli.CommandLine.Command; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanListCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import java.util.function.Predicate; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.List.CMD_NAME, hidden = false) -public class FoDOssScanListCommand extends FoDScanListCommand implements IRecordTransformer { - +public class FoDOssScanListCommand extends AbstractFoDScanListCommand { + @Getter @Mixin private OutputHelperMixins.List outputHelper; + @Override - protected Predicate getFilterPredicate() { - Predicate result = o->true; - result = and(result, "scanType", FoDScanType.OpenSource); - result = and(result, "analysisStatusType", super.getStatus()); - return result; + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanStartCommand.java index 6c32de2fac..8af7b7548d 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanStartCommand.java @@ -20,10 +20,10 @@ import com.fortify.cli.common.output.transform.IRecordTransformer; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.oss.FoDScanOssHelper; +import com.fortify.cli.fod._common.scan.helper.oss.FoDScanOssStartRequest; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.oss.FoDScanOssHelper; -import com.fortify.cli.fod.scan.helper.oss.FoDScanOssStartRequest; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanWaitForCommand.java index 3374beaffc..7ce271dd60 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanWaitForCommand.java @@ -14,10 +14,15 @@ package com.fortify.cli.fod.oss_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import picocli.CommandLine.Command; @Command(name = OutputHelperMixins.WaitFor.CMD_NAME, hidden = false) -public class FoDOssScanWaitForCommand extends FoDScanWaitForCommand { - +public class FoDOssScanWaitForCommand extends AbstractFoDScanWaitForCommand { + @Override + protected FoDScanType getScanType() { + return FoDScanType.OpenSource; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseAssessmentTypeListCommand.java similarity index 87% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeListCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseAssessmentTypeListCommand.java index 97ed59dd35..54f463b24c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/cli/cmd/FoDAssessmentTypeListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseAssessmentTypeListCommand.java @@ -11,13 +11,14 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.assessment_type.cli.cmd; +package com.fortify.cli.fod.release.cli.cmd; import java.util.stream.Stream; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fortify.cli.common.cli.util.CommandGroup; import com.fortify.cli.common.json.JsonHelper; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; @@ -26,8 +27,8 @@ import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.rest.helper.FoDInputTransformer; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanType; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -35,9 +36,9 @@ import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; -@Command(name = OutputHelperMixins.List.CMD_NAME) -public final class FoDAssessmentTypeListCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer { - @Getter @Mixin private OutputHelperMixins.List outputHelper; +@Command(name = "list-assessment-types", aliases = "lsat") @CommandGroup("assessment-type") +public final class FoDReleaseAssessmentTypeListCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @Option(names = "--scan-types", required = true, split = ",", defaultValue = "Static,Dynamic,Mobile") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseCommands.java index ecafc2ee2b..2f35f2c9b8 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseCommands.java @@ -26,7 +26,8 @@ FoDReleaseCreateCommand.class, FoDReleaseUpdateCommand.class, FoDReleaseDeleteCommand.class, - FoDReleaseDownloadResultsCommand.class + FoDReleaseAssessmentTypeListCommand.class, + FoDReleaseScanListCommand.class } ) @DefaultVariablePropertyName("releaseId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseScanListCommand.java new file mode 100644 index 0000000000..1ce2376a54 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseScanListCommand.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.fod.release.cli.cmd; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import com.fortify.cli.common.output.transform.IRecordTransformer; +import com.fortify.cli.fod._common.output.cli.AbstractFoDBaseRequestOutputCommand; +import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = "list-scans", aliases = "lss") +public class FoDReleaseScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; + @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; + + @Override + public HttpRequest getBaseRequest(UnirestInstance unirest) { + return FoDScanHelper.addDefaultScanListParams(unirest.get(FoDUrls.RELEASE_SCANS) + .routeParam("relId", releaseResolver.getReleaseId(unirest))); + } + + @Override + public JsonNode transformRecord(JsonNode record) { + return FoDScanHelper.renameFields(record); + } + + @Override + public boolean isSingular() { + return false; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java similarity index 93% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java index 7e3c21d3b0..dc110ecb4f 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.assessment_type.helper; +package com.fortify.cli.fod.release.helper; import com.fasterxml.jackson.annotation.JsonFormat; import com.formkiq.graalvm.annotations.Reflectable; @@ -25,7 +25,7 @@ @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper = true) -public class FoDAssessmentTypeDescriptor extends JsonNodeHolder { +public class FoDReleaseAssessmentTypeDescriptor extends JsonNodeHolder { private Integer assessmentTypeId; private String name; private String scanType; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java similarity index 84% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java index 6daf36dcf5..6e6a5c8fd4 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/assessment_type/helper/FoDAssessmentTypeHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java @@ -10,15 +10,16 @@ * herein. The information contained herein is subject to change * without notice. */ -package com.fortify.cli.fod.assessment_type.helper; +package com.fortify.cli.fod.release.helper; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fortify.cli.common.json.JsonHelper; import com.fortify.cli.fod._common.rest.FoDUrls; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; import com.fortify.cli.fod._common.util.FoDEnums; -import com.fortify.cli.fod.scan.helper.FoDScanType; + import kong.unirest.GetRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -28,13 +29,13 @@ import java.time.Instant; import java.util.Date; -public final class FoDAssessmentTypeHelper { - private static final Log LOG = LogFactory.getLog(FoDAssessmentTypeHelper.class); +public final class FoDReleaseAssessmentTypeHelper { + private static final Log LOG = LogFactory.getLog(FoDReleaseAssessmentTypeHelper.class); @Getter private static final ObjectMapper objectMapper = new ObjectMapper(); - private FoDAssessmentTypeHelper() {} + private FoDReleaseAssessmentTypeHelper() {} - public static final FoDAssessmentTypeDescriptor[] getAssessmentTypes(UnirestInstance unirestInstance, + public static final FoDReleaseAssessmentTypeDescriptor[] getAssessmentTypes(UnirestInstance unirestInstance, String relId, FoDScanType scanType, FoDEnums.EntitlementFrequencyType entitlementFrequencyType, @@ -50,11 +51,11 @@ public static final FoDAssessmentTypeDescriptor[] getAssessmentTypes(UnirestInst if (failIfNotFound && assessmentTypes.size() == 0) { throw new IllegalStateException("No assessment types found for release id: " + relId); } - return JsonHelper.treeToValue(assessmentTypes, FoDAssessmentTypeDescriptor[].class); + return JsonHelper.treeToValue(assessmentTypes, FoDReleaseAssessmentTypeDescriptor[].class); } public final static void validateEntitlement(String relId, - FoDAssessmentTypeDescriptor atd) { + FoDReleaseAssessmentTypeDescriptor atd) { if (atd == null || atd.getAssessmentTypeId() == null || atd.getAssessmentTypeId() <= 0) { throw new IllegalStateException("Invalid or empty FODAssessmentTypeDescriptor."); } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCancelCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCancelCommand.java index 9ad73f6799..402ea1a2ae 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCancelCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCancelCommand.java @@ -14,12 +14,19 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanCancelCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanCancelCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Cancel.CMD_NAME, hidden = false) -public class FoDSastScanCancelCommand extends FoDScanCancelCommand implements IRecordTransformer, IActionCommandResultSupplier { - +public class FoDSastScanCancelCommand extends AbstractFoDScanCancelCommand { +@Getter @Mixin private OutputHelperMixins.Cancel outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Static; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCommands.java index de0cd95a97..b3cd7cf0c7 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCommands.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanCommands.java @@ -15,9 +15,10 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.common.variable.DefaultVariablePropertyName; + import picocli.CommandLine; -@CommandLine.Command(name = "sast-scan", hidden = false, +@CommandLine.Command(name = "sast-scan", aliases = "sast", subcommands = { FoDSastScanListCommand.class, FoDSastScanGetCommand.class, @@ -27,7 +28,8 @@ FoDSastScanCancelCommand.class, FoDSastScanWaitForCommand.class, FoDSastScanImportCommand.class, - FoDSastScanDownloadCommand.class + FoDSastScanDownloadCommand.class, + FoDSastScanDownloadLatestCommand.class } ) @DefaultVariablePropertyName("scanId") diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadCommand.java index 66f2034e7f..c3c7298233 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadCommand.java @@ -14,17 +14,19 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDDownloadScanCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import lombok.Getter; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Download.CMD_NAME) -public class FoDSastScanDownloadCommand extends AbstractFoDDownloadScanCommand { +public class FoDSastScanDownloadCommand extends AbstractFoDScanDownloadFprCommand { @Getter @Mixin private OutputHelperMixins.Download outputHelper; @Override - protected String getDownloadScanType() { - return "Static"; + protected FoDScanType getScanType() { + return FoDScanType.Static; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadLatestCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadLatestCommand.java new file mode 100644 index 0000000000..46698d1970 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanDownloadLatestCommand.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.fod.sast_scan.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanDownloadLatestFprCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.DownloadLatest.CMD_NAME) +public class FoDSastScanDownloadLatestCommand extends AbstractFoDScanDownloadLatestFprCommand { + @Getter @Mixin private FoDOutputHelperMixins.DownloadLatest outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Static; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetCommand.java index febc37e51e..d91f068ddd 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetCommand.java @@ -14,11 +14,19 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanGetCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanGetCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + +import lombok.Getter; import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = false) -public class FoDSastScanGetCommand extends FoDScanGetCommand implements IRecordTransformer { - +public class FoDSastScanGetCommand extends AbstractFoDScanGetCommand { + @Getter @Mixin private OutputHelperMixins.Get outputHelper; + + @Override + protected FoDScanType getScanType() { + return FoDScanType.Static; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetConfigCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetConfigCommand.java index 844a6a8b24..14d7fafb38 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetConfigCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanGetConfigCommand.java @@ -13,9 +13,9 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastDescriptor; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastHelper; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanConfigGetCommand; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanImportCommand.java index d5280c65b5..15a2b1e0f2 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanImportCommand.java @@ -14,7 +14,9 @@ import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.fod._common.rest.FoDUrls; -import com.fortify.cli.fod.scan.cli.cmd.AbstractFoDScanImportCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanImportCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -31,7 +33,7 @@ protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseI } @Override - protected String getImportScanType() { - return "Static"; + protected FoDScanType getScanType() { + return FoDScanType.Static; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanListCommand.java index e364be7183..e230acdc80 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanListCommand.java @@ -12,23 +12,21 @@ *******************************************************************************/ package com.fortify.cli.fod.sast_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; import com.fortify.cli.common.output.transform.IRecordTransformer; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanListCommand; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import picocli.CommandLine.Command; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanListCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; -import java.util.function.Predicate; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.List.CMD_NAME, hidden = false) -public class FoDSastScanListCommand extends FoDScanListCommand implements IRecordTransformer { - +public class FoDSastScanListCommand extends AbstractFoDScanListCommand implements IRecordTransformer { + @Getter @Mixin private OutputHelperMixins.List outputHelper; + @Override - protected Predicate getFilterPredicate() { - Predicate result = o->true; - result = and(result, "scanType", FoDScanType.Static); - result = and(result, "analysisStatusType", super.getStatus()); - return result; + protected FoDScanType getScanType() { + return FoDScanType.Static; } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanSetupCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanSetupCommand.java index af4f41ce12..381dff863b 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanSetupCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanSetupCommand.java @@ -24,10 +24,14 @@ import com.fortify.cli.common.util.DisableTest.TestType; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; +import com.fortify.cli.fod._common.scan.helper.sast.FoDScanSastHelper; import com.fortify.cli.fod._common.util.FoDEnums; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeDescriptor; -import com.fortify.cli.fod.assessment_type.helper.FoDAssessmentTypeHelper; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeDescriptor; +import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeHelper; import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; import com.fortify.cli.fod.rest.lookup.helper.FoDLookupDescriptor; import com.fortify.cli.fod.rest.lookup.helper.FoDLookupHelper; @@ -35,10 +39,7 @@ import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastDescriptor; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastHelper; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastSetupRequest; -import com.fortify.cli.fod.scan.cli.mixin.FoDEntitlementFrequencyTypeMixins; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.sast.FoDScanSastHelper; + import kong.unirest.UnirestInstance; import lombok.Getter; import org.apache.commons.logging.Log; @@ -101,8 +102,8 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Finding appropriate entitlement to use."); // find an appropriate assessment type to use - Optional atd = Arrays.stream( - FoDAssessmentTypeHelper.getAssessmentTypes(unirest, + Optional atd = Arrays.stream( + FoDReleaseAssessmentTypeHelper.getAssessmentTypes(unirest, relId, FoDScanType.Static, entitlementFrequencyTypeMixin.getEntitlementFrequencyType(), false, true) @@ -131,7 +132,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { LOG.info("Configuring release to use entitlement " + entitlementIdToUse); // check if the entitlement is still valid - FoDAssessmentTypeHelper.validateEntitlement(relId, atd.get()); + FoDReleaseAssessmentTypeHelper.validateEntitlement(relId, atd.get()); LOG.info("The entitlement " + entitlementIdToUse + " is valid."); // find/check technology stack / language level diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanStartCommand.java index 36c6c5e9cb..f4de131736 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanStartCommand.java @@ -24,13 +24,13 @@ import com.fortify.cli.common.util.StringUtils; import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; +import com.fortify.cli.fod._common.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; +import com.fortify.cli.fod._common.scan.helper.FoDScanHelper; +import com.fortify.cli.fod._common.scan.helper.sast.FoDScanSastHelper; +import com.fortify.cli.fod._common.scan.helper.sast.FoDScanSastStartRequest; import com.fortify.cli.fod._common.util.FoDEnums; import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastDescriptor; -import com.fortify.cli.fod.scan.cli.mixin.FoDRemediationScanPreferenceTypeMixins; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.sast.FoDScanSastHelper; -import com.fortify.cli.fod.scan.helper.sast.FoDScanSastStartRequest; import kong.unirest.UnirestInstance; import lombok.Getter; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanWaitForCommand.java index f291eee2fc..572e268792 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanWaitForCommand.java @@ -14,10 +14,15 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; -import com.fortify.cli.fod.scan.cli.cmd.FoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanWaitForCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanType; + import picocli.CommandLine.Command; @Command(name = OutputHelperMixins.WaitFor.CMD_NAME, hidden = false) -public class FoDSastScanWaitForCommand extends FoDScanWaitForCommand { - +public class FoDSastScanWaitForCommand extends AbstractFoDScanWaitForCommand { + @Override + protected FoDScanType getScanType() { + return FoDScanType.Static; + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDDownloadScanCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDDownloadScanCommand.java deleted file mode 100644 index 731a21293e..0000000000 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/AbstractFoDDownloadScanCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * 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.fod.scan.cli.cmd; - -import java.io.File; -import java.nio.file.StandardCopyOption; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.transform.IActionCommandResultSupplier; -import com.fortify.cli.fod._common.cli.mixin.FoDDelimiterMixin; -import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; -import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; -import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanDescriptor; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; -import com.fortify.cli.fod.scan.helper.FoDScanType; - -import kong.unirest.UnirestInstance; -import lombok.SneakyThrows; -import picocli.CommandLine.Command; -import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; - -@Command(name = FoDOutputHelperMixins.DownloadResults.CMD_NAME) -public abstract class AbstractFoDDownloadScanCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; - - @Option(names = {"-f", "--fpr"}, required = true) - private File outputFile; - - @Override @SneakyThrows - public JsonNode getJsonNode(UnirestInstance unirest) { - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); - - FoDScanDescriptor lastScan = FoDScanHelper.getLatestScanDescriptor(unirest, releaseDescriptor.getReleaseId(), - FoDScanType.valueOf(getDownloadScanType()), false); - FoDScanHelper.validateScanDate(lastScan, FoDScanHelper.MAX_RETENTION_PERIOD); - - int status = 202; int maxRetries = 10; - while ( status==202 ) { - status = unirest.get("/api/v3/releases/{releaseId}/fpr") - .routeParam("releaseId", releaseDescriptor.getReleaseId()) - .accept("application/octet-stream") - .queryString("scanType", getDownloadScanType()) - .asFile(outputFile.getAbsolutePath(), StandardCopyOption.REPLACE_EXISTING) - .getStatus(); - if ( status==202 ) { Thread.sleep(30000L); } - //if ( maxRetries++ >= 5) { throw new RuntimeException("Timed out while trying to retrieve latest scan results."); } - } - return releaseDescriptor.asObjectNode() - .put("scanType", getDownloadScanType()) - .put("file", outputFile.getName()); - } - - protected abstract String getDownloadScanType(); - - @Override - public String getActionCommandResult() { - return "FPR_DOWNLOADED"; - } - - @Override - public boolean isSingular() { - return true; - } -} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCommands.java deleted file mode 100644 index 83b445326d..0000000000 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanCommands.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * 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.fod.scan.cli.cmd; - -import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; -import com.fortify.cli.common.variable.DefaultVariablePropertyName; - -import picocli.CommandLine; - -@CommandLine.Command(name = "scan", hidden = false, - subcommands = { - FoDScanListCommand.class, - } -) -@DefaultVariablePropertyName("scanId") -public class FoDScanCommands extends AbstractContainerCommand { -}