From faefbb54c23561fe6dc1f1bab85756897b0072df Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Wed, 9 Aug 2023 11:44:28 +0200 Subject: [PATCH] chore: FoD refactoring --- .../fortify/cli/common/json/JsonHelper.java | 11 -- .../output/mixin/FoDOutputHelperMixins.java | 43 +++++-- .../cli/fod/_main/cli/cmd/FoDCommands.java | 4 + .../release/cli/cmd/FoDReleaseCommands.java | 1 - .../cli/cmd/FoDReleaseImportScanCommand.java | 116 ------------------ .../cli/fod/scan/cli/cmd/FoDScanCommands.java | 11 +- ...mand.java => FoDScanStartDastCommand.java} | 21 ++-- ...nd.java => FoDScanStartMobileCommand.java} | 14 +-- ...mand.java => FoDScanStartSastCommand.java} | 20 +-- .../helper/FoDAssessmentTypeDescriptor.java | 8 +- .../FoDImportScanSessionDescriptor.java | 29 ----- .../cli/fod/scan/helper/FoDScanHelper.java | 22 +--- ...riptor.java => FoDScanDastDescriptor.java} | 2 +- ...ScanHelper.java => FoDScanDastHelper.java} | 13 +- ...uest.java => FoDScanDastStartRequest.java} | 2 +- ...anHelper.java => FoDScanMobileHelper.java} | 13 +- ...st.java => FoDScanMobileStartRequest.java} | 2 +- .../cli/fod/scan/helper/oss/FoDOssHelper.java | 35 ------ ...riptor.java => FoDScanSastDescriptor.java} | 2 +- ...ScanHelper.java => FoDScanSastHelper.java} | 23 ++-- ...uest.java => FoDScanSastStartRequest.java} | 2 +- .../cli/cmd/AbstractFoDScanImportCommand.java | 71 +++++++++++ .../cli/cmd/FoDScanImportCommands.java | 29 +++++ .../cli/cmd/FoDScanImportDastCommand.java | 32 +++++ .../cli/cmd/FoDScanImportMobileCommand.java | 32 +++++ .../cmd/FoDScanImportOpenSourceCommand.java | 54 ++++++++ .../cli/cmd/FoDScanImportSastCommand.java | 32 +++++ .../cli/cmd/FoDScanSetupCommands.java | 26 ++++ .../cli/cmd/FoDScanSetupSastCommand.java} | 20 +-- .../helper/FoDScanDastSetupDescriptor.java} | 4 +- .../helper/FoDScanDastSetupHelper.java} | 22 ++-- .../helper/FoDScanDastSetupRequest.java} | 4 +- .../helper/FoDScanMobileSetupDescriptor.java} | 4 +- .../helper/FoDScanMobileSetupHelper.java} | 23 ++-- .../helper/FoDScanSastSetupDescriptor.java} | 4 +- .../helper/FoDScanSastSetupHelper.java | 40 ++++++ .../helper/FoDScanSastSetupRequest.java} | 4 +- .../cli/fod/i18n/FoDMessages.properties | 44 ++++--- 38 files changed, 484 insertions(+), 355 deletions(-) delete mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseImportScanCommand.java rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/{dast/FoDDastScanStartCommand.java => FoDScanStartDastCommand.java} (92%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/{mobile/FoDMobileScanStartCommand.java => FoDScanStartMobileCommand.java} (94%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/{sast/FoDSastScanStartCommand.java => FoDScanStartSastCommand.java} (91%) delete mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanSessionDescriptor.java rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/{FoDDastScanDescriptor.java => FoDScanDastDescriptor.java} (94%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/{FoDDastScanHelper.java => FoDScanDastHelper.java} (84%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/{FoDStartDastScanRequest.java => FoDScanDastStartRequest.java} (97%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/{FoDMobileScanHelper.java => FoDScanMobileHelper.java} (85%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/{FoDStartMobileScanRequest.java => FoDScanMobileStartRequest.java} (97%) delete mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDOssHelper.java rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/{FoDSastScanDescriptor.java => FoDScanSastDescriptor.java} (94%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/{FoDSastScanHelper.java => FoDScanSastHelper.java} (85%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/{FoDStartSastScanRequest.java => FoDScanSastStartRequest.java} (97%) create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/AbstractFoDScanImportCommand.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportCommands.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportDastCommand.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportMobileCommand.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportOpenSourceCommand.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportSastCommand.java create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupCommands.java rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/cli/cmd/sast/FoDSastScanSetupCommand.java => scan_setup/cli/cmd/FoDScanSetupSastCommand.java} (91%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/dast/FoDDastScanSetupDescriptor.java => scan_setup/helper/FoDScanDastSetupDescriptor.java} (91%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/FoDScanNotFoundException.java => scan_setup/helper/FoDScanDastSetupHelper.java} (51%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/dast/FoDSetupDastScanRequest.java => scan_setup/helper/FoDScanDastSetupRequest.java} (97%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/mobile/FoDMobileScanSetupDescriptor.java => scan_setup/helper/FoDScanMobileSetupDescriptor.java} (91%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/FoDImportScanResponse.java => scan_setup/helper/FoDScanMobileSetupHelper.java} (50%) rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/sast/FoDSastScanSetupDescriptor.java => scan_setup/helper/FoDScanSastSetupDescriptor.java} (91%) create mode 100644 fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupHelper.java rename fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/{scan/helper/sast/FoDSetupSastScanRequest.java => scan_setup/helper/FoDScanSastSetupRequest.java} (93%) diff --git a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/json/JsonHelper.java b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/json/JsonHelper.java index fc2ed4745e..6572b368a4 100644 --- a/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/json/JsonHelper.java +++ b/fcli-core/fcli-common/src/main/java/com/fortify/cli/common/json/JsonHelper.java @@ -122,17 +122,6 @@ public static T jsonStringToValue(String jsonString, Class returnType) { } } - public static final void stripNulls(JsonNode node) { - Iterator it = node.iterator(); - while (it.hasNext()) { - JsonNode child = it.next(); - if (child.isNull()) - it.remove(); - else - stripNulls(child); - } - } - private static final class ArrayNodeCollector implements Collector { @Override public Supplier supplier() { 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 861d99c9f3..5f055e6e47 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 @@ -15,41 +15,60 @@ import com.fortify.cli.common.output.cli.mixin.IOutputHelper; import com.fortify.cli.common.output.cli.mixin.OutputHelperMixins; +import picocli.CommandLine.Command; + /** *

This class provides FoD-specific {@link IOutputHelper} implementations.

* * @author rsenden */ public class FoDOutputHelperMixins { - public static class SetupSast extends OutputHelperMixins.TableNoQuery { + public static class SetupSast extends OutputHelperMixins.DetailsNoQuery { public static final String CMD_NAME = "setup-sast"; } - public static class SetupDast extends OutputHelperMixins.TableNoQuery { + public static class SetupDast extends OutputHelperMixins.DetailsNoQuery { public static final String CMD_NAME = "setup-dast"; } - public static class SetupOss extends OutputHelperMixins.TableNoQuery { - public static final String CMD_NAME = "setup-oss"; - } - public static class SetupMobile extends OutputHelperMixins.TableNoQuery { + public static class SetupMobile extends OutputHelperMixins.DetailsNoQuery { public static final String CMD_NAME = "setup-mobile"; } + public static class GetSast extends OutputHelperMixins.DetailsNoQuery { + public static final String CMD_NAME = "get-sast"; + } + public static class GetDast extends OutputHelperMixins.DetailsNoQuery { + public static final String CMD_NAME = "get-dast"; + } + public static class GetMobile extends OutputHelperMixins.DetailsNoQuery { + public static final String CMD_NAME = "get-mobile"; + } - public static class StartSast extends OutputHelperMixins.TableNoQuery { + public static class StartSast extends OutputHelperMixins.TableNoQuery { public static final String CMD_NAME = "start-sast"; } - public static class StartDast extends OutputHelperMixins.TableNoQuery { + public static class StartDast extends OutputHelperMixins.TableNoQuery { public static final String CMD_NAME = "start-dast"; } - public static class StartOss extends OutputHelperMixins.TableNoQuery { - public static final String CMD_NAME = "start-oss"; - } - public static class StartMobile extends OutputHelperMixins.TableNoQuery { + public static class StartMobile extends OutputHelperMixins.TableNoQuery { public static final String CMD_NAME = "start-mobile"; } public static class ImportScan extends OutputHelperMixins.TableNoQuery { public static final String CMD_NAME = "import-scan"; } + + public static class ImportSast extends OutputHelperMixins.TableNoQuery { + public static final String CMD_NAME = "import-sast"; + } + public static class ImportDast extends OutputHelperMixins.TableNoQuery { + public static final String CMD_NAME = "import-dast"; + } + public static class ImportMobile extends OutputHelperMixins.TableNoQuery { + public static final String CMD_NAME = "import-mobile"; + } + @Command(aliases = "import-oss") + public static class ImportOpenSource extends OutputHelperMixins.TableNoQuery { + public static final String CMD_NAME = "import-open-source"; + } public static class Lookup extends OutputHelperMixins.TableWithQuery { public static final String CMD_NAME = "lookup"; 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 2985cc2b73..50ee260838 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 @@ -19,6 +19,8 @@ import com.fortify.cli.fod.release.cli.cmd.FoDReleaseCommands; import com.fortify.cli.fod.rest.cli.cmd.FoDRestCommands; import com.fortify.cli.fod.scan.cli.cmd.FoDScanCommands; +import com.fortify.cli.fod.scan_import.cli.cmd.FoDScanImportCommands; +import com.fortify.cli.fod.scan_setup.cli.cmd.FoDScanSetupCommands; import com.fortify.cli.fod.user.cli.cmd.FoDUserCommands; import com.fortify.cli.fod.user_group.cli.cmd.FoDUserGroupCommands; @@ -41,6 +43,8 @@ FoDReleaseCommands.class, FoDMicroserviceCommands.class, FoDScanCommands.class, + FoDScanImportCommands.class, + FoDScanSetupCommands.class, FoDUserCommands.class, FoDUserGroupCommands.class, FoDRestCommands.class, 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 cb00e08050..fc4bf362a4 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 @@ -23,7 +23,6 @@ FoDReleaseCreateCommand.class, FoDReleaseListCommand.class, FoDReleaseGetCommand.class, - FoDReleaseImportScanCommand.class, FoDReleaseUpdateCommand.class, FoDReleaseDeleteCommand.class } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseImportScanCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseImportScanCommand.java deleted file mode 100644 index f7b30ec17f..0000000000 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/release/cli/cmd/FoDReleaseImportScanCommand.java +++ /dev/null @@ -1,116 +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.release.cli.cmd; - -import java.io.File; -import java.util.function.BiFunction; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -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.output.mixin.FoDOutputHelperMixins; -import com.fortify.cli.fod._common.rest.FoDUrls; -import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; -import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; -import com.fortify.cli.fod.scan.helper.FoDScanHelper; - -import kong.unirest.HttpRequest; -import kong.unirest.UnirestInstance; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import picocli.CommandLine.Command; -import picocli.CommandLine.Mixin; -import picocli.CommandLine.Option; - -@Command(name = FoDOutputHelperMixins.ImportScan.CMD_NAME) -public class FoDReleaseImportScanCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { - @Getter @Mixin private FoDOutputHelperMixins.ImportScan outputHelper; - - @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins - @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.PositionalParameter releaseResolver; - - @Option(names = {"-f", "--file"}, required = true) - private File scanFile; - - @Option(names="--type", required = true) - private FoDReleaseScanImportType type; - - @Override - public final JsonNode getJsonNode(UnirestInstance unirest) { - var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); - var releaseId = releaseDescriptor.getReleaseId(); - var importScanSessionId = getImportScanSessionId(unirest, releaseId); - HttpRequest baseRequest = type.getBaseRequest(unirest, releaseId) - .queryString("importScanSessionId", importScanSessionId) - .queryString("fileLength", scanFile.length()); - FoDFileTransferHelper.uploadChunked(unirest, baseRequest, scanFile); - return releaseDescriptor.asJsonNode(); - } - - public final JsonNode transformRecord(JsonNode record) { - return FoDScanHelper.renameFields(record); - } - - @Override - public final String getActionCommandResult() { - return "IMPORT_REQUESTED"; - } - - @Override - public final boolean isSingular() { - return true; - } - - private static final String getImportScanSessionId(UnirestInstance unirest, String relId) { - return unirest.get(FoDUrls.RELEASE_IMPORT_SCAN_SESSION) - .routeParam("relId", relId) - .asObject(ObjectNode.class) - .getBody() - .get("importScanSessionId") - .asText(); - } - - @RequiredArgsConstructor - public static enum FoDReleaseScanImportType { - Dast(FoDReleaseScanImportType::getBaseRequestDast), - Sast(FoDReleaseScanImportType::getBaseRequestSast), - Mobile(FoDReleaseScanImportType::getBaseRequestMobile), - CycloneDX(FoDReleaseScanImportType::getBaseRequestCycloneDX); - - private final BiFunction> f; - - public HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { - return f.apply(unirest, releaseId); - } - - private static final HttpRequest getBaseRequestSast(UnirestInstance unirest, String releaseId) { - return unirest.put(FoDUrls.STATIC_SCANS_IMPORT).routeParam("relId", releaseId); - } - - private static final HttpRequest getBaseRequestDast(UnirestInstance unirest, String releaseId) { - return unirest.put(FoDUrls.DYNAMIC_SCANS_IMPORT).routeParam("relId", releaseId); - } - - private static final HttpRequest getBaseRequestMobile(UnirestInstance unirest, String releaseId) { - return unirest.put(FoDUrls.MOBILE_SCANS_IMPORT).routeParam("relId", releaseId); - } - - private static final HttpRequest getBaseRequestCycloneDX(UnirestInstance unirest, String releaseId) { - return unirest.put(FoDUrls.RELEASE_IMPORT_CYCLONEDX_SBOM).routeParam("relId", releaseId); - } - } -} 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 index b61382839d..0797c3e5db 100644 --- 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 @@ -15,10 +15,6 @@ import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; import com.fortify.cli.common.variable.DefaultVariablePropertyName; -import com.fortify.cli.fod.scan.cli.cmd.dast.FoDDastScanStartCommand; -import com.fortify.cli.fod.scan.cli.cmd.mobile.FoDMobileScanStartCommand; -import com.fortify.cli.fod.scan.cli.cmd.sast.FoDSastScanSetupCommand; -import com.fortify.cli.fod.scan.cli.cmd.sast.FoDSastScanStartCommand; import picocli.CommandLine; @@ -27,10 +23,9 @@ FoDScanCancelCommand.class, FoDScanGetCommand.class, FoDScanListCommand.class, - FoDSastScanSetupCommand.class, - FoDSastScanStartCommand.class, - FoDDastScanStartCommand.class, - FoDMobileScanStartCommand.class, + FoDScanStartSastCommand.class, + FoDScanStartDastCommand.class, + FoDScanStartMobileCommand.class, FoDScanWaitForCommand.class } ) diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/dast/FoDDastScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartDastCommand.java similarity index 92% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/dast/FoDDastScanStartCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartDastCommand.java index 3db5eed116..845bf35877 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/dast/FoDDastScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartDastCommand.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd.dast; +package com.fortify.cli.fod.scan.cli.cmd; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -37,9 +37,10 @@ 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.dast.FoDDastScanHelper; -import com.fortify.cli.fod.scan.helper.dast.FoDDastScanSetupDescriptor; -import com.fortify.cli.fod.scan.helper.dast.FoDStartDastScanRequest; +import com.fortify.cli.fod.scan.helper.dast.FoDScanDastHelper; +import com.fortify.cli.fod.scan.helper.dast.FoDScanDastStartRequest; +import com.fortify.cli.fod.scan_setup.helper.FoDScanDastSetupDescriptor; +import com.fortify.cli.fod.scan_setup.helper.FoDScanDastSetupHelper; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -48,7 +49,7 @@ import picocli.CommandLine.Option; @Command(name = FoDOutputHelperMixins.StartDast.CMD_NAME) -public class FoDDastScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDScanStartDastCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm"); @Getter @Mixin private FoDOutputHelperMixins.StartDast outputHelper; @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @@ -99,7 +100,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { var relId = String.valueOf(releaseDescriptor.getReleaseId()); // get current setup and check if its valid - FoDDastScanSetupDescriptor currentSetup = FoDDastScanHelper.getSetupDescriptor(unirest, relId); + FoDScanDastSetupDescriptor currentSetup = FoDScanDastSetupHelper.getSetupDescriptor(unirest, relId); if (StringUtils.isBlank(currentSetup.getDynamicSiteURL())) { throw new IllegalStateException("The dynamic scan configuration for release with id '" + relId + "' has not been setup correctly - 'Dynamic Site URL' is missing or empty."); @@ -119,11 +120,11 @@ public JsonNode getJsonNode(UnirestInstance unirest) { } else if (remediationScanType.getRemediationScanPreferenceType() != null && (remediationScanType.getRemediationScanPreferenceType() == FoDEnums.RemediationScanPreferenceType.RemediationScanOnly)) { // if requesting a remediation scan make we have one available - entitlementToUse = FoDDastScanHelper.validateRemediationEntitlement(unirest, progressWriter, relId, + entitlementToUse = FoDScanDastHelper.validateRemediationEntitlement(unirest, progressWriter, relId, currentSetup.getEntitlementId(), FoDScanType.Dynamic); } else if (assessmentType != null && entitlementType.getEntitlementPreferenceType() != null) { // if assessment and entitlement type are both specified, find entitlement to use - entitlementToUse = FoDDastScanHelper.getEntitlementToUse(unirest, progressWriter, relId, + entitlementToUse = FoDScanDastHelper.getEntitlementToUse(unirest, progressWriter, relId, assessmentType, entitlementType.getEntitlementPreferenceType(), FoDScanType.Dynamic); } else { @@ -138,7 +139,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { String startDateStr = (startDate == null || startDate.isEmpty()) ? LocalDateTime.now().format(dtf) : LocalDateTime.parse(startDate, dtf).toString(); - FoDStartDastScanRequest startScanRequest = FoDStartDastScanRequest.builder() + FoDScanDastStartRequest startScanRequest = FoDScanDastStartRequest.builder() .startDate(startDateStr) .assessmentTypeId(entitlementToUse.getAssessmentTypeId()) .entitlementId(entitlementToUse.getEntitlementId()) @@ -150,7 +151,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .scanToolVersion(fcliProperties.getProperty("projectVersion", "unknown")).build(); //System.out.println(startScanRequest); - return FoDDastScanHelper.startScan(unirest, releaseDescriptor, startScanRequest).asJsonNode(); + return FoDScanDastHelper.startScan(unirest, releaseDescriptor, startScanRequest).asJsonNode(); } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/mobile/FoDMobileScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartMobileCommand.java similarity index 94% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/mobile/FoDMobileScanStartCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartMobileCommand.java index fa0e5a1f00..76a6c335d5 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/mobile/FoDMobileScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartMobileCommand.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd.mobile; +package com.fortify.cli.fod.scan.cli.cmd; import java.io.File; import java.time.LocalDateTime; @@ -38,8 +38,8 @@ import com.fortify.cli.fod.scan.helper.FoDAssessmentTypeDescriptor; import com.fortify.cli.fod.scan.helper.FoDScanHelper; import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.mobile.FoDMobileScanHelper; -import com.fortify.cli.fod.scan.helper.mobile.FoDStartMobileScanRequest; +import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileHelper; +import com.fortify.cli.fod.scan.helper.mobile.FoDScanMobileStartRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -48,7 +48,7 @@ import picocli.CommandLine.Option; @Command(name = FoDOutputHelperMixins.StartMobile.CMD_NAME) -public class FoDMobileScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDScanStartMobileCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { DateTimeFormatter dtf = DateTimeFormatter.ofPattern("MM/dd/yyyy HH:mm"); @Getter @Mixin private FoDOutputHelperMixins.StartMobile outputHelper; @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @@ -101,7 +101,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { ? LocalDateTime.now().format(dtf) : LocalDateTime.parse(startDate, dtf).toString(); - FoDStartMobileScanRequest startScanRequest = FoDStartMobileScanRequest.builder() + FoDScanMobileStartRequest startScanRequest = FoDScanMobileStartRequest.builder() .startDate(startDateStr) .assessmentTypeId(entitlementToUse.getAssessmentTypeId()) .entitlementId(entitlementToUse.getEntitlementId()) @@ -113,7 +113,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .scanTool(fcliProperties.getProperty("projectName", "fcli")) .scanToolVersion(fcliProperties.getProperty("projectVersion", "unknown")).build(); - return FoDMobileScanHelper.startScan(unirest, progressWriter, releaseDescriptor, startScanRequest, scanFile).asJsonNode(); + return FoDScanMobileHelper.startScan(unirest, progressWriter, releaseDescriptor, startScanRequest, scanFile).asJsonNode(); } } @@ -148,7 +148,7 @@ private FoDAssessmentTypeDescriptor getEntitlementToUse(UnirestInstance unirest, // if assessment and entitlement type are both specified, find entitlement to use FoDAssessmentType assessmentType = FoDAssessmentType.valueOf(String.valueOf(mobileAssessmentType)); FoDEnums.EntitlementPreferenceType entitlementPreferenceType = FoDEnums.EntitlementPreferenceType.fromInt(entitlementFrequencyTypeMixin.getEntitlementFrequencyType().getValue()); - entitlementToUse = FoDMobileScanHelper.getEntitlementToUse(unirest, progressWriter, relId, + entitlementToUse = FoDScanMobileHelper.getEntitlementToUse(unirest, progressWriter, relId, assessmentType, entitlementPreferenceType, FoDScanType.Mobile); diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanStartCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartSastCommand.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanStartCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartSastCommand.java index fc388cc961..64dee33ad1 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanStartCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/FoDScanStartSastCommand.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd.sast; +package com.fortify.cli.fod.scan.cli.cmd; import java.io.File; import java.util.Properties; @@ -34,9 +34,9 @@ import com.fortify.cli.fod.scan.helper.FoDAssessmentTypeDescriptor; import com.fortify.cli.fod.scan.helper.FoDScanHelper; import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.sast.FoDSastScanHelper; -import com.fortify.cli.fod.scan.helper.sast.FoDSastScanSetupDescriptor; -import com.fortify.cli.fod.scan.helper.sast.FoDStartSastScanRequest; +import com.fortify.cli.fod.scan.helper.sast.FoDScanSastHelper; +import com.fortify.cli.fod.scan.helper.sast.FoDScanSastStartRequest; +import com.fortify.cli.fod.scan_setup.helper.FoDScanSastSetupDescriptor; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -46,7 +46,7 @@ import picocli.CommandLine.Option; @Command(name = FoDOutputHelperMixins.StartSast.CMD_NAME) -public class FoDSastScanStartCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +public class FoDScanStartSastCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { @Getter @Mixin private FoDOutputHelperMixins.StartSast outputHelper; @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @@ -78,7 +78,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { String relId = releaseDescriptor.getReleaseId(); // get current setup and check if its valid - FoDSastScanSetupDescriptor currentSetup = FoDSastScanHelper.getSetupDescriptor(unirest, relId); + FoDScanSastSetupDescriptor currentSetup = FoDScanSastHelper.getSetupDescriptor(unirest, relId); if (StringUtils.isBlank(currentSetup.getTechnologyStack())) { throw new IllegalStateException("The static scan configuration for release with id '" + relId + "' has not been setup correctly - 'Technology Stack/Language Level' is missing or empty."); @@ -87,7 +87,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { // get entitlement to use FoDAssessmentTypeDescriptor entitlementToUse = getEntitlementToUse(unirest, progressWriter, relId, currentSetup); - FoDStartSastScanRequest startScanRequest = FoDStartSastScanRequest.builder() + FoDScanSastStartRequest startScanRequest = FoDScanSastStartRequest.builder() .purchaseEntitlement(purchaseEntitlement) .inProgressScanActionType(inProgressScanActionType.getInProgressScanActionType() != null ? inProgressScanActionType.getInProgressScanActionType().name() : FoDEnums.InProgressScanActionType.Queue.name()) @@ -105,7 +105,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { startScanRequest.setEntitlementPreferenceType(String.valueOf(FoDEnums.EntitlementPreferenceType.SubscriptionFirstThenSingleScan)); } - return FoDSastScanHelper.startScan(unirest, releaseDescriptor, startScanRequest, scanFile).asJsonNode(); + return FoDScanSastHelper.startScan(unirest, releaseDescriptor, startScanRequest, scanFile).asJsonNode(); } } @@ -124,7 +124,7 @@ public boolean isSingular() { return true; } - private FoDAssessmentTypeDescriptor getEntitlementToUse(UnirestInstance unirest, IProgressWriterI18n progressWriter, String relId, FoDSastScanSetupDescriptor currentSetup) { + private FoDAssessmentTypeDescriptor getEntitlementToUse(UnirestInstance unirest, IProgressWriterI18n progressWriter, String relId, FoDScanSastSetupDescriptor currentSetup) { FoDAssessmentTypeDescriptor entitlementToUse = new FoDAssessmentTypeDescriptor(); /** @@ -138,7 +138,7 @@ private FoDAssessmentTypeDescriptor getEntitlementToUse(UnirestInstance unirest, } if (remediationScanType.getRemediationScanPreferenceType() != null && (remediationScanType.getRemediationScanPreferenceType() == FoDEnums.RemediationScanPreferenceType.RemediationScanOnly)) { // if requesting a remediation scan make we have one available - FoDSastScanHelper.validateRemediationEntitlement(unirest, progressWriter, relId, + FoDScanSastHelper.validateRemediationEntitlement(unirest, progressWriter, relId, currentSetup.getEntitlementId(), FoDScanType.Static).getEntitlementId(); } return entitlementToUse; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentTypeDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentTypeDescriptor.java index 2efc54ff77..dd4fc09e4c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentTypeDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDAssessmentTypeDescriptor.java @@ -14,8 +14,8 @@ package com.fortify.cli.fod.scan.helper; import com.formkiq.graalvm.annotations.Reflectable; -import com.fortify.cli.fod.scan.helper.dast.FoDDastScanSetupDescriptor; -import com.fortify.cli.fod.scan.helper.sast.FoDSastScanSetupDescriptor; +import com.fortify.cli.fod.scan_setup.helper.FoDScanDastSetupDescriptor; +import com.fortify.cli.fod.scan_setup.helper.FoDScanSastSetupDescriptor; import lombok.Data; import lombok.NoArgsConstructor; @@ -33,7 +33,7 @@ public class FoDAssessmentTypeDescriptor { private Integer frequencyTypeId; private String frequencyType; - public FoDAssessmentTypeDescriptor copyFromCurrentSetup(FoDDastScanSetupDescriptor curSetup) { + public FoDAssessmentTypeDescriptor copyFromCurrentSetup(FoDScanDastSetupDescriptor curSetup) { this.assessmentTypeId = curSetup.getAssessmentTypeId(); this.entitlementId = curSetup.getEntitlementId(); this.entitlementDescription = curSetup.getEntitlementDescription(); @@ -42,7 +42,7 @@ public FoDAssessmentTypeDescriptor copyFromCurrentSetup(FoDDastScanSetupDescript return this; } - public FoDAssessmentTypeDescriptor copyFromCurrentSetup(FoDSastScanSetupDescriptor curSetup) { + public FoDAssessmentTypeDescriptor copyFromCurrentSetup(FoDScanSastSetupDescriptor curSetup) { this.assessmentTypeId = curSetup.getAssessmentTypeId(); this.entitlementId = curSetup.getEntitlementId(); this.entitlementDescription = curSetup.getEntitlementDescription(); diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanSessionDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanSessionDescriptor.java deleted file mode 100644 index de4e13ad40..0000000000 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanSessionDescriptor.java +++ /dev/null @@ -1,29 +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.helper; - -import com.formkiq.graalvm.annotations.Reflectable; -import com.fortify.cli.common.json.JsonNodeHolder; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.ToString; - -@Reflectable @NoArgsConstructor -@Data @ToString -@EqualsAndHashCode(callSuper=false) -public class FoDImportScanSessionDescriptor extends JsonNodeHolder { - private String importScanSessionId; -} 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/scan/helper/FoDScanHelper.java index bf1207a9ea..b36e9be046 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/scan/helper/FoDScanHelper.java @@ -24,13 +24,11 @@ import com.fortify.cli.common.json.JsonHelper; import com.fortify.cli.common.output.transform.fields.RenameFieldsTransformer; import com.fortify.cli.common.progress.helper.IProgressWriterI18n; -import com.fortify.cli.common.rest.unirest.UnexpectedHttpResponseException; import com.fortify.cli.fod._common.rest.FoDUrls; import com.fortify.cli.fod._common.util.FoDEnums; import com.fortify.cli.fod.release.helper.FoDReleaseAssessmentTypeDescriptor; import com.fortify.cli.fod.release.helper.FoDReleaseHelper; -import kong.unirest.HttpResponse; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -120,20 +118,12 @@ private final static Integer unitsRequired(FoDAssessmentType assessmentType, } } - public static final FoDScanDescriptor getScanDescriptor(UnirestInstance unirest, String scanId) throws FoDScanNotFoundException { - try { - HttpResponse response = unirest.get(FoDUrls.SCAN + "/summary") - .routeParam("scanId", scanId).asObject(ObjectNode.class); - if (response.isSuccess()) { - JsonNode scan = response.getBody(); - return scan == null ? null : getDescriptor(scan); - } - } catch (UnexpectedHttpResponseException ex) { - if (ex.getMessage().contains("404 Not Found")) { - throw new FoDScanNotFoundException("Could not retrieve scan with id: " + scanId); - } - } - return null; + public static final FoDScanDescriptor getScanDescriptor(UnirestInstance unirest, String scanId) { + var result = unirest.get(FoDUrls.SCAN + "/summary") + .routeParam("scanId", scanId) + .asObject(ObjectNode.class) + .getBody(); + return getDescriptor(result); } public static final FoDScanDescriptor getLatestScanDescriptor(UnirestInstance unirest, String relId, diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java similarity index 94% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java index 94aafa09ad..8bc41df21f 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastDescriptor.java @@ -24,7 +24,7 @@ @Reflectable @NoArgsConstructor @Data @ToString @EqualsAndHashCode(callSuper = true) -public class FoDDastScanDescriptor extends JsonNodeHolder { +public class FoDScanDastDescriptor extends JsonNodeHolder { private Integer scanId; private String scanType; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java similarity index 84% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java index a32234420b..2fd5a7cb89 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastHelper.java @@ -24,11 +24,10 @@ import com.fortify.cli.fod.scan.helper.FoDScanType; import com.fortify.cli.fod.scan.helper.FoDStartScanResponse; -import kong.unirest.GetRequest; import kong.unirest.UnirestInstance; import lombok.Getter; -public class FoDDastScanHelper extends FoDScanHelper { +public class FoDScanDastHelper extends FoDScanHelper { @Getter private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -42,7 +41,7 @@ public class FoDDastScanHelper extends FoDScanHelper { return JsonHelper.treeToValue(response, FoDDastScanSetupDescriptor.class); }*/ - public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDStartDastScanRequest startDastScanRequest) { + public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanDastStartRequest startDastScanRequest) { ObjectNode body = objectMapper.valueToTree(startDastScanRequest); JsonNode response = unirest.post(FoDUrls.DYNAMIC_SCANS + "/start-scan") .routeParam("relId", releaseDescriptor.getReleaseId()) @@ -60,12 +59,4 @@ public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDRele .put("microserviceName", releaseDescriptor.getMicroserviceName()); return JsonHelper.treeToValue(node, FoDScanDescriptor.class); } - - public static final FoDDastScanSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { - GetRequest request = unirest.get(FoDUrls.DYNAMIC_SCANS + "/scan-setup") - .routeParam("relId", relId); - JsonNode setup = request.asObject(ObjectNode.class).getBody(); - return JsonHelper.treeToValue(setup, FoDDastScanSetupDescriptor.class); - } - } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDStartDastScanRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDStartDastScanRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java index 1e872d4325..c2a94068f0 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDStartDastScanRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDScanDastStartRequest.java @@ -24,7 +24,7 @@ @Reflectable @NoArgsConstructor @AllArgsConstructor @Getter @ToString @Builder -public class FoDStartDastScanRequest { +public class FoDScanDastStartRequest { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy HH:mm") private String startDate; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java similarity index 85% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java index 6f5a9bd505..0bb31e6dc3 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileHelper.java @@ -17,7 +17,6 @@ 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.common.progress.helper.IProgressWriterI18n; import com.fortify.cli.fod._common.rest.FoDUrls; @@ -28,17 +27,16 @@ import com.fortify.cli.fod.scan.helper.FoDScanHelper; import com.fortify.cli.fod.scan.helper.FoDScanType; -import kong.unirest.GetRequest; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; -public class FoDMobileScanHelper extends FoDScanHelper { +public class FoDScanMobileHelper extends FoDScanHelper { @Getter private static final ObjectMapper objectMapper = new ObjectMapper(); // TODO Split into multiple methods - public static final FoDScanDescriptor startScan(UnirestInstance unirest, IProgressWriterI18n progressWriter, FoDReleaseDescriptor releaseDescriptor, FoDStartMobileScanRequest req, + public static final FoDScanDescriptor startScan(UnirestInstance unirest, IProgressWriterI18n progressWriter, FoDReleaseDescriptor releaseDescriptor, FoDScanMobileStartRequest req, File scanFile) { var relId = releaseDescriptor.getReleaseId(); HttpRequest request = unirest.post(FoDUrls.MOBILE_SCANS_START).routeParam("relId", relId) @@ -66,11 +64,4 @@ public static final FoDScanDescriptor startScan(UnirestInstance unirest, IProgre .put("microserviceName", releaseDescriptor.getMicroserviceName()); return JsonHelper.treeToValue(node, FoDScanDescriptor.class); } - - public static final FoDMobileScanSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { - GetRequest request = unirest.get(FoDUrls.MOBILE_SCANS + "/scan-setup") - .routeParam("relId", relId); - JsonNode setup = request.asObject(ObjectNode.class).getBody(); - return JsonHelper.treeToValue(setup, FoDMobileScanSetupDescriptor.class); - } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDStartMobileScanRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDStartMobileScanRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java index dc387cc547..c34f4cc110 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDStartMobileScanRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDScanMobileStartRequest.java @@ -24,7 +24,7 @@ @Reflectable @NoArgsConstructor @AllArgsConstructor @Getter @ToString @Builder -public class FoDStartMobileScanRequest { +public class FoDScanMobileStartRequest { @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy HH:mm") private String startDate; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDOssHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDOssHelper.java deleted file mode 100644 index 2ac064ac4e..0000000000 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/oss/FoDOssHelper.java +++ /dev/null @@ -1,35 +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.helper.oss; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fortify.cli.common.output.transform.fields.RenameFieldsTransformer; - -import lombok.Getter; - -public class FoDOssHelper { - @Getter - private static final ObjectMapper objectMapper = new ObjectMapper(); - - // TODO Any plans to actually rename any fields? We should document - // a convention for methods like these; do we want commands to - // consistently call a *Helper.renameFields/transformRecord method, - // even if it doesn't do anything, reducing the risk that commands - // forget to invoke this method when it actually does something? - public static final JsonNode renameFields(JsonNode record) { - return new RenameFieldsTransformer(new String[]{}).transform(record); - } - -} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java similarity index 94% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java index 09c8c09f5e..ca7cbbaea3 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastDescriptor.java @@ -22,7 +22,7 @@ @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper = true) -public class FoDSastScanDescriptor extends JsonNodeHolder { +public class FoDScanSastDescriptor extends JsonNodeHolder { private Integer scanId; private String scanType; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java similarity index 85% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanHelper.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java index 63cac0be92..8fb95cd66c 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanHelper.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastHelper.java @@ -28,28 +28,19 @@ 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_setup.helper.FoDScanSastSetupDescriptor; import kong.unirest.GetRequest; import kong.unirest.HttpRequest; import kong.unirest.UnirestInstance; import lombok.Getter; -public class FoDSastScanHelper extends FoDScanHelper { +public class FoDScanSastHelper extends FoDScanHelper { @Getter private static final ObjectMapper objectMapper = new ObjectMapper(); - public static final FoDSastScanSetupDescriptor setupScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDSetupSastScanRequest setupSastScanRequest) { - var relId = releaseDescriptor.getReleaseId(); - ObjectNode body = objectMapper.valueToTree(setupSastScanRequest); - JsonHelper.stripNulls(body); - unirest.put(FoDUrls.STATIC_SCANS + "/scan-setup") - .routeParam("relId", relId) - .body(body).asObject(JsonNode.class).getBody(); - return getSetupDescriptorWithAppRel(unirest, releaseDescriptor); - } - // TODO Split into multiple methods - public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDStartSastScanRequest req, + public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanSastStartRequest req, File scanFile) { var relId = releaseDescriptor.getReleaseId(); HttpRequest request = unirest.post(FoDUrls.STATIC_SCAN_START).routeParam("relId", relId) @@ -85,22 +76,22 @@ public static final FoDScanDescriptor startScan(UnirestInstance unirest, FoDRele return JsonHelper.treeToValue(node, FoDScanDescriptor.class); } - public static final FoDSastScanSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { + public static final FoDScanSastSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { GetRequest request = unirest.get(FoDUrls.STATIC_SCANS + "/scan-setup") .routeParam("relId", relId); JsonNode setup = request.asObject(ObjectNode.class).getBody() .put("applicationName", "test"); - return JsonHelper.treeToValue(setup, FoDSastScanSetupDescriptor.class); + return JsonHelper.treeToValue(setup, FoDScanSastSetupDescriptor.class); } - public static final FoDSastScanSetupDescriptor getSetupDescriptorWithAppRel(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { + public static final FoDScanSastSetupDescriptor getSetupDescriptorWithAppRel(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { GetRequest request = unirest.get(FoDUrls.STATIC_SCANS + "/scan-setup") .routeParam("relId", releaseDescriptor.getReleaseId()); JsonNode setup = request.asObject(ObjectNode.class).getBody() .put("applicationName", releaseDescriptor.getApplicationName()) .put("releaseName", releaseDescriptor.getReleaseName()) .put("microserviceName", releaseDescriptor.getMicroserviceName()); - return JsonHelper.treeToValue(setup, FoDSastScanSetupDescriptor.class); + return JsonHelper.treeToValue(setup, FoDScanSastSetupDescriptor.class); } // TODO Consider having a generic abbreviate method in StringUtils diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDStartSastScanRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDStartSastScanRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java index 76975f0489..8072658777 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDStartSastScanRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDScanSastStartRequest.java @@ -22,7 +22,7 @@ @Reflectable @NoArgsConstructor @AllArgsConstructor @Data @Builder -public class FoDStartSastScanRequest { +public class FoDScanSastStartRequest { private String entitlementPreferenceType; private Boolean purchaseEntitlement; private Integer entitlementId; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/AbstractFoDScanImportCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/AbstractFoDScanImportCommand.java new file mode 100644 index 0000000000..7ace769dc3 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/AbstractFoDScanImportCommand.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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_import.cli.cmd; + +import java.io.File; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +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.rest.FoDUrls; +import com.fortify.cli.fod._common.rest.helper.FoDFileTransferHelper; +import com.fortify.cli.fod.release.cli.mixin.FoDReleaseByQualifiedNameOrIdResolverMixin; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import picocli.CommandLine.Mixin; +import picocli.CommandLine.Parameters; + +public abstract class AbstractFoDScanImportCommand extends AbstractFoDJsonNodeOutputCommand implements IActionCommandResultSupplier { + @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins + @Mixin private FoDReleaseByQualifiedNameOrIdResolverMixin.RequiredOption releaseResolver; + + @Parameters(index = "0", arity = "1") + private File scanFile; + + @Override + public final JsonNode getJsonNode(UnirestInstance unirest) { + var releaseDescriptor = releaseResolver.getReleaseDescriptor(unirest); + var releaseId = releaseDescriptor.getReleaseId(); + var importScanSessionId = getImportScanSessionId(unirest, releaseId); + HttpRequest baseRequest = getBaseRequest(unirest, releaseId) + .queryString("importScanSessionId", importScanSessionId) + .queryString("fileLength", scanFile.length()); + FoDFileTransferHelper.uploadChunked(unirest, baseRequest, scanFile); + return releaseDescriptor.asJsonNode(); + } + + protected abstract HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId); + + @Override + public final String getActionCommandResult() { + return "IMPORT_REQUESTED"; + } + + @Override + public final boolean isSingular() { + return true; + } + + private static final String getImportScanSessionId(UnirestInstance unirest, String relId) { + return unirest.get(FoDUrls.RELEASE_IMPORT_SCAN_SESSION) + .routeParam("relId", relId) + .asObject(ObjectNode.class) + .getBody() + .get("importScanSessionId") + .asText(); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportCommands.java new file mode 100644 index 0000000000..335800b56f --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportCommands.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.scan_import.cli.cmd; + +import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; + +import picocli.CommandLine.Command; + +@Command(name = "scan-import", + subcommands = { + FoDScanImportDastCommand.class, + FoDScanImportMobileCommand.class, + FoDScanImportOpenSourceCommand.class, + FoDScanImportSastCommand.class, + } +) +public class FoDScanImportCommands extends AbstractContainerCommand { +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportDastCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportDastCommand.java new file mode 100644 index 0000000000..f4dc77ae6f --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportDastCommand.java @@ -0,0 +1,32 @@ +/** + * 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.scan_import.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.rest.FoDUrls; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.ImportDast.CMD_NAME) +public class FoDScanImportDastCommand extends AbstractFoDScanImportCommand { + @Getter @Mixin private FoDOutputHelperMixins.ImportDast outputHelper; + + @Override + protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { + return unirest.put(FoDUrls.DYNAMIC_SCANS_IMPORT).routeParam("relId", releaseId); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportMobileCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportMobileCommand.java new file mode 100644 index 0000000000..5256ea46f1 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportMobileCommand.java @@ -0,0 +1,32 @@ +/** + * 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.scan_import.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.rest.FoDUrls; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.ImportMobile.CMD_NAME) +public class FoDScanImportMobileCommand extends AbstractFoDScanImportCommand { + @Getter @Mixin private FoDOutputHelperMixins.ImportMobile outputHelper; + + @Override + protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { + return unirest.put(FoDUrls.MOBILE_SCANS_IMPORT).routeParam("relId", releaseId); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportOpenSourceCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportOpenSourceCommand.java new file mode 100644 index 0000000000..b4196d9fb4 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportOpenSourceCommand.java @@ -0,0 +1,54 @@ +/** + * 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.scan_import.cli.cmd; + +import java.util.function.BiFunction; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.rest.FoDUrls; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; +import picocli.CommandLine.Option; + +@Command(name = FoDOutputHelperMixins.ImportOpenSource.CMD_NAME) +public class FoDScanImportOpenSourceCommand extends AbstractFoDScanImportCommand { + @Getter @Mixin private FoDOutputHelperMixins.ImportOpenSource outputHelper; + + @Option(names="--type", required = true, defaultValue = "CycloneDX") + private FoDScanImportOpenSourceType type; + + @Override + protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { + return unirest.put(FoDUrls.MOBILE_SCANS_IMPORT).routeParam("relId", releaseId); + } + + @RequiredArgsConstructor + public static enum FoDScanImportOpenSourceType { + CycloneDX(FoDScanImportOpenSourceType::getBaseRequestCycloneDX); + + private final BiFunction> f; + + public HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { + return f.apply(unirest, releaseId); + } + + private static final HttpRequest getBaseRequestCycloneDX(UnirestInstance unirest, String releaseId) { + return unirest.put(FoDUrls.RELEASE_IMPORT_CYCLONEDX_SBOM).routeParam("relId", releaseId); + } + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportSastCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportSastCommand.java new file mode 100644 index 0000000000..07eea450ec --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_import/cli/cmd/FoDScanImportSastCommand.java @@ -0,0 +1,32 @@ +/** + * 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.scan_import.cli.cmd; + +import com.fortify.cli.fod._common.output.mixin.FoDOutputHelperMixins; +import com.fortify.cli.fod._common.rest.FoDUrls; + +import kong.unirest.HttpRequest; +import kong.unirest.UnirestInstance; +import lombok.Getter; +import picocli.CommandLine.Command; +import picocli.CommandLine.Mixin; + +@Command(name = FoDOutputHelperMixins.ImportSast.CMD_NAME) +public class FoDScanImportSastCommand extends AbstractFoDScanImportCommand { + @Getter @Mixin private FoDOutputHelperMixins.ImportSast outputHelper; + + @Override + protected HttpRequest getBaseRequest(UnirestInstance unirest, String releaseId) { + return unirest.put(FoDUrls.STATIC_SCANS_IMPORT).routeParam("relId", releaseId); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupCommands.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupCommands.java new file mode 100644 index 0000000000..6229e40ce0 --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupCommands.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 2021, 2023 Open Text. + * + * The only warranties for products and services of Open Text + * and its affiliates and licensors ("Open Text") are as may + * be set forth in the express warranty statements accompanying + * such products and services. Nothing herein should be construed + * as constituting an additional warranty. Open Text shall not be + * liable for technical or editorial errors or omissions contained + * herein. The information contained herein is subject to change + * without notice. + *******************************************************************************/ + +package com.fortify.cli.fod.scan_setup.cli.cmd; + +import com.fortify.cli.common.cli.cmd.AbstractContainerCommand; + +import picocli.CommandLine.Command; + +@Command(name = "scan-setup", + subcommands = { + FoDScanSetupSastCommand.class, + } +) +public class FoDScanSetupCommands extends AbstractContainerCommand { +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanSetupCommand.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupSastCommand.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanSetupCommand.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupSastCommand.java index 4958c4f2b8..a2e0f7b002 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/cli/cmd/sast/FoDSastScanSetupCommand.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/cli/cmd/FoDScanSetupSastCommand.java @@ -11,13 +11,15 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.cli.cmd.sast; +package com.fortify.cli.fod.scan_setup.cli.cmd; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; 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.DisableTest; +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.output.mixin.FoDOutputHelperMixins; @@ -33,9 +35,10 @@ import com.fortify.cli.fod.scan.helper.FoDAssessmentTypeDescriptor; import com.fortify.cli.fod.scan.helper.FoDScanHelper; import com.fortify.cli.fod.scan.helper.FoDScanType; -import com.fortify.cli.fod.scan.helper.sast.FoDSastScanHelper; -import com.fortify.cli.fod.scan.helper.sast.FoDSastScanSetupDescriptor; -import com.fortify.cli.fod.scan.helper.sast.FoDSetupSastScanRequest; +import com.fortify.cli.fod.scan.helper.sast.FoDScanSastHelper; +import com.fortify.cli.fod.scan_setup.helper.FoDScanSastSetupDescriptor; +import com.fortify.cli.fod.scan_setup.helper.FoDScanSastSetupHelper; +import com.fortify.cli.fod.scan_setup.helper.FoDScanSastSetupRequest; import kong.unirest.UnirestInstance; import lombok.Getter; @@ -44,7 +47,8 @@ import picocli.CommandLine.Option; @Command(name = FoDOutputHelperMixins.SetupSast.CMD_NAME) -public class FoDSastScanSetupCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { +@DisableTest(TestType.CMD_DEFAULT_TABLE_OPTIONS_PRESENT) +public class FoDScanSetupSastCommand extends AbstractFoDJsonNodeOutputCommand implements IRecordTransformer, IActionCommandResultSupplier { @Getter @Mixin private FoDOutputHelperMixins.SetupSast outputHelper; @Mixin private FoDDelimiterMixin delimiterMixin; // Is automatically injected in resolver mixins @@ -84,7 +88,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { // TODO Unused variable // get current setup - FoDSastScanSetupDescriptor currentSetup = FoDSastScanHelper.getSetupDescriptor(unirest, relId); + FoDScanSastSetupDescriptor currentSetup = FoDScanSastHelper.getSetupDescriptor(unirest, relId); // find/check out assessment type id //FoDScanTypeOptions.FoDScanType scanType = assessmentType.getAssessmentType().toScanType(); @@ -141,7 +145,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { //System.out.println("languageLevelId = " + languageLevelId); } - FoDSetupSastScanRequest setupSastScanRequest = FoDSetupSastScanRequest.builder() + FoDScanSastSetupRequest setupSastScanRequest = FoDScanSastSetupRequest.builder() .entitlementId(entitlementIdToUse) .assessmentTypeId(assessmentTypeId) .entitlementFrequencyType(entitlementFrequencyTypeMixin.getEntitlementFrequencyType().name()) @@ -152,7 +156,7 @@ public JsonNode getJsonNode(UnirestInstance unirest) { .includeThirdPartyLibraries(includeThirdPartyLibraries) .useSourceControl(useSourceControl).build(); - return FoDSastScanHelper.setupScan(unirest, releaseDescriptor, setupSastScanRequest).asJsonNode(); + return FoDScanSastSetupHelper.setupScan(unirest, releaseDescriptor, setupSastScanRequest).asJsonNode(); } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanSetupDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupDescriptor.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanSetupDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupDescriptor.java index ce5c08f3ce..4cb31d4610 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDDastScanSetupDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.dast; +package com.fortify.cli.fod.scan_setup.helper; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; @@ -24,7 +24,7 @@ @Reflectable @NoArgsConstructor @Data @ToString @EqualsAndHashCode(callSuper=false) -public class FoDDastScanSetupDescriptor extends JsonNodeHolder { +public class FoDScanDastSetupDescriptor extends JsonNodeHolder { private Integer assessmentTypeId; private Integer entitlementId; private String entitlementDescription; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanNotFoundException.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupHelper.java similarity index 51% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanNotFoundException.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupHelper.java index 567257c037..46749814f4 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDScanNotFoundException.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupHelper.java @@ -10,13 +10,21 @@ * herein. The information contained herein is subject to change * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; -// TODO Although we still need to come to a final conclusion (https://github.com/fortify/fcli/issues/15), -// most fcli code throws existing exceptions like IllegalArumentException in case an entity is not found. -public class FoDScanNotFoundException extends RuntimeException { - private static final long serialVersionUID = 1L; - public FoDScanNotFoundException(String message) { - super(message); +package com.fortify.cli.fod.scan_setup.helper; + +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fortify.cli.common.json.JsonHelper; +import com.fortify.cli.fod._common.rest.FoDUrls; + +import kong.unirest.UnirestInstance; + +public class FoDScanDastSetupHelper { + public static final FoDScanDastSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { + var body = unirest.get(FoDUrls.DYNAMIC_SCANS + "/scan-setup") + .routeParam("relId", relId) + .asObject(ObjectNode.class) + .getBody(); + return JsonHelper.treeToValue(body, FoDScanDastSetupDescriptor.class); } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDSetupDastScanRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupRequest.java similarity index 97% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDSetupDastScanRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupRequest.java index 5b498ea022..28a3e04c5e 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/dast/FoDSetupDastScanRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanDastSetupRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.dast; +package com.fortify.cli.fod.scan_setup.helper; import java.util.ArrayList; @@ -26,7 +26,7 @@ @Reflectable @NoArgsConstructor @AllArgsConstructor @Getter @ToString @Builder -public class FoDSetupDastScanRequest { +public class FoDScanDastSetupRequest { @Reflectable @NoArgsConstructor @Getter @ToString diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanSetupDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupDescriptor.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanSetupDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupDescriptor.java index e2c569a4b3..264adc2248 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/mobile/FoDMobileScanSetupDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.mobile; +package com.fortify.cli.fod.scan_setup.helper; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; @@ -22,7 +22,7 @@ @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper=false) -public class FoDMobileScanSetupDescriptor extends JsonNodeHolder { +public class FoDScanMobileSetupDescriptor extends JsonNodeHolder { private Integer releaseId; private Integer assessmentTypeId; private Integer entitlementId; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanResponse.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupHelper.java similarity index 50% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanResponse.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupHelper.java index 5cb631650f..9d8d592698 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/FoDImportScanResponse.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanMobileSetupHelper.java @@ -11,17 +11,20 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper; +package com.fortify.cli.fod.scan_setup.helper; -import com.formkiq.graalvm.annotations.Reflectable; -import com.fortify.cli.common.json.JsonNodeHolder; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.fortify.cli.common.json.JsonHelper; +import com.fortify.cli.fod._common.rest.FoDUrls; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; +import kong.unirest.UnirestInstance; -@Reflectable @NoArgsConstructor -@Data @EqualsAndHashCode(callSuper=false) -public class FoDImportScanResponse extends JsonNodeHolder { - String referenceId; +public class FoDScanMobileSetupHelper { + public static final FoDScanMobileSetupDescriptor getSetupDescriptor(UnirestInstance unirest, String relId) { + var body = unirest.get(FoDUrls.MOBILE_SCANS + "/scan-setup") + .routeParam("relId", relId) + .asObject(ObjectNode.class) + .getBody(); + return JsonHelper.treeToValue(body, FoDScanMobileSetupDescriptor.class); + } } diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanSetupDescriptor.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupDescriptor.java similarity index 91% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanSetupDescriptor.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupDescriptor.java index 3930fe4e20..18868e3ebc 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSastScanSetupDescriptor.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupDescriptor.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.sast; +package com.fortify.cli.fod.scan_setup.helper; import com.formkiq.graalvm.annotations.Reflectable; import com.fortify.cli.common.json.JsonNodeHolder; @@ -22,7 +22,7 @@ @Reflectable @NoArgsConstructor @Data @EqualsAndHashCode(callSuper=false) -public class FoDSastScanSetupDescriptor extends JsonNodeHolder { +public class FoDScanSastSetupDescriptor extends JsonNodeHolder { private Integer releaseId; private Integer assessmentTypeId; private Integer entitlementId; diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupHelper.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupHelper.java new file mode 100644 index 0000000000..5ca161cbfc --- /dev/null +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupHelper.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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_setup.helper; + +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.release.helper.FoDReleaseDescriptor; + +import kong.unirest.UnirestInstance; + +public class FoDScanSastSetupHelper { + public static final FoDScanSastSetupDescriptor getSetupDescriptor(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor) { + var body = unirest.get(FoDUrls.STATIC_SCANS + "/scan-setup") + .routeParam("relId", releaseDescriptor.getReleaseId()) + .asObject(ObjectNode.class) + .getBody(); + return JsonHelper.treeToValue(body, FoDScanSastSetupDescriptor.class); + } + + public static final FoDScanSastSetupDescriptor setupScan(UnirestInstance unirest, FoDReleaseDescriptor releaseDescriptor, FoDScanSastSetupRequest setupSastScanRequest) { + var relId = releaseDescriptor.getReleaseId(); + unirest.put(FoDUrls.STATIC_SCANS + "/scan-setup") + .routeParam("relId", relId) + .body(setupSastScanRequest) + .asString().getBody(); + return getSetupDescriptor(unirest, releaseDescriptor); + } +} diff --git a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSetupSastScanRequest.java b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupRequest.java similarity index 93% rename from fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSetupSastScanRequest.java rename to fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupRequest.java index be8035a8f2..7e5ee3832a 100644 --- a/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan/helper/sast/FoDSetupSastScanRequest.java +++ b/fcli-core/fcli-fod/src/main/java/com/fortify/cli/fod/scan_setup/helper/FoDScanSastSetupRequest.java @@ -11,7 +11,7 @@ * without notice. *******************************************************************************/ -package com.fortify.cli.fod.scan.helper.sast; +package com.fortify.cli.fod.scan_setup.helper; import com.formkiq.graalvm.annotations.Reflectable; @@ -22,7 +22,7 @@ @Reflectable @NoArgsConstructor @AllArgsConstructor @Data @Builder -public class FoDSetupSastScanRequest { +public class FoDScanSastSetupRequest { private Integer assessmentTypeId; private String entitlementFrequencyType; private Integer entitlementId; 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 c6e256e193..248f084fce 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 @@ -220,9 +220,6 @@ fcli.fod.release.create.skip-if-exists = Check to see if release already exists fcli.fod.release.delete.usage.header = Delete an application release. fcli.fod.release.list.usage.header = List application releases. fcli.fod.release.get.usage.header = Get application release details. -fcli.fod.release.import-scan.usage.header = Import existing scan results into a release. -fcli.fod.release.import-scan.file = File containing existing scan results to be imported. -fcli.fod.release.import-scan.type = Type of scan results to be imported. Valid values: ${COMPLETION-CANDIDATES}. fcli.fod.release.update.usage.header = Update an existing application release. fcli.fod.release.update.name = The updated name for the release. fcli.fod.release.update.description = Updated description for the release. @@ -233,8 +230,9 @@ fcli.fod.release.update.status = SDLC lifecycle status of the release. Valid val ### For the "fod scan" command ### fcli.fod.scan.usage.header = Manage FoD scans. -fcli.fod.scan.usage.description = The commands listed below allow for managing scans on FoD. For importing \ - existing scan results into FoD, please see the 'fcli fod release import-scan' command. +fcli.fod.scan.usage.description = The commands listed below allow for starting and managing scans on FoD. \ + Commands for setting up scans and importing existing scan results can be found on the \ + 'fcli fod scan-setup' and 'fcli fod scan-import' commands respectively. fcli.fod.scan.output.header.scanId = Id fcli.fod.scan.output.header.scanType = Type fcli.fod.scan.output.header.analysisStatusType = Analysis Status @@ -260,18 +258,6 @@ fcli.fod.scan.wait-for.usage.description.2 = ${fcli.fod.scan.states:-See fcli he fcli.fod.scan.wait-for.until=Wait until either any or all scans match. If neither --until or --while are specified, default is to wait until all scans match. fcli.fod.scan.wait-for.while=Wait while either any or all scans match. fcli.fod.scan.wait-for.any-state=One or more scan states against which to match the given scans. -fcli.fod.scan.setup-sast.usage.header = Set up a new SAST scan. -fcli.fod.scan.setup-sast.entitlement-frequency = The Entitlement Frequency to use. Valid values: ${COMPLETION-CANDIDATES}. -fcli.fod.scan.setup-sast.entitlement-id = Entitlement Id to use. If not specified Frequency and Assessment Type will be used to find one. -fcli.fod.scan.setup-sast.assessment-type = The type of Static assessment to carry out. Valid values: ${COMPLETION-CANDIDATES} -fcli.fod.scan.setup-sast.technology-stack = The technology stack of the application. -fcli.fod.scan.setup-sast.language-level = The language level of the technology stack (if needed). -fcli.fod.scan.setup-sast.oss = Perform Open Source Analysis scan. -fcli.fod.scan.setup-sast.audit-preference = Audit preference, e.g. Manual or Automated -fcli.fod.scan.setup-sast.include-third-party-libs = Indicates if third party libraries should be included. -fcli.fod.scan.setup-sast.use-source-control = Indicates if source control should be used. -fcli.fod.scan.setup-dast.usage.header = Set up a new DAST scan. -fcli.fod.scan.setup-mobile.usage.header = Set up a new Mobile scan. fcli.fod.scan.start-sast.usage.header = Start a new SAST scan. fcli.fod.scan.start-sast.start-date = Date to start the scan (in MM/dd/yyyy HH:mm format). fcli.fod.scan.start-sast.remediation = Identify this scan as a remediation scan. @@ -310,6 +296,28 @@ fcli.fod.scan.start-mobile.using-entitlement = Running scan using entitlement %s fcli.fod.scan.start-mobile.validating-remediation-entitlement = Validating remediation entitlements. fcli.fod.scan.start-mobile.using-remediation-entitlement = Running scan using entitlement %s. +fcli.fod.scan-import.usage.header = Import existing scan results into FoD. +fcli.fod.scan-import.import-dast.usage.header = Import existing DAST scan results. +fcli.fod.scan-import.import-dast.[0] = FPR file containing existing DAST scan results to be imported. +fcli.fod.scan-import.import-mobile.usage.header = Import existing mobile scan results. +fcli.fod.scan-import.import-mobile.[0] = File containing existing mobile scan results to be imported. +fcli.fod.scan-import.import-open-source.usage.header = Import existing Open Source scan results. +fcli.fod.scan-import.import-open-source.[0] = File containing existing Open Source scan results to be imported. +fcli.fod.scan-import.import-open-source.type = Open Source scan results file type. Valid values: ${COMPLETION-CANDIDATES} (default value). +fcli.fod.scan-import.import-sast.usage.header = Import existing SAST scan results. +fcli.fod.scan-import.import-sast.[0] = FPR file containing existing SAST scan results to be imported. + +fcli.fod.scan-setup.usage.header = Setup scan configurations on FoD. +fcli.fod.scan-setup.setup-sast.usage.header = Configure the release for enabling SAST scans. +fcli.fod.scan-setup.setup-sast.entitlement-frequency = The Entitlement Frequency to use. Valid values: ${COMPLETION-CANDIDATES}. +fcli.fod.scan-setup.setup-sast.entitlement-id = Entitlement Id to use. If not specified Frequency and Assessment Type will be used to find one. +fcli.fod.scan-setup.setup-sast.assessment-type = The type of Static assessment to carry out. Valid values: ${COMPLETION-CANDIDATES} +fcli.fod.scan-setup.setup-sast.technology-stack = The technology stack of the application. +fcli.fod.scan-setup.setup-sast.language-level = The language level of the technology stack (if needed). +fcli.fod.scan-setup.setup-sast.oss = Perform Open Source Analysis scan. +fcli.fod.scan-setup.setup-sast.audit-preference = Audit preference, e.g. Manual or Automated +fcli.fod.scan-setup.setup-sast.include-third-party-libs = Indicates if third party libraries should be included. +fcli.fod.scan-setup.setup-sast.use-source-control = Indicates if source control should be used. ### For the "fod user" command ### fcli.fod.user.usage.header = Manage FoD users. @@ -391,7 +399,7 @@ fcli.fod.scan.cancel.output.table.options = scanId,scanType,applicationName,micr fcli.fod.scan.start-sast.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName fcli.fod.scan.start-dast.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName fcli.fod.scan.start-mobile.output.table.options = scanId,scanType,analysisStatusType,applicationName,microserviceName,releaseName -fcli.fod.scan.setup-sast.output.table.options = applicationName,microserviceName,releaseName,entitlementId +fcli.fod.scan-import.output.table.options = releaseId,releaseName,microserviceName,applicationName 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