From d71ef52a656d787eb18174d09d79cc5fc009b3a3 Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Mon, 23 Oct 2023 12:17:23 +0200 Subject: [PATCH] chore: FoD command refactoring --- .../cli/common/cli/util/CommandGroup.java | 2 + .../cli/cmd/AbstractFoDScanCancelCommand.java | 10 +-- .../cmd/AbstractFoDScanConfigGetCommand.java | 10 +-- .../cmd/AbstractFoDScanDownloadCommand.java | 2 + .../AbstractFoDScanDownloadFprCommand.java | 2 +- .../AbstractFoDScanDownloadLatestCommand.java | 2 + .../cli/cmd/AbstractFoDScanGetCommand.java | 11 +-- .../cli/cmd/AbstractFoDScanImportCommand.java | 2 + .../cli/cmd/AbstractFoDScanListCommand.java | 25 ++----- .../cli/cmd/AbstractFoDScanStartCommand.java | 50 ++++++++++++++ .../cmd/AbstractFoDScanWaitForCommand.java | 4 +- .../_common/scan/helper/FoDScanHelper.java | 5 -- .../scan/helper/oss/FoDScanOssDescriptor.java | 1 + .../scan/helper/oss/FoDScanOssHelper.java | 4 +- .../helper/oss/FoDScanOssStartRequest.java | 1 + .../app/cli/cmd/FoDAppScanListCommand.java | 12 +--- .../cli/cmd/FoDDastScanCommands.java | 11 +-- .../cli/cmd/FoDDastScanGetCommand.java | 3 +- .../cmd/FoDDastScanStartLegacyCommand.java | 56 +++++---------- .../cli/cmd/FoDMastScanCommands.java | 10 +-- .../cli/cmd/FoDMastScanStartCommand.java | 54 +++++---------- .../oss_scan/cli/cmd/FoDOssScanCommands.java | 8 +-- .../cli/cmd/FoDOssScanStartCommand.java | 42 ++--------- .../helper/FoDScanConfigOssDescriptor.java | 1 + .../cli/cmd/FoDReleaseScanListCommand.java | 14 ++-- .../FoDReleaseAssessmentTypeDescriptor.java | 4 +- .../FoDReleaseAssessmentTypeHelper.java | 11 +-- .../cli/cmd/FoDSastScanCommands.java | 10 +-- .../cli/cmd/FoDSastScanSetupCommand.java | 20 +++--- .../cli/cmd/FoDSastScanStartCommand.java | 40 +++-------- .../cli/fod/i18n/FoDMessages.properties | 69 ++++++++----------- .../fortify/cli/ftest/fod/FoDScanSpec.groovy | 11 --- 32 files changed, 204 insertions(+), 303 deletions(-) create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanStartCommand.java diff --git a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/cli/util/CommandGroup.java b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/cli/util/CommandGroup.java index ed2424fae0..321048442a 100644 --- a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/cli/util/CommandGroup.java +++ b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/cli/util/CommandGroup.java @@ -15,6 +15,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -27,6 +28,7 @@ */ @Retention(RUNTIME) @Target(ElementType.TYPE) +@Inherited public @interface CommandGroup { String value(); } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java index 89d7076e7b..ee9f35efdb 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanCancelCommand.java @@ -14,19 +14,19 @@ package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.util.CommandGroup; 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._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 picocli.CommandLine.Mixin; -public abstract class AbstractFoDScanCancelCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +@CommandGroup("*-scan") +public abstract class AbstractFoDScanCancelCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; @Override @@ -40,10 +40,6 @@ public final JsonNode getJsonNode(UnirestInstance unirest) { protected abstract FoDScanType getScanType(); - public final JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - @Override public final String getActionCommandResult() { return "CANCELLED"; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java index fd660cf146..0dd7ddbbee 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanConfigGetCommand.java @@ -14,7 +14,7 @@ package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fortify.cli.common.cli.util.CommandGroup; import com.fortify.cli.common.json.JsonNodeHolder; import com.fortify.cli.common.util.DisableTest; import com.fortify.cli.common.util.DisableTest.TestType; @@ -25,7 +25,7 @@ import kong.unirest.UnirestInstance; import picocli.CommandLine.Mixin; -@DisableTest(TestType.CMD_DEFAULT_TABLE_OPTIONS_PRESENT) +@DisableTest(TestType.CMD_DEFAULT_TABLE_OPTIONS_PRESENT) @CommandGroup("*-scan-config") public abstract class AbstractFoDScanConfigGetCommand extends AbstractFoDJsonNodeOutputCommand { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @@ -33,10 +33,10 @@ public abstract class AbstractFoDScanConfigGetCommand extends AbstractFoDJsonNod @Override public final JsonNode getJsonNode(UnirestInstance unirest) { var releaseId = releaseResolver.getReleaseId(unirest); - var result = getDescriptor(unirest, releaseId).asJsonNode(); + var result = getDescriptor(unirest, releaseId).asObjectNode(); return result.get("assessmentTypeId").asText().equals("0") - ? new ObjectMapper().createObjectNode().put("state", "Not configured") - : result; + ? result.put("state", "Not configured") + : result.put("state", "Configured"); } protected abstract JsonNodeHolder getDescriptor(UnirestInstance unirest, String releaseId); diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java index fbf517f41c..f11a292a49 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadCommand.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.cli.mixin.CommonOptionMixins; +import com.fortify.cli.common.cli.util.CommandGroup; 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; @@ -29,6 +30,7 @@ import lombok.SneakyThrows; import picocli.CommandLine.Mixin; +@CommandGroup("*-scan-download") public abstract class AbstractFoDScanDownloadCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java index 085550e114..44626cf516 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadFprCommand.java @@ -20,7 +20,7 @@ public abstract class AbstractFoDScanDownloadFprCommand extends AbstractFoDScanDownloadCommand { @Override protected GetRequest getDownloadRequest(UnirestInstance unirest, FoDScanDescriptor scanDescriptor) { - return unirest.get("GET /api/v3/scans/{scanId}/fpr") + return unirest.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/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java index 7538a76d0a..97901e267d 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanDownloadLatestCommand.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.cli.mixin.CommonOptionMixins; +import com.fortify.cli.common.cli.util.CommandGroup; 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; @@ -30,6 +31,7 @@ import lombok.SneakyThrows; import picocli.CommandLine.Mixin; +@CommandGroup("*-scan-download") public abstract class AbstractFoDScanDownloadLatestCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java index 81ee2beb6e..137ab186a4 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanGetCommand.java @@ -14,16 +14,16 @@ package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; -import com.fortify.cli.common.output.transform.IRecordTransformer; +import com.fortify.cli.common.cli.util.CommandGroup; import com.fortify.cli.fod._common.output.cli.AbstractFoDJsonNodeOutputCommand; 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 picocli.CommandLine.Mixin; -public abstract class AbstractFoDScanGetCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer { +@CommandGroup("*-scan") +public abstract class AbstractFoDScanGetCommand extends AbstractFoDJsonNodeOutputCommand { @Mixin private FoDScanResolverMixin.PositionalParameter scanResolver; @Override @@ -33,11 +33,6 @@ public JsonNode getJsonNode(UnirestInstance unirest) { protected abstract FoDScanType getScanType(); - @Override - public JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - @Override public boolean isSingular() { return true; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java index 1d98d093f0..b0f4dfc3bc 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanImportCommand.java @@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fortify.cli.common.cli.mixin.CommonOptionMixins; +import com.fortify.cli.common.cli.util.CommandGroup; 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; @@ -28,6 +29,7 @@ import kong.unirest.UnirestInstance; import picocli.CommandLine.Mixin; +@CommandGroup("*-scan-import") public abstract class AbstractFoDScanImportCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java index 6193554c7e..3d4f961110 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanListCommand.java @@ -13,50 +13,37 @@ package com.fortify.cli.fod._common.scan.cli.cmd; import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.util.CommandGroup; 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 kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import picocli.CommandLine.Mixin; +@CommandGroup("*-scan") 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; + @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @Override public final HttpRequest getBaseRequest(UnirestInstance unirest) { - var appId = appResolver.getAppId(unirest); var releaseId = releaseResolver.getReleaseId(unirest); - HttpRequest baseRequest; - if ( appId!=null ) { - if (releaseId!=null) { - // specifying a release takes precedence over app as its more specific - baseRequest = unirest.get(FoDUrls.RELEASE_SCANS).routeParam("relId", releaseId); - } else { - baseRequest = unirest.get(FoDUrls.APP_SCANS).routeParam("appId", appId); - } - } else if ( releaseId!=null ) { - baseRequest = unirest.get(FoDUrls.RELEASE_SCANS).routeParam("relId", releaseId); - } else { - baseRequest = unirest.get(FoDUrls.SCANS); - } + var baseRequest = unirest.get(FoDUrls.RELEASE_SCANS).routeParam("relId", releaseId); return FoDScanHelper.addDefaultScanListParams(baseRequest); } @Override public final JsonNode transformRecord(JsonNode record) { var scanType = getScanType(); - return scanType!=null && !scanType.equals(record.get("scanType")) + return scanType!=null && !scanType.name().equals(record.get("scanType").asText()) ? null - : FoDScanHelper.renameFields(record); + : record; } protected abstract FoDScanType getScanType(); diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanStartCommand.java new file mode 100644 index 0000000000..32fd7415ee --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanStartCommand.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ + +package com.fortify.cli.fod._common.scan.cli.cmd; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.util.CommandGroup; +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.scan.helper.FoDScanDescriptor; +import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; +import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; + +import kong.unirest.UnirestInstance; +import picocli.CommandLine.Mixin; + +@CommandGroup("*-scan") +public abstract class AbstractFoDScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { + @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins + @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; + + @Override + public final JsonNode getJsonNode(UnirestInstance unirest) { + var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); + return startScan(unirest, releaseDescriptor).asJsonNode(); + } + + protected abstract FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor); + + @Override + public final String getActionCommandResult() { + return "STARTED"; + } + + @Override + public final boolean isSingular() { + return true; + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java index c3611a65d3..509e385a4e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/cli/cmd/AbstractFoDScanWaitForCommand.java @@ -15,11 +15,11 @@ import java.util.Set; +import com.fortify.cli.common.cli.util.CommandGroup; 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._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; @@ -29,6 +29,7 @@ import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; +@CommandGroup("*-scan") public abstract class AbstractFoDScanWaitForCommand extends AbstractWaitForCommand { @Getter @Mixin FoDProductHelperStandardMixin productHelper; @Mixin private FoDScanResolverMixin.PositionalParameterMulti scansResolver; @@ -39,7 +40,6 @@ public abstract class AbstractFoDScanWaitForCommand extends AbstractWaitForComma protected final WaitHelperBuilder configure(UnirestInstance unirest, WaitHelperBuilder builder) { return builder .recordsSupplier(scansResolver::getScanDescriptorJsonNodes) - .recordTransformer(FoDScanHelper::renameFields) .currentStateProperty("analysisStatusType") .knownStates(FoDScanStatus.getKnownStateNames()) .failureStates(FoDScanStatus.getFailureStateNames()) diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java index d5458f9375..6e4e4ef66c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/FoDScanHelper.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fortify.cli.common.json.JsonHelper; -import com.fortify.cli.common.output.transform.fields.RenameFieldsTransformer; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod.rest.lookup.helper.FoDLookupDescriptor; import com.fortify.cli.fod.rest.lookup.helper.FoDLookupHelper; @@ -42,10 +41,6 @@ public class FoDScanHelper { // max retention period (in years) of FPRs public static int MAX_RETENTION_PERIOD = 2; - public static final JsonNode renameFields(JsonNode record) { - return new RenameFieldsTransformer(new String[]{}).transform(record); - } - public static final FoDScanDescriptor getScanDescriptor(UnirestInstance unirest, String scanId) { var result = unirest.get(FoDUrls.SCAN + "/summary") .routeParam("scanId", scanId) diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java index ca67a2f428..7a153a30dc 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssDescriptor.java @@ -15,6 +15,7 @@ import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java index 170bb857bf..d0395ff517 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssHelper.java @@ -13,6 +13,8 @@ package com.fortify.cli.fod._common.scan.helper.oss; +import java.io.File; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -31,8 +33,6 @@ import kong.unirest.UnirestInstance; import lombok.Getter; -import java.io.File; - public class FoDScanOssHelper extends FoDScanHelper { @Getter private static final ObjectMapper objectMapper = new ObjectMapper(); diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java index 2cb7980428..6567723198 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/_common/scan/helper/oss/FoDScanOssStartRequest.java @@ -14,6 +14,7 @@ package com.fortify.cli.fod._common.scan.helper.oss; import com.formkiq.graalvm.annotations.Reflectable; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; 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 index 1a198dbdca..dc823cbd79 100644 --- 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 @@ -12,9 +12,8 @@ *******************************************************************************/ package com.fortify.cli.fod.app.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.util.CommandGroup; 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; @@ -26,8 +25,8 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -@Command(name = "list-scans", aliases = "lss") -public class FoDAppScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { +@Command(name = "list-scans", aliases = "lss") @CommandGroup("scan") +public class FoDAppScanListCommand extends AbstractFoDBaseRequestOutputCommand { @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; @Mixin private FoDAppResolverMixin.RequiredOption appResolver; @@ -37,11 +36,6 @@ public HttpRequest getBaseRequest(UnirestInstance unirest) { .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/FoDDastScanCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanCommands.java index 0ea2f22d52..fa596be8a1 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 @@ -15,20 +15,21 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.common.variable.DefaultVariablePropertyName; + import picocli.CommandLine; @CommandLine.Command(name = "dast-scan", aliases = "dast", subcommands = { - FoDDastScanListCommand.class, + FoDDastScanCancelCommand.class, + FoDDastScanDownloadCommand.class, + FoDDastScanDownloadLatestCommand.class, FoDDastScanGetCommand.class, FoDDastScanGetConfigLegacyCommand.class, + FoDDastScanImportCommand.class, + FoDDastScanListCommand.class, //FoDDastScanSetupCommand.class, FoDDastScanStartLegacyCommand.class, - FoDDastScanCancelCommand.class, FoDDastScanWaitForCommand.class, - FoDDastScanImportCommand.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/FoDDastScanGetCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/dast_scan/cli/cmd/FoDDastScanGetCommand.java index e679d53532..fd743534e3 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 @@ -14,7 +14,6 @@ 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.IRecordTransformer; import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanGetCommand; import com.fortify.cli.fod._common.scan.helper.FoDScanType; @@ -23,7 +22,7 @@ import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Get.CMD_NAME, hidden = true) -public class FoDDastScanGetCommand extends AbstractFoDScanGetCommand implements IRecordTransformer { +public class FoDDastScanGetCommand extends AbstractFoDScanGetCommand { @Getter @Mixin private OutputHelperMixins.Get outputHelper; @Override 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 0d9f242c8e..eba636df1e 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 @@ -13,53 +13,48 @@ package com.fortify.cli.fod.dast_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.Objects; +import java.util.Optional; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + 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.common.progress.cli.mixin.ProgressWriterFactoryMixin; 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.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.scan.cli.cmd.AbstractFoDScanStartCommand; 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.FoDScanDescriptor; 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.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.release.helper.FoDReleaseAssessmentTypeDescriptor; import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeHelper; +import com.fortify.cli.fod.release.helper.FoDReleaseDescriptor; import kong.unirest.UnirestInstance; import lombok.Getter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Objects; -import java.util.Optional; -import java.util.Properties; - @Command(name = FoDOutputHelperMixins.StartLegacy.CMD_NAME, hidden = true) -public class FoDDastScanStartLegacyCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDDastScanStartLegacyCommand extends AbstractFoDScanStartCommand { private static final Log LOG = LogFactory.getLog(FoDDastScanStartLegacyCommand.class); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm"); @Getter @Mixin private OutputHelperMixins.Start outputHelper; - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @Option(names = {"--assessment-type"}, required = true) //private DynamicAssessmentTypes dynamicAssessmentType; private String dynamicAssessmentType; @@ -78,13 +73,11 @@ public class FoDDastScanStartLegacyCommand extends AbstractFoDJsonNodeOutputComm private FoDEntitlementFrequencyTypeMixins.RequiredOption entitlementFrequencyTypeMixin; @Mixin private ProgressWriterFactoryMixin progressWriterFactory; - - // TODO Method too long, consider splitting into multiple methods + @Override - public JsonNode getJsonNode(UnirestInstance unirest) { + protected FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { try ( var progressWriter = progressWriterFactory.create() ) { Properties fcliProperties = FcliBuildPropertiesHelper.getBuildProperties(); - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); String relId = releaseDescriptor.getReleaseId(); Integer entitlementIdToUse = 0; Integer assessmentTypeId = 0; @@ -156,22 +149,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .scanToolVersion(fcliProperties.getProperty("projectVersion", "unknown")).build(); //System.out.println(startScanRequest); - return FoDScanDastHelper.startScan(unirest, releaseDescriptor, startScanRequest).asJsonNode(); + return FoDScanDastHelper.startScan(unirest, releaseDescriptor, startScanRequest); } } - - @Override - public JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - - @Override - public String getActionCommandResult() { - return "STARTED"; - } - - @Override - public boolean isSingular() { - return true; - } } 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 16341a9396..ef40c648cc 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 @@ -20,16 +20,16 @@ @CommandLine.Command(name = "mast-scan", aliases = "mast", subcommands = { - FoDMastScanListCommand.class, + FoDMastScanCancelCommand.class, + FoDMastScanDownloadCommand.class, + FoDMastScanDownloadLatestCommand.class, FoDMastScanGetCommand.class, FoDMastScanGetConfigCommand.class, + FoDMastScanImportCommand.class, + FoDMastScanListCommand.class, //FoDMastScanSetupCommand.class, FoDMastScanStartCommand.class, - FoDMastScanCancelCommand.class, FoDMastScanWaitForCommand.class, - FoDMastScanImportCommand.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/FoDMastScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/mast_scan/cli/cmd/FoDMastScanStartCommand.java index b78e57101e..d889ca9269 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 @@ -13,50 +13,46 @@ package com.fortify.cli.fod.mast_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.Objects; +import java.util.Optional; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.fortify.cli.common.cli.mixin.CommonOptionMixins; 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.common.progress.cli.mixin.ProgressWriterFactoryMixin; 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.cmd.AbstractFoDScanStartCommand; 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.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.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.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 kong.unirest.UnirestInstance; import lombok.Getter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Objects; -import java.util.Optional; -import java.util.Properties; - @Command(name = OutputHelperMixins.Start.CMD_NAME) -public class FoDMastScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDMastScanStartCommand extends AbstractFoDScanStartCommand { private static final Log LOG = LogFactory.getLog(FoDMastScanStartCommand.class); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm"); @Getter @Mixin private OutputHelperMixins.Start outputHelper; - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @Option(names = {"--assessment-type"}, required = true) private String mobileAssessmentType; @Option(names = {"--entitlement-id"}) @@ -76,12 +72,10 @@ private enum MobileFrameworks { iOS, Android } @Mixin private ProgressWriterFactoryMixin progressWriterFactory; - // TODO Split into multiple methods @Override - public JsonNode getJsonNode(UnirestInstance unirest) { + protected FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { try ( var progressWriter = progressWriterFactory.create() ) { Properties fcliProperties = FcliBuildPropertiesHelper.getBuildProperties(); - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); String relId = releaseDescriptor.getReleaseId(); Integer entitlementIdToUse = 0; Integer assessmentTypeId = 0; @@ -155,23 +149,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .scanTool(fcliProperties.getProperty("projectName", "fcli")) .scanToolVersion(fcliProperties.getProperty("projectVersion", "unknown")).build(); - return FoDScanMobileHelper.startScan(unirest, progressWriter, releaseDescriptor, startScanRequest, scanFileMixin.getFile()).asJsonNode(); + return FoDScanMobileHelper.startScan(unirest, progressWriter, releaseDescriptor, startScanRequest, scanFileMixin.getFile()); } } - - @Override - public JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - - @Override - public String getActionCommandResult() { - return "STARTED"; - } - - @Override - public boolean isSingular() { - return true; - } - } 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 0bd3d59c83..1c8a9b5da3 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 @@ -20,16 +20,16 @@ @CommandLine.Command(name = "oss-scan", aliases = "oss", subcommands = { - FoDOssScanListCommand.class, + FoDOssScanDownloadCommand.class, + FoDOssScanDownloadLatestCommand.class, FoDOssScanGetCommand.class, + FoDOssScanImportCommand.class, + FoDOssScanListCommand.class, //FoDOssScanGetConfigCommand.class, //FoDOssScanSetupCommand.class, FoDOssScanStartCommand.class, //FoDOssScanCancelCommand.class, FoDOssScanWaitForCommand.class, - FoDOssScanImportCommand.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/FoDOssScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/cli/cmd/FoDOssScanStartCommand.java index 8af7b7548d..418b89c512 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 @@ -13,17 +13,13 @@ package com.fortify.cli.fod.oss_scan.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.cli.mixin.CommonOptionMixins; 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.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.cli.cmd.AbstractFoDScanStartCommand; +import com.fortify.cli.fod._common.scan.helper.FoDScanDescriptor; 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.release.helper.FoDReleaseDescriptor; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -31,37 +27,13 @@ import picocli.CommandLine.Mixin; @Command(name = OutputHelperMixins.Start.CMD_NAME, hidden = false) -public class FoDOssScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDOssScanStartCommand extends AbstractFoDScanStartCommand { @Getter @Mixin private OutputHelperMixins.Start outputHelper; - - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; - @Mixin private CommonOptionMixins.RequiredFile scanFileMixin; - + @Override - public JsonNode getJsonNode(UnirestInstance unirest) { - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); - //String relId = releaseDescriptor.getReleaseId(); - + protected FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { FoDScanOssStartRequest startScanRequest = FoDScanOssStartRequest.builder().build(); - - return FoDScanOssHelper.startScanWithDefaults(unirest, releaseDescriptor, startScanRequest, scanFileMixin.getFile()).asJsonNode(); - } - - @Override - public JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); + return FoDScanOssHelper.startScanWithDefaults(unirest, releaseDescriptor, startScanRequest, scanFileMixin.getFile()); } - - @Override - public String getActionCommandResult() { - return "STARTED"; - } - - @Override - public boolean isSingular() { - return true; - } - } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/helper/FoDScanConfigOssDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/helper/FoDScanConfigOssDescriptor.java index a858320996..a0104d1aae 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/helper/FoDScanConfigOssDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/oss_scan/helper/FoDScanConfigOssDescriptor.java @@ -15,6 +15,7 @@ import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; 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 index 1ce2376a54..7609e53927 100644 --- 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 @@ -12,9 +12,9 @@ *******************************************************************************/ package com.fortify.cli.fod.release.cli.cmd; -import com.fasterxml.jackson.databind.JsonNode; +import com.fortify.cli.common.cli.util.CommandGroup; 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; @@ -26,9 +26,10 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; -@Command(name = "list-scans", aliases = "lss") -public class FoDReleaseScanListCommand extends AbstractFoDBaseRequestOutputCommand implements IRecordTransformer { +@Command(name = "list-scans", aliases = "lss") @CommandGroup("scan") +public class FoDReleaseScanListCommand extends AbstractFoDBaseRequestOutputCommand { @Getter @Mixin private OutputHelperMixins.TableWithQuery outputHelper; + @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; @Override @@ -37,11 +38,6 @@ public HttpRequest getBaseRequest(UnirestInstance unirest) { .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/release/helper/FoDReleaseAssessmentTypeDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java index dc110ecb4f..a377aa8d6a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeDescriptor.java @@ -13,6 +13,8 @@ package com.fortify.cli.fod.release.helper; +import java.util.Date; + import com.fasterxml.jackson.annotation.JsonFormat; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; @@ -21,8 +23,6 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.util.Date; - @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper = true) public class FoDReleaseAssessmentTypeDescriptor extends JsonNodeHolder { diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java index 6e6a5c8fd4..14c131db8b 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/helper/FoDReleaseAssessmentTypeHelper.java @@ -12,6 +12,12 @@ */ package com.fortify.cli.fod.release.helper; +import java.time.Instant; +import java.util.Date; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -23,11 +29,6 @@ import kong.unirest.GetRequest; import kong.unirest.UnirestInstance; import lombok.Getter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.time.Instant; -import java.util.Date; public final class FoDReleaseAssessmentTypeHelper { private static final Log LOG = LogFactory.getLog(FoDReleaseAssessmentTypeHelper.class); 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 b3cd7cf0c7..e50315da0b 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 @@ -20,16 +20,16 @@ @CommandLine.Command(name = "sast-scan", aliases = "sast", subcommands = { - FoDSastScanListCommand.class, + FoDSastScanCancelCommand.class, + FoDSastScanDownloadCommand.class, + FoDSastScanDownloadLatestCommand.class, FoDSastScanGetCommand.class, FoDSastScanGetConfigCommand.class, + FoDSastScanImportCommand.class, + FoDSastScanListCommand.class, FoDSastScanSetupCommand.class, FoDSastScanStartCommand.class, - FoDSastScanCancelCommand.class, FoDSastScanWaitForCommand.class, - FoDSastScanImportCommand.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/FoDSastScanSetupCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/sast_scan/cli/cmd/FoDSastScanSetupCommand.java index 381dff863b..a75305e3d7 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 @@ -13,6 +13,13 @@ package com.fortify.cli.fod.sast_scan.cli.cmd; +import java.util.Arrays; +import java.util.Objects; +import java.util.Optional; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -25,7 +32,6 @@ 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; @@ -42,16 +48,10 @@ import kong.unirest.UnirestInstance; import lombok.Getter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import picocli.CommandLine.Command; import picocli.CommandLine.Mixin; import picocli.CommandLine.Option; -import java.util.Arrays; -import java.util.Objects; -import java.util.Optional; - @Command(name = OutputHelperMixins.Setup.CMD_NAME, hidden = false) @DisableTest(TestType.CMD_DEFAULT_TABLE_OPTIONS_PRESENT) public class FoDSastScanSetupCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { @@ -172,12 +172,10 @@ public JsonNode getJsonNode(UnirestInstance unirest) { @Override public JsonNode transformRecord(JsonNode record) { FoDReleaseDescriptor releaseDescriptor = releaseResolver.getReleaseDescriptor(getUnirestInstance()); - return FoDScanHelper.renameFields( - ((ObjectNode)record) + return ((ObjectNode)record) .put("applicationName", releaseDescriptor.getApplicationName()) .put("releaseName", releaseDescriptor.getReleaseName()) - .put("microserviceName", releaseDescriptor.getMicroserviceName()) - ); + .put("microserviceName", releaseDescriptor.getMicroserviceName()); } @Override 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 f4de131736..2f13e46588 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 @@ -15,21 +15,17 @@ import java.util.Properties; -import com.fasterxml.jackson.databind.JsonNode; import com.fortify.cli.common.cli.mixin.CommonOptionMixins; 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.common.util.FcliBuildPropertiesHelper; 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.cmd.AbstractFoDScanStartCommand; 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.FoDScanDescriptor; 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.release.helper.FoDReleaseDescriptor; import com.fortify.cli.fod.sast_scan.helper.FoDScanConfigSastDescriptor; import kong.unirest.UnirestInstance; @@ -39,23 +35,18 @@ import picocli.CommandLine.Option; @Command(name = OutputHelperMixins.Start.CMD_NAME, hidden = false) -public class FoDSastScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDSastScanStartCommand extends AbstractFoDScanStartCommand { @Getter @Mixin private OutputHelperMixins.Start outputHelper; - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; - @Option(names = {"--notes"}) private String notes; @Mixin private CommonOptionMixins.RequiredFile scanFileMixin; - @Mixin - private FoDRemediationScanPreferenceTypeMixins.OptionalOption remediationScanType; - + @Mixin private FoDRemediationScanPreferenceTypeMixins.OptionalOption remediationScanType; + @Override - public JsonNode getJsonNode(UnirestInstance unirest) { + protected FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { Properties fcliProperties = FcliBuildPropertiesHelper.getBuildProperties(); - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); String relId = releaseDescriptor.getReleaseId(); Boolean isRemediation = false; @@ -77,22 +68,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .scanToolVersion(fcliProperties.getProperty("projectVersion", "unknown")) .build(); - return FoDScanSastHelper.startScanWithDefaults(unirest, releaseDescriptor, startScanRequest, scanFileMixin.getFile()).asJsonNode(); - } - - @Override - public JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - - @Override - public String getActionCommandResult() { - return "STARTED"; - } - - @Override - public boolean isSingular() { - return true; + return FoDScanSastHelper.startScanWithDefaults(unirest, releaseDescriptor, startScanRequest, scanFileMixin.getFile()); } private void validateScanSetup(UnirestInstance unirest, String relId) { diff --git a/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties b/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties index 7c65720127..deb5f2fdf3 100644 --- a/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties +++ b/fcli-core/fcli-fod/src/main/resources/com/fortify/cli/fod/i18n/FoDMessages.properties @@ -191,6 +191,7 @@ fcli.fod.app.update.description = The updated description for the application. fcli.fod.app.update.notify = Email address of user(s) to send notifications to (Please note, any existing entries will be replaced). fcli.fod.app.update.criticality = The business criticality of the application. fcli.fod.app.update.attr = Attribute id or name and its value to set on the application. +fcli.fod.app.list-scans.usage.header = List scans for a given application. ### For the "fod microservice" command ### fcli.fod.microservice.usage.header = Manage FoD application microservices. @@ -242,6 +243,9 @@ fcli.fod.release.update.description = Updated description for the release. fcli.fod.release.update.owner = Updated id or username for the owner of the release. fcli.fod.release.update.microservice = The updated microservice id or name to create the release on. fcli.fod.release.update.status = SDLC lifecycle status of the release. Valid values: ${COMPLETION-CANDIDATES}. +fcli.fod.release.list-assessment-types.usage.header = List assessment types for a given release. +fcli.fod.release.list-assessment-types.scan-types = Comma-separated list of scan types for which to list assessment types. Default value: ${DEFAULT-VALUE}. Valid values: ${COMPLETION-CANDIDATES}. +fcli.fod.release.list-scans.usage.header = List scans for a given release. ### For the "fod assessment-type" command ### fcli.fod.assessment-type.usage.header = Manage FoD assessment types. @@ -356,8 +360,10 @@ fcli.fod.sast-scan.setup.include-third-party-libs = Indicates if third party lib fcli.fod.sast-scan.setup.use-source-control = Indicates if source control should be used. fcli.fod.sast-scan.import.usage.header = Import existing SAST scan results (from an FPR file). fcli.fod.sast-scan.import.file = FPR file containing existing SAST scan results to be imported. -fcli.fod.sast-scan.download.usage.header = Download previous scan results (as an FPR file). -fcli.fod.sast-scan.download.fpr = File path and name where to save the FPR file. +fcli.fod.sast-scan.download.usage.header = Download scan results. +fcli.fod.sast-scan.download.file = File path and name where to save the FPR file. +fcli.fod.sast-scan.download-latest.usage.header = Download latest scan results from release. +fcli.fod.sast-scan.download-latest.file = File path and name where to save the FPR file. ### For the "fod dast-scan" command ### fcli.fod.dast-scan.usage.header = Manage FoD DAST scans. @@ -411,8 +417,10 @@ fcli.fod.dast-scan.start-legacy.chunk-size = ${fcli.fod.sast-scan.start.chunk-si fcli.fod.dast-scan.start-legacy.timezone = The timezone to use for starting the scan - default is UTC. Use 'fod rest lookup TimeZones' to see the values. fcli.fod.dast-scan.import.usage.header = Import existing DAST scan results (from an FPR file). fcli.fod.dast-scan.import.file = FPR file containing existing DAST scan results to be imported. -fcli.fod.dast-scan.download.usage.header = Download previous scan results (as an FPR file). -fcli.fod.dast-scan.download.fpr = File path and name where to save the FPR file. +fcli.fod.dast-scan.download.usage.header = Download scan results. +fcli.fod.dast-scan.download.file = File path and name where to save the FPR file. +fcli.fod.dast-scan.download-latest.usage.header = Download latest scan results from release. +fcli.fod.dast-scan.download-latest.file = File path and name where to save the FPR file. ### For the "fod mast-scan" command ### fcli.fod.mast-scan.usage.header = Manage FoD MAST scans. @@ -466,23 +474,10 @@ fcli.fod.mast-scan.start.framework = The Mobile Framework to use. Valid values: fcli.fod.mast-scan.start.timezone = The timezone to use for starting the scan - default is UTC. Use 'fod rest lookup TimeZones' to see the values. fcli.fod.mast-scan.import.usage.header = Import existing MAST scan results (from an FPR file). fcli.fod.mast-scan.import.file = FPR file containing existing MAST scan results to be imported. -fcli.fod.mast-scan.download.usage.header = Download previous scan results (as an FPR file). -fcli.fod.mast-scan.download.fpr = File path and name where to save the FPR file. - -fcli.fod.scan-config.usage.header = Setup scan configurations on FoD. -fcli.fod.scan-config.usage.description = This command and all sub-commands are intended for preview purposes only. \ - Command names, options and behavior may change at any time, even between patch or minor releases, potentially affecting \ - any workflows in which these commands are being used. -fcli.fod.scan-config.get-dast.usage.header = (PREVIEW) Get current DAST scan configuration. -fcli.fod.scan-config.get-dast.usage.description = This command is not fully implemented and is intended for preview only. \ - Command name, options and behavior may change at any time, even between patch or minor releases, potentially affecting \ - any workflows in which this command is being used. -fcli.fod.scan-config.get-mobile.usage.header = Get current Mobile scan configuration (UNAVAILABLE). -fcli.fod.scan-config.get-mobile.usage.description = This command will currently fail as FoD doesn't provide \ - an API endpoint for retrieving mobile scan configuration. For now, this command only exists for consistency \ - with the other get-* commands, to not leave users wondering why there is no 'get-mobile' command. \ - If the necessary endpoint is added to a future FoD version, this command should start functioning \ - automatically, and this message will be removed in a next fcli release. +fcli.fod.mast-scan.download.usage.header = Download scan results. +fcli.fod.mast-scan.download.file = File path and name where to save the FPR file. +fcli.fod.mast-scan.download-latest.usage.header = Download latest scan results from release. +fcli.fod.mast-scan.download-latest.file = File path and name where to save the FPR file. ### For the "fod oss-scan" command ### fcli.fod.oss-scan.usage.header = Manage FoD OSS scans. @@ -500,8 +495,6 @@ fcli.fod.oss-scan.list.usage.header = List OSS scans. fcli.fod.oss-scan.import.usage.header = Import existing OSS scan results (from an SBOM file). fcli.fod.oss-scan.import.file = FPR file containing existing OSS scan results to be imported. fcli.fod.oss-scan.import.type = Open Source scan results file type. Valid values: ${COMPLETION-CANDIDATES} (default value is CycloneDX). -fcli.fod.oss-scan.download.usage.header = Download previous scan results (as an SBOM file). -fcli.fod.oss-scan.download.sbom = File path and name where to save the SBOM file. fcli.fod.oss-scan.start.usage.header = (PREVIEW) Start a new OSS scan. fcli.fod.oss-scan.start.usage.description = This command is not fully implemented and is intended for preview only. \ Command name, options and behavior may change at any time, even between patch or minor releases, potentially affecting \ @@ -515,6 +508,10 @@ fcli.fod.oss-scan.wait-for.usage.description.2 = ${fcli.fod.scan.states:-See fcl fcli.fod.oss-scan.wait-for.until = ${fcli.fod.scan.wait-for.until} fcli.fod.oss-scan.wait-for.while = ${fcli.fod.scan.wait-for.while} fcli.fod.oss-scan.wait-for.any-state = ${fcli.fod.scan.wait-for.any-state} +fcli.fod.oss-scan.download.usage.header = Download scan results. +fcli.fod.oss-scan.download.file = File path and name where to save the SBOM file. +fcli.fod.oss-scan.download-latest.usage.header = Download latest scan results from release. +fcli.fod.oss-scan.download-latest.file = File path and name where to save the SBOM file. # various messages displayed during execution fcli.fod.validating-entitlement = Validating entitlement. @@ -590,28 +587,16 @@ fcli.env.default.prefix=FCLI_DEFAULT # Table output columns configuration fcli.fod.app.output.table.options = applicationId,applicationName,fcliApplicationType,businessCriticalityType +fcli.fod.app.scan.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName fcli.fod.microservice.output.table.options = microserviceId,microserviceName,applicationName fcli.fod.release.output.table.options = releaseId,releaseName,microserviceName,applicationName,sdlcStatusType -fcli.fod.assessment-type.output.table.options = assessmentTypeId,name,scanType,frequencyType,unitInfo,entitlementId,entitlementDescription +fcli.fod.release.scan.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName +fcli.fod.release.assessment-type.output.table.options = assessmentTypeId,name,scanType,frequencyType,unitInfo,entitlementId,entitlementDescription fcli.fod.entitlement.output.table.options = entitlementId,entitlementDescription,startDate,endDate,unitInfo -fcli.fod.scan.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.sast-scan.output.table.options = scanId,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.sast-scan.setup.output.table.options = applicationName,microserviceName,releaseName,entitlementId,technologyStack,languageLevel,performOpenSourceAnalysis -fcli.fod.sast-scan.import.output.table.options = importScanSessionId,applicationName,microserviceName,releaseName,scanType -fcli.fod.sast-scan.download.output.table.options = applicationName,microserviceName,releaseName,scanType,file -fcli.fod.dast-scan.output.table.options = scanId,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.dast-scan.setup.output.table.options = applicationName,microserviceName,releaseName,entitlementId,dynamicSiteURL,webServiceType -fcli.fod.dast-scan.import.output.table.options = importScanSessionId,applicationName,microserviceName,releaseName,scanType -fcli.fod.dast-scan.download.output.table.options = applicationName,microserviceName,releaseName,scanType,file -fcli.fod.mast-scan.output.table.options = scanId,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.mast-scan.setup.output.table.options = applicationName,microserviceName,releaseName,entitlementId -fcli.fod.mast-scan.import.output.table.options = importScanSessionId,applicationName,microserviceName,releaseName,scanType -fcli.fod.mast-scan.download.output.table.options = applicationName,microserviceName,releaseName,scanType,file -fcli.fod.oss-scan.output.table.options = scanId,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.oss-scan.import.output.table.options = importScanSessionId,applicationName,microserviceName,releaseName,scanType -fcli.fod.oss-scan.download.output.table.options = scanId,scanType,file -fcli.fod.scan.cancel.output.table.options = scanId,scanType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName -fcli.fod.scan-import.output.table.options = releaseId,releaseName,microserviceName,applicationName +fcli.fod.*-scan.output.table.options = scanId,analysisStatusType,applicationName,microserviceName,releaseName,startedDateTime,completedDateTime,scanMethodTypeName +fcli.fod.*-scan-import.output.table.options = importScanSessionId,applicationName,microserviceName,releaseName,scanType +fcli.fod.*-scan-download.output.table.options = scanId,scanType,file +fcli.fod.*-scan-config.output.table.options = applicationName,microserviceName,releaseName,entitlementId,status fcli.fod.user.output.table.options = userId,userName,firstName,lastName,email,roleName fcli.fod.user.update.output.table.options = userId,userName,firstName,lastName,email,roleName fcli.fod.user-group.output.table.options = id,name,assignedUsersCount,assignedApplicationsCount diff --git a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy index 4ed89c5668..0889f0c111 100644 --- a/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy +++ b/fcli-other/fcli-functional-test/src/ftest/groovy/com/fortify/cli/ftest/fod/FoDScanSpec.groovy @@ -23,17 +23,6 @@ class FoDScanSpec extends FcliBaseSpec { //@Shared @TestResource("runtime/shared/iwa_net_cyclonedx.json") String ossResults @Shared @AutoCleanup FoDWebAppSupplier app = new FoDWebAppSupplier() - def "list"() { - def args = "fod scan list --store scans" - when: - def result = Fcli.run(args) - then: - verifyAll(result.stdout) { - size()>=3 - it[0].replace(' ', '').equals("IdTypeAnalysisStatusApplicationMicroserviceReleaseStartedCompletedScanMethod") - } - } - def "get.byId"() { def args = "fod sast-scan get ::scans::get(0).scanId" when: